[Release] Orbit Reborn - Source

11/01/2014 11:06 somalia_#271
Quote:
Originally Posted by supraturbo92 View Post
hi guys,
so i was looking thru the emulator and fond this: [Only registered and activated users can see links. Click Here To Register...]

dont b-b-b-b-bash me bash me im still learning.
but is this x1 x2 x3 x4 sab ammo?
if i ad case 6, multi 6 is that for rsb?

thanks for ur time.
Punching ppl with a Wall-of-Text you want help from isn't cool.

[Only registered and activated users can see links. Click Here To Register...] :rtfm: Read the f*cking manual.

Check Usages of 'Session.CharacterInfo.SelectedAmmo' to find out what SelectedAmmo is and where it is used at.

If you add case 6 with 'Damagemultiplier' of 6 well.. Check the line below the switch Statement.
Code:
int Damage = Random.Next(MinDmg, MaxDmg) * DamageMultiplier;
11/01/2014 11:07 xelle#272
Hello I installed the orbital-reborn server but some errors occurred and I want to fix them in a batch format your help.

MySQL information.

[Only registered and activated users can see links. Click Here To Register...]

Web site IP address

[Only registered and activated users can see links. Click Here To Register...]

Now can you tell me where I made mistakes by checking the following photos ?

My inventory.php

[Only registered and activated users can see links. Click Here To Register...]

My shipAnim.php

[Only registered and activated users can see links. Click Here To Register...]

My database.php

[Only registered and activated users can see links. Click Here To Register...]

My paths.php

[Only registered and activated users can see links. Click Here To Register...]

My index.php

[Only registered and activated users can see links. Click Here To Register...]

My server.php

[Only registered and activated users can see links. Click Here To Register...]

My maps.php

[Only registered and activated users can see links. Click Here To Register...]

My gameserver.es

[Only registered and activated users can see links. Click Here To Register...]

OrbitReborn Emulator Scractch server - server-main.cfg

[Only registered and activated users can see links. Click Here To Register...]

İnventory Error

[Only registered and activated users can see links. Click Here To Register...]

Shop Error

[Only registered and activated users can see links. Click Here To Register...]

Emulator Error

[Only registered and activated users can see links. Click Here To Register...]

Waiting for your help please
11/01/2014 11:12 supraturbo92#273
ok thanks mate i dont know y it went bbb bash lol
11/01/2014 11:16 PRΞĐΛTØR#274
Quote:
Originally Posted by xelle View Post
Hello I installed the orbital-reborn server but some errors occurred and I want to fix them in a batch format your help.

MySQL information.

[Only registered and activated users can see links. Click Here To Register...]

Web site IP address

[Only registered and activated users can see links. Click Here To Register...]

Now can you tell me where I made mistakes by checking the following photos ?

My inventory.php

[Only registered and activated users can see links. Click Here To Register...]

My shipAnim.php

[Only registered and activated users can see links. Click Here To Register...]

My database.php

[Only registered and activated users can see links. Click Here To Register...]

My paths.php

[Only registered and activated users can see links. Click Here To Register...]

My index.php

[Only registered and activated users can see links. Click Here To Register...]

My server.php

[Only registered and activated users can see links. Click Here To Register...]

My maps.php

[Only registered and activated users can see links. Click Here To Register...]

My gameserver.es

[Only registered and activated users can see links. Click Here To Register...]

OrbitReborn Emulator Scractch server - server-main.cfg

[Only registered and activated users can see links. Click Here To Register...]

İnventory Error

[Only registered and activated users can see links. Click Here To Register...]

Shop Error

[Only registered and activated users can see links. Click Here To Register...]

Emulator Error

[Only registered and activated users can see links. Click Here To Register...]

Waiting for your help please

You also want a coffee? :facepalm:
11/01/2014 12:04 LEJYONER(PvP)#275
[Only registered and activated users can see links. Click Here To Register...]

Why Spaceball Dont Work ? :(
11/01/2014 12:46 steppdroid#276
chat does not work .. why ?! work only in local.
I have modified with my ip the file www/view/internalMap/index.php

PHP Code:
chatHost=MYSERVERIP&useHash=0&host=MYSERVERIP
Quote:
Originally Posted by LEJYONER(PvP) View Post
[Only registered and activated users can see links. Click Here To Register...]

Why Spaceball Dont Work ? :(
Remplace you Spaceball.cs with this!

Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Data;
using System.Linq;
using System.Windows;

using OrbitReborn_Emulator.Specialized;
using OrbitReborn_Emulator.Storage;
using OrbitReborn_Emulator.Game.Sessions;
using OrbitReborn_Emulator.Communication;
using OrbitReborn_Emulator.Communication.Outgoing;
using OrbitReborn_Emulator.Util;
using OrbitReborn_Emulator.Game.Maps;
using OrbitReborn_Emulator.Game.Npcs;




namespace OrbitReborn_Emulator.Game.Event
{
    public static class Spaceball
    {
        private static int mId;
        private static bool mActive;
        private static int mMMOScore;
        private static int mEICScore;
        private static int mVRUScore;
        private static int mMoveToFirm;
        private static int mBallSpeed;
        private static int mDamageMMO;
        private static int mDamageEIC;
        private static int mDamageVRU;
        private static int mMostDamage;
        private static bool mIsMoving;
        private static int mLastMoveToFirm;
        private static int mLastBallSpeed;
        private static Timer mPerformUpdate;
        private static Timer mPathFinding;
        private static bool mChangeBallSpeed;
        private static bool mChangeMoveToFirm;

        public static int BallSpeed
        {
            get
            {
                return mBallSpeed;
            }
        }

        public static void Initialize()
        {
            mActive = false;
            mMMOScore = 0;
            mEICScore = 0;
            mVRUScore = 0;
            mMoveToFirm = 0;
            mBallSpeed = 0;
        }

        public static void ShowHud(Session Session)
        {
            if (mActive)
            {
                Session.SendData(PacketComposer.Compose("n", "ssi|" + mMMOScore + "|" + mEICScore + "|" + mVRUScore + "|" + mBallSpeed + "|" + mMoveToFirm));
            }
        }

        public static void SendHud()
        {
            SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssi|" + mMMOScore + "|" + mEICScore + "|" + mVRUScore + "|" + mBallSpeed +"|" + mMoveToFirm));
        }

        public static void UpdateScore(int FactionId)
        {
            if (FactionId == 1)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssc|"+FactionId+"|"+mMMOScore));
            }
            if (FactionId == 2)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssc|" + FactionId + "|" + mEICScore));
            }
            if (FactionId == 3)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssc|" + FactionId + "|" + mVRUScore));
            }
        }

        public static void UpdateSpeed(int FactionId)
        {
            if (FactionId == 1)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|" + FactionId + "|" + mBallSpeed));
            }
            if (FactionId == 2)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|" + FactionId + "|" + mBallSpeed));
            }
            if (FactionId == 3)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|" + FactionId + "|" + mBallSpeed));
            }
            if (FactionId == 0)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|0|" + mBallSpeed));
            }
        }

        public static void ResetBall(Npc Npc)
        {
            if (mPerformUpdate != null)
            {
                mPerformUpdate.Dispose();
                TimerManager.TimerRunning -= 1;
                mPerformUpdate = null;
            }

            // Try to retrieve Map information
            MapInfo Info = MapInfoLoader.GetMapInfo(16);

            // Load Map instance into the server memory if needed
            if (!MapManager.InstanceIsLoadedForMap(Info.Id))
            {
                MapManager.TryLoadMapInstance(Info.Id);
            }

            MapInstance Instance = MapManager.GetInstanceByMapId(16);

            if (Instance != null)
            {
                Instance.BroadcastMessage(PacketComposer.Compose("K", Npc.Id.ToString()));
                MapActor Actor = Instance.GetActorByReferenceId(mId, MapActorType.AiBot);
                if (Actor != null)
                {
                    Instance.KickNpc(Actor.Id);
                }
                Npc = NpcManager.CreateNewInstance("Spaceball", 16, 210, 130, 442, 1000, 1000, 1000, 1000, 100);
                Instance.AddNpcToMap(Npc);
                mId = Npc.Id;
                mPerformUpdate = new Timer(PerformUpdate, Npc, 0, 5000);
                TimerManager.TimerRunning += 1;
            }
        }

        public static void GiveReward(int FactionId)
        {
            List<Session> SessionUser = SessionManager.SessionsUser;
            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                foreach (Session Session in SessionUser)
                {
                    //Output.WriteLine("iterate");
                    if (Session.CharacterInfo.FactionId == FactionId)
                    {
                        string message = "Spaceball reward : + 10 kills.";
                        Session.SendData(PacketComposer.Compose("A", "STD|" + message));
                        Session.CharacterInfo.AddLog(MySqlClient, message);
                        Session.CharacterInfo.AddKillReward(MySqlClient, 10);
                    }
                }
            }
        }

        public static void CreateSpaceball()
        {
            if (mPerformUpdate != null)
            {
                mPerformUpdate.Dispose();
                TimerManager.TimerRunning -= 1;
                mPerformUpdate = null;
            }
            mActive = true;
            SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssi|" + mMMOScore + "|" + mEICScore + "|" + mVRUScore + "|" + mBallSpeed + "|" + mMoveToFirm));

            MapInfo Info = MapInfoLoader.GetMapInfo(16);

            if (!MapManager.InstanceIsLoadedForMap(Info.Id))
            {
                MapManager.TryLoadMapInstance(Info.Id);
            }

            MapInstance Instance = MapManager.GetInstanceByMapId(16);
            if (Instance != null)
            {
                Instance.Info.MaxUsers = 20;
                Npc Npc = NpcManager.CreateNewInstance("Spaceball", 16, 210, 130, 442, 1000, 1000, 1000, 1000, 100);
                Instance.AddNpcToMap(Npc);
                mId = Npc.Id;
                mPerformUpdate = new Timer(PerformUpdate, Npc, 0, 5000);
                TimerManager.TimerRunning += 1;
                //Instance.BroadcastMessage(PacketComposer.Compose("C", "-10|1|0||pointer|21000|13000|0|0|0|0|0|0"));
            }

        }

        public static void StopSpaceball()
        {
            mActive = false;
            if (mPerformUpdate != null)
            {
                mPerformUpdate.Dispose();
                TimerManager.TimerRunning -= 1;
                mPerformUpdate = null;
            }
            UpdateSpeed(0);
            MapInstance Instance = MapManager.GetInstanceByMapId(16);
            if (Instance != null)
            {
                Instance.Info.MaxUsers = 0;
                MapActor Actor = Instance.GetActorByReferenceId(mId, MapActorType.AiBot);
                if (Actor != null)
                {
                    Instance.KickNpc(Actor.Id);
                }
            }
        }

        public static void DoDamage(int Damage, int FactionId)
        {
            if (FactionId == 1)
            {
                mDamageMMO += Damage;
            }
            if (FactionId == 2)
            {
                mDamageEIC += Damage;
            }
            if (FactionId == 3)
            {
                mDamageVRU += Damage;
            }
            //Output.WriteLine("dmg : " + Damage);

        }

        private static void PerformUpdate(object state)
        {
            Npc Npc = (Npc)state;

            MapInstance Instance = MapManager.GetInstanceByMapId(16);
            if (Instance == null)
            {
                return;
            }

            //Output.WriteLine("npc is moving : " + Npc.IsMoving);

            int temp;
            int bestfaction;

            if (mDamageMMO > mDamageEIC)
            {
                temp = mDamageMMO;
                bestfaction = 1;
            }
            else
            {
                temp = mDamageEIC;
                bestfaction = 2;
            }

            if (mDamageVRU > temp)
            {
                temp = mDamageVRU;
                bestfaction = 3;
            }

            if (mDamageVRU > 0 || mDamageMMO > 0 || mDamageEIC > 0)
            {
                mMostDamage = temp;
                mMoveToFirm = bestfaction;
            }
            else
            {
                mMostDamage = 0;
                mMoveToFirm = 0;
                mBallSpeed = 0;
            }

            if (mMostDamage <= 10000)
            {
                mBallSpeed = 0;
            }

            if (mMostDamage > 8000)
            {
                mBallSpeed = 1;
            }
            if (mMostDamage > 4000)
            {
                mBallSpeed = 2;
            }
            if (mMostDamage > 1500)
            {
                mBallSpeed = 3;
            }

            //Output.WriteLine("ball speed : " + mBallSpeed);


            if (mBallSpeed == 0 && mBallSpeed != mLastBallSpeed)
            {
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                Npc.IsMoving = false;
                Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, Npc.LocX*100, Npc.LocY*100, 1000));
            }

            if (mMoveToFirm != mLastMoveToFirm)
            {
                if (mMoveToFirm == 1)
                {
                    Npc.NewLocX = 20;
                    Npc.NewLocY = 130;
                }
                if (mMoveToFirm == 2)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 20;
                }
                if (mMoveToFirm == 3)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 250;
                }
                UpdateSpeed(mMoveToFirm);
                mChangeMoveToFirm = true;
            }

            if (mBallSpeed > 0 && mBallSpeed != mLastBallSpeed && mMoveToFirm == mLastMoveToFirm)
            {
                mChangeBallSpeed = true;
            }

            if (mBallSpeed != mLastBallSpeed)
            {
                UpdateSpeed(mMoveToFirm);
            }

            if (mBallSpeed > 0 && !Npc.IsMoving)
            {
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                Npc.IsMoving = true;
                Npc.TimeTaken = 1;
                Npc.OldLocX = Npc.LocX;
                Npc.OldLocY = Npc.LocY;
                if (mMoveToFirm == 1)
                {
                    Npc.NewLocX = 20;
                    Npc.NewLocY = 130;
                }
                if (mMoveToFirm == 2)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 20;
                }
                if (mMoveToFirm == 3)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 250;
                }
                int deltaX = Npc.LocX * 100 - Npc.NewLocX * 100;
                int deltaY = Npc.LocY * 100 - Npc.NewLocY * 100;
                double distance = (Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)));
                double timeTaken = (distance / (Npc.ShipSpeed * mBallSpeed)) * 1000;
                timeTaken = timeTaken * 1.03;
                Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, Npc.NewLocX * 100, Npc.NewLocY * 100, timeTaken));
                mPathFinding = new Timer(PathFinding, Npc, 0, 235);
                TimerManager.TimerRunning += 1;
            }

            mLastBallSpeed = mBallSpeed;
            mLastMoveToFirm = mMoveToFirm;

            //Output.WriteLine("most damage : " + mMostDamage + " from : " + mMoveToFirm);
            //Output.WriteLine("npc id : " + Npc.Id);
            mDamageMMO = 0;
            mDamageEIC = 0;
            mDamageVRU = 0;
            mMostDamage = 0;
            //mBallSpeed = 0;
        }

        private static void PathFinding(object state)
        {
            Npc Npc = (Npc)state;

            //if (!mActive || mBallSpeed == 0)
            //{
            //    if (mPathFinding != null)
            //    {
            //        mPathFinding.Dispose();
            //        TimerManager.TimerRunning -= 1;
            //        mPathFinding = null;
            //    }
            //}

            //Output.WriteLine("this is running");

            if (!mActive || !Npc.IsMoving)
            {
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                return;
            }

            if (mChangeMoveToFirm)
            {
                MapInstance Instance = MapManager.GetInstanceByMapId(16);
                if (Instance != null)
                {
                    mChangeMoveToFirm = false;
                    int LocX = Npc.LocX * 100;
                    int LocY = Npc.LocY * 100;
                    int NewLocX = Npc.NewLocX * 100;
                    int NewLocY = Npc.NewLocY * 100;
                    int deltaX = LocX - NewLocX;
                    int deltaY = LocY - NewLocY;
                    double distance = (Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)));
                    double timeTaken = (distance / (Npc.ShipSpeed * mBallSpeed) * 1000);
                    timeTaken = timeTaken * 1.03;
                    //Output.WriteLine("new ball speed !");
                    Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, NewLocX, NewLocY, timeTaken));
                    Npc.TimeTaken = 1;
                    Npc.OldLocX = Npc.LocX;
                    Npc.OldLocY = Npc.LocY;
                }
            }

            if (mChangeBallSpeed)
            {
                MapInstance Instance = MapManager.GetInstanceByMapId(16);
                if (Instance != null)
                {
                    mChangeBallSpeed = false;
                    int LocX = Npc.LocX * 100;
                    int LocY = Npc.LocY * 100;
                    int NewLocX = Npc.NewLocX * 100;
                    int NewLocY = Npc.NewLocY * 100;
                    int deltaX = LocX - NewLocX;
                    int deltaY = LocY - NewLocY;
                    double distance = (Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)));
                    double timeTaken = (distance / (Npc.ShipSpeed * mBallSpeed) * 1000);
                    timeTaken = timeTaken * 1.03;
                    //Output.WriteLine("new ball speed !");
                    Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, NewLocX, NewLocY, timeTaken));
                    Npc.TimeTaken = 1;
                    Npc.OldLocX = Npc.LocX;
                    Npc.OldLocY = Npc.LocY;
                }
            }


            //Output.WriteLine("pathfinding still running bro.");

            Npc.TimeTaken += 1;
            Vector startpos = new Vector(Npc.OldLocX, Npc.OldLocY);
            Vector endpos = new Vector(Npc.NewLocX, Npc.NewLocY);

            Vector mov_vec = Vector.Subtract(endpos, startpos);


            double mov_vec_len = Math.Sqrt(Math.Pow(mov_vec.X, 2) + Math.Pow(mov_vec.Y, 2));
            Vector result = calculatePosition(ref startpos, ref endpos, (double)Npc.TimeTaken, ((double)Npc.ShipSpeed * mBallSpeed) / 416);
            Vector result_vec = Vector.Subtract(startpos, result);
            double result_mov_len = Math.Sqrt(Math.Pow(result_vec.X, 2) + Math.Pow(result_vec.Y, 2));

            if (result_mov_len > mov_vec_len)
            {
                Npc.IsMoving = false;
                if (mMoveToFirm == 1)
                {
                    mMMOScore += 1;
                    UpdateScore(1);
                }
                if (mMoveToFirm == 2)
                {
                    mEICScore += 1;
                    UpdateScore(2);
                }
                if (mMoveToFirm == 3)
                {
                    mVRUScore += 1;
                    UpdateScore(3);
                }

                GiveReward(mMoveToFirm);

                UpdateSpeed(0);
                ResetBall(Npc);

                //Output.WriteLine("is arrived.");
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                return;
            }

            //Output.WriteLine(" " + Npc.Name + " " + Math.Round(result.X) + "/" + Math.Round(result.Y));
            Npc.LocX = (int)Math.Round(result.X);
            Npc.LocY = (int)Math.Round(result.Y);
            //Session TargetUser2 = SessionManager.GetSessionByCharacterId(62);
            //TargetUser2.SendData(PacketComposer.Compose("1", "-10|"+Npc.LocX+"00|"+Npc.LocY+"00"));

            //if (Session.StoppedPlayer || Session.CharacterInfo.Destroy || Session.CharacterInfo.Disconnected)
            //{
            //    if (Session.CharacterInfo.PathFinding != null)
            //    {
            //        Session.CharacterInfo.PathFinding.Dispose();
            //        TimerManager.TimerRunning -= 1;
            //        Session.CharacterInfo.PathFinding = null;
            //    }
            //}

            //Session.CharacterInfo.TmpActiveConfig = Session.CharacterInfo.ActiveConfig;
        }

        private static Vector calculatePosition(ref Vector start_pos, ref Vector end_pos, double time, double speed)
        {
            Vector mov_vec = Vector.Subtract(end_pos, start_pos);

            mov_vec.Normalize();

            Vector delta_vec = mov_vec * time * speed;

            Vector result = Vector.Add(start_pos, delta_vec);
            return result;
        }
    }
}
11/01/2014 13:40 xelle#277
Quote:
Originally Posted by hugo95=) View Post

You also want a coffee? :facepalm:
I did file settings such problem stems from?
Inventory and shops problematic.
?
11/01/2014 14:14 BotorCrime#278
[Only registered and activated users can see links. Click Here To Register...]
How I can add new button ? ( In : ui.swf ... window1.sfw ... ????? )
11/01/2014 15:30 steppdroid#279
Quote:
Originally Posted by LEJYONER(PvP) View Post
[Only registered and activated users can see links. Click Here To Register...]

Why Spaceball Dont Work ? :(
Emulator with spaceball fix
[Only registered and activated users can see links. Click Here To Register...]

LEJYONER for fix "You've killed .. players" in hall of fame go to www\views\internalStart\index.php and
remplace line 111 with this:
PHP Code:
<span class="menu" style="font-size: 10px">You've killed <?php echo Auth::getUser('user_kill'); ?> players</span>
11/01/2014 15:41 Destiny#280
212.67.156.149 test i have bug with eq and shop :( idk where error i try find
11/01/2014 15:44 LEJYONER(PvP)#281
Quote:
Originally Posted by steppdroid View Post
Emulator with spaceball fix
[Only registered and activated users can see links. Click Here To Register...]

LEJYONER for fix "You've killed .. players" in hall of fame go to www\views\internalStart\index.php and
remplace line 111 with this:
PHP Code:
<span class="menu" style="font-size: 10px">You've killed <?php echo Auth::getUser('user_kill'); ?> players</span>
Thanks and What Emulator Download Key ?
11/01/2014 15:55 steppdroid#282
Quote:
Originally Posted by edox77 View Post
212.67.156.149 test i have bug with eq and shop :( idk where error i try find
ramplace in www/view/internalDock/index.php
with you ip.
11/01/2014 16:31 Arby#283
I can understand if you have questions regarding the actual source/files. However, any questions which aren't related to the source (this could be, how do I add this, make this new things, fix this), ask [Only registered and activated users can see links. Click Here To Register...].

This source is a basis and can be used for a guideline towards making your PServer, the people here don't mind helping out if you have problems with the actual source. But questions with problems of coding or whatever needed to be posted [Only registered and activated users can see links. Click Here To Register...].

I'm fine with people asking for help, but you can't expect them to do everything.
Please consider this as a little warning.

I'll try and check this topic when I can, if I see any posts which I believe should be posted in the other thread, they will more than likely be deleted (with other possible consequences).

I'm sure that what linkpad wanted of this thread, as a basis to help people. If I misunderstood the thread, then I apologise, if so, please contact me linkpad. But from what I'm seeing, it serves as a type of guide.
11/01/2014 17:07 WrednYTrainer#284
i don't understand too
11/01/2014 18:05 linkpad#285
Quote:
Originally Posted by steppdroid View Post
chat does not work .. why ?! work only in local.
I have modified with my ip the file www/view/internalMap/index.php

PHP Code:
chatHost=MYSERVERIP&useHash=0&host=MYSERVERIP


Remplace you Spaceball.cs with this!

Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Data;
using System.Linq;
using System.Windows;

using OrbitReborn_Emulator.Specialized;
using OrbitReborn_Emulator.Storage;
using OrbitReborn_Emulator.Game.Sessions;
using OrbitReborn_Emulator.Communication;
using OrbitReborn_Emulator.Communication.Outgoing;
using OrbitReborn_Emulator.Util;
using OrbitReborn_Emulator.Game.Maps;
using OrbitReborn_Emulator.Game.Npcs;




namespace OrbitReborn_Emulator.Game.Event
{
    public static class Spaceball
    {
        private static int mId;
        private static bool mActive;
        private static int mMMOScore;
        private static int mEICScore;
        private static int mVRUScore;
        private static int mMoveToFirm;
        private static int mBallSpeed;
        private static int mDamageMMO;
        private static int mDamageEIC;
        private static int mDamageVRU;
        private static int mMostDamage;
        private static bool mIsMoving;
        private static int mLastMoveToFirm;
        private static int mLastBallSpeed;
        private static Timer mPerformUpdate;
        private static Timer mPathFinding;
        private static bool mChangeBallSpeed;
        private static bool mChangeMoveToFirm;

        public static int BallSpeed
        {
            get
            {
                return mBallSpeed;
            }
        }

        public static void Initialize()
        {
            mActive = false;
            mMMOScore = 0;
            mEICScore = 0;
            mVRUScore = 0;
            mMoveToFirm = 0;
            mBallSpeed = 0;
        }

        public static void ShowHud(Session Session)
        {
            if (mActive)
            {
                Session.SendData(PacketComposer.Compose("n", "ssi|" + mMMOScore + "|" + mEICScore + "|" + mVRUScore + "|" + mBallSpeed + "|" + mMoveToFirm));
            }
        }

        public static void SendHud()
        {
            SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssi|" + mMMOScore + "|" + mEICScore + "|" + mVRUScore + "|" + mBallSpeed +"|" + mMoveToFirm));
        }

        public static void UpdateScore(int FactionId)
        {
            if (FactionId == 1)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssc|"+FactionId+"|"+mMMOScore));
            }
            if (FactionId == 2)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssc|" + FactionId + "|" + mEICScore));
            }
            if (FactionId == 3)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssc|" + FactionId + "|" + mVRUScore));
            }
        }

        public static void UpdateSpeed(int FactionId)
        {
            if (FactionId == 1)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|" + FactionId + "|" + mBallSpeed));
            }
            if (FactionId == 2)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|" + FactionId + "|" + mBallSpeed));
            }
            if (FactionId == 3)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|" + FactionId + "|" + mBallSpeed));
            }
            if (FactionId == 0)
            {
                SessionManager.BroadcastToUser(PacketComposer.Compose("n", "sss|0|" + mBallSpeed));
            }
        }

        public static void ResetBall(Npc Npc)
        {
            if (mPerformUpdate != null)
            {
                mPerformUpdate.Dispose();
                TimerManager.TimerRunning -= 1;
                mPerformUpdate = null;
            }

            // Try to retrieve Map information
            MapInfo Info = MapInfoLoader.GetMapInfo(16);

            // Load Map instance into the server memory if needed
            if (!MapManager.InstanceIsLoadedForMap(Info.Id))
            {
                MapManager.TryLoadMapInstance(Info.Id);
            }

            MapInstance Instance = MapManager.GetInstanceByMapId(16);

            if (Instance != null)
            {
                Instance.BroadcastMessage(PacketComposer.Compose("K", Npc.Id.ToString()));
                MapActor Actor = Instance.GetActorByReferenceId(mId, MapActorType.AiBot);
                if (Actor != null)
                {
                    Instance.KickNpc(Actor.Id);
                }
                Npc = NpcManager.CreateNewInstance("Spaceball", 16, 210, 130, 442, 1000, 1000, 1000, 1000, 100);
                Instance.AddNpcToMap(Npc);
                mId = Npc.Id;
                mPerformUpdate = new Timer(PerformUpdate, Npc, 0, 5000);
                TimerManager.TimerRunning += 1;
            }
        }

        public static void GiveReward(int FactionId)
        {
            List<Session> SessionUser = SessionManager.SessionsUser;
            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                foreach (Session Session in SessionUser)
                {
                    //Output.WriteLine("iterate");
                    if (Session.CharacterInfo.FactionId == FactionId)
                    {
                        string message = "Spaceball reward : + 10 kills.";
                        Session.SendData(PacketComposer.Compose("A", "STD|" + message));
                        Session.CharacterInfo.AddLog(MySqlClient, message);
                        Session.CharacterInfo.AddKillReward(MySqlClient, 10);
                    }
                }
            }
        }

        public static void CreateSpaceball()
        {
            if (mPerformUpdate != null)
            {
                mPerformUpdate.Dispose();
                TimerManager.TimerRunning -= 1;
                mPerformUpdate = null;
            }
            mActive = true;
            SessionManager.BroadcastToUser(PacketComposer.Compose("n", "ssi|" + mMMOScore + "|" + mEICScore + "|" + mVRUScore + "|" + mBallSpeed + "|" + mMoveToFirm));

            MapInfo Info = MapInfoLoader.GetMapInfo(16);

            if (!MapManager.InstanceIsLoadedForMap(Info.Id))
            {
                MapManager.TryLoadMapInstance(Info.Id);
            }

            MapInstance Instance = MapManager.GetInstanceByMapId(16);
            if (Instance != null)
            {
                Instance.Info.MaxUsers = 20;
                Npc Npc = NpcManager.CreateNewInstance("Spaceball", 16, 210, 130, 442, 1000, 1000, 1000, 1000, 100);
                Instance.AddNpcToMap(Npc);
                mId = Npc.Id;
                mPerformUpdate = new Timer(PerformUpdate, Npc, 0, 5000);
                TimerManager.TimerRunning += 1;
                //Instance.BroadcastMessage(PacketComposer.Compose("C", "-10|1|0||pointer|21000|13000|0|0|0|0|0|0"));
            }

        }

        public static void StopSpaceball()
        {
            mActive = false;
            if (mPerformUpdate != null)
            {
                mPerformUpdate.Dispose();
                TimerManager.TimerRunning -= 1;
                mPerformUpdate = null;
            }
            UpdateSpeed(0);
            MapInstance Instance = MapManager.GetInstanceByMapId(16);
            if (Instance != null)
            {
                Instance.Info.MaxUsers = 0;
                MapActor Actor = Instance.GetActorByReferenceId(mId, MapActorType.AiBot);
                if (Actor != null)
                {
                    Instance.KickNpc(Actor.Id);
                }
            }
        }

        public static void DoDamage(int Damage, int FactionId)
        {
            if (FactionId == 1)
            {
                mDamageMMO += Damage;
            }
            if (FactionId == 2)
            {
                mDamageEIC += Damage;
            }
            if (FactionId == 3)
            {
                mDamageVRU += Damage;
            }
            //Output.WriteLine("dmg : " + Damage);

        }

        private static void PerformUpdate(object state)
        {
            Npc Npc = (Npc)state;

            MapInstance Instance = MapManager.GetInstanceByMapId(16);
            if (Instance == null)
            {
                return;
            }

            //Output.WriteLine("npc is moving : " + Npc.IsMoving);

            int temp;
            int bestfaction;

            if (mDamageMMO > mDamageEIC)
            {
                temp = mDamageMMO;
                bestfaction = 1;
            }
            else
            {
                temp = mDamageEIC;
                bestfaction = 2;
            }

            if (mDamageVRU > temp)
            {
                temp = mDamageVRU;
                bestfaction = 3;
            }

            if (mDamageVRU > 0 || mDamageMMO > 0 || mDamageEIC > 0)
            {
                mMostDamage = temp;
                mMoveToFirm = bestfaction;
            }
            else
            {
                mMostDamage = 0;
                mMoveToFirm = 0;
                mBallSpeed = 0;
            }

            if (mMostDamage <= 10000)
            {
                mBallSpeed = 0;
            }

            if (mMostDamage > 8000)
            {
                mBallSpeed = 1;
            }
            if (mMostDamage > 4000)
            {
                mBallSpeed = 2;
            }
            if (mMostDamage > 1500)
            {
                mBallSpeed = 3;
            }

            //Output.WriteLine("ball speed : " + mBallSpeed);


            if (mBallSpeed == 0 && mBallSpeed != mLastBallSpeed)
            {
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                Npc.IsMoving = false;
                Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, Npc.LocX*100, Npc.LocY*100, 1000));
            }

            if (mMoveToFirm != mLastMoveToFirm)
            {
                if (mMoveToFirm == 1)
                {
                    Npc.NewLocX = 20;
                    Npc.NewLocY = 130;
                }
                if (mMoveToFirm == 2)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 20;
                }
                if (mMoveToFirm == 3)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 250;
                }
                UpdateSpeed(mMoveToFirm);
                mChangeMoveToFirm = true;
            }

            if (mBallSpeed > 0 && mBallSpeed != mLastBallSpeed && mMoveToFirm == mLastMoveToFirm)
            {
                mChangeBallSpeed = true;
            }

            if (mBallSpeed != mLastBallSpeed)
            {
                UpdateSpeed(mMoveToFirm);
            }

            if (mBallSpeed > 0 && !Npc.IsMoving)
            {
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                Npc.IsMoving = true;
                Npc.TimeTaken = 1;
                Npc.OldLocX = Npc.LocX;
                Npc.OldLocY = Npc.LocY;
                if (mMoveToFirm == 1)
                {
                    Npc.NewLocX = 20;
                    Npc.NewLocY = 130;
                }
                if (mMoveToFirm == 2)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 20;
                }
                if (mMoveToFirm == 3)
                {
                    Npc.NewLocX = 360;
                    Npc.NewLocY = 250;
                }
                int deltaX = Npc.LocX * 100 - Npc.NewLocX * 100;
                int deltaY = Npc.LocY * 100 - Npc.NewLocY * 100;
                double distance = (Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)));
                double timeTaken = (distance / (Npc.ShipSpeed * mBallSpeed)) * 1000;
                timeTaken = timeTaken * 1.03;
                Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, Npc.NewLocX * 100, Npc.NewLocY * 100, timeTaken));
                mPathFinding = new Timer(PathFinding, Npc, 0, 235);
                TimerManager.TimerRunning += 1;
            }

            mLastBallSpeed = mBallSpeed;
            mLastMoveToFirm = mMoveToFirm;

            //Output.WriteLine("most damage : " + mMostDamage + " from : " + mMoveToFirm);
            //Output.WriteLine("npc id : " + Npc.Id);
            mDamageMMO = 0;
            mDamageEIC = 0;
            mDamageVRU = 0;
            mMostDamage = 0;
            //mBallSpeed = 0;
        }

        private static void PathFinding(object state)
        {
            Npc Npc = (Npc)state;

            //if (!mActive || mBallSpeed == 0)
            //{
            //    if (mPathFinding != null)
            //    {
            //        mPathFinding.Dispose();
            //        TimerManager.TimerRunning -= 1;
            //        mPathFinding = null;
            //    }
            //}

            //Output.WriteLine("this is running");

            if (!mActive || !Npc.IsMoving)
            {
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                return;
            }

            if (mChangeMoveToFirm)
            {
                MapInstance Instance = MapManager.GetInstanceByMapId(16);
                if (Instance != null)
                {
                    mChangeMoveToFirm = false;
                    int LocX = Npc.LocX * 100;
                    int LocY = Npc.LocY * 100;
                    int NewLocX = Npc.NewLocX * 100;
                    int NewLocY = Npc.NewLocY * 100;
                    int deltaX = LocX - NewLocX;
                    int deltaY = LocY - NewLocY;
                    double distance = (Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)));
                    double timeTaken = (distance / (Npc.ShipSpeed * mBallSpeed) * 1000);
                    timeTaken = timeTaken * 1.03;
                    //Output.WriteLine("new ball speed !");
                    Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, NewLocX, NewLocY, timeTaken));
                    Npc.TimeTaken = 1;
                    Npc.OldLocX = Npc.LocX;
                    Npc.OldLocY = Npc.LocY;
                }
            }

            if (mChangeBallSpeed)
            {
                MapInstance Instance = MapManager.GetInstanceByMapId(16);
                if (Instance != null)
                {
                    mChangeBallSpeed = false;
                    int LocX = Npc.LocX * 100;
                    int LocY = Npc.LocY * 100;
                    int NewLocX = Npc.NewLocX * 100;
                    int NewLocY = Npc.NewLocY * 100;
                    int deltaX = LocX - NewLocX;
                    int deltaY = LocY - NewLocY;
                    double distance = (Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2)));
                    double timeTaken = (distance / (Npc.ShipSpeed * mBallSpeed) * 1000);
                    timeTaken = timeTaken * 1.03;
                    //Output.WriteLine("new ball speed !");
                    Instance.BroadcastMessage(MapShipMovementComposer.Compose(Npc.Id, NewLocX, NewLocY, timeTaken));
                    Npc.TimeTaken = 1;
                    Npc.OldLocX = Npc.LocX;
                    Npc.OldLocY = Npc.LocY;
                }
            }


            //Output.WriteLine("pathfinding still running bro.");

            Npc.TimeTaken += 1;
            Vector startpos = new Vector(Npc.OldLocX, Npc.OldLocY);
            Vector endpos = new Vector(Npc.NewLocX, Npc.NewLocY);

            Vector mov_vec = Vector.Subtract(endpos, startpos);


            double mov_vec_len = Math.Sqrt(Math.Pow(mov_vec.X, 2) + Math.Pow(mov_vec.Y, 2));
            Vector result = calculatePosition(ref startpos, ref endpos, (double)Npc.TimeTaken, ((double)Npc.ShipSpeed * mBallSpeed) / 416);
            Vector result_vec = Vector.Subtract(startpos, result);
            double result_mov_len = Math.Sqrt(Math.Pow(result_vec.X, 2) + Math.Pow(result_vec.Y, 2));

            if (result_mov_len > mov_vec_len)
            {
                Npc.IsMoving = false;
                if (mMoveToFirm == 1)
                {
                    mMMOScore += 1;
                    UpdateScore(1);
                }
                if (mMoveToFirm == 2)
                {
                    mEICScore += 1;
                    UpdateScore(2);
                }
                if (mMoveToFirm == 3)
                {
                    mVRUScore += 1;
                    UpdateScore(3);
                }

                GiveReward(mMoveToFirm);

                UpdateSpeed(0);
                ResetBall(Npc);

                //Output.WriteLine("is arrived.");
                if (mPathFinding != null)
                {
                    mPathFinding.Dispose();
                    TimerManager.TimerRunning -= 1;
                    mPathFinding = null;
                }
                return;
            }

            //Output.WriteLine(" " + Npc.Name + " " + Math.Round(result.X) + "/" + Math.Round(result.Y));
            Npc.LocX = (int)Math.Round(result.X);
            Npc.LocY = (int)Math.Round(result.Y);
            //Session TargetUser2 = SessionManager.GetSessionByCharacterId(62);
            //TargetUser2.SendData(PacketComposer.Compose("1", "-10|"+Npc.LocX+"00|"+Npc.LocY+"00"));

            //if (Session.StoppedPlayer || Session.CharacterInfo.Destroy || Session.CharacterInfo.Disconnected)
            //{
            //    if (Session.CharacterInfo.PathFinding != null)
            //    {
            //        Session.CharacterInfo.PathFinding.Dispose();
            //        TimerManager.TimerRunning -= 1;
            //        Session.CharacterInfo.PathFinding = null;
            //    }
            //}

            //Session.CharacterInfo.TmpActiveConfig = Session.CharacterInfo.ActiveConfig;
        }

        private static Vector calculatePosition(ref Vector start_pos, ref Vector end_pos, double time, double speed)
        {
            Vector mov_vec = Vector.Subtract(end_pos, start_pos);

            mov_vec.Normalize();

            Vector delta_vec = mov_vec * time * speed;

            Vector result = Vector.Add(start_pos, delta_vec);
            return result;
        }
    }
}
You really don't understand these lines of code :

Code:
            if (mMostDamage <= 10000)
            {
                mBallSpeed = 0;
            }

            if (mMostDamage > 8000)
            {
                mBallSpeed = 1;
            }
            if (mMostDamage > 4000)
            {
                mBallSpeed = 2;
            }
            if (mMostDamage > 1500)
            {
                mBallSpeed = 3;
            }
For all people complaining about spaceball not "working", trust me it does. The spaceball was programmed for a lot of players playing it and not one or two users. How does it works ? It check how many damage players did to the ball every 5secs. If the ball speed is 0, the ball dont move, 3 is the fastest ball speed. Now you know that, you should edit your if statement because as it stand, more damage you do, more slow the ball will be...

Quote:
Originally Posted by steppdroid View Post
Emulator with spaceball fix
[Only registered and activated users can see links. Click Here To Register...]

LEJYONER for fix "You've killed .. players" in hall of fame go to www\views\internalStart\index.php and
remplace line 111 with this:
PHP Code:
<span class="menu" style="font-size: 10px">You've killed <?php echo Auth::getUser('user_kill'); ?> players</span>
I'm ok with giving a pack of my source but at least provide improvement in it, and a correct one. Not this "false" fix of spaceball.

Quote:
Originally Posted by Arby View Post
I can understand if you have questions regarding the actual source/files. However, any questions which aren't related to the source (this could be, how do I add this, make this new things, fix this), ask [Only registered and activated users can see links. Click Here To Register...].

This source is a basis and can be used for a guideline towards making your PServer, the people here don't mind helping out if you have problems with the actual source. But questions with problems of coding or whatever needed to be posted [Only registered and activated users can see links. Click Here To Register...].

I'm fine with people asking for help, but you can't expect them to do everything.
Please consider this as a little warning.

I'll try and check this topic when I can, if I see any posts which I believe should be posted in the other thread, they will more than likely be deleted (with other possible consequences).

I'm sure that what linkpad wanted of this thread, as a basis to help people. If I misunderstood the thread, then I apologise, if so, please contact me linkpad. But from what I'm seeing, it serves as a type of guide.
You didn't misunderstand the thread, these source I published to the community are here for helping others programmers and not for making a copy of "Orbit Reborn." So yes, post in this thread should be related to coding and not "how to install the server".