Remove Speed attribute from UnitType (and so UnitStat).

(its only effect was to be shown in panel)
This commit is contained in:
jarod42 2004-10-12 14:38:00 +00:00
parent 68906dea78
commit 3c381dbb3d
11 changed files with 24 additions and 53 deletions

View file

@ -271,7 +271,7 @@ static void MoveToTarget(Unit* unit)
unit->Stats->AttackRange) {
// Reached another unit, now attacking it
unit->State = 0;
if (unit->Stats->Speed) {
if (!unit->Type->Building) {
UnitHeadingFromDeltaXY(unit,
goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);
@ -288,7 +288,7 @@ static void MoveToTarget(Unit* unit)
unit->Stats->AttackRange) {
// Reached wall or ground, now attacking it
unit->State = 0;
if (unit->Stats->Speed) {
if (!unit->Type->Building) {
UnitHeadingFromDeltaXY(unit, unit->Orders[0].X - unit->X,
unit->Orders[0].Y - unit->Y);
}
@ -485,7 +485,7 @@ static void AttackTarget(Unit* unit)
//
// Turn always to target
//
if (unit->Stats->Speed && goal) {
if (!unit->Type->Building && goal) {
UnitHeadingFromDeltaXY(unit,
goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);

View file

@ -231,7 +231,7 @@ void HandleActionFollow(Unit* unit)
// If don't set the goal, the unit can than choose a
// better goal if moving nearer to enemy.
//
if (unit->Type->CanAttack && unit->Stats->Speed &&
if (unit->Type->CanAttack &&
(!goal || goal->Orders[0].Action == UnitActionAttack ||
goal->Orders[0].Action == UnitActionStill)) {
goal = AttackUnitsInReactRange(unit);

View file

@ -89,7 +89,7 @@ void HandleActionPatrol(Unit* unit)
// If don't set the goal, the unit can than choose a
// better goal if moving nearer to enemy.
//
if (unit->Type->CanAttack && unit->Stats->Speed) {
if (unit->Type->CanAttack) {
goal = AttackUnitsInReactRange(unit);
if (goal) {
DebugPrint("Patrol attack %d\n" _C_ UnitNumber(goal));

View file

@ -187,7 +187,7 @@ void ActionStillGeneric(Unit* unit, int ground)
// Normal units react in reaction range.
// Removed units can only attack in AttackRange, from bunker
//
if (unit->Stats->Speed && !unit->Removed && !ground) {
if (!type->Building && !unit->Removed && !ground) {
if ((goal = AttackUnitsInReactRange(unit))) {
// Weak goal, can choose other unit, come back after attack
CommandAttack(unit, goal->X, goal->Y, NULL, FlushCommands);
@ -218,7 +218,7 @@ void ActionStillGeneric(Unit* unit, int ground)
unit->Reset = 0;
unit->State = 0;
unit->SubAction = 1; // Mark attacking.
if (type->Stats[unit->Player->Player].Speed) {
if (!type->Building) {
UnitHeadingFromDeltaXY(unit,
goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);

View file

@ -1392,8 +1392,8 @@ static void AiMoveUnitInTheWay(Unit* unit)
continue;
}
if (!blockertype->_Speed || blockertype->Building) {
// FIXME : check movement from animation
if (blockertype->Building) {
continue;
}

View file

@ -135,10 +135,6 @@ struct lua_State;
** Index into corpse animation script. Used if unit-types share
** the same corpse but have different animations.
**
** UnitType::_Speed
**
** Non upgraded movement speed.
** @note Until now we didn't support speed upgrades.
**
** @todo continue this documentation
**
@ -651,16 +647,15 @@ typedef struct _variable_type_ {
#define SUPPLY_INDEX 12
#define DEMAND_INDEX 13
#define ARMOR_INDEX 14
#define SPEED_INDEX 15
#define SIGHTRANGE_INDEX 16
#define ATTACKRANGE_INDEX 17
#define PIERCINGDAMAGE_INDEX 18
#define BASICDAMAGE_INDEX 19
#define DAMAGE_INDEX 20
#define EXTRADAMAGE_INDEX 21
#define POSX_INDEX 22
#define POSY_INDEX 23
#define SLOT_INDEX 24
#define SIGHTRANGE_INDEX 15
#define ATTACKRANGE_INDEX 16
#define PIERCINGDAMAGE_INDEX 17
#define BASICDAMAGE_INDEX 18
#define DAMAGE_INDEX 19
#define EXTRADAMAGE_INDEX 20
#define POSX_INDEX 21
#define POSY_INDEX 22
#define SLOT_INDEX 23
#define NVARALREADYDEFINED SLOT_INDEX + 1 // Hardcoded variables
@ -817,8 +812,6 @@ struct _unit_type_ {
UnitType* CorpseType; ///< Corpse unit-type
int CorpseScript; ///< Corpse script start
int _Speed; ///< Movement speed
// this is taken from the UDTA section
struct _construction_* Construction; ///< What is shown in construction phase
int _SightRange; ///< Sight range

View file

@ -128,7 +128,6 @@ typedef struct _unit_stats_ {
int Armor; ///< armor strength
int BasicDamage; ///< weapon basic damage
int PiercingDamage; ///< weapon piercing damage
int Speed; ///< movement speed
int HitPoints; ///< hit points
int RegenerationRate; ///< HP regeration rate in HP
int Costs[MaxCosts]; ///< current costs of the unit
@ -161,7 +160,6 @@ typedef struct _modifiers_ {
int BasicDamage; ///< basic damage modifier
int PiercingDamage; ///< piercing damage modifier
int Armor; ///< armor modifier
int Speed; ///< speed modifier (FIXME: not working)
int HitPoints; ///< hit points modifier
int RegenerationRate; ///< HP regeneration rate modifier

View file

@ -420,8 +420,6 @@ static int CclDefineUnitType(lua_State* l)
} else if (!strcmp(value, "Construction")) {
// FIXME: What if constructions aren't yet loaded?
type->Construction = ConstructionByIdent(LuaToString(l, -1));
} else if (!strcmp(value, "Speed")) {
type->_Speed = LuaToNumber(l, -1);
} else if (!strcmp(value, "DrawLevel")) {
type->DrawLevel = LuaToNumber(l, -1);
} else if (!strcmp(value, "MaxOnBoard")) {
@ -1049,8 +1047,6 @@ static int CclDefineUnitStats(lua_State* l)
if (!strcmp(value, "level")) {
stats->Level = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "speed")) {
stats->Speed = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "attack-range")) {
stats->AttackRange = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "sight-range")) {
@ -1788,10 +1784,6 @@ void UpdateUnitVariables(const Unit* unit)
unit->Variable[ARMOR_INDEX].Value = unit->Type->_Armor;
unit->Variable[ARMOR_INDEX].Max = unit->Stats->Armor;
// Speed
unit->Variable[SPEED_INDEX].Value = unit->Type->_Speed;
unit->Variable[SPEED_INDEX].Max = unit->Stats->Speed;
// SightRange
unit->Variable[SIGHTRANGE_INDEX].Value = unit->Type->_SightRange;
unit->Variable[SIGHTRANGE_INDEX].Max = unit->Stats->SightRange;
@ -1848,7 +1840,7 @@ void InitDefinedVariables()
{
const char* var[NVARALREADYDEFINED] = {"HitPoints", "Build", "Mana", "Transport",
"Research", "Training", "UpgradeTo", "GiveResource", "CarryResource",
"Xp", "Level", "Kill", "Supply", "Demand", "Armor", "Speed", "SightRange",
"Xp", "Level", "Kill", "Supply", "Demand", "Armor", "SightRange",
"AttackRange", "PiercingDamage", "BasicDamage", "Damage", "ExtraDamage",
"PosX", "PosY", "Slot"
}; // names of the variable.

View file

@ -3184,7 +3184,7 @@ void HitUnit(Unit* attacker, Unit* target, int damage)
// Attack units in range (which or the attacker?)
//
if (attacker && !type->Coward) {
if (type->CanAttack && target->Stats->Speed) {
if (type->CanAttack && !target->Type->Building) {
if (RevealAttacker && CanTarget(target->Type, attacker->Type)) {
// Reveal Unit that is attacking
goal = attacker;

View file

@ -172,7 +172,6 @@ void UpdateStats(int reset)
stats->Armor = type->_Armor;
stats->BasicDamage = type->_BasicDamage;
stats->PiercingDamage = type->_PiercingDamage;
stats->Speed = type->_Speed;
stats->HitPoints = type->_HitPoints;
for (i = 0; i < MaxCosts; ++i) {
stats->Costs[i] = type->_Costs[i];
@ -557,7 +556,6 @@ static void SaveUnitStats(const UnitStats* stats, const char* ident, int plynr,
Assert(plynr < PlayerMax);
CLprintf(file, "DefineUnitStats(\"%s\", %d,\n ", ident, plynr);
CLprintf(file, "\"level\", %d, ", stats->Level);
CLprintf(file, "\"speed\", %d, ", stats->Speed);
CLprintf(file, "\"attack-range\", %d, ", stats->AttackRange);
CLprintf(file, "\"sight-range\", %d,\n ", stats->SightRange);
CLprintf(file, "\"armor\", %d, ", stats->Armor);

View file

@ -59,7 +59,7 @@
struct _unit_type_;
static int AddUpgradeModifierBase(int, int, int, int, int, int, int, int, int,
static int AddUpgradeModifierBase(int, int, int, int, int, int, int, int,
int*, const int[UnitTypeMax], const char*, const char*, struct _unit_type_*);
static void AllowUnitId(Player* player, int id, int units);
@ -597,7 +597,6 @@ static int CclDefineModifier(lua_State* l)
int basic_damage;
int piercing_damage;
int armor;
int speed;
int regeneration_rate;
int hit_points;
int costs[MaxCosts];
@ -616,7 +615,6 @@ static int CclDefineModifier(lua_State* l)
basic_damage = 0;
piercing_damage = 0;
armor = 0;
speed = 0;
hit_points = 0;
regeneration_rate = 0;
memset(costs, 0, sizeof(costs));
@ -656,10 +654,6 @@ static int CclDefineModifier(lua_State* l)
lua_rawgeti(l, j + 1, 2);
armor = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(temp, "speed")) {
lua_rawgeti(l, j + 1, 2);
speed = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(temp, "hit-points")) {
lua_rawgeti(l, j + 1, 2);
hit_points = LuaToNumber(l, -1);
@ -726,7 +720,7 @@ static int CclDefineModifier(lua_State* l)
}
AddUpgradeModifierBase(uid, attack_range, sight_range, basic_damage,
piercing_damage, armor, speed, hit_points, regeneration_rate, costs,
piercing_damage, armor, hit_points, regeneration_rate, costs,
units, upgrades, apply_to,convert_to);
return 0;
@ -932,7 +926,6 @@ void UpgradesCclRegister(void)
** @param basic_damage Basic damage modification.
** @param piercing_damage Piercing damage modification.
** @param armor Armor modification.
** @param speed Speed modification (Currently not possible).
** @param hit_points Hitpoint modification.
** @param regeneration_rate Regenerations modification.
** @param costs Costs modification.
@ -945,7 +938,7 @@ void UpgradesCclRegister(void)
** (actually this id is useless, just error checking)
*/
static int AddUpgradeModifierBase(int uid, int attack_range, int sight_range,
int basic_damage, int piercing_damage, int armor, int speed,
int basic_damage, int piercing_damage, int armor,
int hit_points, int regeneration_rate, int* costs,
const int units[UnitTypeMax],
const char* af_upgrades, const char* apply_to, UnitType* convert_to)
@ -966,7 +959,6 @@ static int AddUpgradeModifierBase(int uid, int attack_range, int sight_range,
um->Modifier.BasicDamage = basic_damage;
um->Modifier.PiercingDamage = piercing_damage;
um->Modifier.Armor = armor;
um->Modifier.Speed = speed;
um->Modifier.HitPoints = hit_points;
um->Modifier.RegenerationRate = regeneration_rate;
@ -991,7 +983,7 @@ static int AddUpgradeModifierBase(int uid, int attack_range, int sight_range,
** useless, just error checking)
*/
static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
int basic_damage, int piercing_damage, int armor, int speed,
int basic_damage, int piercing_damage, int armor,
int hit_points, int* costs,
const int units[UnitTypeMax],
// following are comma separated list of required string id's
@ -1017,7 +1009,6 @@ static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
um->Modifier.BasicDamage = basic_damage;
um->Modifier.PiercingDamage = piercing_damage;
um->Modifier.Armor = armor;
um->Modifier.Speed = speed;
um->Modifier.HitPoints = hit_points;
for (i = 0; i < MaxCosts; ++i) {
@ -1258,7 +1249,6 @@ static void ApplyUpgradeModifier(Player* player, const UpgradeModifier* um)
UnitTypes[z]->Stats[pn].BasicDamage += um->Modifier.BasicDamage;
UnitTypes[z]->Stats[pn].PiercingDamage += um->Modifier.PiercingDamage;
UnitTypes[z]->Stats[pn].Armor += um->Modifier.Armor;
UnitTypes[z]->Stats[pn].Speed += um->Modifier.Speed;
UnitTypes[z]->Stats[pn].HitPoints += um->Modifier.HitPoints;
UnitTypes[z]->Stats[pn].RegenerationRate += um->Modifier.RegenerationRate;