From 5fa58b0d8174a60c30c516fc586c26235612ee53 Mon Sep 17 00:00:00 2001 From: johns <> Date: Sat, 28 Apr 2001 20:24:57 +0000 Subject: [PATCH] Fixed bug: Casting invisibilty/unholy armor on volatile units, they should explode. --- doc/ChangeLog.html | 2 ++ src/include/unittype.h | 2 +- src/stratagus/spells.cpp | 32 ++++++++++++++++++++++++++------ src/ui/botpanel.cpp | 4 ++-- src/ui/mouse.cpp | 2 +- src/unit/script_unittype.cpp | 4 ++-- src/unit/unittype.cpp | 6 +++--- tools/udta.c | 10 +++++----- 8 files changed, 42 insertions(+), 20 deletions(-) diff --git a/doc/ChangeLog.html b/doc/ChangeLog.html index ee1f6bf18..e8ee32b38 100644 --- a/doc/ChangeLog.html +++ b/doc/ChangeLog.html @@ -625,6 +625,8 @@ <LI>Automatic groups added. <LI>Fixed bug: Units in training queues aren't upgraded. (Paladin,Ranger...) <LI>Fixed bug: Polymorph over water, places a critter on water :). + <LI>Fixed bug: Casting invisibilty/unholy armor on volatile units, they + should explode. <LI>+++ </UL> </UL> diff --git a/src/include/unittype.h b/src/include/unittype.h index e712a0c6d..950b78baf 100644 --- a/src/include/unittype.h +++ b/src/include/unittype.h @@ -173,7 +173,7 @@ struct _unit_type_ { unsigned GoldMine : 1; /// unsigned Hero : 1; /// unsigned StoresOil : 1; /// - unsigned Explodes : 1; /// invisiblity/unholy armor kills unit + unsigned Volatile : 1; /// invisiblity/unholy armor kills unit unsigned CowerMage : 1; /// unsigned Organic : 1; /// organic diff --git a/src/stratagus/spells.cpp b/src/stratagus/spells.cpp index 138c8c5a6..b5742d5b7 100644 --- a/src/stratagus/spells.cpp +++ b/src/stratagus/spells.cpp @@ -701,13 +701,23 @@ global int SpellCast(const SpellType * spell, Unit * unit, Unit * target, && target->Invisible < spell->TTL/FRAMES_PER_SECOND) { // get mana cost unit->Mana -= spell->ManaCost; - target->Invisible = spell->TTL/FRAMES_PER_SECOND; // about 50 sec - CheckUnitToBeDrawn(target); + if( target->Type->Volatile ) { + RemoveUnit(target); + UnitLost(target); + ReleaseUnit(target); + MakeMissile(MissileTypeExplosion, + x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2, + x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2 ); + } else { + // about 50 sec + target->Invisible = spell->TTL/FRAMES_PER_SECOND; + CheckUnitToBeDrawn(target); + } PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); MakeMissile(MissileTypeSpell, - x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2, - x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2 ); + x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2, + x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2 ); } break; @@ -972,8 +982,18 @@ global int SpellCast(const SpellType * spell, Unit * unit, Unit * target, && target->UnholyArmor < spell->TTL/FRAMES_PER_SECOND) { // get mana cost unit->Mana -= spell->ManaCost; - target->UnholyArmor = spell->TTL/FRAMES_PER_SECOND; // about 13 sec - CheckUnitToBeDrawn(target); + if( target->Type->Volatile ) { + RemoveUnit(target); + UnitLost(target); + ReleaseUnit(target); + MakeMissile(MissileTypeExplosion, + x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2, + x*TileSizeX+TileSizeX/2, y*TileSizeY+TileSizeY/2 ); + } else { + // about 13 sec + target->UnholyArmor = spell->TTL/FRAMES_PER_SECOND; + CheckUnitToBeDrawn(target); + } PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); MakeMissile(MissileTypeSpell, diff --git a/src/ui/botpanel.cpp b/src/ui/botpanel.cpp index 5528fb0d8..c06b7813a 100644 --- a/src/ui/botpanel.cpp +++ b/src/ui/botpanel.cpp @@ -588,7 +588,7 @@ local void UpdateButtonPanelMultipleUnits(void) } } else if ( UnitButtonTable[z]->Action == ButtonDemolish ) { for( i=NumSelected; --i; ) { - if( Selected[i]->Type->Explodes ) { + if( Selected[i]->Type->Volatile ) { allow = 1; break; } @@ -719,7 +719,7 @@ global void UpdateButtonPanel(void) } break; case ButtonDemolish: - if( Selected[0]->Type->Explodes ) { + if( Selected[0]->Type->Volatile ) { allow = 1; } break; diff --git a/src/ui/mouse.cpp b/src/ui/mouse.cpp index 0d1170889..ce48ea2bc 100644 --- a/src/ui/mouse.cpp +++ b/src/ui/mouse.cpp @@ -766,7 +766,7 @@ local void SendDemolish(int x,int y) for( i=0; i<NumSelected; ++i ) { unit=Selected[i]; - if( unit->Type->Explodes ) { + if( unit->Type->Volatile ) { // FIXME: choose correct unit no flying ... dest=TargetOnMapTile(unit,x,y); if( dest==unit ) { // don't let an unit self destruct diff --git a/src/unit/script_unittype.cpp b/src/unit/script_unittype.cpp index 24bf80ee3..564680009 100644 --- a/src/unit/script_unittype.cpp +++ b/src/unit/script_unittype.cpp @@ -441,7 +441,7 @@ local SCM CclDefineUnitType(SCM list) type->GoldMine=0; type->Hero=0; type->StoresOil=0; - type->Explodes=0; + type->Volatile=0; type->CowerMage=0; type->Organic=0; type->SelectableByRectangle=0; @@ -534,7 +534,7 @@ local SCM CclDefineUnitType(SCM list) } else if( gh_eq_p(value,gh_symbol2scm("stores-oil")) ) { type->StoresOil=1; } else if( gh_eq_p(value,gh_symbol2scm("volatile")) ) { - type->Explodes=1; + type->Volatile=1; } else if( gh_eq_p(value,gh_symbol2scm("cower-mage")) ) { type->CowerMage=1; } else if( gh_eq_p(value,gh_symbol2scm("organic")) ) { diff --git a/src/unit/unittype.cpp b/src/unit/unittype.cpp index 8d700a23c..902ba0731 100644 --- a/src/unit/unittype.cpp +++ b/src/unit/unittype.cpp @@ -483,7 +483,7 @@ global void PrintUnitTypeTable(void) printf("\t,%5d,%5d,%10d,%6d,%8d,%6d\n" ,type->Hero ,type->StoresOil - ,type->Explodes + ,type->Volatile ,type->CowerMage ,type->Organic ,type->SelectableByRectangle); @@ -764,7 +764,7 @@ global void ParsePudUDTA(const char* udta,int length) unittype->GoldMine=BIT(22,v); unittype->Hero=BIT(23,v); unittype->StoresOil=BIT(24,v); - unittype->Explodes=BIT(25,v); + unittype->Volatile=BIT(25,v); unittype->CowerMage=BIT(26,v); unittype->Organic=BIT(27,v); @@ -1129,7 +1129,7 @@ local void SaveUnitType(const UnitType* type,FILE* file) if( type->StoresOil ) { fprintf(file," 'stores-oil\n"); } - if( type->Explodes ) { + if( type->Volatile ) { fprintf(file," 'volatile\n"); } if( type->CowerMage ) { diff --git a/tools/udta.c b/tools/udta.c index ba7014676..9dec445b5 100644 --- a/tools/udta.c +++ b/tools/udta.c @@ -286,7 +286,7 @@ typedef struct _unit_type_ { unsigned GoldMine : 1; unsigned Hero : 1; unsigned StoresOil : 1; - unsigned Explodes : 1; // invisiblity/unholy armor killes this unit + unsigned Volatile : 1; // invisiblity/unholy armor killes this unit unsigned CowerMage : 1; unsigned Organic : 1; @@ -1569,7 +1569,7 @@ void DumpUdtaAsScm(void) if( UnitTypes[i].StoresOil ) { printf(" 'stores-oil\n"); } - if( UnitTypes[i].Explodes ) { + if( UnitTypes[i].Volatile ) { printf(" 'volatile\n"); } if( UnitTypes[i].CowerMage ) { @@ -1739,7 +1739,7 @@ int main(int argc,char** argv) UnitTypes[i].GoldMine=BIT(22,v); UnitTypes[i].Hero=BIT(23,v); UnitTypes[i].StoresOil=BIT(24,v); - UnitTypes[i].Explodes=BIT(25,v); + UnitTypes[i].Volatile=BIT(25,v); UnitTypes[i].CowerMage=BIT(26,v); UnitTypes[i].Organic=BIT(27,v); if( BIT(28,v) ) printf("Unused bit 28 used in %d\n",i); @@ -1806,7 +1806,7 @@ if( 0 ) printf("\tMine\t%d\n",UnitTypes[i].GoldMine); printf("\tHero\t%d\n",UnitTypes[i].Hero); printf("\tStoresOil\t%d\n",UnitTypes[i].StoresOil); - printf("\tExplodes\t%d\n",UnitTypes[i].Explodes); + printf("\tVolatile\t%d\n",UnitTypes[i].Volatile); printf("\tCowerMage\t%d\n",UnitTypes[i].CowerMage); printf("\tOrganic\t%d\n",UnitTypes[i].Organic); } @@ -1928,7 +1928,7 @@ if( 0 ) printf(",%d,%d,%d,%d,%d,%d" ,UnitTypes[i].Hero ,UnitTypes[i].StoresOil - ,UnitTypes[i].Explodes + ,UnitTypes[i].Volatile ,UnitTypes[i].CowerMage ,UnitTypes[i].Organic ,UnitTypes[i].SelectableByRectangle);