[+]New parameter in the "spawn-missile" spell, added "use-unit-var" which uses caster's damage parameters and ignores the "damage" field.

[+]New parameter in the "polymorph" spell, added "player-caster" parameter, which converts target unit to caster's side.

Patch from Cybermind
This commit is contained in:
joris 2012-02-18 13:43:16 +01:00
parent 590805e3bf
commit d2e61fda55
3 changed files with 18 additions and 5 deletions

View file

@ -148,14 +148,15 @@ public:
class SpawnMissile : public SpellActionType {
public:
SpawnMissile() : Damage(0), TTL(-1), Delay(0),
StartPoint(LocBaseCaster), EndPoint(LocBaseTarget), Missile(0) {};
SpawnMissile() : Damage(0), TTL(-1), Delay(0), UseUnitVar(false),
StartPoint(LocBaseCaster), EndPoint(LocBaseTarget), Missile(0) {}
virtual int Cast(CUnit &caster, const SpellType *spell,
CUnit *target, int x, int y);
int Damage; /// Missile damage.
int TTL; /// Missile TTL.
int Delay; /// Missile original delay.
bool UseUnitVar; /// Use the caster's damage parameters
SpellActionMissileLocation StartPoint; /// Start point description.
SpellActionMissileLocation EndPoint; /// Start point description.
MissileType *Missile; /// Missile fired on cast
@ -225,7 +226,7 @@ public:
CUnit *target, int x, int y);
CUnitType *NewForm; /// The new form
int PlayerNeutral; /// Convert the unit to the neutral player.
int PlayerNeutral; /// Convert the unit to the neutral player, or to the caster's player.
// TODO: temporary polymorphs would be awesome, but hard to implement
};

View file

@ -144,6 +144,9 @@ static SpellActionType *CclSpellAction(lua_State *l)
lua_rawgeti(l, -1, j + 1);
spellaction->Damage = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "use-unit-var")) {
spellaction->UseUnitVar = true;
--j;
} else if (!strcmp(value, "delay")) {
lua_rawgeti(l, -1, j + 1);
spellaction->Delay = LuaToNumber(l, -1);
@ -425,6 +428,9 @@ static SpellActionType *CclSpellAction(lua_State *l)
} else if (!strcmp(value, "player-neutral")) {
spellaction->PlayerNeutral = 1;
--j;
} else if (!strcmp(value, "player-caster")) {
spellaction->PlayerNeutral = 2;
--j;
} else {
LuaError(l, "Unsupported polymorph tag: %s" _C_ value);
}

View file

@ -349,7 +349,11 @@ int SpawnMissile::Cast(CUnit &caster, const SpellType *, CUnit *target, int x, i
missile->TTL = this->TTL;
missile->Delay = this->Delay;
missile->Damage = this->Damage;
if (missile->Damage != 0) {
if (this->UseUnitVar) {
missile->Damage = 0;
missile->SourceUnit = &caster;
caster.RefsIncrease();
} else if (missile->Damage != 0) {
missile->SourceUnit = &caster;
caster.RefsIncrease();
}
@ -553,8 +557,10 @@ int Polymorph::Cast(CUnit &caster, const SpellType *spell, CUnit *target, int x,
}
}
caster.Variable[MANA_INDEX].Value -= spell->ManaCost;
if (this->PlayerNeutral) {
if (this->PlayerNeutral == 1) {
MakeUnitAndPlace(pos, type, Players + PlayerNumNeutral);
} else if (this->PlayerNeutral == 2) {
MakeUnitAndPlace(pos, type, caster.Player);
} else {
MakeUnitAndPlace(pos, type, target->Player);
}