private bool AllowCast() { AbilityResult myResult = AbilityResult.ABILITYRESULT_OK; if (AbInfo.Target != null) { if (AbInfo.Target.IsDead && !AbInfo.ConstantInfo.AffectsDead) { myResult = AbilityResult.ABILITYRESULT_ILLEGALTARGET_DEAD; } else if (!AbInfo.Target.IsDead && AbInfo.ConstantInfo.AffectsDead) { myResult = AbilityResult.ABILITYRESULT_ILLEGALTARGET_NOT_DEAD_ALLY; } else if (AbInfo.Target != _caster) { if (AbInfo.ConstantInfo.CastAngle != 0 && _caster.IsMoving && !_caster.IsObjectInFront(AbInfo.Target, AbInfo.ConstantInfo.CastAngle)) { myResult = AbilityResult.ABILITYRESULT_OUT_OF_ARC; } // Explicit LOS check for move-cast abilities if (AbInfo.CastTime > 0 && AbInfo.CanCastWhileMoving && AbInfo.Target != null && !_caster.LOSHit(AbInfo.Target)) { myResult = AbilityResult.ABILITYRESULT_NOT_VISIBLE; } } } if (myResult != AbilityResult.ABILITYRESULT_OK) { CancelCast((ushort)myResult); return(false); } if (myResult == AbilityResult.ABILITYRESULT_OK && _caster.ItmInterface != null) { myResult = _caster.ItmInterface.WeaponCheck(AbInfo.ConstantInfo.WeaponNeeded); } if (AbInfo.ApCost > 0 && _caster is Player && !_caster.ConsumeActionPoints(AbInfo.ApCost)) { myResult = AbilityResult.ABILITYRESULT_AP; } if (myResult != AbilityResult.ABILITYRESULT_OK) { CancelCast((ushort)myResult); return(false); } AbilityMgr.GetCommandsFor(_caster, AbInfo); return(true); }
public override void ApplyEffect(Unit actor, Unit target, ref AbilityResultList results) { AbilityResult r = new AbilityResult() { actor = actor, target = target, amount = amount, result = Result.Heal }; results.targets.Add(r); }
public override void Counterattack(Unit actor, Unit target, ref AbilityResultList results) { //TODO roll for miss AbilityResult r = new AbilityResult() { target = target, amount = (int)(target.stats.GetStat(StatType.damage) * multiplier), result = Result.Hit }; actor.stats.TakeDamage(r.amount); results.counter.Add(r); }
public override void ApplyEffect(Unit actor, Unit target, ref AbilityResultList results) { //TODO: roll for crit def Vector2Int def = actor.stats.Defense(); AbilityResult r = new AbilityResult() { actor = actor, target = target, amount = Mathf.Min(amount, def.y - def.x), result = Result.Def }; results.targets.Add(r); }
// ParseNetMessage accepts input of raw bytes from a NetMessage. Parses and returns a Net message. public static INet Parse(ushort msgType, byte[] content) { INet msg = null; MsgType mt = (MsgType)msgType; switch (mt) { case MsgType.Multipart: msg = new Multipart(); break; case MsgType.Heartbeat: msg = new Heartbeat(); break; case MsgType.Connected: msg = new Connected(); break; case MsgType.Disconnected: msg = new Disconnected(); break; case MsgType.CreateAcct: msg = new CreateAcct(); break; case MsgType.CreateAcctResp: msg = new CreateAcctResp(); break; case MsgType.Login: msg = new Login(); break; case MsgType.LoginResp: msg = new LoginResp(); break; case MsgType.Character: msg = new Character(); break; case MsgType.ListGames: msg = new ListGames(); break; case MsgType.ListGamesResp: msg = new ListGamesResp(); break; case MsgType.CreateGame: msg = new CreateGame(); break; case MsgType.CreateGameResp: msg = new CreateGameResp(); break; case MsgType.JoinGame: msg = new JoinGame(); break; case MsgType.GameConnected: msg = new GameConnected(); break; case MsgType.GameMasterFrame: msg = new GameMasterFrame(); break; case MsgType.Entity: msg = new Entity(); break; case MsgType.MovePlayer: msg = new MovePlayer(); break; case MsgType.UseAbility: msg = new UseAbility(); break; case MsgType.AbilityResult: msg = new AbilityResult(); break; case MsgType.EndGame: msg = new EndGame(); break; } MemoryStream ms = new MemoryStream(content); msg.Deserialize(new BinaryReader(ms)); return(msg); }