____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "missile.h"
#include "actions.h"
#include "sound.h"
#include "map.h"
#include "pathfinder.h"
Go to the source code of this file.
Defines | |
| #define | WEAK_TARGET 2 |
| Weak target, could be changed. | |
| #define | MOVE_TO_TARGET 4 |
| Move to target state. | |
| #define | ATTACK_TARGET 5 |
| Attack target state. | |
Functions | |
| void | AnimateActionAttack (CUnit *unit) |
| Handle command attack. | |
| static int | CheckForDeadGoal (CUnit *unit) |
| static int | CheckForTargetInRange (CUnit *unit) |
| static void | MoveToTarget (CUnit *unit) |
| static void | AttackTarget (CUnit *unit) |
| void | HandleActionAttack (CUnit *unit) |
| Handle command board. | |
Definition in file action_attack.cpp.
| #define ATTACK_TARGET 5 |
Attack target state.
Definition at line 61 of file action_attack.cpp.
Referenced by HandleActionAttack(), and MoveToTarget().
| #define MOVE_TO_TARGET 4 |
Move to target state.
Definition at line 60 of file action_attack.cpp.
Referenced by AttackTarget(), and HandleActionAttack().
| #define WEAK_TARGET 2 |
Weak target, could be changed.
Definition at line 59 of file action_attack.cpp.
Referenced by AttackTarget(), CheckForTargetInRange(), HandleActionAttack(), and MoveToTarget().
| void AnimateActionAttack | ( | CUnit * | unit | ) |
Handle command attack.
Animate unit attack!
| unit | Unit, for that the attack animation is played. |
Definition at line 74 of file action_attack.cpp.
References CUnitType::Animations, CAnimations::Attack, FireMissile(), CUnit::Type, and UnitShowAnimation().
Referenced by ActionStillGeneric(), and AttackTarget().
| static void AttackTarget | ( | CUnit * | unit | ) | [static] |
Handle attacking the target.
| unit | Unit, for that the attack is handled. |
Definition at line 312 of file action_attack.cpp.
References _C_, COrder::Action, CUnit::Anim, AnimateActionAttack(), Assert, ATTACKRANGE_INDEX, AttackUnitsInReactRange(), CheckForDeadGoal(), DebugPrint, CUnit::Frame, COrder::Goal, MapDistanceBetweenUnits(), CVariable::Max, CUnitType::MinAttackRange, COrder::MinRange, MOVE_TO_TARGET, NewResetPath, NoUnitP, CUnit::Orders, CUnitType::Priority, COrder::Range, CUnit::RefsDecrease(), CUnit::RefsIncrease(), CUnit::SavedOrder, CUnit::State, CUnit::Stats, CUnit::SubAction, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, CUnit::_unit_anim_::Unbreakable, UnitActionAttackGround, UnitActionStill, UnitHeadingFromDeltaXY(), UnitNumber, CUnitStats::Variables, WEAK_TARGET, CUnit::X, COrder::X, CUnit::Y, and COrder::Y.
Referenced by HandleActionAttack().
| static int CheckForDeadGoal | ( | CUnit * | unit | ) | [static] |
Check for dead goal.
| unit | Unit using the goal. |
Definition at line 98 of file action_attack.cpp.
References COrder::Action, CUnit::ClearAction(), COrder::Goal, CUnit::IsVisibleAsGoal(), NewResetPath, NoUnitP, CUnit::Orders, CUnit::Player, CUnit::RefsDecrease(), CUnit::SavedOrder, CUnit::State, UnitActionStill, CUnit::X, and CUnit::Y.
Referenced by AttackTarget(), and CheckForTargetInRange().
| static int CheckForTargetInRange | ( | CUnit * | unit | ) | [static] |
Change invalid target for new target in range.
| unit | Unit to check if goal is in range |
Definition at line 141 of file action_attack.cpp.
References COrder::Action, Assert, ATTACKRANGE_INDEX, AttackUnitsInReactRange(), CheckForDeadGoal(), CUnit::Destroyed, COrder::Goal, CVariable::Max, CUnitType::MinAttackRange, COrder::MinRange, NewResetPath, NoUnitP, CUnit::Orders, CUnitType::Priority, COrder::Range, CUnit::RefsDecrease(), CUnit::RefsIncrease(), CUnit::Removed, CUnit::SavedOrder, CUnit::Stats, CUnit::SubAction, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitActionAttack, UnitActionAttackGround, UnitActionStill, CUnitType::Vanishes, CUnitStats::Variables, WEAK_TARGET, CUnit::X, COrder::X, CUnit::Y, and COrder::Y.
Referenced by HandleActionAttack(), and MoveToTarget().
| void HandleActionAttack | ( | CUnit * | unit | ) |
Handle command board.
Unit attacks!
I added a little trick, if SubAction&WEAK_TARGET is true the goal is a weak goal. This means the unit AI (little AI) could choose a new better goal.
| unit | Unit, for that the attack is handled. |
Definition at line 464 of file action_attack.cpp.
References COrder::Action, Assert, ATTACK_TARGET, ATTACKRANGE_INDEX, AttackTarget(), CanMove(), CheckForTargetInRange(), DebugPrint, COrder::Goal, MapDistanceBetweenUnits(), CUnitType::MinAttackRange, MOVE_TO_TARGET, MoveToTarget(), NewResetPath, NoUnitP, CUnit::Orders, CUnit::SavedOrder, CUnit::State, CUnit::SubAction, CUnit::Type, UnitActionAttack, UnitActionAttackGround, UnitActionStill, UnitHeadingFromDeltaXY(), CUnit::Wait, WEAK_TARGET, CUnit::X, and CUnit::Y.
| static void MoveToTarget | ( | CUnit * | unit | ) | [static] |
Controls moving a unit to its target when attacking
| unit | Unit that is attacking and moving |
Definition at line 211 of file action_attack.cpp.
References COrder::Action, CUnit::Anim, Assert, ATTACK_TARGET, ATTACKRANGE_INDEX, CanMove(), CheckForTargetInRange(), CUnit::Destroyed, DoActionMove(), COrder::Goal, CMap::Info, Map, MapDistanceBetweenUnits(), MapDistanceToUnit(), CMapInfo::MapHeight, CMapInfo::MapWidth, CVariable::Max, NewResetPath, NoUnitP, CUnit::Orders, PF_REACHED, PF_UNREACHABLE, CUnit::Removed, CUnit::SavedOrder, CUnit::State, CUnit::Stats, CUnit::SubAction, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, CUnit::_unit_anim_::Unbreakable, UnitActionAttack, UnitActionAttackGround, UnitActionStill, UnitHeadingFromDeltaXY(), CUnitType::Vanishes, CUnitStats::Variables, CUnit::Wait, WEAK_TARGET, CUnit::X, and CUnit::Y.
Referenced by HandleActionAttack().
1.5.6