public override void executeAction() { CombatEngine combatEngine = GameObject.FindObjectOfType <CombatEngine>(); for (int i = 0; i < number; i++) { combatEngine.SpawnEnemy(minion); } }
/// <summary> /// Navigate through a given menu, return the action performed (if applicable), or a submenu (if applicable) /// </summary> /// <param name="menu"></param> /// <param name="action"></param> /// <param name="cir"></param> /// <returns></returns> public List <GameAction> OnConfirmationInputReceived(MenuTypes menu, string action) { List <GameAction> retList = new List <GameAction>(); switch (menu) { case MenuTypes.Unit: switch (action) { case "Wait": retList.AddRange(MoveSelectedUnitAndWait()); openMenus.Clear(); return(retList); case "Attack": //Go to Attack Details Menu (Pick Weapon / Pick Target) List <UnitEntity> targets = GetAttackTargets(); List <IWeaponItem> weapons = selectedUnit.WeaponList.FindAll(c => c is FEWeapon); AttackDetailsMenuData attackDetails = new AttackDetailsMenuData(new List <string>() { "Attack" }) { MenuType = MenuTypes.AttackDetails, Targets = targets, Weapons = weapons, EngagementSquare = lastPath[lastPath.Count - 1] }; openMenus.Push(attackDetails); retList.Add(new MenuOpenedAction(openMenus.Peek())); return(retList); default: return(null); } case MenuTypes.AttackDetails: switch (action) { case "Attack": //read attack details from the top most menu AttackDetailsMenuData admd = openMenus.Peek() as AttackDetailsMenuData; selectedUnit.EquipWeapon(admd.Weapons[0]); List <GameAction> results = CombatEngine.InitiateCombat(selectedUnit, admd.Targets[0], CalculateEngagementRange(admd.EngagementSquare, admd.Targets[0])); openMenus.Clear(); return(results); default: return(null); } default: return(null); } }
public override void Execute() { if (!StateMachine.IsMeInCombat() && !StateMachine.IsPartyInCombat()) { StateMachine.SwitchState(typeof(BotStateIdle)); return; } CombatEngine?.Execute(); }
private void SelectCombatSelectedIndexChanged(object sender, EventArgs e) { if (SelectCombat.SelectedIndex != -1) { LazySettings.SelectedCombat = SelectCombat.Text; LazySettings.SaveSettings(); var cs = (CustomClass)SelectCombat.SelectedItem; CombatEngine = ClassCompiler.Assemblys[cs.AssemblyName]; } }
public bool Event_GetSkillDescr(ComponentEvent e) { var skillDescr = (EGetSkillDescription)e; // calculate the damage increase based on attributes so its reflected in description float modifier = CombatEngine.GetEntitySkillStrength(null, owner); int val = (int)(modifier * baseDamage); skillDescr.description += "Does Damage %2+" + val + "%. "; return(true); }
public void AddCombatEngine(CombatEngine engine, int seed) { switch (engine) { case WarpedCourtEngine.CombatEngine.GBA: this.CombatEngine = new FE7CombatEngine(new Random(seed)); break; default: throw new NotImplementedException("Combat Engine Not Implemented"); } }
public bool Event_ResistDamage(ComponentEvent e) { var damageEvent = (EDoDamage)e; // Use the combat engine to calculate the resistance based on the damageEvent.damage = CombatEngine.CalcDamageResistance( damageEvent.damageType, damageEvent.damage, resistType, out damageEvent.effectiveness); return(true); }
public void TakeDamage(int damage) { //tech bonus 0 check update if (isEnemy) { CombatEngine ce = GameObject.FindObjectOfType <CombatEngine>(); ce.TechCheckUpdate(0, ce.levelLoader.turnCount); //tech bonus 1 check update ce.TechCheckUpdate(1, 1); } int takenDamage = 0; if (efShield <= 0) { HPcurr -= damage; takenDamage = damage; if (HPcurr <= 0) { //tech bonus 3 check update if (HPcurr * -1 == HPmax / 2) { GameObject.FindObjectOfType <CombatEngine>().TechCheckUpdate(3, 1); } HPcurr = 0; Die(); } } else { efShield--; takenDamage = 0; int tempFlag = 0; while (tempFlag < statusEffectList.Count) { if (statusEffectList[tempFlag].StatusID == 12) { statusEffectList[tempFlag].level--; if (statusEffectList[tempFlag].level <= 0) { statusEffectList.RemoveAt(tempFlag); break; } } tempFlag++; } } //find combatscene and pass chara (to later find ID) and damage GameObject.FindObjectOfType <CombatEngine>().PlayHitFX(damage, this); }
public override void Execute(Player player, Entity entity, Coordinate targetCoordinate, Entity target) { base.Execute(player, entity, targetCoordinate, target); int distance = mapController.GetPositionOfEntity(entity.Id).Distance(mapController.GetPositionOfEntity(target.Id)); CombatEngine combatEngine = new CombatEngine() { attackingEntity = entity, defendingEntity = target, distance = distance, modifiers = attackModifiers }; CombatResult result = combatEngine.Battle(); }
private void OnTriggerEnter(Collider other) { var eobj = other.GetComponent <Visual>()?.Obj; if (eobj == null) { eobj = other.GetComponentInParent <Visual>()?.Obj; } if (eobj != null && eobj is GhostedEntity ge && ge.Id != CombatEngine.ParentEntity.Id) { CombatEngine.ProjectileHit(ProjectileData.StrikeDef, ge.Id); var fx = GameObject.Instantiate(FxOnStrike, transform.position, transform.rotation, null); Destroy(fx, fx.GetComponent <ParticleSystem>().main.duration); Destroy(gameObject); } }
public bool Event_OnAttack(ComponentEvent e) { var baseAttack = (EOnPerformAttack)e; // if there was a skill waiting to be used as an attack modifier, pass along this attack event to be modified if (pendingAttackSkill != null) { float attributeModifier = CombatEngine.GetEntitySkillStrength(owner, pendingAttackSkill); // add the fact that it was a skill being used to the original combat baseAttack.damageEvent.combat.Set("skill", pendingAttackSkill); ECompileSkillEffects compileSkillEvent = new ECompileSkillEffects() { user = owner, skillStrength = attributeModifier, baseLocation = baseAttack.damageEvent.combat.defender.position, }; compileSkillEvent.combats.Add(baseAttack.damageEvent.combat); pendingAttackSkill.FireEvent(compileSkillEvent); foreach (var combat in compileSkillEvent.combats) { CombatEngine.ProcessCombat(combat); } // check if the skill is done var skillCompleted = (EGetSkillCompleted)pendingAttackSkill.FireEvent(new EGetSkillCompleted() { isCompleted = true }); // and reset the skill if (skillCompleted.isCompleted) { pendingAttackSkill = null; } // set the base attack state to not apply damage, because the skill handles it baseAttack.canPerform = false; } return(true); }
private void DoIteration(bool updateViews = true) { if (FightIsOver) { return; } if (Me.Health <= 0) { ScoreTarget++; FightIsOver = true; if (updateViews) { this.Dispatcher.Invoke(UpdateViews); } return; } if (Target.Health <= 0) { ScoreMe++; FightIsOver = true; if (updateViews) { this.Dispatcher.Invoke(UpdateViews); } return; } if (Me.Energy + 1 <= Me.MaxEnergy) { Me.Energy += 1; } if (Target.Energy + 1 <= Target.MaxEnergy) { Target.Energy += 1; } CombatEngine.DoIteration(Me, Target); CombatEngine2.DoIteration(Target, Me); }
public bool Event_OnAttack(ComponentEvent e) { Entity target = ((EDoAttack)e).target; // check if the attack has the range to even perfom this attack var getRangeEvent = (EGetAttackRange)owner.FireEvent(new EGetAttackRange()); int dist = Vector2.TaxiDistance(target.position, owner.position); if (dist > 2 && dist > getRangeEvent.range) { return(true); } // otherwise, calculate the damage to be dealt, then send off the damage event int baseDamage = strength; // fire off another event that will gather info from other components about the specifics of the attack var attackEvent = (ECompileAttack)owner.FireEvent(new ECompileAttack() { combat = new CombatInstance(owner, target) { { "damage", baseDamage } } }); // notify other components about the attack var checkAttackEvent = (EOnPerformAttack)owner.FireEvent(new EOnPerformAttack() { damageEvent = attackEvent, canPerform = true }); // back out before applying the damage, in case some other component doesn't want the attack to be performed if (!checkAttackEvent.canPerform) { return(true); } CombatEngine.ProcessCombat(attackEvent.combat); return(true); }
protected void Page_Init(object sender, EventArgs e) { if (!Page.IsPostBack) { PlayerCharacter PC = (PlayerCharacter)System.Web.HttpContext.Current.Session["attacker"]; Enemy enemy = (Enemy)System.Web.HttpContext.Current.Session["target"]; this.combatEngine = new CombatEngine(PC, enemy); } else { this.combatEngine = (CombatEngine)System.Web.HttpContext.Current.Session["combatEngine"]; } int attackCount = this.combatEngine.PC.Attacks.Count; for (int i = 0; i < attackCount; i++) { Button attackButton = (Button)attackGrid.FindControl("Button" + (i + 1).ToString()); attackButton.CommandName = this.combatEngine.PC.Attacks.ElementAt(i).Name; attackButton.Text = attackButton.CommandName; attackButton.Click += new EventHandler(this.AttackButtonClick); attackButton.Visible = true; } }
private void InitCombatEngine() { FightIsOver = false; /* * Random rnd = new Random(); * * int health = rnd.Next(20000, 30000); * int healthTarget = rnd.Next(20000, 30000); * * int energy = rnd.Next(5000, 10000); * int energyTarget = rnd.Next(5000, 10000); */ int health = 8000; int healthTarget = 8000; int energy = 10000; int energyTarget = 10000; Vector3 positionMe = new Vector3(100, 50, 0); Vector3 positionTarget = new Vector3(300, 50, 0); Me = new Unit(health, health, energy, energy, CombatState.Standing, positionMe); Target = new Unit(healthTarget, healthTarget, energyTarget, energyTarget, CombatState.Standing, positionTarget); this.Dispatcher.Invoke(UpdateViews); CombatEngine = new CombatEngine(SpellsA, new SpellSimple(SpellsA, 30), new MovementCloseCombat()); CombatEngine.OnCastSpell += HandleMeCast; CombatEngine.OnMoveCharacter += HandleMeMove; CombatEngine2 = new CombatEngine(SpellsB, new SpellSimple(SpellsB, 0), new MovementDefensiveRanged(positionTarget)); CombatEngine2.OnCastSpell += HandleTargetCast; CombatEngine2.OnMoveCharacter += HandleTargetMove; }
public override void HandleInput() { base.HandleInput(); bool hasMoved = false; Entity player = m_ActiveWorld.Player; /* * if (m_Input.currentMouseState.ScrollWheelValue > m_Input.lastMouseState.ScrollWheelValue) * { * m_Camera.zoom += 0.05f; * } * * if (m_Input.currentMouseState.ScrollWheelValue < m_Input.lastMouseState.ScrollWheelValue) * { * m_Camera.zoom -= 0.05f; * } * * if(m_Input.IsOldPress(MouseButtons.RightButton)) * { * m_GUIManager.Screen.Desktop.Children.Remove(m_ContextMenu); * m_ContextMenu.MoveTo(m_Input.currentMouseState.Position); * m_GUIManager.Screen.Desktop.Children.Add(m_ContextMenu); * * Vector2 mouseVector = (m_Input.currentMouseState.Position - (new Point(m_Renderer.m_ScreenWidth / 2, m_Renderer.m_ScreenHeight / 2))).ToVector2(); * m_MenuTile = new Point((int)Math.Floor(mouseVector.X / (ObjectIcons.SPRITE_SIZE * m_Camera.zoom)), (int)Math.Floor(mouseVector.Y / (ObjectIcons.SPRITE_SIZE * m_Camera.zoom))) + s_ActiveWorld.player.position; * } * * if(m_Input.IsOldPress(Keys.Space)) * { * autoTurn = !autoTurn; * } * * if(m_Input.IsOldPress(Keys.L)) * { * s_ActiveWorld.player.LevelUp(); * } * */ /* * if(Input.GetMouseButtonDown(0)) * { * Vector3 mouseWorld = m_Camera.ScreenToWorldPoint(Input.mousePosition); * int x = (int)mouseWorld.x; * int y = (int)mouseWorld.y; * * Pathfinder pathfinder = new Pathfinder(); * Queue<Vector2Int> path = pathfinder.FindPath(player.WorldPosition, new Vector2Int(x, y), m_ActiveWorld); * player.SetPath(path); * autoTurn = true; * } */ if (Input.GetKeyDown(KeyCode.I)) { m_InventoryOpen = !m_InventoryOpen; if (m_InventoryOpen == false) { s_GUIManager.OpenGUI("NeedsPanel"); } else { s_GUIManager.OpenGUI("GUIInventory"); } } if (s_GUIManager.RemovesControl()) { return; } if (Input.GetKeyDown(KeyCode.Return)) { //Going up a level if (m_ActiveWorld.Parent != null && player.WorldPosition == m_ActiveWorld.SpawnPoint && !player.HasMoved) { ChangeWorld(m_ActiveWorld.Parent, m_ActiveWorld.GetTransitionPointForParent()); return; } //Going down a level else if (m_ActiveWorld.Areas.ContainsKey(player.WorldPosition) && !player.HasMoved) { ChangeWorld(m_ActiveWorld.Areas[player.WorldPosition], m_ActiveWorld.Areas[player.WorldPosition].SpawnPoint); return; } PhysicsResult physicsResult = PhysicsManager.IsCollision(player.WorldPosition, player.WorldPosition, m_ActiveWorld); if (physicsResult == PhysicsResult.ObjectCollision) { //Get the item picked up ItemInstance pickUp = m_ActiveWorld.PickUpObject(player); //And try to destroy the corresponding GameObject if (pickUp != null) { GameObject.Destroy(GameObject.Find(pickUp.JoyName + ":" + pickUp.GUID)); } } } Vector2Int newPlayerPoint = m_ActiveWorld.Player.WorldPosition; //North if (Input.GetKeyDown(KeyCode.Keypad8)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x, player.TargetPoint.y - 1); } else { newPlayerPoint.y += 1; hasMoved = true; } } //North east else if (Input.GetKeyDown(KeyCode.Keypad9)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y - 1); } else { newPlayerPoint.x += 1; newPlayerPoint.y += 1; hasMoved = true; } } //East else if (Input.GetKeyDown(KeyCode.Keypad6)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y); } else { newPlayerPoint.x += 1; hasMoved = true; } } //South east else if (Input.GetKeyDown(KeyCode.Keypad3)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y + 1); } else { newPlayerPoint.x += 1; newPlayerPoint.y -= 1; hasMoved = true; } } //South else if (Input.GetKeyDown(KeyCode.Keypad2)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x, player.TargetPoint.y + 1); } else { newPlayerPoint.y -= 1; hasMoved = true; } } //South west else if (Input.GetKeyDown(KeyCode.Keypad1)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y + 1); } else { newPlayerPoint.x -= 1; newPlayerPoint.y -= 1; hasMoved = true; } } //West else if (Input.GetKeyDown(KeyCode.Keypad4)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y); } else { newPlayerPoint.x -= 1; hasMoved = true; } } //North west else if (Input.GetKeyDown(KeyCode.Keypad7)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y - 1); } else { newPlayerPoint.x -= 1; newPlayerPoint.y += 1; hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.Keypad5)) { Tick(); return; } if (hasMoved) { PhysicsResult physicsResult = PhysicsManager.IsCollision(player.WorldPosition, newPlayerPoint, m_ActiveWorld); if (physicsResult == PhysicsResult.EntityCollision) { Entity tempEntity = m_ActiveWorld.GetEntity(newPlayerPoint); if (m_GameplayFlags == GameplayFlags.Interacting) { if (tempEntity.Sentient) { TalkToPlayer(tempEntity); } } else if (m_GameplayFlags == GameplayFlags.Giving) { } else if (m_GameplayFlags == GameplayFlags.Moving) { playerWorld.SwapPosition(player, tempEntity); Tick(); } else if (m_GameplayFlags == GameplayFlags.Attacking) { if (tempEntity.GUID != player.GUID) { CombatEngine.SwingWeapon(player, tempEntity); tempEntity.InfluenceMe(player.GUID, -50); if (!tempEntity.Alive) { m_ActiveWorld.RemoveEntity(newPlayerPoint); //Find a way to remove the GameObject for (int i = 0; i < m_EntitiesHolder.transform.childCount; i++) { if (m_EntitiesHolder.transform.GetChild(i).name.Contains(tempEntity.GUID.ToString())) { GameObject.Destroy(m_EntitiesHolder.transform.GetChild(i).gameObject); break; } } } } } Tick(); } else if (physicsResult == PhysicsResult.WallCollision) { //Do nothing! } else { if (newPlayerPoint.x >= 0 && newPlayerPoint.x < m_ActiveWorld.Tiles.GetLength(0) && newPlayerPoint.y >= 0 && newPlayerPoint.y < m_ActiveWorld.Tiles.GetLength(1)) { player.Move(newPlayerPoint); Tick(); } } } else if (m_GameplayFlags == GameplayFlags.Targeting) { if (player.TargetingAbility.targetType == AbilityTarget.Adjacent) { if (AdjacencyHelper.IsAdjacent(player.WorldPosition, player.TargetPoint)) { Entity tempEntity = m_ActiveWorld.GetEntity(player.TargetPoint); if (tempEntity != null && Input.GetKeyDown(KeyCode.Return)) { player.TargetingAbility.Use(player, tempEntity); Tick(); m_GameplayFlags = GameplayFlags.Moving; } } } else if (player.TargetingAbility.targetType == AbilityTarget.Ranged) { Entity tempEntity = m_ActiveWorld.GetEntity(player.TargetPoint); if (tempEntity != null && Input.GetKeyDown(KeyCode.Return)) { player.TargetingAbility.Use(player, tempEntity); Tick(); m_GameplayFlags = GameplayFlags.Moving; } } } if (autoTurn) { Tick(); } m_Camera.transform.position = new Vector3(player.WorldPosition.x, player.WorldPosition.y, m_Camera.transform.position.z); }
public void Monster_Timer() { //Perform all monster logic here switch (Mode) { case MonsterMode.Attack: { var target = Map.Search <Entity>(TargetID); if (target == null || !target.Alive || target.HasEffect(ClientEffect.Fly)) { Mode = MonsterMode.Idle; return; } var dist = Calculations.GetDistance(Location, target.Location); if (dist > BaseMonster.ViewRange) { Mode = MonsterMode.Idle; } else if (dist > BaseMonster.AttackRange) { Mode = MonsterMode.Walk; } else if (Common.Clock - LastAttack > BaseMonster.AttackSpeed) { LastAttack = Common.Clock; CombatEngine.ProcessInteractionPacket(InteractPacket.Create(UID, TargetID, target.X, target.Y, InteractAction.Attack, 0)); } break; } case MonsterMode.Idle: { var d1 = BaseMonster.ViewRange; foreach (var t in Map.QueryScreen <Entity>(this)) { if (!CombatEngine.IsValidTarget(t) || (BaseMonster.Mesh != 900 && t.HasEffect(ClientEffect.Fly)) || t.HasStatus(ClientStatus.ReviveProtection)) { continue; } var d2 = Calculations.GetDistance(Location, t.Location); if (d2 < d1) { d1 = d2; TargetID = t.UID; if (d2 <= BaseMonster.AttackRange) { break; } } } var Target = Map.Search <Entity>(TargetID); /*if ((Life < MaximumLife) && (isSearching == false)) //Get the target that is range attacking * { * var searchRange = 30; * foreach (var t in Map.QueryScreen<Entity>(this)) * { * if (!CombatEngine.IsValidTarget(t) || (BaseMonster.Mesh != 900 && t.HasEffect(ClientEffect.Fly)) || t.HasStatus(ClientStatus.ReviveProtection)) * continue; * var d2 = Calculations.GetDistance(Location, t.Location); * if (d2 < searchRange) * { * searchRange = d2; * TargetID = t.UID; * } * } * Target = Map.Search<Entity>(TargetID); * Mode = MonsterMode.Search; * }*/ if (Life < isAttacked) { Mode = MonsterMode.Search; isAttacked = Life; foreach (var t in Map.QueryScreen <Entity>(this)) { if (!CombatEngine.IsValidTarget(t) || (BaseMonster.Mesh != 900 && t.HasEffect(ClientEffect.Fly)) || t.HasStatus(ClientStatus.ReviveProtection)) { continue; } var d2 = Calculations.GetDistance(Location, t.Location); if (d2 < 30) //Range of searching { TargetID = t.UID; if (d2 <= BaseMonster.AttackRange) { break; } } } } else { if (Target != null) { var dist = Calculations.GetDistance(Location, Target.Location); if (dist < BaseMonster.AttackRange) { Mode = MonsterMode.Attack; } else if (dist < BaseMonster.ViewRange) { Mode = MonsterMode.Walk; } } else if (BaseMonster.Mesh != 900 && Common.Clock - LastMove > BaseMonster.MoveSpeed * 4) { var dir = (byte)Common.Random.Next(9); Point tryMove = new Point(Location.X + Common.DeltaX[dir], Location.Y + Common.DeltaY[dir]); if (Common.MapService.Valid(MapID, (ushort)tryMove.X, (ushort)tryMove.Y) && !Common.MapService.HasFlag(MapID, (ushort)tryMove.X, (ushort)tryMove.Y, TinyMap.TileFlag.Monster)) { //Send to screen new walk packet SendToScreen(WalkPacket.Create(UID, dir)); Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); X = (ushort)tryMove.X; Y = (ushort)tryMove.Y; Direction = dir; Common.MapService.AddFlag(MapID, X, Y, TinyMap.TileFlag.Monster); LastMove = Common.Clock; UpdateSurroundings(); } } } break; } case MonsterMode.Walk: { var target = Map.Search <Entity>(TargetID); if (target == null || !target.Alive || (BaseMonster.Mesh != 900 && target.HasEffect(ClientEffect.Fly) || target.HasStatus(ClientStatus.ReviveProtection))) { Mode = MonsterMode.Idle; } else if (Common.Clock - LastMove > BaseMonster.MoveSpeed) { var dist = Calculations.GetDistance(Location, target.Location); if (dist > BaseMonster.ViewRange) { Mode = MonsterMode.Idle; } else if (dist > BaseMonster.AttackRange) { var dir = Calculations.GetDirection(Location, target.Location); Point tryMove = new Point(Location.X + Common.DeltaX[dir], Location.Y + Common.DeltaY[dir]); if (Common.MapService.Valid(MapID, (ushort)tryMove.X, (ushort)tryMove.Y) && !Common.MapService.HasFlag(MapID, (ushort)tryMove.X, (ushort)tryMove.Y, TinyMap.TileFlag.Monster)) { //Send to screen new walk packet SendToScreen(WalkPacket.Create(UID, dir)); Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); X = (ushort)tryMove.X; Y = (ushort)tryMove.Y; Direction = dir; Common.MapService.AddFlag(MapID, X, Y, TinyMap.TileFlag.Monster); LastMove = Common.Clock; } else if (Common.Clock - LastMove > BaseMonster.MoveSpeed * 5) { Mode = MonsterMode.Encircle; } } else { LastAttack = Common.Clock - AttackSpeed + 100; Mode = MonsterMode.Attack; } } break; } case MonsterMode.Encircle: { var Target = Map.Search <Entity>(TargetID); if (Target != null) { var dir = (byte)Common.Random.Next(9); //This should move to turn around an object. Now is random. for (int i = 0; i < Common.Random.Next(2, 5); i++) { Point tryMove = new Point(Location.X + Common.DeltaX[dir], Location.Y + Common.DeltaY[dir]); if (Common.MapService.Valid(MapID, (ushort)tryMove.X, (ushort)tryMove.Y) && !Common.MapService.HasFlag(MapID, (ushort)tryMove.X, (ushort)tryMove.Y, TinyMap.TileFlag.Monster)) { //Send to screen new walk packet SendToScreen(WalkPacket.Create(UID, dir)); Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); X = (ushort)tryMove.X; Y = (ushort)tryMove.Y; Direction = dir; Common.MapService.AddFlag(MapID, X, Y, TinyMap.TileFlag.Monster); LastMove = Common.Clock; //UpdateSurroundings(); } } } Mode = MonsterMode.Idle; break; } case MonsterMode.Search: { var target = Map.Search <Entity>(TargetID); if (target == null || !target.Alive || (BaseMonster.Mesh != 900 && target.HasEffect(ClientEffect.Fly) || target.HasStatus(ClientStatus.ReviveProtection))) { Mode = MonsterMode.Idle; } else if (Common.Clock - LastMove > BaseMonster.MoveSpeed) { var dist = Calculations.GetDistance(Location, target.Location); if (dist > 30) //Max range of search. { Mode = MonsterMode.Idle; } else if (dist > BaseMonster.AttackRange) { var dir = Calculations.GetDirection(Location, target.Location); Point tryMove = new Point(Location.X + Common.DeltaX[dir], Location.Y + Common.DeltaY[dir]); if (Common.MapService.Valid(MapID, (ushort)tryMove.X, (ushort)tryMove.Y) && !Common.MapService.HasFlag(MapID, (ushort)tryMove.X, (ushort)tryMove.Y, TinyMap.TileFlag.Monster)) { //Send to screen new walk packet SendToScreen(WalkPacket.Create(UID, dir)); Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); X = (ushort)tryMove.X; Y = (ushort)tryMove.Y; Direction = dir; Common.MapService.AddFlag(MapID, X, Y, TinyMap.TileFlag.Monster); LastMove = Common.Clock; } else if (Common.Clock - LastMove > BaseMonster.MoveSpeed * 5) { Mode = MonsterMode.Encircle; } } else { LastAttack = Common.Clock - AttackSpeed + 100; Mode = MonsterMode.Attack; } } break; } } }
public static CombatEngine getInstance() { if(instance == null) instance = new CombatEngine(); return instance; }
/// <summary> /// Handle user input to the actions menu. /// </summary> public void UpdateActionsMenu() { // cursor up if (InputManager.IsActionTriggered(InputManager.Action.CursorUp)) { if (highlightedAction > 0) { highlightedAction--; } return; } // cursor down if (InputManager.IsActionTriggered(InputManager.Action.CursorDown)) { if (highlightedAction < actionList.Length - 1) { highlightedAction++; } return; } // select an action if (InputManager.IsActionTriggered(InputManager.Action.Ok)) { switch (actionList[highlightedAction]) { case "Attack": { ActionText = "Performing a Melee Attack"; CombatEngine.HighlightedCombatant.CombatAction = new MeleeCombatAction(CombatEngine.HighlightedCombatant); CombatEngine.HighlightedCombatant.CombatAction.Target = CombatEngine.FirstEnemyTarget; } break; case "Spell": { SpellbookScreen spellbookScreen = new SpellbookScreen( CombatEngine.HighlightedCombatant.Character, CombatEngine.HighlightedCombatant.Statistics); spellbookScreen.SpellSelected += new SpellbookScreen.SpellSelectedHandler( spellbookScreen_SpellSelected); Session.ScreenManager.AddScreen(spellbookScreen); } break; case "Item": { InventoryScreen inventoryScreen = new InventoryScreen(true); inventoryScreen.GearSelected += new InventoryScreen.GearSelectedHandler( inventoryScreen_GearSelected); Session.ScreenManager.AddScreen(inventoryScreen); } break; case "Defend": { ActionText = "Defending"; CombatEngine.HighlightedCombatant.CombatAction = new DefendCombatAction( CombatEngine.HighlightedCombatant); CombatEngine.HighlightedCombatant.CombatAction.Start(); } break; case "Flee": CombatEngine.AttemptFlee(); break; } return; } }
public override void Exit() { CombatEngine?.Exit(); }
public override void executeAction() { CombatEngine combatEngine = GameObject.FindObjectOfType <CombatEngine>(); combatEngine.SpawnEnemy(3); }
/// <summary> /// Damages the combatant by the given amount. /// </summary> public virtual void Damage(StatisticsValue damageStatistics, int duration) { State = RolePlayingGameData.Character.CharacterState.Hit; CombatEngine.AddNewDamageEffects(OriginalPosition, damageStatistics); }
/// <summary> /// Heal the combatant by the given amount. /// </summary> public virtual void Heal(StatisticsValue healingStatistics, int duration) { CombatEngine.AddNewHealingEffects(OriginalPosition, healingStatistics); }
public bool Event_ThrowItem(ComponentEvent e) { AreaMap map = Engine.instance.world.currentMap; var throwEvent = ((EThrowItem)e); string itemType = throwEvent.itemName; // try to find the item on the entity to throw it var consumeItemEvent = (EConsumeItem)owner.FireEvent(new EConsumeItem() { itemName = itemType }); if (!consumeItemEvent.hasItem) { return(true); } // This enttiy did have the item to throw Entity projectile = consumeItemEvent.consumedItem; // Get the thrwoer strength and item weight, in order to calc both damage and max throw distance var getStrength = (EGetAttributeLevel)owner.FireEvent(new EGetAttributeLevel() { target = "strength" }); int strength = getStrength.level; float strRatio = (strength / 100.0f); var getWeight = (EGetWeight)owner.FireEvent(new EGetWeight()); int thrownWeight = getWeight.weight; float maxDistance = CombatEngine.GetThrowRange(owner, projectile); int throwDamage = (int)(strRatio * thrownWeight); // if the target position is farther than the max distance, select the nearest point in that direction Vector2 targetLoc = throwEvent.targetLocation; Vector2 toTarget = targetLoc - owner.position; if (toTarget.Magnitude() > maxDistance) { Vector2 dir = toTarget.Normalized(); targetLoc = owner.position + (dir * maxDistance); } // check where the item hits, if there is something in the way Vector2 hitNormal; Vector2 endPosition = map.CollisionPointFromTo(owner.position, targetLoc, out hitNormal); // find the target to hit, and apply some damage and knock them back Entity[] targets = map.GetAllObjectsAt(endPosition.X, endPosition.Y); foreach (Entity hit in targets) { CombatInstance combat = new CombatInstance(owner, hit) { { "damage", throwDamage }, { "weapon", projectile } }; CombatEngine.ProcessCombat(combat); } // the thrown item ends up next to the target location, or the nearest valid location toTarget = Vector2.OrthoNormal(toTarget); endPosition = endPosition - toTarget; endPosition = map.GetNearestValidMove(endPosition); Engine.instance.world.SpawnExisting(projectile, endPosition); return(true); }
public void Attack(string attackName, Character target, CombatEngine engine) { this.attacks.Attack(attackName, this, target, engine); }
/// <summary> /// When a skill recieves an activation event, it will come back here, where it can be handled by the correct system. /// This is done because some skills use targeting UI / AI and some use attack events and some are immediate /// </summary> public bool Event_HandleSkillActivation(ComponentEvent e) { var activationEvent = (EOnSkillActivated)e; Entity skill = activationEvent.skill; // check how much energy the skill uses, and dont let it be used if its too much var checkSkillReq = (EGetEnergy)skill.FireEvent(new EGetEnergy()); if (checkSkillReq.requiredEnergy > currentEnergy) { return(true); } bool skillActivated = false; // Handle different use mode cases. switch (activationEvent.useMode) { case SkillUseMode.EType.NextAttack: // for now, only one pending attack skill can be active at a time if (pendingAttackSkill == null) { pendingAttackSkill = skill; skillActivated = true; } else if (pendingAttackSkill == skill) { // if the same skill is re-activated, cancel it pendingAttackSkill = null; } break; case SkillUseMode.EType.Targeted: // TODO: delegate this somehow to UI or AI to select the target location / entity break; case SkillUseMode.EType.Self: // use immediatly on self skillActivated = true; float attributeModifier = CombatEngine.GetEntitySkillStrength(owner, skill); var skillEffects = new ECompileSkillEffects() { user = owner, skillStrength = attributeModifier, baseLocation = owner.position, }; skillEffects.combats.Add(new CombatInstance(owner, owner) { { "skill", skill } }); skill.FireEvent(skillEffects); // process the events foreach (var combat in skillEffects.combats) { CombatEngine.ProcessCombat(combat); } break; } // if the skill was activated, reduce the energy level if (skillActivated) { currentEnergy -= checkSkillReq.requiredEnergy; nextEnergyPoint = 0; } return(true); }
/// <summary> /// Create a new GameplayScreen object. /// </summary> private GameplayScreen() : base() { CombatEngine.ClearCombat(); this.Exiting += new EventHandler(GameplayScreen_Exiting); }
/// <summary> /// Handle user input to the actions menu. /// </summary> public void UpdateActionsMenu() { bool isMenuItemPressed = false; if (firstCombatMenuPosition != Rectangle.Empty) { int x = firstCombatMenuPosition.X; for (int playerCount = 0; playerCount < CombatEngine.Players.Count; playerCount++) { for (int actionIndex = 0; actionIndex < actionList.Length; actionIndex++) { float yPosition = firstCombatMenuPosition.Y; if (actionIndex + 1 > 1) { yPosition = yPosition + (heightInterval * actionIndex + 1); } Rectangle currentActionPosition = new Rectangle(x, (int)yPosition, (int)(firstCombatMenuPosition.Width * ScaledVector2.ScaleFactor), (int)(firstCombatMenuPosition.Height * ScaledVector2.ScaleFactor)); if (InputManager.IsButtonClicked(currentActionPosition)) { highlightedAction = actionIndex; isMenuItemPressed = true; break; } } x += (int)(activeCharInfoTexture.Width * ScaledVector2.DrawFactor - 6f * ScaledVector2.ScaleFactor); } } // select an action if (isMenuItemPressed) { switch (actionList[highlightedAction]) { case "Attack": { ActionText = "Performing a Melee Attack"; CombatEngine.HighlightedCombatant.CombatAction = new MeleeCombatAction(CombatEngine.HighlightedCombatant); CombatEngine.HighlightedCombatant.CombatAction.Target = CombatEngine.FirstEnemyTarget; } break; case "Spell": { SpellbookScreen spellbookScreen = new SpellbookScreen( CombatEngine.HighlightedCombatant.Character, CombatEngine.HighlightedCombatant.Statistics); spellbookScreen.SpellSelected += new SpellbookScreen.SpellSelectedHandler( spellbookScreen_SpellSelected); Session.ScreenManager.AddScreen(spellbookScreen); } break; case "Item": { InventoryScreen inventoryScreen = new InventoryScreen(true); inventoryScreen.GearSelected += new InventoryScreen.GearSelectedHandler( inventoryScreen_GearSelected); Session.ScreenManager.AddScreen(inventoryScreen); } break; case "Defend": { ActionText = "Defending"; CombatEngine.HighlightedCombatant.CombatAction = new DefendCombatAction( CombatEngine.HighlightedCombatant); CombatEngine.HighlightedCombatant.CombatAction.Start(); } break; case "Flee": CombatEngine.AttemptFlee(); break; } return; } }
public void ExecuteAttack(Character attacker, Character target, CombatEngine engine) { if (attacker.CurrentTP - this.tpCost < 0) { attacker.CurrentTP = 0; } else { attacker.CurrentTP -= this.tpCost; } double chanceToHit = attacker.ChanceToHit - this.hitPenalty; int damage = (int)((this.dmgModifier * (1 + attacker.DMGModifier)) * attacker.DMG); Random random = new Random(); if (chanceToHit >= random.NextDouble()) { target.CurrentHP -= damage; string result = attacker.Name + " hit " + target.Name + " for " + damage + " damage!"; engine.AddCombatResult(result); if (this.effect != null) { target.Attach(this.effect); } } else { string result = attacker.Name + " missed " + target.Name + "!"; engine.AddCombatResult(result); } }
public Battle(Player player, Opponent opponent) { CurrentPlayer = player; CurrentOpponent = opponent; _combatEngine = new CombatEngine(); }
public void Monster_Timer() { //Perform all monster logic here switch (Mode) { case MonsterMode.Attack: { var target = Map.Search <Entity>(TargetID); if (target == null || !target.Alive || target.HasEffect(ClientEffect.Fly)) { Mode = MonsterMode.Idle; return; } var dist = Calculations.GetDistance(Location, target.Location); if (dist > BaseMonster.ViewRange) { Mode = MonsterMode.Idle; } else if (dist > BaseMonster.AttackRange) { Mode = MonsterMode.Walk; } else if (Common.Clock - LastAttack > BaseMonster.AttackSpeed) { LastAttack = Common.Clock; CombatEngine.ProcessInteractionPacket(InteractPacket.Create(UID, TargetID, target.X, target.Y, InteractAction.Attack, 0)); } break; } case MonsterMode.Idle: { var d1 = BaseMonster.ViewRange; foreach (var t in Map.QueryScreen <Entity>(this)) { if (!CombatEngine.IsValidTarget(t) || (BaseMonster.Mesh != 900 && t.HasEffect(ClientEffect.Fly)) || t.HasStatus(ClientStatus.ReviveProtection)) { continue; } var d2 = Calculations.GetDistance(Location, t.Location); if (d2 < d1) { d1 = d2; TargetID = t.UID; if (d2 <= BaseMonster.AttackRange) { break; } } } var Target = Map.Search <Entity>(TargetID); if (Target == null) { return; } var dist = Calculations.GetDistance(Location, Target.Location); if (dist < BaseMonster.AttackRange) { Mode = MonsterMode.Attack; } else if (dist < BaseMonster.ViewRange) { Mode = MonsterMode.Walk; } else if (BaseMonster.Mesh != 900 && Common.Clock - LastMove > BaseMonster.MoveSpeed * 4) { var dir = (byte)Common.Random.Next(9); Point tryMove = new Point(Location.X + Common.DeltaX[dir], Location.Y + Common.DeltaY[dir]); if (Common.MapService.Valid(MapID, (ushort)tryMove.X, (ushort)tryMove.Y) && !Common.MapService.HasFlag(MapID, (ushort)tryMove.X, (ushort)tryMove.Y, TinyMap.TileFlag.Monster)) { //Send to screen new walk packet SendToScreen(WalkPacket.Create(UID, dir)); Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); X = (ushort)tryMove.X; Y = (ushort)tryMove.Y; Direction = dir; Common.MapService.AddFlag(MapID, X, Y, TinyMap.TileFlag.Monster); LastMove = Common.Clock; UpdateSurroundings(); } } break; } case MonsterMode.Walk: { var target = Map.Search <Entity>(TargetID); if (target == null || !target.Alive || (BaseMonster.Mesh != 900 && target.HasEffect(ClientEffect.Fly))) { Mode = MonsterMode.Idle; } else if (Common.Clock - LastMove > BaseMonster.MoveSpeed) { var dist = Calculations.GetDistance(Location, target.Location); if (dist > BaseMonster.ViewRange) { Mode = MonsterMode.Idle; } else if (dist > BaseMonster.AttackRange) { var dir = Calculations.GetDirection(Location, target.Location); Point tryMove = new Point(Location.X + Common.DeltaX[dir], Location.Y + Common.DeltaY[dir]); if (Common.MapService.Valid(MapID, (ushort)tryMove.X, (ushort)tryMove.Y) && !Common.MapService.HasFlag(MapID, (ushort)tryMove.X, (ushort)tryMove.Y, TinyMap.TileFlag.Monster)) { //Send to screen new walk packet SendToScreen(WalkPacket.Create(UID, dir)); Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); X = (ushort)tryMove.X; Y = (ushort)tryMove.Y; Common.MapService.AddFlag(MapID, X, Y, TinyMap.TileFlag.Monster); LastMove = Common.Clock; } else if (Common.Clock - LastMove > BaseMonster.MoveSpeed * 5) { Mode = MonsterMode.Idle; } } else { LastAttack = Common.Clock; Mode = MonsterMode.Attack; } } break; } } }
private void Start() { main = FindObjectOfType <CombatEngine>(); }
// dynamic features public override TCODConsole GetUpdatedConsole() { base.GetUpdatedConsole(); const int left = 2; int hoveredItemY = -1; Entity hoveredItem = null; int width = console.getWidth() - (left + 3); Vector2 mLoc = ScreenToConsoleCoord(engine.mouseData.CellX, engine.mouseData.CellY); InitializeConsole(); // devider line is a horizontal line that can be drawn across the console string deviderLine = CharConstants.E_TJOINT + ""; for (int i = 1; i < console.getWidth() - 1; i++) { deviderLine += CharConstants.HORZ_LINE; } deviderLine += CharConstants.W_TJOINT; // inventory weight: TODO DrawText(left, 2, " weight: X/X", Constants.COL_FRIENDLY); // equipped area ------------------------------------------------------------- int equiptopY = equipSection.starty; DrawText(0, equiptopY, deviderLine, TCODColor.white); DrawText(left, equiptopY, " equipped ", Constants.COL_NORMAL); if (equipment.weapon != null) { EGetScreenName getName = (EGetScreenName)equipment.weapon.FireEvent(new EGetScreenName()); string weaponName = getName.text; // the weapon is being hovered over if (mLoc.y == equiptopY + 3 && mLoc.x >= left && mLoc.x < weaponName.Length + 1 + left) { DrawRect(left, equiptopY + 3, width, Constants.COL_FRIENDLY); hoveredItem = equipment.weapon; hoveredItemY = equiptopY + 3; // was clicked, start dragging it if (engine.mouseData.LeftButtonPressed) { parent.SetDragDrop(weaponName, equipment.weapon, OnDragDroppedEquippedItem); parent.rangeIndicator.range = CombatEngine.GetThrowRange(player, equipment.weapon); draggingItem = true; } } DrawText(left, equiptopY + 2, "weapon: ", Constants.COL_NORMAL); DrawText(left, equiptopY + 3, " " + weaponName, TCODColor.white); } // pack adrea (general unequipped items) ------------------------------------- int packtopY = invSection.starty; DrawText(0, packtopY, deviderLine, TCODColor.white); DrawText(left, packtopY, " pack ", Constants.COL_NORMAL); int line = 1; foreach (Entity item in inventory.items) { // get the screen name dynamically: TODO: maybe cache this? EGetScreenName getName = (EGetScreenName)item.FireEvent(new EGetScreenName()); string screenName = getName.text; // check if the mouse is hovering on this item row if (mLoc.y == packtopY + line && mLoc.x >= left && mLoc.x < screenName.Length + 1 + left) { hoveredItem = item; hoveredItemY = packtopY + line; // highlight the item that is hovered on DrawRect(left, packtopY + line, width, Constants.COL_FRIENDLY); // check for clicks on this item, and start dragging it if (engine.mouseData.LeftButtonPressed) { parent.SetDragDrop(screenName, item, OnDragDroppedInvItem); // set the range indicator based on how far the dragged item can be thrown, in case the player dicides to throw its parent.rangeIndicator.range = CombatEngine.GetThrowRange(player, item); draggingItem = true; } } DrawText(left, packtopY + line, screenName, TCODColor.white); DrawText(left - 1, packtopY + line, ">", Constants.COL_ATTENTION); line += 1; } // if there is a hovered item, open the item details window if (hoveredItem != null && (!itemInfoWindow.isVisible || hoveredItem != itemInfoWindow.targetItem)) { // move the window to the correct position, and open it for the new item itemInfoWindow.origin.y = hoveredItemY; itemInfoWindow.origin.x = origin.x - itemInfoWindow.console.getWidth(); itemInfoWindow.OpenForItem(hoveredItem); } else if (hoveredItem == null && itemInfoWindow.isVisible) { itemInfoWindow.Close(); } // tell the parent to draw the range indicator if the user is looking like they will drop the dragged item if (draggingItem) { if (!ScreenCoordInConsole(new Vector2(engine.mouseData.CellX, engine.mouseData.CellY))) { parent.rangeIndicator.active = true; } else { parent.rangeIndicator.active = false; } } return(console); }
public void UpdateMe() { if (this.MyWorld.IsDirty) { FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.MyWorld.Dimensions, this.VisionMod, this.MyWorld.Walls.Keys.ToList()); m_Vision = board.Vision; } else { FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.VisionMod); m_Vision = board.Vision; } HasMoved = false; if (!PlayerControlled) { //Attack immediate threats /* * REDO THIS TO BE IN LUA * //List<NeedAIData> targets = MyWorld.SearchForEntities(this, "Any", Intent.Attack, EntityTypeSearch.Any, EntitySentienceSearch.Any); * //List<NeedAIData> validTargets = targets.Where(x => this.HasRelationship(x.target.GUID) < ATTACK_THRESHOLD).ToList(); * if(validTargets.Count > 0 && CurrentTarget.target == null) * { * //TODO: Write a threat assessment system * //For now, choose a random target and go after them * int result = RNG.Roll(0, validTargets.Count - 1); * NeedAIData data = validTargets[result]; * * CurrentTarget = data; * m_PathfindingData = m_Pathfinder.FindPath(this.WorldPosition, CurrentTarget.target.WorldPosition, this.MyWorld); * } */ //If you're idle if (CurrentTarget.idle == true) { //Let's find something to do List <EntityNeed> needs = m_Needs.Values.OrderByDescending(x => x.priority).ToList(); //Act on first need bool idle = true; foreach (EntityNeed need in needs) { if (need.contributingHappiness) { continue; } Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName); ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) }); idle = false; break; } m_CurrentTarget.idle = idle; } //Otherwise, carry on with what you're doing else { if (WorldPosition == CurrentTarget.targetPoint || (CurrentTarget.target != null && WorldPosition == CurrentTarget.target.WorldPosition)) { //If we have a target if (CurrentTarget.target != null) { //We're interacting with an entity here if (CurrentTarget.intent == Intent.Interact) { //TODO: WRITE AN ENTITY INTERACTION EntityNeed need = this.Needs[CurrentTarget.need]; Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName); ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) }); } else if (CurrentTarget.intent == Intent.Attack) { CombatEngine.SwingWeapon(this, CurrentTarget.target); } } } //If we've not arrived at our target else if (WorldPosition != CurrentTarget.targetPoint || (CurrentTarget.target != null && AdjacencyHelper.IsAdjacent(WorldPosition, CurrentTarget.target.WorldPosition) == false)) { //Move to target MoveToTarget(CurrentTarget); } } } else { if (!HasMoved && m_PathfindingData.Count > 0) { Vector2Int nextPoint = m_PathfindingData.Peek(); PhysicsResult physicsResult = PhysicsManager.IsCollision(WorldPosition, nextPoint, MyWorld); if (physicsResult != PhysicsResult.EntityCollision) { m_PathfindingData.Dequeue(); Move(nextPoint); HasMoved = true; } else if (physicsResult == PhysicsResult.EntityCollision) { MyWorld.SwapPosition(this, MyWorld.GetEntity(nextPoint)); m_PathfindingData.Dequeue(); Move(nextPoint); HasMoved = true; } } } }
public void Pet_Timer() { if (Remove == true) { return; } if (PetOwner != null) { if (Alive) { #region Movement if (Target == null || Space.Calculations.GetDistance(this, PetOwner) > 15 || Space.Calculations.GetDistance(this, Target) > BaseMonster.ViewRange) { int OwnerDistance = Space.Calculations.GetDistance(this, PetOwner); if (OwnerDistance > 15) { if (Map.IsValidMonsterLocation(PetOwner.Location)) { Point newloc = NextLocation(PetOwner); X = (ushort)newloc.X; Y = (ushort)newloc.Y; SendToScreen(this.SpawnPacket); UpdateSurroundings(); LastMove = Common.Clock; } } else if (OwnerDistance >= 8 && OwnerDistance <= 15 && Common.Clock > LastMove + 900) { if (Remove != true) { Jump(PetOwner); } } else if (OwnerDistance < 8 && OwnerDistance >= 3) { if (Common.Clock - LastMove > BaseMonster.MoveSpeed) { if (Remove != true) { Walk(PetOwner); } } } } #endregion else { #region Targeting if (!CombatEngine.IsValidTarget(Target) || !Target.Alive) { //Target = null; return; } int TargetDistance = Space.Calculations.GetDistance(this, Target); if (TargetDistance <= BaseMonster.AttackRange) { if (Common.Clock - LastAttack > BaseMonster.AttackSpeed) { if (BaseMonster.Mesh == 920) { LastAttack = Common.Clock; /*var skill = Database.ServerDatabase.Context.MagicType.GetById(BaseMonster.SkillType); * dmg = CalculateSkillDamage(Target, skill, skill.Percent < 100); * var packet = SkillEffectPacket.Create(UID, Target.UID, BaseMonster.SkillType, 0); * packet.AddTarget(Target.UID, dmg); * * SendToScreen(packet);*/ var pack = InteractPacket.Create(UID, Target.UID, Target.X, Target.Y, InteractAction.MagicAttack, 0); pack.MagicType = BaseMonster.SkillType; pack.MagicLevel = 0; pack.Target = Target.UID; CombatEngine.ProcessInteractionPacket(pack); } else if (!Target.HasEffect(ClientEffect.Fly)) { LastAttack = Common.Clock; //dmg = CalculatePhysicalDamage(Target, null, true); //SendToScreen(InteractPacket.Create(UID, Target.UID, (ushort)Target.Location.X, (ushort)Target.Location.Y, InteractAction.Attack, dmg)); CombatEngine.ProcessInteractionPacket(InteractPacket.Create(UID, Target.UID, Target.X, Target.Y, InteractAction.Attack, 0)); } /*if (dmg > 0) * { * Target.ReceiveDamage(dmg, UID); * * var expGain = CalculateExperienceGain(Target, dmg); * ((Player)PetOwner).GainExperience(expGain); * }*/ } } else if (TargetDistance > BaseMonster.AttackRange && TargetDistance <= BaseMonster.ViewRange) { if (TargetDistance - BaseMonster.AttackRange <= 4) { Walk(Target); } else { Jump(Target); } } } #endregion } } else { Map.Remove(this, false); } }
internal MagicEffectsEngine(PhysicsEngine physicsEngine, CombatEngine combatEngine) { m_combatEngine = combatEngine; m_physicsEngine = physicsEngine; m_effectEngine = new EffectEngine(CoreGameEngineInterface.Instance); }
public void Attack(string attackName, Character attacker, Character target, CombatEngine engine) { Attack current = this.attacks.Find(delegate(Attack att) { return att.Name == attackName; }); current.ExecuteAttack(attacker, target, engine); }