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()); //} }