Skip to content

Commit

Permalink
TSAGE: Added missing default item response code logic in Blue Force
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Sep 4, 2011
1 parent b893f9f commit 8f9af26
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 16 deletions.
4 changes: 2 additions & 2 deletions engines/tsage/blue_force/blueforce_dialogs.cpp
Expand Up @@ -342,15 +342,15 @@ void AmmoBeltDialog::draw() {

// Draw the first clip if necessary
if (clip1) {
GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip1Frame);
GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip1Bullets);
_clip1Rect.resize(clipSurface, _clip1Rect.left, _clip1Rect.top, 100);
_globals->gfxManager().copyFrom(clipSurface, bounds.left + _clip1Rect.left,
bounds.top + _clip1Rect.top);
}

// Draw the second clip if necessary
if (clip2) {
GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip2Frame);
GfxSurface clipSurface = surfaceFromRes(9, 6, BF_GLOBALS._clip2Bullets);
_clip2Rect.resize(clipSurface, _clip2Rect.left, _clip2Rect.top, 100);
_globals->gfxManager().copyFrom(clipSurface, bounds.left + _clip2Rect.left,
bounds.top + _clip2Rect.top);
Expand Down
51 changes: 44 additions & 7 deletions engines/tsage/blue_force/blueforce_logic.cpp
Expand Up @@ -340,10 +340,9 @@ void NamedObject::startAction(CursorType action) {
handled = false;
break;
}
/*

if (!handled)
((SceneExt *)BF_GLOBALS._sceneManager._scene)->display(action);
*/
}

void NamedObject::setup(int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) {
Expand Down Expand Up @@ -501,20 +500,58 @@ void SceneExt::loadScene(int sceneNum) {
}

void SceneExt::checkGun() {
if (BF_GLOBALS.getFlag(fLoadedSpare) && (BF_GLOBALS._v4CEBA > 0)) {
if (--BF_GLOBALS._v4CEBA == 0)
// Remove a bullet from the currently loaded clip
if (BF_GLOBALS.getFlag(fLoadedSpare) && (BF_GLOBALS._clip2Bullets > 0)) {
if (--BF_GLOBALS._clip2Bullets == 0)
BF_GLOBALS.clearFlag(fGunLoaded);
} else {
if (BF_GLOBALS._v4CEB8 > 0)
--BF_GLOBALS._v4CEB8;
if (BF_GLOBALS._clip1Bullets > 0)
--BF_GLOBALS._clip1Bullets;

if (!BF_GLOBALS._v4CEB8)
if (!BF_GLOBALS._clip1Bullets)
BF_GLOBALS.clearFlag(fGunLoaded);
}

BF_GLOBALS._sound3.play(4);
}

void SceneExt::display(CursorType action) {
switch (action) {
case CURSOR_LOOK:
SceneItem::display2(9000, BF_GLOBALS._randomSource.getRandomNumber(2));
break;
case CURSOR_USE:
SceneItem::display2(9000, BF_GLOBALS._randomSource.getRandomNumber(2) + 6);
break;
case CURSOR_TALK:
SceneItem::display2(9000, BF_GLOBALS._randomSource.getRandomNumber(2) + 3);
break;
case INV_COLT45:
gunDisplay();
break;
default:
if (action < BF_LAST_INVENT)
SceneItem::display2(9002, (int)action);
break;
}
}

void SceneExt::gunDisplay() {
if (!BF_GLOBALS.getFlag(gunDrawn)) {
// Gun not drawn
SceneItem::display2(1, BF_GLOBALS.getFlag(fCanDrawGun) ? 0 : 4);
} else if (!BF_GLOBALS.getFlag(fGunLoaded)) {
// Gun not loaded
SceneItem::display2(1, 1);
} else if (!BF_GLOBALS.getHasBullets()) {
// Out of ammunition
SceneItem::display2(1, 2);
} else {
// Check scene for whether gun can fire
checkGun();
}
}

/*--------------------------------------------------------------------------*/

GameScene::GameScene() {
Expand Down
3 changes: 3 additions & 0 deletions engines/tsage/blue_force/blueforce_logic.h
Expand Up @@ -137,6 +137,8 @@ class FollowerObject: public NamedObject {
};

class SceneExt: public Scene {
private:
void gunDisplay();
public:
AObjectArray _timerList, _objArray2;
int _field372;
Expand All @@ -156,6 +158,7 @@ class SceneExt: public Scene {

void addTimer(Timer *timer) { _timerList.add(timer); }
void removeTimer(Timer *timer) { _timerList.remove(timer); }
void display(CursorType action);
};

class GameScene: public SceneExt {
Expand Down
1 change: 1 addition & 0 deletions engines/tsage/events.h
Expand Up @@ -80,6 +80,7 @@ enum CursorType {
INV_9MM_BULLETS = 54, INV_SCHEDULE = 55, INV_GRENADES = 56, INV_YELLOW_CORD = 57,
INV_HALF_YELLOW_CORD = 58, INV_BLACK_CORD = 59, INV_HALF_BLACK_CORD = 61, INV_WARRANT = 62,
INV_JACKET = 63, INV_GREENS_KNIFE = 64, INV_DOG_WHISTLE = 65, INV_AMMO_BELT = 66,
BF_LAST_INVENT = 67,

// Cursors
CURSOR_WALK = 0x100, CURSOR_LOOK = 0x200, CURSOR_700 = 700, CURSOR_USE = 0x400, CURSOR_TALK = 0x800,
Expand Down
12 changes: 8 additions & 4 deletions engines/tsage/globals.cpp
Expand Up @@ -212,14 +212,18 @@ void BlueForceGlobals::reset() {
_dayNumber = 0;
_v4CEA4 = 0;
_v4CEA8 = 0;
_v4CEB8 = 0;
_v4CEBA = 0;
_v4CF9E = 0;
_v4E238 = 0;
_v501FC = 0;
_v51C42 = 0;
_clip1Frame = 8;
_clip2Frame = 8;
_clip1Bullets = 8;
_clip2Bullets = 8;
}

bool BlueForceGlobals::getHasBullets() {
if (!getFlag(fGunLoaded))
return false;
return BF_GLOBALS.getFlag(fLoadedSpare) ? (_clip2Bullets > 0) : (_clip1Bullets > 0);
}

} // end of namespace BlueForce
Expand Down
5 changes: 2 additions & 3 deletions engines/tsage/globals.h
Expand Up @@ -169,8 +169,6 @@ class BlueForceGlobals: public Globals {
int _dayNumber;
int _v4CEA4;
int _v4CEA8;
int _v4CEB8;
int _v4CEBA;
int _driveFromScene;
int _driveToScene;
int _v4CF9E;
Expand All @@ -181,10 +179,11 @@ class BlueForceGlobals: public Globals {
int _interfaceY;
Bookmark _bookmark;
int _mapLocationId;
int _clip1Frame, _clip2Frame;
int _clip1Bullets, _clip2Bullets;

BlueForceGlobals();
void reset();
bool getHasBullets();

virtual Common::String getClassName() { return "BFGlobals"; }
virtual void synchronize(Serializer &s);
Expand Down

0 comments on commit 8f9af26

Please sign in to comment.