This commit is contained in:
cybermind 2015-03-10 23:55:35 +05:00
parent fb09101b86
commit 4382085b4f
4 changed files with 7 additions and 14 deletions

View file

@ -170,18 +170,8 @@ static bool MoveRandomly(CUnit &unit)
// pick random location
Vec2i pos = unit.tilePos;
switch ((SyncRand() >> 12) & 15) {
case 0: pos.x++; break;
case 1: pos.y++; break;
case 2: pos.x--; break;
case 3: pos.y--; break;
case 4: pos.x++; pos.y++; break;
case 5: pos.x--; pos.y++; break;
case 6: pos.y--; pos.x++; break;
case 7: pos.x--; pos.y--; break;
default:
break;
}
pos.x += SyncRand(unit.Type->RandomMovementDistance * 2 + 1) - unit.Type->RandomMovementDistance;
pos.y += SyncRand(unit.Type->RandomMovementDistance * 2 + 1) - unit.Type->RandomMovementDistance;
// restrict to map
Map.Clamp(pos);

View file

@ -513,6 +513,7 @@ public:
char *AutoCastActive; /// Default value for autocast.
int AutoBuildRate; /// The rate at which the building builds itself
int RandomMovementProbability; /// Probability to move randomly.
int RandomMovementDistance; /// Quantity of tiles to move randomly.
int ClicksToExplode; /// Number of consecutive clicks until unit suicides.
int MaxOnBoard; /// Number of Transporter slots.
int BoardSize; /// How much "cells" unit occupies inside transporter

View file

@ -758,7 +758,9 @@ static int CclDefineUnitType(lua_State *l)
} else if (!strcmp(value, "SeaUnit")) {
type->SeaUnit = LuaToBoolean(l, -1);
} else if (!strcmp(value, "RandomMovementProbability")) {
type->RandomMovementProbability = LuaToNumber(l, -1);
type->RandomMovementProbability = LuaToNumber(l, -1);
} else if (!strcmp(value, "RandomMovementDistance")) {
type->RandomMovementDistance = LuaToNumber(l, -1);
} else if (!strcmp(value, "ClicksToExplode")) {
type->ClicksToExplode = LuaToNumber(l, -1);
} else if (!strcmp(value, "Indestructible")) {

View file

@ -618,7 +618,7 @@ CUnitType::CUnitType() :
MinAttackRange(0), ReactRangeComputer(0), ReactRangePerson(0),
BurnPercent(0), BurnDamageRate(0), RepairRange(0),
CanCastSpell(NULL), AutoCastActive(NULL),
AutoBuildRate(0), RandomMovementProbability(0), ClicksToExplode(0),
AutoBuildRate(0), RandomMovementProbability(0), RandomMovementDistance(1), ClicksToExplode(0),
MaxOnBoard(0), BoardSize(1), ButtonLevelForTransporter(0), StartingResources(0),
UnitType(UnitTypeLand), DecayRate(0), AnnoyComputerFactor(0), AiAdjacentRange(-1),
MouseAction(0), CanTarget(0),