add "opponent" flag in condition spell (bug 940362)

This commit is contained in:
jarod42 2004-05-21 15:05:40 +00:00
parent e90e0b4155
commit 2501689a4c
3 changed files with 21 additions and 2 deletions

View file

@ -192,12 +192,15 @@ typedef struct ConditionInfo {
#define CONDITION_TRUE 0
#define CONDITION_ONLY 2
char Coward; ///< Target is coward. Don't bloodlust them.
char Alliance; ///< Target is allied.
char Alliance; ///< Target is allied. (neutral is neither allied, nor opponent)
char Opponent; ///< Target is opponent. (neutral is neither allied, nor opponent)
char Building; ///< Target is a building.
char TargetSelf; ///< Target is the same as the caster.
char *BoolFlag; ///< User defined boolean flag.
#if 0
// TODO: NOT IMPLEMENTED:
char UnitBuffed; ///< Target is buffed(haste/slow/bloodlust). Dispel magic?
#endif
//
// Conditions related to vitals:
//

View file

@ -486,6 +486,10 @@ local void CclSpellCondition(lua_State* l, ConditionInfo* condition)
lua_rawgeti(l, -1, j + 1);
condition->Alliance = Ccl2Condition(l, LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "opponent")) {
lua_rawgeti(l, -1, j + 1);
condition->Opponent = Ccl2Condition(l, LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "building")) {
lua_rawgeti(l, -1, j + 1);
condition->Building = Ccl2Condition(l, LuaToString(l, -1));
@ -746,6 +750,8 @@ global void SpellCclRegister(void)
lua_register(Lua, "DefineSpell", CclDefineSpell);
}
#if 0 // Use old ccl config.
/**
** Save a spell action to a file.
**
@ -939,4 +945,6 @@ void SaveSpellAutoCast(CLFile* file, AutoCastInfo* autocast)
CLprintf(file, " )\n");
}
#endif
//@}

View file

@ -775,10 +775,18 @@ local int PassCondition(const Unit* caster, const SpellType* spell, const Unit*
}
if (condition->Alliance != CONDITION_TRUE) {
if ((condition->Alliance == CONDITION_ONLY) ^
(IsAllied(caster->Player,target) || target->Player == caster->Player)) {
// own units could be not allied ?
(IsAllied(caster->Player, target) || target->Player == caster->Player)) {
return 0;
}
}
if (condition->Opponent != CONDITION_TRUE) {
if ((condition->Opponent == CONDITION_ONLY) ^
IsEnemy(caster->Player, target)) {
return 0;
}
}
if (condition->TargetSelf != CONDITION_TRUE) {
if ((condition->TargetSelf == CONDITION_ONLY) ^ (caster == target)) {
return 0;