public bool HandlePacket(Peer peer, byte[] data) { var spell = new CastSpell(data); //Todo spellslot 0-3 qwer, 4-5 d f, 6-11 items // There are some bits triggering this /*if ((spell.spellSlotType & 0x0F) > 0) * { * Logger.LogCoreInfo("Summoner Spell Cast"); * Logger.LogCoreInfo("Type: " + spell.spellSlotType.ToString("x") + ", Slot " + spell.spellSlot + ", coord " + spell.x + " ; " + spell.y + ", coord2 " + spell.x2 + ", " + spell.y2 + ", target NetId " + spell.targetNetId.ToString("x")); * return true; * }*/ var futureProjNetId = _networkIdManager.GetNewNetID(); var spellNetId = _networkIdManager.GetNewNetID(); var targetObj = _game.Map.GetObjectById(spell.targetNetId); var TargetUnit = targetObj as Unit; var s = _playerManager.GetPeerInfo(peer).Champion.castSpell( spell.spellSlot, spell.x, spell.y, TargetUnit, futureProjNetId, spellNetId ); if (s == null) { return(false); } var response = new CastSpellAns(s, spell.x, spell.y, futureProjNetId, spellNetId); _game.PacketHandlerManager.broadcastPacket(response, Channel.CHL_S2C); return(true); }
/// <summary> /// Called when the character casts the spell /// </summary> public virtual bool cast(float x, float y, float x2, float y2, AttackableUnit u = null) { if (HasEmptyScript) { return(false); } var stats = Owner.GetStats(); if ((SpellData.ManaCost[Level] * (1 - stats.getSpellCostReduction())) > stats.CurrentMana || state != SpellState.STATE_READY) { return(false); } if (ManaCostsEnabled) { stats.CurrentMana = stats.CurrentMana - SpellData.ManaCost[Level] * (1 - stats.getSpellCostReduction()); } X = x; Y = y; X2 = x2; Y2 = y2; Target = u; FutureProjNetId = _networkIdManager.GetNewNetID(); SpellNetId = _networkIdManager.GetNewNetID(); if (SpellData.TargettingType == 1 && Target != null && Target.GetDistanceTo(Owner) > SpellData.CastRange[Level]) { return(false); } spellGameScript.OnStartCasting(Owner, this, Target); if (SpellData.GetCastTime() > 0 && (SpellData.Flags & (int)SpellFlag.SPELL_FLAG_InstantCast) == 0) { Owner.setPosition(Owner.X, Owner.Y);//stop moving serverside too. TODO: check for each spell if they stop movement or not state = SpellState.STATE_CASTING; CurrentCastTime = SpellData.GetCastTime(); } else { finishCasting(); } var response = new CastSpellResponse(this, x, y, x2, y2, FutureProjNetId, SpellNetId); _game.PacketHandlerManager.broadcastPacket(response, Channel.CHL_S2C); return(true); }
public GameObject(float x, float y, int collisionRadius, int visionRadius = 0, uint netId = 0) : base(x, y) { if (netId != 0) { NetId = netId; // Custom netId } else { NetId = _networkIdManager.GetNewNetID(); // Let the base class (this one) asign a netId } Target = null; CollisionRadius = collisionRadius; VisionRadius = visionRadius; Waypoints = new List <Vector2>(); _visibleByTeam = new Dictionary <TeamId, bool>(); var teams = Enum.GetValues(typeof(TeamId)).Cast <TeamId>(); foreach (var team in teams) { _visibleByTeam.Add(team, false); } Team = TeamId.TEAM_NEUTRAL; movementUpdated = false; toRemove = false; AttackerCount = 0; IsDashing = false; }
public FogUpdate2(AttackableUnit unit, NetworkIdManager idManager) : base(PacketCmd.PKT_S2C_FogUpdate2, 0) { buffer.Write((int)unit.Team); buffer.Write((byte)0xFE); buffer.Write((byte)0xFF); buffer.Write((byte)0xFF); buffer.Write((byte)0xFF); buffer.Write((int)0); buffer.Write((uint)unit.NetId); // Fog Attached, when unit dies it disappears buffer.Write((uint)idManager.GetNewNetID()); //Fog NetID buffer.Write((int)0); buffer.Write((float)unit.X); buffer.Write((float)unit.Y); buffer.Write((float)2500); buffer.Write((float)88.4f); buffer.Write((float)130); buffer.Write((float)1.0f); buffer.Write((int)0); buffer.Write((byte)199); buffer.Write((float)unit.VisionRadius); }