Example #1
0
        public ChampionDie(Champion die, Unit killer, int goldFromKill) : base(PacketCmdS2C.PKT_S2C_ChampionDie, die.getNetId())
        {
            buffer.Write(goldFromKill); // Gold from kill?
            buffer.Write((short)0);
            if (killer != null)
                buffer.Write(killer.getNetId());
            else
                buffer.Write((int)0);

            buffer.Write((short)0);
            buffer.Write((short)7);
            buffer.Write(die.getRespawnTimer() / 1000.0f); // Respawn timer, float
        }
Example #2
0
 public BuyItemAns(Champion actor, ItemInstance item) : base(PacketCmdS2C.PKT_S2C_BuyItemAns, actor.getNetId())
 {
     buffer.Write((int)item.getTemplate().getId());
     buffer.Write((byte)item.getSlot());
     buffer.Write((byte)item.getStacks());
     buffer.Write((byte)0); //unk or stacks => short
     buffer.Write((byte)0x40); //unk
 }
Example #3
0
 public SwapItems(Champion c, byte slotFrom, byte slotTo) : base(PacketCmdS2C.PKT_S2C_SwapItems, c.getNetId())
 {
     buffer.Write((byte)slotFrom);
     buffer.Write((byte)slotTo);
 }
Example #4
0
 public HeroSpawn2(Champion p) : base(PacketCmdS2C.PKT_S2C_ObjectSpawn, p.getNetId())
 {
     buffer.fill(0, 15);
     buffer.Write((byte)0x80); // unk
     buffer.Write((byte)0x3F); // unk
     buffer.fill(0, 13);
     buffer.Write((byte)3); // unk
     buffer.Write((int)1); // unk
     buffer.Write((float)p.getX());
     buffer.Write((float)p.getY());
     buffer.Write((float)0x3F441B7D); // z ?
     buffer.Write((float)0x3F248DBB); // Rotation ?
 }
Example #5
0
 public static void notifyParticleSpawn(Champion source, GameObjects.Target target, string particleName)
 {
     var sp = new SpawnParticle(source, target, particleName, Game.GetNewNetID());
     PacketHandlerManager.getInstace().broadcastPacket(sp, Channel.CHL_S2C);
 }
Example #6
0
        public SpawnParticle(Champion owner, GameObjects.Target t, string particle, int netId) : base(PacketCmdS2C.PKT_S2C_SpawnParticle, owner.getNetId())
        {
            buffer.Write((short)1); // number of particles
            buffer.Write(owner.getChampionHash());
            buffer.Write(RAFManager.getInstance().getHash(particle));
            buffer.Write((int)0x00000020); // flags ?
            buffer.Write((int)0); // unk
            buffer.Write((short)0); // unk
            buffer.Write((short)1); // number of targets ?
            buffer.Write(owner.getNetId());
            buffer.Write(netId); // Particle net id ?
            buffer.Write(owner.getNetId());

            if (t.isSimpleTarget())
                buffer.Write((int)0);
            else
                buffer.Write((t as GameObject).getNetId());

            buffer.Write((int)0); // unk

            for (var i = 0; i < 3; ++i)
            {

                buffer.Write((short)((t.getX() - MAP_WIDTH) / 2));
                buffer.Write(50.0f);
                buffer.Write((short)((t.getY() - MAP_HEIGHT) / 2));
            }

            buffer.Write((int)0); // unk
            buffer.Write((int)0); // unk
            buffer.Write((int)0); // unk
            buffer.Write((int)0); // unk
            buffer.Write(1.0f); // unk

        }
Example #7
0
        public EnterVisionAgain(Champion c) : base(PacketCmdS2C.PKT_S2C_ObjectSpawn, c.getNetId())
        {
            buffer.Write((short)0); // extraInfo
            buffer.Write((byte)0); //c.getInventory().getItems().size(); // itemCount?
                                    //buffer.Write((short)7; // unknown

            /*
            for (int i = 0; i < c.getInventory().getItems().size(); i++) {
               ItemInstance* item = c.getInventory().getItems()[i];

               if (item != 0 && item.getTemplate() != 0) {
                  buffer.Write((short)item.getStacks();
                  buffer.Write((short)0; // unk
                  buffer.Write((int)item.getTemplate().getId();
                  buffer.Write((short)item.getSlot();
               }
               else {
                  buffer.fill(0, 7);
               }
            }
            */

            buffer.fill(0, 10);
            buffer.Write((float)1.0f);
            buffer.fill(0, 13);

            buffer.Write((byte)2); // Type of data: Waypoints=2
            buffer.Write((int)Environment.TickCount); // unk

            List<Vector2> waypoints = c.getWaypoints();

            buffer.Write((byte)((waypoints.Count - c.getCurWaypoint() + 1) * 2)); // coordCount
            buffer.Write(c.getNetId());
            buffer.Write((byte)0); // movement mask; 1=KeepMoving?
            buffer.Write(MovementVector.targetXToNormalFormat(c.getX()));
            buffer.Write(MovementVector.targetYToNormalFormat(c.getY()));
            for (int i = c.getCurWaypoint(); i < waypoints.Count; ++i)
            {
                buffer.Write(MovementVector.targetXToNormalFormat(waypoints[i].X));
                buffer.Write(MovementVector.targetXToNormalFormat(waypoints[i].Y));
            }
        }
Example #8
0
 public static void notifyChampionDeathTimer(Champion die)
 {
     var cdt = new ChampionDeathTimer(die);
     PacketHandlerManager.getInstace().broadcastPacket(cdt, Channel.CHL_S2C);
 }
Example #9
0
 public static void notifyChampionRespawn(Champion c)
 {
     var cr = new ChampionRespawn(c);
     PacketHandlerManager.getInstace().broadcastPacket(cr, Channel.CHL_S2C);
 }
Example #10
0
 public static void notifyRemoveItem(Champion c, byte slot, byte remaining)
 {
     var ri = new RemoveItem(c, slot, remaining);
     PacketHandlerManager.getInstace().broadcastPacketVision(c, ri, Channel.CHL_S2C);
 }
Example #11
0
        public static void notifyChampionDie(Champion die, Unit killer, int goldFromKill)
        {
            var cd = new ChampionDie(die, killer, goldFromKill);
            PacketHandlerManager.getInstace().broadcastPacket(cd, Channel.CHL_S2C);

            notifyChampionDeathTimer(die);
        }
Example #12
0
 public static void notifyLevelUp(Champion c)
 {
     var lu = new SpawnParticle.LevelUp(c);
     PacketHandlerManager.getInstace().broadcastPacket(lu, Channel.CHL_S2C);
 }
Example #13
0
 public static void notifyItemsSwapped(Champion c, byte fromSlot, byte toSlot)
 {
     var sia = new SwapItems(c, fromSlot, toSlot);
     PacketHandlerManager.getInstace().broadcastPacketVision(c, sia, Channel.CHL_S2C);
 }
Example #14
0
 public static void notifyItemBought(Champion c, ItemInstance i)
 {
     var response = new BuyItemAns(c, i);
     PacketHandlerManager.getInstace().broadcastPacketVision(c, response, Channel.CHL_S2C);
 }
Example #15
0
 public ChampionDeathTimer(Champion die) : base(ExtendedPacketCmd.EPKT_S2C_ChampionDeathTimer, die.getNetId())
 {
     buffer.Write(die.getRespawnTimer() / 1000.0f); // Respawn timer, float
 }
Example #16
0
 public static void notifyAddGold(Champion c, Unit died, float gold)
 {
     var ag = new AddGold(c, died, gold);
     PacketHandlerManager.getInstace().broadcastPacket(ag, Channel.CHL_S2C);
 }
Example #17
0
 public ChampionRespawn(Champion c) : base(PacketCmdS2C.PKT_S2C_ChampionRespawn, c.getNetId())
 {
     buffer.Write(c.getX());
     buffer.Write(c.getY());
     buffer.Write(c.getZ());
 }
Example #18
0
 public static void notifyChampionSpawned(Champion c, TeamId team)
 {
     var hs = new HeroSpawn2(c);
     PacketHandlerManager.getInstace().broadcastPacketTeam(team, hs, Channel.CHL_S2C);
 }
Example #19
0
 public LevelUp(Champion c) : base(PacketCmdS2C.PKT_S2C_LevelUp, c.getNetId())
 {
     buffer.Write(c.getStats().getLevel());
     buffer.Write(c.getSkillPoints());
 }
Example #20
0
 public static void notifySetCooldown(Champion c, byte slotId, float currentCd, float totalCd)
 {
     var cd = new SpawnParticle.SetCooldown(c.getNetId(), slotId, currentCd, totalCd);
     PacketHandlerManager.getInstace().broadcastPacket(cd, Channel.CHL_S2C);
 }
Example #21
0
 public AddGold(Champion richMan, Unit died, float gold) : base(PacketCmdS2C.PKT_S2C_AddGold, richMan.getNetId())
 {
     buffer.Write(richMan.getNetId());
     if (died != null)
     {
         buffer.Write(died.getNetId());
     }
     else
     {
         buffer.Write((int)0);
     }
     buffer.Write(gold);
 }
Example #22
0
        public Spell(Champion owner, string spellName, byte slot)
        {
            this.owner = owner;
            this.spellName = spellName;
            this.slot = slot;

            Inibin inibin;
            if (!RAFManager.getInstance().readInibin("DATA/Spells/" + spellName + ".inibin", out inibin))
            {
                if (!RAFManager.getInstance().readInibin("DATA/Characters/" + owner.getType() + "/Spells/" + spellName + ".inibin", out inibin))
                {
                    if (!RAFManager.getInstance().readInibin("DATA/Characters/" + owner.getType() + "/" + spellName + ".inibin", out inibin))
                    {
                        Logger.LogCoreError("Couldn't find spell stats for " + spellName);
                        return;
                    }
                }
            }

            var i = 0;
            // Generate cooldown values for each level of the spell
            for (i = 0; i < cooldown.Length; ++i)
            {
                cooldown[i] = inibin.GetValue<float>("SpellData", "Cooldown" + (i + 1));
            }

            castTime = ((1.0f + inibin.GetValue<float>("SpellData", "DelayCastOffsetPercent"))) / 2.0f;

            flags = inibin.GetValue<int>("SpellData", "Flags");
            castRange = inibin.GetValue<float>("SpellData", "CastRange");
            projectileSpeed = inibin.GetValue<float>("SpellData", "MissileSpeed");
            coefficient = inibin.GetValue<float>("SpellData", "Coefficient");
            lineWidth = inibin.GetValue<float>("SpellData", "LineWidth");

            i = 1;
            while (true)
            {
                string key = "Effect" + (0 + i) + "Level0Amount";
                if (inibin.GetValue<object>("SpellData", key) == null)
                    break;


                List<float> effectValues = new List<float>();
                for (var j = 0; j < 6; ++j)
                {
                    key = "Effect" + (0 + i) + "Level" + (0 + j) + "Amount";
                    effectValues.Add(inibin.GetValue<float>("SpellData", key));
                }

                effects.Add(effectValues);
                ++i;
            }

            targetType = (float)Math.Floor(inibin.GetValue<float>("SpellData", "TargettingType") + 0.5f);


            // This is starting to get ugly. How many more names / paths to go ?
            if (!RAFManager.getInstance().readInibin("DATA/Spells/" + spellName + "Missile.inibin", out inibin))
            {
                if (!RAFManager.getInstance().readInibin("DATA/Spells/" + spellName + "Mis.inibin", out inibin))
                {
                    if (!RAFManager.getInstance().readInibin("DATA/Characters/" + owner.getType() + "/Spells/" + spellName + "Missile.inibin", out inibin))
                    {
                        if (!RAFManager.getInstance().readInibin("DATA/Characters/" + owner.getType() + "/" + spellName + "Missile.inibin", out inibin))
                        {
                            if (!RAFManager.getInstance().readInibin("DATA/Characters/" + owner.getType() + "/Spells/" + spellName + "Mis.inibin", out inibin))
                            {
                                if (!RAFManager.getInstance().readInibin("DATA/Characters/" + owner.getType() + "/" + spellName + "Mis.inibin", out inibin))
                                {
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            castRange = inibin.GetValue<float>("SpellData", "CastRange");
            projectileSpeed = inibin.GetValue<float>("SpellData", "MissileSpeed");
            projectileFlags = inibin.GetValue<float>("SpellData", "Flags");
        }
Example #23
0
 public void setChampion(Champion champion)
 {
     this.champion = champion; //ChampionFactory::getChampionFromType(type);
     champion.setSkin(skinNo);
 }
        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var message = new ChatMessage(data);
            var split = message.msg.Split(' ');
            if (split.Length > 1)
            {
                int x, y = 0;
                if (int.TryParse(split[0], out x))
                {
                    if (int.TryParse(split[1], out y))
                    {
                        var response = new AttentionPingAns(game.getPeerInfo(peer), new AttentionPing { x = x, y = y, targetNetId = 0, type = 0 });
                        PacketHandlerManager.getInstace().broadcastPacketTeam(game.getPeerInfo(peer).getTeam(), response, Channel.CHL_S2C);
                    }
                }
            }

            #region Commands
            //Lets do commands

            if (message.msg.StartsWith("."))
            {
                var cmd = new string[] { ".set", ".gold", ".speed", ".health", ".xp", ".ap", ".ad", ".mana", ".model", ".help", ".spawn", ".size", ".junglespawn", ".skillpoints", ".level", ".tp", ".coords", ".ch" };
                var debugMsg = new StringBuilder();
                split = message.msg.ToLower().Split(' ');
                switch (split[0])
                {
                    case ".set":
                        if (split.Length < 4)
                            return true;
                        int blockNo, fieldNo = 0;
                        float value = 0;
                        if (int.TryParse(split[1], out blockNo))
                            if (int.TryParse(split[2], out fieldNo))
                                if (float.TryParse(split[3], out value))
                                {
                                    // blockNo = 1 << (blockNo - 1);
                                    //var mask = 1 << (fieldNo - 1);
                                    game.getPeerInfo(peer).getChampion().getStats().setStat((MasterMask)blockNo, (FieldMask)fieldNo, value);
                                }
                        return true;
                    case ".gold":
                        float gold;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out gold))
                            game.getPeerInfo(peer).getChampion().getStats().setGold(gold);
                        return true;
                    case ".speed":
                        float speed;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out speed))
                            game.getPeerInfo(peer).getChampion().getStats().setMovementSpeed(speed);
                        return true;
                    case ".health":
                        float hp;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out hp))
                        {
                            game.getPeerInfo(peer).getChampion().getStats().setCurrentHealth(hp);
                            game.getPeerInfo(peer).getChampion().getStats().setMaxHealth(hp);

                            PacketNotifier.notifySetHealth(game.getPeerInfo(peer).getChampion());
                        }
                        return true;
                    case ".xp":
                        float xp;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out xp))
                            game.getPeerInfo(peer).getChampion().getStats().setExp(xp);
                        return true;
                    case ".ap":
                        float ap;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out ap))
                            game.getPeerInfo(peer).getChampion().getStats().setBonusApFlat(ap);
                        return true;
                    case ".ad":
                        float ad;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out ad))
                            game.getPeerInfo(peer).getChampion().getStats().setBonusAdFlat(ad);
                        return true;
                    case ".mana":
                        float mp;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out mp))
                        {
                            game.getPeerInfo(peer).getChampion().getStats().setCurrentMana(mp);
                            game.getPeerInfo(peer).getChampion().getStats().setMaxMana(mp);
                        }
                        return true;
                    case ".model":
                        if (split.Length >= 2)
                            game.getPeerInfo(peer).getChampion().setModel(split[1]);
                        return true;
                    case ".help":
                        debugMsg.Append("List of available commands: ");
                        foreach (var cc in cmd)
                            debugMsg.Append(cc + " ");

                        var dm = new SpawnParticle.DebugMessage(debugMsg.ToString());
                        PacketHandlerManager.getInstace().sendPacket(peer, dm, Channel.CHL_S2C);
                        return true;
                    case ".spawn":
                        Logger.LogCoreInfo("Not implemented command .spawn");
                        return true;
                    case ".size":
                        float size;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out size))
                            game.getPeerInfo(peer).getChampion().getStats().setSize(size);
                        return true;
                    case ".junglespawn":
                        cmd = new string[] { "c baron", "c wolves", "c red", "c blue", "c dragon", "c wraiths", "c golems" };
                        return true;
                    case ".skillpoints":
                        game.getPeerInfo(peer).getChampion().setSkillPoints(17);
                        var skillUpResponse = new SkillUpPacket(game.getPeerInfo(peer).getChampion().getNetId(), 0, 0, 17);
                        PacketHandlerManager.getInstace().sendPacket(peer, skillUpResponse, Channel.CHL_GAMEPLAY);
                        return true;
                    case ".level":
                        float lvl;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out lvl))
                        {
                            if (lvl < 1 || lvl > 18)
                                return true;
                            game.getPeerInfo(peer).getChampion().getStats().setExp(game.getMap().getExperienceToLevelUp()[(int)lvl - 1]);
                            //game.peerInfo(peer).getChampion().getStats().setLevel(lvl);
                        }
                        return true;
                    case ".tp":
                        float x, y;
                        if (split.Length < 3)
                            return true;
                        if (float.TryParse(split[1], out x))
                            if (float.TryParse(split[2], out y))
                                PacketNotifier.notifyTeleport(game.getPeerInfo(peer).getChampion(), x, y);
                        return true;
                    case ".coords":
                        Logger.LogCoreInfo("At " + game.getPeerInfo(peer).getChampion().getX() + ";" + game.getPeerInfo(peer).getChampion().getY());
                        debugMsg.Append("At Coords - X: ");
                        debugMsg.Append(game.getPeerInfo(peer).getChampion().getX());
                        debugMsg.Append(" Y: ");
                        debugMsg.Append(game.getPeerInfo(peer).getChampion().getY());
                        debugMsg.Append(" Z: ");
                        debugMsg.Append(game.getPeerInfo(peer).getChampion().getZ());
                        PacketNotifier.notifyDebugMessage(debugMsg.ToString());
                        return true;
                    case ".ch":
                        if (split.Length < 2)
                            return true;
                        new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                        {
                            var c = new Champion(split[1], game.getMap(), game.getPeerInfo(peer).getChampion().getNetId(), (int)game.getPeerInfo(peer).userId);
                            c.setPosition(game.getPeerInfo(peer).getChampion().getX(), game.getPeerInfo(peer).getChampion().getY());
                            c.setModel(split[1]); // trigger the "modelUpdate" proc
                            game.getMap().removeObject(game.getPeerInfo(peer).getChampion());
                            game.getMap().addObject(c);
                            game.getPeerInfo(peer).setChampion(c);
                        })).Start();
                        return true;
                    case ".packet":
                        try
                        {
                            var s = message.msg.Split(' ');
                            if (s.Length < 2)
                                return true;
                            var bytes = new List<byte>();

                            for (var i = 1; i < s.Length; i++)
                            {
                                var ss = s[i].Split(':');
                                var type = ss[0];
                                dynamic num;
                                if (ss[1] == "netid")
                                    num = game.getPeerInfo(peer).getChampion().getNetId();
                                else
                                    num = System.Convert.ChangeType(int.Parse(ss[1]), Type.GetType("System." + type));
                                var d = BitConverter.GetBytes(num);
                                if (num.GetType() == typeof(byte))
                                    bytes.Add(num);
                                else
                                    bytes.AddRange(d);
                            }

                            PacketHandlerManager.getInstace().sendPacket(peer, bytes.ToArray(), Channel.CHL_C2S);
                        }
                        catch { }
                        return true;
                    case ".mobs":
                        if (split.Length < 2)
                            return true;
                        int team;
                        if (!int.TryParse(split[1], out team))
                            return true;
                        var units = game.getPeerInfo(peer).getChampion().getMap().getObjects().Where(xx => xx.Value.getTeam() == Convert.toTeamId(team)).Where(xx => xx.Value is Minion);
                        foreach (var unit in units)
                        {
                            var response = new AttentionPingAns(game.getPeerInfo(peer), new AttentionPing { x = unit.Value.getX(), y = unit.Value.getY(), targetNetId = 0, type = Pings.Ping_Danger });
                            PacketHandlerManager.getInstace().broadcastPacketTeam(game.getPeerInfo(peer).getTeam(), response, Channel.CHL_S2C);
                        }
                        return true;
                    case ".inhib":
                        var sender = game.getPeerInfo(peer);
                        var min = new Monster(game.getMap(), Game.GetNewNetID(), sender.getChampion().getX(), sender.getChampion().getY(), sender.getChampion().getX(), sender.getChampion().getY(), "AncientGolem", "AncientGolem1.1.1");
                        game.getMap().addObject(min);
                        return true;
                }
            }

            #endregion
            switch (message.type)
            {
                case ChatType.CHAT_ALL:
                    return PacketHandlerManager.getInstace().broadcastPacket(data, Channel.CHL_COMMUNICATION);
                case ChatType.CHAT_TEAM:
                    return PacketHandlerManager.getInstace().broadcastPacketTeam(game.getPeerInfo(peer).getTeam(), data, Channel.CHL_COMMUNICATION);
                default:
                    //Logging.errorLine("Unknown ChatMessageType");
                    return PacketHandlerManager.getInstace().sendPacket(peer, data, Channel.CHL_COMMUNICATION);
            }
        }