protected void useItem(NPCProto npc, Item item, short state, short targetState)
        {
            if (!(state == -1 && targetState == -2))
            {
                return;
            }

            npc.ApplyOverlay("HUMANS_SPRINT.MDS");

            ITPO_SPEED_TIMER timer = (ITPO_SPEED_TIMER)npc.getUserObjects("itpo_speed_timer");

            if (timer == null)
            {
                timer          = new ITPO_SPEED_TIMER(npc); //5 Minuten
                timer.TimeSpan = 10000 * 1000 * 15;         //15 Sekunden
                timer.Start();
                npc.setUserObject("itpo_speed_timer", timer);
            }
            else
            {
                timer.TimeSpan = 10000 * 1000 * 15;//15 Sekunden
                timer.End();
                timer.Start();
            }
        }
Exemplo n.º 2
0
 protected void equip(NPCProto npc, Item item)
 {
     npc.MPMax += 10;
     npc.MP    += 10;
     npc.HPMax += 30;
     npc.HP    += 30;
 }
Exemplo n.º 3
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int casterID = 0, targetID = 0, spellID = 0, itemID = 0;

            stream.Read(out itemID);
            stream.Read(out casterID);
            stream.Read(out targetID);
            stream.Read(out spellID);


            Vob  itemVob = null;
            Item item    = null;

            Vob   casterVob = null;
            Spell spell     = null;

            NPCProto caster = null;
            Vob      target = null;

            sWorld.VobDict.TryGetValue(casterID, out casterVob);
            sWorld.VobDict.TryGetValue(itemID, out itemVob);

            if (casterVob == null)
            {
                throw new Exception("Caster was not found!");
            }
            if (!(casterVob is NPCProto))
            {
                throw new Exception("Caster was not a npcproto " + casterVob);
            }
            caster = (NPCProto)casterVob;
            if (targetID != 0)
            {
                sWorld.VobDict.TryGetValue(targetID, out target);
            }

            Spell.SpellDict.TryGetValue(spellID, out spell);
            if (spell == null)
            {
                throw new Exception("Spell can not be null!");
            }



            if (caster.Address == 0)
            {
                return;
            }
            Process process = Process.ThisProcess();
            oCNpc   npc     = new oCNpc(process, caster.Address);

            if (target != null)
            {
                npc.MagBook.Spell_Setup(npc, new zCVob(process, target.Address), 0);
            }
            //npc.MagBook.GetSelectedSpell().Target = new zCVob(process, target.Address);
            npc.MagBook.SpellCast();

            zERROR.GetZErr(process).Report(2, 'G', "Cast Spell! 2 ", 0, "Program.cs", 0);
        }
Exemplo n.º 4
0
        public static void Write(NPCProto proto, Item itm, Vob target, Spell spell, AddressOrGUID guidExclude)
        {
            BitStream stream = Program.server.SendBitStream;

            stream.Reset();
            stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            stream.Write((byte)NetworkID.CastSpell);

            stream.Write(itm.ID);
            stream.Write(proto.ID);
            if (target == null)
            {
                stream.Write(0);
            }
            else
            {
                stream.Write(target.ID);
            }
            if (spell == null)
            {
                stream.Write(0);
            }
            else
            {
                stream.Write(spell.ID);
            }

            if (guidExclude == null)
            {
                guidExclude = RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS;
            }
            Program.server.ServerInterface.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, guidExclude, true);
        }
Exemplo n.º 5
0
 protected void useItem(NPCProto npc, Item item, short state, short targetState)
 {
     if (!(state == -1 && targetState == 0))
     {
         return;
     }
 }
Exemplo n.º 6
0
        public static Int32 oCStartAnim_ModelAnim(String message)
        {
            int     address = Convert.ToInt32(message);
            Process process = Process.ThisProcess();
            int     err     = 0;

            try
            {
                err = 1;
                zCModel thisModel = new zCModel(process, process.ReadInt(address));
                err = 2;
                int ownerAddress = thisModel.Owner.Address;
                err = 3;
                if (!sWorld.SpawnedVobDict.ContainsKey(ownerAddress))
                {
                    return(0);
                }
                Vob v = sWorld.SpawnedVobDict[ownerAddress];
                if (!(v is NPCProto))
                {
                    return(0);
                }

                NPCProto player = (NPCProto)v;
                if (player == null)
                {
                    return(0);
                }

                if (player != Player.Hero)
                {
                    return(0);
                }

                zCModelAni modelAni = new zCModelAni(process, process.ReadInt(address + 4));
                if (modelAni == null || modelAni.Address == 0)
                {
                    return(0);
                }



                int aniID = modelAni.GetAniID();
                //String name = modelAni.AniName.Value.Trim();//Works
                if (player.Animation == aniID)
                {
                    return(0);
                }

                player.Animation = (short)aniID;
                AnimationUpdateMessage.Write(player);
            }
            catch (Exception ex)
            {
                zERROR.GetZErr(process).Report(2, 'G', err + "Exception: " + ex.Message + " " + ex.StackTrace + " " + ex.Source, 0, "Program.cs", 0);
            }


            return(0);
        }
Exemplo n.º 7
0
 internal void OnContainerPickLocks(MobLockable mobInter, NPCProto npc, char c)
 {
     if (OnPickLocked != null)
     {
         OnPickLocked(mobInter, npc, c);
     }
 }
Exemplo n.º 8
0
 internal void iOnUnTrigger(MobInter mobInter, NPCProto npc)
 {
     if (OnUnTrigger != null)
     {
         OnUnTrigger(mobInter, npc);
     }
 }
Exemplo n.º 9
0
        public static String getRunAnimation(this NPCProto proto)
        {
            String anim = "S_WALKL";

            if (proto.WeaponMode == 1)
            {
                anim = "S_FISTWALKL";
            }

            if (proto.getAI().WalkType == Enumeration.WalkTypes.Run)
            {
                if (proto.WeaponMode == 0)
                {
                    anim = "S_RUNL";
                }
                else if (proto.WeaponMode == 1)
                {
                    anim = "S_FISTRUNL";
                }
                else if (proto.WeaponMode == 2)
                {
                    anim = "S_1HRUNL";
                }
            }
            return(anim);
        }
Exemplo n.º 10
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int  plID, value;
            byte attribType;

            stream.Read(out plID);
            stream.Read(out attribType);
            stream.Read(out value);

            if (plID == 0 || !sWorld.VobDict.ContainsKey(plID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[plID];

            if (!(vob is NPCProto))
            {
                throw new Exception("Vob is not an NPC!");
            }

            NPCProto proto = (NPCProto)vob;

            proto.Attributes[attribType] = value;

            if (vob.Address == 0)
            {
                return;
            }

            Process process = Process.ThisProcess();
            oCNpc   npc     = new oCNpc(process, vob.Address);

            npc.setAttributes(attribType, value);
        }
 protected void equip(NPCProto npc, Item item)
 {
     npc.Strength  += 4;
     npc.Dexterity += 4;
     npc.HPMax     += 40;
     npc.HP        += 40;
 }
Exemplo n.º 12
0
        public static void log_CharacterStat(NPCProto proto, CharStat stat, int value)
        {
            if (proto is NPC)
            {
                return;
            }
            Player player = (Player)proto;

            if (player.getAccount() == null || !player.IsSpawned())
            {
                return;
            }

            lock (connection)
            {
                using (SQLiteCommand command = new SQLiteCommand(connection))
                {
                    command.CommandText  = "INSERT INTO `logStats` (";
                    command.CommandText += "  `id`, `accountID`, `type`, `value`, `time`)";
                    command.CommandText += "VALUES( NULL, @accID, @type, @value, @time)";

                    command.Parameters.AddWithValue("@accID", player.getAccount().accountID);
                    command.Parameters.AddWithValue("@type", (int)stat);
                    command.Parameters.AddWithValue("@value", value);
                    command.Parameters.AddWithValue("@time", DateTime.Now.Ticks);

                    command.ExecuteNonQuery();
                }
            }
        }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            Process process = Process.ThisProcess();
            //oCNpc npc = oCNpc.Player(process);
            //Player.Hero.Attributes[(int)NPCAttributeFlags.ATR_HITPOINTS] = 1;



            float length   = 0;
            int   playerID = 0;

            stream.Read(out playerID);
            stream.Read(out length);

            if (!sWorld.VobDict.ContainsKey(playerID))
            {
                throw new Exception("PlayerID: " + playerID + " was not found!");
            }
            NPCProto proto = (NPCProto)sWorld.VobDict[playerID];

            proto.Attributes[(int)NPCAttribute.ATR_HITPOINTS] = 1;

            if (proto.IsSpawned)
            {
                oCNpc npc = new oCNpc(process, proto.Address);
                npc.DropUnconscious(length, new oCNpc(process, 0));
            }
        }
Exemplo n.º 14
0
 internal void iOnUnEquip(NPCProto proto, Item item)
 {
     if (OnUnEquip != null)
     {
         OnUnEquip(proto, item);
     }
 }
Exemplo n.º 15
0
 internal void iOnUse(NPCProto proto, Item item, short state, short targetState)
 {
     if (OnUse != null)
     {
         OnUse(proto, item, state, targetState);
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Returns the nearest npc
        /// </summary>
        /// <returns></returns>
        public NPCProto getNearestNPC()
        {
            NPCProto mi = null;

            uint[] keys        = WorldObjects.World.getImportantKeysByPosition(this.Position.Data, 4000);
            float  minDistance = float.MaxValue;

            foreach (uint key in keys)
            {
                if (!sWorld.getWorld(this.vob.Map).MobInterPositionList.ContainsKey(key))
                {
                    continue;
                }
                List <WorldObjects.Character.NPCProto> mobs = sWorld.getWorld(this.vob.Map).NPCPositionList[key];

                foreach (WorldObjects.Character.NPCProto m in mobs)
                {
                    if (mi == null)
                    {
                        minDistance = (m.Position - this.Position).Length;
                        mi          = (NPCProto)m.ScriptingVob;
                        continue;
                    }

                    float mD = (m.Position - this.Position).Length;
                    if (mD < minDistance)
                    {
                        mi          = (NPCProto)m.ScriptingVob;
                        minDistance = mD;
                    }
                }
            }
            return(mi);
        }
Exemplo n.º 17
0
        public ITPO_SPEED_TIMER(NPCProto proto)
            : base(3000000000)
        {
            npc = proto;

            OnTick += new Events.TimerEvent(endTimer);
        }
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int casterID = 0;

            stream.Read(out casterID);


            Vob      casterVob = null;
            NPCProto caster    = null;

            sWorld.VobDict.TryGetValue(casterID, out casterVob);


            if (casterVob == null)
            {
                throw new Exception("Caster was not found!");
            }
            if (!(casterVob is NPCProto))
            {
                throw new Exception("Caster was not a npcproto " + casterVob);
            }
            caster = (NPCProto)casterVob;



            Write(caster, packet.guid);
        }
Exemplo n.º 19
0
        public static void InitNPCAI(this NPCProto proto)
        {
            NPCAI ai = new NPCAI(proto);

            proto.setUserObject("AI", ai);
            ai.init();
        }
Exemplo n.º 20
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int callBackID = 0, npcID = 0, vobID = 0;

            stream.Read(out callBackID);
            stream.Read(out npcID);
            stream.Read(out vobID);

            if (!sWorld.VobDict.ContainsKey(npcID) || !sWorld.VobDict.ContainsKey(vobID))
            {
                throw new Exception("Vob or NPC weren't in the List!");
            }

            NPCProto proto = (NPCProto)sWorld.VobDict[npcID];
            Vob      vob   = (Vob)sWorld.VobDict[vobID];

            bool canSee = false;

            if (proto.Address != 0 && vob.Address == 0)
            {
                canSee = (new oCNpc(Process.ThisProcess(), proto.Address).CanSee(new zCVob(Process.ThisProcess(), vob.Address), 0) == 1) ? true : false;
            }

            stream.Reset();
            stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            stream.Write((byte)NetworkID.CallbackNPCCanSee);
            stream.Write(callBackID);
            stream.Write(proto.ID);
            stream.Write(vob.ID);
            stream.Write(canSee);

            Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true);
        }
Exemplo n.º 21
0
 internal void iOnStopInteraction(MobInter mobInter, NPCProto npc)
 {
     if (OnStopInteraction != null)
     {
         OnStopInteraction(mobInter, npc);
     }
 }
Exemplo n.º 22
0
        public void Read(RakNet.BitStream stream, RakNet.Packet packet, Server server)
        {
            int itemID = 0;
            int amount = 0;

            stream.Read(out itemID);
            stream.Read(out amount);


            if (itemID == 0 || !sWorld.VobDict.ContainsKey(itemID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[itemID];

            if (!(vob is Item))
            {
                throw new Exception("Vob is not an item");
            }

            Item item = (Item)vob;

            if (item.Container is NPCProto)
            {
                NPCProto proto = (NPCProto)item.Container;
                proto.removeItem(item, amount);

                Scripting.Objects.Character.NPCProto.isOnUseItem(proto.ScriptingNPC, item.ScriptingProto, -1, -2);
            }

            Write(item, packet.systemAddress);
        }
Exemplo n.º 23
0
 internal void iOnCastSpell(NPCProto caster, Spell spell, Vob target)
 {
     if (OnCastSpell != null)
     {
         OnCastSpell(caster, spell, target);
     }
 }
Exemplo n.º 24
0
        public static void FightRoutine(NPCProto npc)
        {
            //Draw Weapon:


            NPCAI    ai    = npc.getAI();
            NPCProto enemy = ai.EnemyList.First.Value;

            npc.readyBestWeapon(enemy);



            if (enemy.HP == 0)
            {
                ai.EnemyList.Remove(enemy);
                npc.standAnim();
                npc.unreadyWeapon();
                return;
            }
            else if ((enemy.Position - npc.Position).Length > 3000)//Stop running!
            {
                ai.EnemyList.Remove(enemy);
                npc.standAnim();
                npc.unreadyWeapon();
                return;
            }

            if (npc.getAI().FightStates.First != null)
            {
                npc.getAI().FightStates.First.Value.update();
                return;
            }


            npc.turnToPosition(enemy.Position);
            if (rand.NextDouble() > 0.5)
            {
                npc.getAI().FightStates.AddLast(new AnimState(npc, "T_FISTPARADEJUMPB"));
                npc.getAI().FightStates.AddLast(new WaitState(npc, 10000 * 100));
            }

            if (npc.Position.getDistance(enemy.Position) > npc.getAttackRange())
            {
                npc.getAI().FightStates.AddLast(new GotoState(npc, enemy, npc.getAttackRange()));
            }
            else
            {
                npc.getAI().FightStates.AddLast(new AnimState(npc, npc.getFightRunAnimation()));
                npc.getAI().FightStates.AddLast(new DamageState(npc, enemy));
                npc.getAI().FightStates.AddLast(new WaitState(npc, 10000 * 200));
            }


            //if (npc.gotoPosition(enemy.Position, 200))
            //{
            //    npc.standAnim();
            //    npc.playAnimation(npc.getFightAnimation());
            //}
        }
Exemplo n.º 25
0
 protected void unequip(NPCProto npc, Item item)
 {
     npc.ProtectionEdge  -= 7;
     npc.ProtectionBlunt -= 7;
     npc.ProtectionPoint -= 7;
     npc.ProtectionMagic -= 7;
     npc.ProtectionFire  -= 7;
 }
Exemplo n.º 26
0
 protected void equip(NPCProto npc, Item item)
 {
     npc.ProtectionEdge  += 7;
     npc.ProtectionBlunt += 7;
     npc.ProtectionPoint += 7;
     npc.ProtectionMagic += 7;
     npc.ProtectionFire  += 7;
 }
Exemplo n.º 27
0
 public static bool IsMonster(this NPCProto proto)
 {
     if (proto.getGuild() > Guilds.HUM_SPERATOR && proto.getGuild() <= Guilds.MON_SEPERATOR)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 28
0
 public void addEnemy(NPCProto proto)
 {
     if (EnemyList.Contains(proto))
     {
         return;
     }
     EnemyList.AddLast(proto);
 }
Exemplo n.º 29
0
 public static bool IsHuman(this NPCProto proto)
 {
     if (proto.getGuild() <= Guilds.HUM_SPERATOR)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 30
0
 public static bool IsOrc(this NPCProto proto)
 {
     if (proto.getGuild() > Guilds.MON_SEPERATOR && proto.getGuild() <= Guilds.ORC_SEPERATOR)
     {
         return(true);
     }
     return(false);
 }