$treeview $search $mathjax
Stratagus
2.2.6
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include "unit_cache.h"
#include "vec2i.h"
Go to the source code of this file.
actions.h - The actions headerfile. | |
enum | _diplomacy_ { DiplomacyAllied, DiplomacyNeutral, DiplomacyEnemy, DiplomacyCrazy } |
unsigned | SyncHash |
void | CommandQuit (int player) |
Hash calculated to find sync failures. | |
void | CommandStopUnit (CUnit &unit) |
Prepare command stop. | |
void | CommandStandGround (CUnit &unit, int flush) |
Prepare command stand ground. | |
void | CommandFollow (CUnit &unit, CUnit &dest, int flush) |
Prepare command follow. | |
void | CommandMove (CUnit &unit, const Vec2i &pos, int flush) |
Prepare command move. | |
void | CommandRepair (CUnit &unit, const Vec2i &pos, CUnit *dest, int flush) |
Prepare command repair. | |
void | CommandAutoRepair (CUnit &unit, int on) |
Send auto repair command. | |
void | CommandAttack (CUnit &unit, const Vec2i &pos, CUnit *dest, int flush) |
Prepare command attack. | |
void | CommandAttackGround (CUnit &unit, const Vec2i &pos, int flush) |
Prepare command attack ground. | |
void | CommandPatrolUnit (CUnit &unit, const Vec2i &pos, int flush) |
Prepare command patrol. | |
void | CommandBoard (CUnit &unit, CUnit &dest, int flush) |
Prepare command board. | |
void | CommandUnload (CUnit &unit, const Vec2i &pos, CUnit *what, int flush) |
Prepare command unload. | |
void | CommandBuildBuilding (CUnit &unit, const Vec2i &pos, CUnitType &, int flush) |
Prepare command build. | |
void | CommandDismiss (CUnit &unit) |
Prepare command dismiss. | |
void | CommandResourceLoc (CUnit &unit, const Vec2i &pos, int flush) |
Prepare command resource location. | |
void | CommandResource (CUnit &unit, CUnit &dest, int flush) |
Prepare command resource. | |
void | CommandReturnGoods (CUnit &unit, CUnit *goal, int flush) |
Prepare command return. | |
void | CommandTrainUnit (CUnit &unit, CUnitType &what, int flush) |
Prepare command train. | |
void | CommandCancelTraining (CUnit &unit, int slot, const CUnitType *type) |
Prepare command cancel training. | |
void | CommandUpgradeTo (CUnit &unit, CUnitType &what, int flush) |
Prepare command upgrade to. | |
void | CommandTransformIntoType (CUnit &unit, CUnitType &type) |
immediate transforming into type. | |
void | CommandCancelUpgradeTo (CUnit &unit) |
Prepare command cancel upgrade to. | |
void | CommandResearch (CUnit &unit, CUpgrade *what, int flush) |
Prepare command research. | |
void | CommandCancelResearch (CUnit &unit) |
Prepare command cancel research. | |
void | CommandSpellCast (CUnit &unit, const Vec2i &pos, CUnit *dest, SpellType *spell, int flush) |
Prepare command spellcast. | |
void | CommandAutoSpellCast (CUnit &unit, int spellid, int on) |
Prepare command auto spellcast. | |
void | CommandDiplomacy (int player, int state, int opponent) |
Prepare diplomacy command. | |
void | CommandSetResource (int player, int resource, int value) |
Prepare set resources command. | |
void | CommandSharedVision (int player, bool state, int opponent) |
Prepare shared vision command. | |
void | CommandMoveOrder (CUnit &unit, int src, int dst) |
Send any command. | |
void | DropResource (CUnit &unit) |
void | ResourceGiveUp (CUnit &unit) |
int | GetNumWaitingWorkers (const CUnit &mine) |
void | AutoAttack (CUnit &unit, CUnitCache &targets, bool stand_ground) |
void | UnHideUnit (CUnit &unit) |
void | ActionStillGeneric (CUnit &unit, bool stand_ground) |
Generic still action. | |
void | HandleActionStill (CUnit &unit) |
Handle command still. | |
void | HandleActionStandGround (CUnit &unit) |
Handle command stand ground. | |
void | HandleActionFollow (CUnit &unit) |
Handle command follow. | |
int | DoActionMove (CUnit &unit) |
Generic move action. | |
void | HandleActionMove (CUnit &unit) |
Handle command move. | |
void | HandleActionRepair (CUnit &unit) |
Handle command repair. | |
void | HandleActionPatrol (CUnit &unit) |
Handle command patrol. | |
void | AnimateActionAttack (CUnit &unit) |
Show attack animation. | |
void | HandleActionAttack (CUnit &unit) |
Handle command attack. | |
void | HandleActionBoard (CUnit &unit) |
Handle command board. | |
void | HandleActionUnload (CUnit &unit) |
Handle command unload. | |
void | HandleActionResource (CUnit &unit) |
Handle command resource. | |
void | HandleActionReturnGoods (CUnit &unit) |
Handle command return. | |
void | HandleActionDie (CUnit &unit) |
Handle command die. | |
void | HandleActionBuild (CUnit &unit) |
Handle command build. | |
void | HandleActionBuilt (CUnit &unit) |
Handle command built. | |
void | HandleActionTrain (CUnit &unit) |
Handle command train. | |
void | HandleActionUpgradeTo (CUnit &unit) |
Handle command upgrade to. | |
void | HandleActionTransformInto (CUnit &unit) |
Handle command transform into. | |
void | HandleActionUpgrade (CUnit &unit) |
Handle command upgrade. | |
void | HandleActionResearch (CUnit &unit) |
Handle command research. | |
void | HandleActionSpellCast (CUnit &unit) |
Handle command spellcast. | |
int | UnitShowAnimationScaled (CUnit &unit, const CAnimation *anim, int scale) |
Handle the animation of a unit. | |
int | UnitShowAnimation (CUnit &unit, const CAnimation *anim) |
Handle the animation of a unit. | |
void | UnitActions () |
Handle the actions of all units each game cycle. |
enum _diplomacy_ |
void ActionStillGeneric | ( | CUnit & | unit, | |
bool | stand_ground | |||
) |
Generic still action.
Unit stands still or stand ground.
unit | Unit pointer for action. | |
stand_ground | true if unit is standing ground. |
void AnimateActionAttack | ( | CUnit & | unit | ) |
Show attack animation.
Animate unit attack!
unit | Unit, for that the attack animation is played. |
void AutoAttack | ( | CUnit & | unit, | |
CUnitCache & | targets, | |||
bool | stand_ground | |||
) |
Prepare command attack.
Prepare command attack ground.
void CommandAutoRepair | ( | CUnit & | unit, | |
int | on | |||
) |
Send auto repair command.
Auto repair.
unit | pointer to unit. | |
on | 1 for auto repair on, 0 for off. |
void CommandAutoSpellCast | ( | CUnit & | unit, | |
int | spellid, | |||
int | on | |||
) |
Prepare command auto spellcast.
Auto spell cast.
unit | pointer to unit. | |
spellid | Spell id. | |
on | 1 for auto cast on, 0 for off. |
Prepare command board.
Board a transporter with unit.
unit | pointer to unit. | |
dest | unit to be boarded. | |
flush | if true, flush command queue. |
Prepare command build.
void CommandCancelResearch | ( | CUnit & | unit | ) |
Prepare command cancel research.
Cancel Building researching.
unit | Pointer to unit. |
Prepare command cancel training.
Cancel the training of an unit.
unit | pointer to unit. | |
slot | slot number to cancel. | |
type | Unit-type to cancel. |
void CommandCancelUpgradeTo | ( | CUnit & | unit | ) |
Prepare command cancel upgrade to.
Cancel building upgrading to.
unit | pointer to unit. |
void CommandDiplomacy | ( | int | player, | |
int | state, | |||
int | opponent | |||
) |
Prepare diplomacy command.
Diplomacy changed.
player | Player which changes his state. | |
state | New diplomacy state. | |
opponent | Opponent. |
void CommandDismiss | ( | CUnit & | unit | ) |
Prepare command dismiss.
Cancel the building construction, or kill a unit.
unit | pointer to unit. |
Prepare command follow.
Follow unit to new position
unit | pointer to unit. | |
dest | unit to be followed | |
flush | if true, flush command queue. |
void CommandMoveOrder | ( | CUnit & | unit, | |
int | src, | |||
int | dst | |||
) |
Send any command.
Move an order in command queue
Move an order in the order queue. ( Cannot move the order 0 ! )
unit | pointer to unit | |
src | the order to move | |
dst | the new position of the order |
void CommandQuit | ( | int | player | ) |
Hash calculated to find sync failures.
This function gives a unit a new command. If the command is given by the user the function with Send prefix should be used. Prepare command quit
Player quit.
player | Player number that quit. |
Prepare command repair.
Prepare command research.
Building starts researching.
unit | pointer to unit. | |
what | what to research. | |
flush | if true, flush command queue. |
Prepare command resource.
Send unit to harvest resources
unit | pointer to unit. | |
dest | destination unit. | |
flush | if true, flush command queue. |
Prepare command resource location.
Prepare command return.
Let unit returning goods.
unit | pointer to unit. | |
goal | bring goods to this depot. | |
flush | if true, flush command queue. |
void CommandSetResource | ( | int | player, | |
int | resource, | |||
int | value | |||
) |
Prepare set resources command.
Set new resources count for player.
player | Player which changes his state. | |
resource | Resource index | |
value | New value |
void CommandSharedVision | ( | int | player, | |
bool | state, | |||
int | opponent | |||
) |
Prepare shared vision command.
Shared vision changed.
player | Player which changes his state. | |
state | New shared vision state. | |
opponent | Opponent. |
void CommandSpellCast | ( | CUnit & | unit, | |
const Vec2i & | pos, | |||
CUnit * | dest, | |||
SpellType * | spell, | |||
int | flush | |||
) |
Prepare command spellcast.
void CommandStandGround | ( | CUnit & | unit, | |
int | flush | |||
) |
Prepare command stand ground.
Stand ground.
unit | pointer to unit. | |
flush | if true, flush command queue. |
void CommandStopUnit | ( | CUnit & | unit | ) |
Prepare command stop.
Stop unit.
unit | pointer to unit. |
Prepare command train.
Building starts training an unit.
unit | pointer to unit. | |
type | unit type to train. | |
flush | if true, flush command queue. |
immediate transforming into type.
Immediate transforming unit into type.
unit | pointer to unit. | |
type | upgrade to type |
Prepare command unload.
Prepare command upgrade to.
Building starts upgrading to.
unit | pointer to unit. | |
type | upgrade to type | |
flush | if true, flush command queue. |
int DoActionMove | ( | CUnit & | unit | ) |
Generic move action.
Unit moves! Generic function called from other actions.
unit | Pointer to unit. |
void DropResource | ( | CUnit & | unit | ) |
int GetNumWaitingWorkers | ( | const CUnit & | mine | ) |
void HandleActionAttack | ( | CUnit & | unit | ) |
Handle command attack.
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. |
void HandleActionBoard | ( | CUnit & | unit | ) |
Handle command board.
The unit boards a transporter.
unit | Pointer to unit. |
void HandleActionBuild | ( | CUnit & | unit | ) |
Handle command build.
Unit builds a building.
unit | Unit that builds a building |
void HandleActionBuilt | ( | CUnit & | unit | ) |
Handle command built.
Unit under Construction
unit | Unit that is being built |
void HandleActionDie | ( | CUnit & | unit | ) |
Handle command die.
Unit dies!
unit | The unit which dies. |
void HandleActionFollow | ( | CUnit & | unit | ) |
Handle command follow.
Unit follow action:
unit | Pointer to unit. |
???????
void HandleActionMove | ( | CUnit & | unit | ) |
Handle command move.
Unit move action:
Move to a place or to a unit (can move). Tries 10x to reach the target, note this are the complete tries. If the target entered another unit, move to it's position. If the target unit is destroyed, continue to move to it's last position.
unit | Pointer to unit. |
void HandleActionPatrol | ( | CUnit & | unit | ) |
Handle command patrol.
Unit Patrol: The unit patrols between two points. Any enemy unit in reaction range is attacked.
unit | Patroling unit pointer. |
void HandleActionRepair | ( | CUnit & | unit | ) |
Handle command repair.
Unit repairs
unit | Unit, for that the attack is handled. |
void HandleActionResearch | ( | CUnit & | unit | ) |
Handle command research.
Unit researches!
unit | Pointer of researching unit. |
void HandleActionResource | ( | CUnit & | unit | ) |
Handle command resource.
Control the unit action: getting a resource.
This the generic function for oil, gold, ...
unit | Pointer to unit. |
void HandleActionReturnGoods | ( | CUnit & | unit | ) |
Handle command return.
Return goods to gold/wood deposit.
unit | pointer to unit. |
void HandleActionSpellCast | ( | CUnit & | unit | ) |
Handle command spellcast.
Unit casts a spell!
unit | Unit, for that the spell cast is handled. |
void HandleActionStandGround | ( | CUnit & | unit | ) |
Handle command stand ground.
Unit stands ground!
unit | Action handled for this unit pointer. |
void HandleActionStill | ( | CUnit & | unit | ) |
Handle command still.
Unit stands still!
unit | Unit pointer for still action. |
void HandleActionTrain | ( | CUnit & | unit | ) |
Handle command train.
Unit trains unit!
unit | Unit that trains. |
void HandleActionTransformInto | ( | CUnit & | unit | ) |
Handle command transform into.
Unit transform into unit.
unit | Pointer to unit. |
void HandleActionUnload | ( | CUnit & | unit | ) |
Handle command unload.
The transporter unloads a unit.
unit | Pointer to unit. |
void HandleActionUpgrade | ( | CUnit & | unit | ) |
Handle command upgrade.
void HandleActionUpgradeTo | ( | CUnit & | unit | ) |
Handle command upgrade to.
Unit upgrades unit!
unit | Pointer to unit. |
void ResourceGiveUp | ( | CUnit & | unit | ) |
Give up on gathering.
unit | Pointer to unit. |
void UnHideUnit | ( | CUnit & | unit | ) |
void UnitActions | ( | ) |
Handle the actions of all units each game cycle.
Update the actions of all units each game cycle.
int UnitShowAnimation | ( | CUnit & | unit, | |
const CAnimation * | anim | |||
) |
Handle the animation of a unit.
Show unit animation.
unit | Unit of the animation. | |
anim | Animation script to handle. |
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). |
unsigned SyncHash |