____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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 "SDL.h"
#include <vector>
#include "upgrade_structs.h"
#include "unitsound.h"
#include "icons.h"
Go to the source code of this file.
Classes | |
| class | MissileConfig |
| class | CVariable |
| class | CDecoVar |
| class | CDecoVarSpriteBar |
| Sprite contains frame from full (left)to empty state (right). More... | |
| class | CBuildRestriction |
| class | CBuildRestrictionAnd |
| class | CBuildRestrictionAddOn |
| class | CBuildRestrictionOnTop |
| class | CBuildRestrictionDistance |
| class | CUnitType |
| class | CUnitTypeVar |
Defines | |
| #define | MouseActionNone 0 |
| Nothing. | |
| #define | MouseActionAttack 1 |
| Attack. | |
| #define | MouseActionMove 2 |
| Move. | |
| #define | MouseActionHarvest 3 |
| Harvest resources. | |
| #define | MouseActionSpellCast 5 |
| Cast the first spell known. | |
| #define | MouseActionSail 6 |
| Sail. | |
| #define | CanTargetLand 1 |
| Can attack land units. | |
| #define | CanTargetSea 2 |
| Can attack sea units. | |
| #define | CanTargetAir 4 |
| Can attack air units. | |
Enumerations | |
| enum | { HP_INDEX, BUILD_INDEX, MANA_INDEX, TRANSPORT_INDEX, TRAINING_INDEX, GIVERESOURCE_INDEX, KILL_INDEX, ARMOR_INDEX, SIGHTRANGE_INDEX, ATTACKRANGE_INDEX, PIERCINGDAMAGE_INDEX, BASICDAMAGE_INDEX, POSX_INDEX, POSY_INDEX, RADAR_INDEX, RADARJAMMER_INDEX, AUTOREPAIRRANGE_INDEX, SLOT_INDEX, NVARALREADYDEFINED } |
| enum | UnitTypeType { UnitTypeLand, UnitTypeFly, UnitTypeNaval } |
| enum | DistanceTypeType { Equal, NotEqual, LessThan, LessThanEqual, GreaterThan, GreaterThanEqual } |
Functions | |
| CUnitType * | UnitTypeByIdent (const std::string &ident) |
| Get unit-type by ident. | |
| CUnitType * | CclGetUnitType (lua_State *l) |
| Access unit-type object. | |
| void | UnitTypeCclRegister (void) |
| Register ccl features. | |
| void | UpdateStats (int reset_to_default) |
| Update unit stats. | |
| int | GetVariableIndex (const char *VarName) |
| Get index of the variable. | |
| CUnitType * | NewUnitTypeSlot (const std::string &ident) |
| Draw the sprite frame of unit-type. | |
| void | DrawUnitType (const CUnitType *type, CPlayerColorGraphic *sprite, int player, int frame, int x, int y) |
| void | InitUnitTypes (int reset_player_stats) |
| Init unit-type table. | |
| void | LoadUnitTypeSprite (CUnitType *unittype) |
| Load the sprite for a unittype. | |
| void | LoadUnitTypes (void) |
| Load the unit-type data. | |
| void | CleanUnitTypes (void) |
| Cleanup unit-type module. | |
| void | DefineVariableField (lua_State *l, CVariable *var, int lua_index) |
| < Parse User Variables field. | |
| void | UpdateUnitVariables (const CUnit *unit) |
Variables | |
| std::vector< CUnitType * > | UnitTypes |
| All unit-types. | |
| CUnitTypeVar | UnitTypeVar |
| Variables for UnitType and unit. | |
Definition in file unittype.h.
| #define CanTargetAir 4 |
Can attack air units.
Definition at line 650 of file unittype.h.
Referenced by CanTarget(), and CclDefineUnitType().
| #define CanTargetLand 1 |
Can attack land units.
Definition at line 648 of file unittype.h.
Referenced by CanTarget(), and CclDefineUnitType().
| #define CanTargetSea 2 |
Can attack sea units.
Definition at line 649 of file unittype.h.
Referenced by CanTarget(), and CclDefineUnitType().
| #define MouseActionAttack 1 |
Attack.
Definition at line 641 of file unittype.h.
Referenced by CclDefineUnitType(), and DoRightButton().
| #define MouseActionHarvest 3 |
Harvest resources.
Definition at line 643 of file unittype.h.
Referenced by CclDefineUnitType(), and DoRightButton().
| #define MouseActionMove 2 |
Move.
Definition at line 642 of file unittype.h.
Referenced by CclDefineUnitType(), and DoRightButton().
| #define MouseActionNone 0 |
| #define MouseActionSail 6 |
Sail.
Definition at line 645 of file unittype.h.
Referenced by CclDefineUnitType(), and DoRightButton().
| #define MouseActionSpellCast 5 |
Cast the first spell known.
Definition at line 644 of file unittype.h.
Referenced by CclDefineUnitType(), and DoRightButton().
| anonymous enum |
Definition at line 421 of file unittype.h.
| enum DistanceTypeType |
Definition at line 494 of file unittype.h.
| enum UnitTypeType |
| UnitTypeLand | Unit lives on land. |
| UnitTypeFly | Unit lives in air. |
| UnitTypeNaval | Unit lives on water. |
Definition at line 488 of file unittype.h.
| CUnitType* CclGetUnitType | ( | lua_State * | l | ) |
Access unit-type object.
Access unit-type object
| l | Lua state. |
Definition at line 737 of file script_unittype.cpp.
References _lua_user_data_::Data, data, LuaError, LuaToString(), LuaUnitType, _lua_user_data_::Type, and UnitTypeByIdent().
Referenced by CclAiForce(), CclAiNeed(), CclAiSet(), CclAiWait(), CclCreateUnit(), CclIfNearUnit(), CclIfRescuedNearUnit(), and TriggerGetUnitType().
| void CleanUnitTypes | ( | void | ) |
Cleanup unit-type module.
Cleanup the unit-type module.
Definition at line 464 of file unittype.cpp.
References AnimationMap, AnimationsArray, CleanAnimation(), CUnitTypeVar::DecoVar, NumAnimations, CUnitTypeVar::NumberVariable, UnitTypeMap, UnitTypes, UnitTypeVar, CUnitTypeVar::Variable, and CUnitTypeVar::VariableName.
Referenced by CleanModules().
| void DefineVariableField | ( | lua_State * | l, | |
| CVariable * | var, | |||
| int | lua_index | |||
| ) |
< Parse User Variables field.
Update custom Variables with other variable (like Hp, ...)
Define the field of the UserDefined variables.
| l | Lua state. | |
| var | Variable to set. | |
| lua_index | Index of the table where are the infos |
Definition at line 1042 of file script_unittype.cpp.
References _C_, CVariable::Enable, CVariable::Increase, LuaError, LuaToBoolean(), LuaToNumber(), LuaToString(), CVariable::Max, and CVariable::Value.
Referenced by CclDefineUnitType(), CclDefineVariables(), and CclUnit().
| void DrawUnitType | ( | const CUnitType * | type, | |
| CPlayerColorGraphic * | sprite, | |||
| int | player, | |||
| int | frame, | |||
| int | x, | |||
| int | y | |||
| ) |
Draw unit-type on map.
| type | Unit-type pointer. | |
| sprite | Sprite to use for drawing | |
| player | Player number for color substitution. | |
| frame | Animation frame of unit-type. | |
| x | Screen X pixel postion to draw unit-type. | |
| y | Screen Y pixel postion to draw unit-type. |
Definition at line 297 of file unittype.cpp.
References CPlayerColorGraphic::DrawPlayerColorFrameClip(), CPlayerColorGraphic::DrawPlayerColorFrameClipX(), CUnitType::Flip, CUnitType::Height, CUnitType::NumDirections, CUnitType::OffsetX, CUnitType::OffsetY, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, and CUnitType::Width.
Referenced by CUnit::Draw(), DrawBuildingCursor(), and DrawStartLocations().
| int GetVariableIndex | ( | const char * | varname | ) |
Get index of the variable.
Return the index of the variable.
| varname | Name of the variable. |
Definition at line 1074 of file script_unittype.cpp.
References CUnitTypeVar::NumberVariable, and CUnitTypeVar::VariableName.
Referenced by CclDefineDecorations(), CclDefineUnitType(), CclDefineVariables(), CclGetUnitVariable(), CclSetUnitVariable(), CclSpellAction(), CclSpellCondition(), and CclUnit().
| void InitUnitTypes | ( | int | reset_player_stats | ) |
Init unit-type table.
Init unit types.
Definition at line 348 of file unittype.cpp.
References Assert, CUnitType::BuildingRules, GetStillFrame(), CUnitType::Ident, CUnitType::Slot, CUnitType::StillFrame, UnitTypeMap, UnitTypes, and UpdateStats().
Referenced by CreateGame(), CEditor::Init(), InitModules(), and LoadGame().
| void LoadUnitTypes | ( | void | ) |
Load the unit-type data.
Load the graphics for the unit-types.
Definition at line 402 of file unittype.cpp.
References CUnitType::CorpseName, CUnitType::CorpseType, CUnitType::Explosion, CUnitType::Icon, IconConfig::Load(), LoadUnitTypeSprite(), MissileConfig::Missile, CUnitType::Missile, MissileTypeByIdent(), CUnitType::Name, MissileConfig::Name, ShowLoadProgress(), CUnitType::Sprite, UnitTypeByIdent(), and UnitTypes.
Referenced by CreateGame(), and LoadModules().
| void LoadUnitTypeSprite | ( | CUnitType * | type | ) |
Load the sprite for a unittype.
Loads the Sprite for a unit type
| type | type of unit to load |
Definition at line 378 of file unittype.cpp.
References CUnitType::File, CGraphic::Flip(), CUnitType::Flip, CGraphic::ForceNew(), CUnitType::Height, CGraphic::Load(), CGraphic::MakeShadow(), CPlayerColorGraphic::New(), CUnitType::ShadowFile, CUnitType::ShadowHeight, CUnitType::ShadowSprite, CUnitType::ShadowWidth, CUnitType::Sprite, and CUnitType::Width.
Referenced by LoadUnitTypes().
| CUnitType* NewUnitTypeSlot | ( | const std::string & | ident | ) |
Draw the sprite frame of unit-type.
Allocate an empty unit-type slot
Allocate an empty unit-type slot.
| ident | Identifier to identify the slot (malloced by caller!). |
Definition at line 264 of file unittype.cpp.
References ExitFatal(), CUnitType::Ident, CUnitTypeVar::NumberVariable, CUnitType::Slot, UnitTypeMap, UnitTypes, UnitTypeVar, CUnitTypeVar::Variable, and CUnitType::Variable.
Referenced by CclDefineUnitType().
| CUnitType * UnitTypeByIdent | ( | const std::string & | ident | ) |
Get unit-type by ident.
Find unit-type by identifier.
| ident | The unit-type identifier. |
Definition at line 252 of file unittype.cpp.
References UnitTypeMap.
Referenced by CalculateMaxIconSize(), CclDefineAiHelper(), CclDefineAiPlayer(), CclDefineUnitType(), CclGetUnitType(), CclParseOrder(), CclSpellAction(), CclUnit(), DoNextReplay(), getUnitTypeFromString(), CPlayer::HaveUnitTypeByIdent(), CBuildRestrictionDistance::Init(), CBuildRestrictionOnTop::Init(), CBuildRestrictionAddOn::Init(), CEditor::Init(), InitAiHelper(), LoadUnitTypes(), RecalculateShownUnits(), tolua_stratagus_UnitTypeByIdent00(), and UnitTypeIdByIdent().
| void UnitTypeCclRegister | ( | void | ) |
Register ccl features.
Register CCL features for unit-type.
Definition at line 1371 of file script_unittype.cpp.
References CclDefineAnimations(), CclDefineDecorations(), CclDefineUnitType(), CclDefineVariables(), InitDefinedVariables(), and Lua.
Referenced by InitCcl().
| void UpdateStats | ( | int | reset | ) |
Update unit stats.
Update the player stats for changed unit types.
| reset | indicates wether default value should be set to each stat (level, upgrades) |
Definition at line 133 of file unittype.cpp.
References CUnitType::Building, CUnitType::CanTransport, DebugPrint, CUnitType::FieldFlags, HP_INDEX, MapFieldAirUnit, MapFieldBuilding, MapFieldCoastAllowed, MapFieldLandAllowed, MapFieldLandUnit, MapFieldNoBuilding, MapFieldSeaUnit, MapFieldUnpassable, MapFieldWaterAllowed, CVariable::Max, CUnitType::MovementMask, CUnitTypeVar::NumberVariable, PlayerMax, CUnitType::ShoreBuilding, CUnitType::Stats, CUnitType::UnitType, UnitTypeFly, UnitTypeLand, UnitTypeNaval, UnitTypes, UnitTypeVar, CUnitType::Variable, and CUnitStats::Variables.
Referenced by InitUnitTypes().
| void UpdateUnitVariables | ( | const CUnit * | unit | ) |
Update unit variables which are not user defined.
Definition at line 1250 of file script_unittype.cpp.
Referenced by DrawDecoration(), and DrawUnitInfo().
All unit-types.
Definition at line 62 of file unittype.cpp.
Referenced by AiAssignHarvester(), AiFindAvailableUnitTypeEquiv(), AiMakeUnit(), AiReduceMadeInBuilt(), AiRemoveFromBuilt(), CclAiForce(), CclDefineSpell(), CleanUnitTypes(), CButtonPanel::DoClicked(), DrawPopup(), getReparableUnits(), getUnitTypeFromString(), InitUnitTypes(), LoadUnitTypes(), MapUnitSounds(), NewUnitTypeSlot(), ParseCommand(), SaveUpgrades(), UpdateStats(), and UpdateStatusLineForButton().
Variables for UnitType and unit.
Definition at line 72 of file script_unittype.cpp.
Referenced by CUnit::AssignToPlayer(), AdjustVariable::Cast(), CclSpellAction(), CclSpellCondition(), CleanUnitTypes(), DrawDecoration(), HandleBuffs(), CUnit::Init(), NewUnitTypeSlot(), PassCondition(), SaveUnit(), and UpdateStats().
1.5.6