aboutsummaryrefslogtreecommitdiff
path: root/engines/griffon
diff options
context:
space:
mode:
authorStrangerke2019-10-28 08:17:06 +0100
committerEugene Sandulenko2019-11-13 22:07:08 +0100
commitddb4e2eb3e28b58afc61907649b510cb9efa2a45 (patch)
treee95f24f47e3c966b2ac380ef3a5102be551579aa /engines/griffon
parent47e27334693bb5aad09d8ad481c34773438f1004 (diff)
downloadscummvm-rg350-ddb4e2eb3e28b58afc61907649b510cb9efa2a45.tar.gz
scummvm-rg350-ddb4e2eb3e28b58afc61907649b510cb9efa2a45.tar.bz2
scummvm-rg350-ddb4e2eb3e28b58afc61907649b510cb9efa2a45.zip
GRIFFON: Start refactoring Combat + rename constant due to typo
Diffstat (limited to 'engines/griffon')
-rw-r--r--engines/griffon/combat.cpp386
-rw-r--r--engines/griffon/griffon.h2
-rw-r--r--engines/griffon/resources.cpp6
3 files changed, 196 insertions, 198 deletions
diff --git a/engines/griffon/combat.cpp b/engines/griffon/combat.cpp
index 66f6eb56f4..1e387d0881 100644
--- a/engines/griffon/combat.cpp
+++ b/engines/griffon/combat.cpp
@@ -61,37 +61,37 @@ void GriffonEngine::attack() {
o = 10;
int oscript = _objectInfo[o][5];
- if (oscript == kScriptFlask && _player.inventory[kInvFlask] < 9) {
- _player.inventory[kInvFlask]++;
- addFloatIcon(6, lx * 16, (ly - 1) * 16);
+ switch (oscript) {
+ case kScriptFlask:
+ if (_player.inventory[kInvFlask] < 9) {
+ _player.inventory[kInvFlask]++;
+ addFloatIcon(6, lx * 16, (ly - 1) * 16);
- _objmapf[_curmap][lx][ly - 1] = 1;
+ _objmapf[_curmap][lx][ly - 1] = 1;
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
- }
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
- eventText("Found Flask!");
- _itemticks = _ticks + 215;
- return;
- }
+ eventText("Found Flask!");
+ _itemticks = _ticks + 215;
+ return;
+ } else if (_player.inventory[kInvFlask] == 9) {
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndChest]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (oscript == kScriptFlask && _player.inventory[kInvFlask] == 9) {
- if (config.effects) {
- int snd = playSound(_sfx[kSndChest]);
- setChannelVolume(snd, config.effectsvol);
+ eventText("Cannot Carry any more Flasks!");
+ _itemticks = _ticks + 215;
+ return;
}
-
- eventText("Cannot Carry any more Flasks!");
- _itemticks = _ticks + 215;
- return;
- }
-
- if (oscript == kScriptMasterKey) {
+ break;
+ case kScriptMasterKey:
_player.inventory[kInvMasterKey]++;
addFloatIcon(14, lx * 16, (ly - 1) * 16);
@@ -100,9 +100,9 @@ void GriffonEngine::attack() {
if (_curmap == 34)
_scriptflag[kScriptMasterKey][0] = 2;
- if (_curmap == 62)
+ else if (_curmap == 62)
_scriptflag[kScriptGardenMasterKey][0] = 2;
- if (_curmap == 81)
+ else if (_curmap == 81)
_scriptflag[kScriptCitadelMasterKey][0] = 2;
if (config.effects) {
@@ -114,9 +114,7 @@ void GriffonEngine::attack() {
_objectMap[lx][ly - 1] = 3;
eventText("Found the Temple Key!");
return;
- }
-
- if (oscript == kScriptFindCtystal) {
+ case kScriptFindCrystal:
_player.foundSpell[0] = 1;
_player.spellCharge[0] = 0;
@@ -133,47 +131,47 @@ void GriffonEngine::attack() {
eventText("Found the Infinite Crystal!");
_itemticks = _ticks + 215;
return;
- }
+ case kScriptFindShield:
+ if (_player.shield == 1) {
+ _player.shield = 2;
- if (oscript == kScriptFindShield && _player.shield == 1) {
- _player.shield = 2;
+ addFloatIcon(4, lx * 16, (ly - 1) * 16);
- addFloatIcon(4, lx * 16, (ly - 1) * 16);
+ _itemticks = _ticks + 215;
- _itemticks = _ticks + 215;
-
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
- }
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
- eventText("Found the Obsidian Shield!");
- _objmapf[4][1][2] = 1;
- return;
- }
+ eventText("Found the Obsidian Shield!");
+ _objmapf[4][1][2] = 1;
+ return;
+ }
+ break;
+ case kScriptFindSword:
+ if (_player.sword == 1) {
+ _player.sword = 2;
- if (oscript == kScriptFindSword && _player.sword == 1) {
- _player.sword = 2;
+ addFloatIcon(3, lx * 16, (ly - 1) * 16);
- addFloatIcon(3, lx * 16, (ly - 1) * 16);
+ _itemticks = _ticks + 215;
- _itemticks = _ticks + 215;
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
+ eventText("Found the Fidelis Sword!");
+ return;
}
-
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
- eventText("Found the Fidelis Sword!");
- return;
- }
-
- if (oscript == kScriptKeyChest) {
+ break;
+ case kScriptKeyChest:
if (_player.inventory[kInvNormalKey] < 9) {
_player.inventory[kInvNormalKey]++;
@@ -203,117 +201,115 @@ void GriffonEngine::attack() {
eventText("Cannot Carry Any More Keys");
}
- }
-
- if (oscript == kScriptBlueFlask && _player.inventory[kInvDoubleFlask] < 9) {
- _player.inventory[kInvDoubleFlask]++;
- addFloatIcon(12, lx * 16, (ly - 1) * 16);
+ break;
+ case kScriptBlueFlask:
+ if (_player.inventory[kInvDoubleFlask] < 9) {
+ _player.inventory[kInvDoubleFlask]++;
+ addFloatIcon(12, lx * 16, (ly - 1) * 16);
- _objmapf[_curmap][lx][ly - 1] = 1;
+ _objmapf[_curmap][lx][ly - 1] = 1;
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
- }
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
- eventText("Found Mega Flask!");
- _itemticks = _ticks + 215;
- return;
- }
+ eventText("Found Mega Flask!");
+ _itemticks = _ticks + 215;
+ return;
+ } else if (_player.inventory[kInvDoubleFlask] == 9) {
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndChest]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (oscript == kScriptBlueFlask && _player.inventory[kInvDoubleFlask] == 9) {
- if (config.effects) {
- int snd = playSound(_sfx[kSndChest]);
- setChannelVolume(snd, config.effectsvol);
+ eventText("Cannot Carry any more Mega Flasks!");
+ _itemticks = _ticks + 215;
+ return;
}
- eventText("Cannot Carry any more Mega Flasks!");
- _itemticks = _ticks + 215;
- return;
- }
-
- if (oscript == kScriptBlueFlaskChest && _player.inventory[kInvDoubleFlask] < 9) {
- _player.inventory[kInvDoubleFlask]++;
- addFloatIcon(12, lx * 16, (ly - 1) * 16);
+ break;
+ case kScriptBlueFlaskChest:
+ if (_player.inventory[kInvDoubleFlask] < 9) {
+ _player.inventory[kInvDoubleFlask]++;
+ addFloatIcon(12, lx * 16, (ly - 1) * 16);
- _objmapf[_curmap][lx][ly - 1] = 1;
+ _objmapf[_curmap][lx][ly - 1] = 1;
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
- }
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
- eventText("Found Mega Flask!");
- _itemticks = _ticks + 215;
- return;
- }
+ eventText("Found Mega Flask!");
+ _itemticks = _ticks + 215;
+ return;
+ } else if (_player.inventory[kInvDoubleFlask] == 9) {
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndChest]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (oscript == kScriptBlueFlaskChest && _player.inventory[kInvDoubleFlask] == 9) {
- if (config.effects) {
- int snd = playSound(_sfx[kSndChest]);
- setChannelVolume(snd, config.effectsvol);
+ eventText("Cannot Carry any more Mega Flasks!");
+ _itemticks = _ticks + 215;
+ return;
}
+ break;
+ case kScriptLightningChest:
+ if (_player.inventory[kInvShock] < 9) {
+ _player.inventory[kInvShock]++;
+ addFloatIcon(17, lx * 16, (ly - 1) * 16);
- eventText("Cannot Carry any more Mega Flasks!");
- _itemticks = _ticks + 215;
- return;
- }
-
- if (oscript == kScriptLightningChest && _player.inventory[kInvShock] < 9) {
- _player.inventory[kInvShock]++;
- addFloatIcon(17, lx * 16, (ly - 1) * 16);
-
- _objmapf[_curmap][lx][ly - 1] = 1;
+ _objmapf[_curmap][lx][ly - 1] = 1;
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
- }
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
- eventText("Found Lightning Bomb!");
- _itemticks = _ticks + 215;
- return;
- }
+ eventText("Found Lightning Bomb!");
+ _itemticks = _ticks + 215;
+ return;
+ } else if (_player.inventory[kInvShock] == 9) {
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndChest]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (oscript == kScriptLightningChest && _player.inventory[kInvShock] == 9) {
- if (config.effects) {
- int snd = playSound(_sfx[kSndChest]);
- setChannelVolume(snd, config.effectsvol);
+ eventText("Cannot Carry any more Lightning Bombs!");
+ _itemticks = _ticks + 215;
+ return;
}
+ break;
+ case kScriptArmourChest:
+ if (_player.armour == 1) {
+ _player.armour = 2;
- eventText("Cannot Carry any more Lightning Bombs!");
- _itemticks = _ticks + 215;
- return;
- }
+ addFloatIcon(5, lx * 16, (ly - 1) * 16);
- if (oscript == kScriptArmourChest && _player.armour == 1) {
- _player.armour = 2;
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- addFloatIcon(5, lx * 16, (ly - 1) * 16);
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
+ eventText("Found the Fidelis Mail!");
+ _itemticks = _ticks + 215;
+ return;
}
-
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
-
- eventText("Found the Fidelis Mail!");
- _itemticks = _ticks + 215;
- return;
- }
-
- if (oscript == kScriptLever) {
+ break;
+ case kScriptLever:
if (_curmap == 58 && _scriptflag[kScriptLever][0] == 0) {
_scriptflag[kScriptLever][0] = 1;
@@ -346,62 +342,64 @@ void GriffonEngine::attack() {
eventText("It's stuck!");
}
+ break;
+ case kScriptGetSword3:
+ if (_player.sword < 3) {
+ _player.sword = 3;
- }
-
- if (oscript == kScriptGetSword3 && _player.sword < 3) {
- _player.sword = 3;
+ addFloatIcon(18, lx * 16, (ly - 1) * 16);
- addFloatIcon(18, lx * 16, (ly - 1) * 16);
+ _itemticks = _ticks + 215;
- _itemticks = _ticks + 215;
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
+ eventText("Found the Blood Sword!");
+ _objmapf[4][1][2] = 1;
+ return;
}
+ break;
+ case kScriptShield3:
+ if (_player.shield < 3) {
+ _player.shield = 3;
+ addFloatIcon(19, lx * 16, (ly - 1) * 16);
+ _itemticks = _ticks + 215;
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
- eventText("Found the Blood Sword!");
- _objmapf[4][1][2] = 1;
- return;
- }
-
- if (oscript == kScriptShield3 && _player.shield < 3) {
- _player.shield = 3;
- addFloatIcon(19, lx * 16, (ly - 1) * 16);
- _itemticks = _ticks + 215;
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
+ eventText("Found the Entropy Shield!");
+ _objmapf[4][1][2] = 1;
+ return;
}
+ break;
+ case kScriptArmour3:
+ if (_player.armour < 3) {
+ _player.armour = 3;
+ addFloatIcon(20, lx * 16, (ly - 1) * 16);
+ _itemticks = _ticks + 215;
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
- eventText("Found the Entropy Shield!");
- _objmapf[4][1][2] = 1;
- return;
- }
-
- if (oscript == kScriptArmour3 && _player.armour < 3) {
- _player.armour = 3;
- addFloatIcon(20, lx * 16, (ly - 1) * 16);
- _itemticks = _ticks + 215;
+ if (config.effects) {
+ int snd = playSound(_sfx[kSndPowerUp]);
+ setChannelVolume(snd, config.effectsvol);
+ }
- if (config.effects) {
- int snd = playSound(_sfx[kSndPowerUp]);
- setChannelVolume(snd, config.effectsvol);
+ if (_objectInfo[o][4] == 1)
+ _objectMap[lx][ly - 1] = 3;
+ eventText("Found the Rubyscale Armour!");
+ _objmapf[4][1][2] = 1;
+ return;
}
-
- if (_objectInfo[o][4] == 1)
- _objectMap[lx][ly - 1] = 3;
- eventText("Found the Rubyscale Armour!");
- _objmapf[4][1][2] = 1;
- return;
+ break;
}
-
}
}
}
@@ -681,7 +679,7 @@ void GriffonEngine::damageNPC(int npcnum, int damage, int spell) {
}
// academy crystal chest script
- if (_npcinfo[npcnum].script == kScriptFindCtystal) {
+ if (_npcinfo[npcnum].script == kScriptFindCrystal) {
bool alive = false;
for (int i = 1; i <= _lastnpc; i++) {
if (_npcinfo[i].hp > 0)
@@ -707,7 +705,7 @@ void GriffonEngine::damageNPC(int npcnum, int damage, int spell) {
if (lx == cx && ly == cy)
_player.py += 16;
- _scriptflag[kScriptFindCtystal][0] = 1;
+ _scriptflag[kScriptFindCrystal][0] = 1;
_clipbg2->fillRect(rcDest, _clipbg->format.RGBToColor(255, 255, 255));
}
}
diff --git a/engines/griffon/griffon.h b/engines/griffon/griffon.h
index 1a830f6f43..30df532f33 100644
--- a/engines/griffon/griffon.h
+++ b/engines/griffon/griffon.h
@@ -94,7 +94,7 @@ enum {
enum {
kScriptFlask = 0, // get flask
kScriptMasterKey = 2, // find master key
- kScriptFindCtystal = 3, // find crystal
+ kScriptFindCrystal = 3, // find crystal
kScriptFindShield = 4, // find shield - obj 8
kScriptFindSword = 5, // find sword - obj 9
kScriptKeyChest = 6, // regular key chest
diff --git a/engines/griffon/resources.cpp b/engines/griffon/resources.cpp
index e81502ec75..d24a947a7c 100644
--- a/engines/griffon/resources.cpp
+++ b/engines/griffon/resources.cpp
@@ -706,9 +706,9 @@ void GriffonEngine::loadMap(int mapnum) {
}
}
- if (_npcinfo[i].script == kScriptFindCtystal) {
+ if (_npcinfo[i].script == kScriptFindCrystal) {
_roomlock = true;
- if (_scriptflag[kScriptFindCtystal][0] > 0) {
+ if (_scriptflag[kScriptFindCrystal][0] > 0) {
_roomlock = false;
_npcinfo[i].hp = 0;
}
@@ -763,7 +763,7 @@ void GriffonEngine::loadMap(int mapnum) {
}
// academy crystal
- if (_curmap == 24 && _player.foundSpell[0] == 0 && _scriptflag[kScriptFindCtystal][0] == 1) {
+ if (_curmap == 24 && _player.foundSpell[0] == 0 && _scriptflag[kScriptFindCrystal][0] == 1) {
cx = 9;
cy = 7;