____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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 <time.h>
#include "stratagus.h"
#include "version.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "missile.h"
#include "interface.h"
#include "map.h"
#include "sound.h"
#include "spells.h"
Go to the source code of this file.
Functions | |
| static void | UnitRotate (CUnit *unit, int rotate) |
| int | UnitShowAnimation (CUnit *unit, const CAnimation *anim) |
| Handle the actions of all units each game cycle. | |
| int | UnitShowAnimationScaled (CUnit *unit, const CAnimation *anim, int scale) |
| < Handle the animation of a unit | |
| static void | HandleActionNone (CUnit *unit) |
| static void | HandleRegenerations (CUnit *unit) |
| static void | HandleBuffs (CUnit *unit, int amount) |
| static void | RunAction (unsigned char action, CUnit *unit) |
| static void | HandleUnitAction (CUnit *unit) |
| void | UnitActions (void) |
| Unload a unit. | |
Variables | |
| unsigned | SyncHash |
| Hash calculated to find sync failures. | |
| static void(* | HandleActionTable [])(CUnit *) |
Definition in file actions.cpp.
| static void HandleActionNone | ( | CUnit * | unit | ) | [static] |
Unit does nothing!
| unit | Unit pointer for none action. |
Definition at line 243 of file actions.cpp.
References _C_, DebugPrint, CUnitType::Ident, CUnit::Type, and UnitNumber.
| static void HandleBuffs | ( | CUnit * | unit, | |
| int | amount | |||
| ) | [static] |
Handle things about the unit that decay over time
| unit | The unit that the decay is handled for | |
| amount | The amount of time to make up for.(in cycles) |
Definition at line 307 of file actions.cpp.
References _C_, DebugPrint, CVariable::Enable, GameCycle, HP_INDEX, CVariable::Increase, LetUnitDie(), CVariable::Max, CUnitTypeVar::NumberVariable, CUnit::TTL, UnitTypeVar, CVariable::Value, and CUnit::Variable.
Referenced by UnitActions().
| static void HandleRegenerations | ( | CUnit * | unit | ) | [static] |
Increment a unit's health
| unit | the unit to operate on |
Definition at line 280 of file actions.cpp.
References CUnitType::BurnDamageRate, CUnit::Destroyed, HitUnit(), HP_INDEX, CVariable::Increase, CVariable::Max, NoUnitP, CUnit::Orders, CUnit::Removed, CUnit::Stats, CUnit::Type, UnitActionBuilt, UnitActionDie, CVariable::Value, CUnit::Variable, and CUnitStats::Variables.
Referenced by UnitActions().
| static void HandleUnitAction | ( | CUnit * | unit | ) | [static] |
Handle the action of a unit.
| unit | Pointer to handled unit. |
Definition at line 348 of file actions.cpp.
References CUnit::Anim, Assert, DebugPrint, IsOnlySelected, CUnit::OrderCount, CUnit::OrderFlush, CUnit::Orders, CUnit::Removed, RunAction(), SelectedUnitChanged(), CUnit::State, CUnit::SubAction, CUnit::_unit_anim_::Unbreakable, UnitActionStill, UnitRemoveConsumingResources(), and CUnit::Wait.
Referenced by UnitActions().
| static void RunAction | ( | unsigned char | action, | |
| CUnit * | unit | |||
| ) | [static] |
Definition at line 337 of file actions.cpp.
References HandleActionTable.
Referenced by HandleUnitAction().
| void UnitActions | ( | void | ) |
Unload a unit.
Update the actions of all units each game cycle.
Definition at line 412 of file actions.cpp.
References CUnit::Blink, CYCLES_PER_SECOND, CMapInfo::Description, GameCycle, HandleBuffs(), HandleRegenerations(), HandleUnitAction(), CUnitType::Ident, CPlayer::Index, CMap::Info, CUnit::IX, CUnit::IY, Map, NumUnits, CUnit::Orders, CUnit::Player, CUnit::Refs, sprintf_s(), CUnit::State, CUnit::SubAction, SyncHash, SyncRandSeed, ThisPlayer, CUnit::Type, UnitMax, UnitNumber, Units, VERSION, CUnit::X, and CUnit::Y.
Referenced by GameMainLoop().
| static void UnitRotate | ( | CUnit * | unit, | |
| int | rotate | |||
| ) | [static] |
Rotate a unit
| unit | Unit to rotate | |
| rotate | Number of frames to rotate (>0 clockwise, <0 counterclockwise) |
Definition at line 73 of file actions.cpp.
References CUnit::Direction, CUnitType::NumDirections, CUnit::Type, and UnitUpdateHeading().
Referenced by UnitShowAnimationScaled().
| int UnitShowAnimation | ( | CUnit * | unit, | |
| const CAnimation * | anim | |||
| ) |
Handle the actions of all units each game cycle.
Show unit animation.
| unit | Unit of the animation. | |
| anim | Animation script to handle. |
Definition at line 87 of file actions.cpp.
References UnitShowAnimationScaled().
Referenced by ActionStillGeneric(), AnimateActionAttack(), AnimateActionHarvest(), AnimateActionRepair(), HandleActionBoard(), HandleActionDie(), HandleActionSpellCast(), and HandleActionTrain().
| int UnitShowAnimationScaled | ( | CUnit * | unit, | |
| const CAnimation * | anim, | |||
| int | scale | |||
| ) |
< Handle the animation of a unit
Show unit animation.
| unit | Unit of the animation. | |
| anim | Animation script to handle. | |
| scale | Scaling factor of the wait times in animation (8 means no scaling). |
Definition at line 101 of file actions.cpp.
References CUnit::_unit_anim_::Anim, CUnit::Anim, AnimationAttack, AnimationExactFrame, AnimationFrame, AnimationGoto, AnimationLabel, AnimationMove, AnimationNone, AnimationRandomFrame, AnimationRandomGoto, AnimationRandomRotate, AnimationRandomSound, AnimationRandomWait, AnimationRotate, AnimationSound, AnimationUnbreakable, AnimationWait, Assert, CUnit::_unit_anim_::CurrAnim, CAnimation::D, FireMissile(), CAnimation::Frame, CUnit::Frame, CAnimation::Goto, CUnit::IsVisible(), CAnimation::Move, CAnimation::Next, CUnit::Orders, CUnit::Player, PlayUnitSound(), CAnimation::RandomFrame, CAnimation::RandomGoto, CAnimation::RandomSound, CAnimation::RandomWait, CUnit::ReCast, ReplayRevealMap, CAnimation::Rotate, CSound::Sound, CAnimation::Sound, SpellCast(), SyncRand(), ThisPlayer, CAnimation::Type, CAnimation::Unbreakable, CUnit::_unit_anim_::Unbreakable, UnitActionSpellCast, UnitRotate(), UnitUpdateHeading(), CAnimation::Wait, and CUnit::_unit_anim_::Wait.
Referenced by DoActionMove(), and UnitShowAnimation().
void(* HandleActionTable[])(CUnit *) [static] |
Initial value:
{
HandleActionNone,
HandleActionStill,
HandleActionStandGround,
HandleActionFollow,
HandleActionMove,
HandleActionAttack,
HandleActionAttack,
HandleActionDie,
HandleActionSpellCast,
HandleActionTrain,
HandleActionBuilt,
HandleActionBoard,
HandleActionUnload,
HandleActionPatrol,
HandleActionBuild,
HandleActionRepair,
HandleActionResource,
}
Referenced by RunAction().
| unsigned SyncHash |
Hash calculated to find sync failures.
Definition at line 57 of file actions.cpp.
Referenced by CclSavedGameInfo(), CreateGame(), InitModules(), LoadGame(), NetworkSendCommands(), SaveGame(), and UnitActions().
1.5.6