Skip to content

Commit 8f94391

Browse files
committed
Fixed shop wares refresh bug
1 parent 764d2d8 commit 8f94391

File tree

5 files changed

+55
-51
lines changed

5 files changed

+55
-51
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
savegame/
55
arena
66
gharena
7+
gearhead2
78
cosplay
89
xxran
910
*.exe

gearhead2

-2.88 MB
Binary file not shown.

gearhead2.pas

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{$ENDIF}
4040

4141
const
42-
Version = '0.628';
42+
Version = '0.630';
4343

4444
Procedure RedrawOpening;
4545
{ The opening menu redraw procedure. }

history.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
0.630 June 30 2016
2+
- Fixed shopkeepers never changing wares bug (services.pp)
3+
- Added more item sprites by Francisco Munoz
14
- Added Names_Above_Heads to options menu (pcaction.pp)
25
- Added updated ColorMenu from GH1 (colormenu.pp)
36
- Game automatically saved upon quit (pcaction.pp)

services.pp

+50-50
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface
3737
'201 205 229 49 91 161 0 200 0', { Aero Blue, Azure, Green }
3838
'240 240 240 208 34 51 50 50 150' { White, Red Goes Fasta, Blue }
3939
);
40-
40+
4141
SATT_SaleTag = 'SALETAG';
4242

4343
var
@@ -148,17 +148,17 @@ implementation
148148
end;
149149

150150
Function ScalePrice( GB: GameBoardPtr; PC,NPC: GearPtr; Price: Int64 ): LongInt;
151-
{ Modify the price listed based upon the PC's shopping skill, }
151+
{ Modify the price listed based upon the PC's shopping skill, }
152152
{ faction membership, and whatever else. }
153153
var
154-
ShopRk,ShopTr,R: Integer; { ShopRank and ShopTarget }
155-
PriceMod: LongInt;
154+
ShopRk,ShopTr,R: Integer; { ShopRank and ShopTarget }
155+
PriceMod: LongInt;
156156
Adv: GearPtr;
157-
begin
158-
{ Start with the assumption that we're paying 100%. }
159-
PriceMod := 100;
157+
begin
158+
{ Start with the assumption that we're paying 100%. }
159+
PriceMod := 100;
160160

161-
{ First, let's modify this by Shopping skill. }
161+
{ First, let's modify this by Shopping skill. }
162162
{ Determine the Shopping skill rank of the buyer. }
163163
ShopRk := SkillValue( PC , NAS_Shopping , STAT_Charm );
164164

@@ -175,8 +175,8 @@ implementation
175175
end else if R < 0 then begin
176176
{ It's much harder to haggle if the shopkeep }
177177
{ doesn't like you. }
178-
ShopTr := ShopTr + Abs( R ) div 2;
179-
{ If the dislike ventures into hate, there's a markup. }
178+
ShopTr := ShopTr + Abs( R ) div 2;
179+
{ If the dislike ventures into hate, there's a markup. }
180180
if R < -20 then PriceMod := PriceMod + Abs( R ) div 5;
181181
end;
182182
end;
@@ -189,20 +189,20 @@ implementation
189189
if ShopRk > 50 then ShopRk := 50;
190190

191191
PriceMod := PriceMod - ShopRk;
192-
end;
193-
194-
{ Next, let's take a look at factions. }
195-
if ( GB <> Nil ) and ( GB^.Scene <> Nil ) and ( NPC <> Nil ) then begin
196-
{ ArchEnemies get a 20% markup, allies get a 10% discount. }
197-
Adv := FindRoot( GB^.Scene );
198-
if IsArchEnemy( Adv , NPC ) then begin
199-
PriceMod := PriceMod + 20;
200-
end else if IsArchAlly( Adv , NPC ) then begin
201-
PriceMod := PriceMod - 10;
202-
end;
203-
end;
204-
205-
{ Calculate the final price. }
192+
end;
193+
194+
{ Next, let's take a look at factions. }
195+
if ( GB <> Nil ) and ( GB^.Scene <> Nil ) and ( NPC <> Nil ) then begin
196+
{ ArchEnemies get a 20% markup, allies get a 10% discount. }
197+
Adv := FindRoot( GB^.Scene );
198+
if IsArchEnemy( Adv , NPC ) then begin
199+
PriceMod := PriceMod + 20;
200+
end else if IsArchAlly( Adv , NPC ) then begin
201+
PriceMod := PriceMod - 10;
202+
end;
203+
end;
204+
205+
{ Calculate the final price. }
206206
Price := ( Price * PriceMod ) div 100;
207207
if Price < 1 then Price := 1;
208208

@@ -1129,7 +1129,7 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
11291129
{ Certain items may need some initialization. }
11301130
var
11311131
mecha_colors: String;
1132-
Fac: GearPtr;
1132+
Fac: GearPtr;
11331133
Discount: Integer;
11341134
begin
11351135
if I^.G = GG_Mecha then begin
@@ -1154,13 +1154,13 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
11541154
end;
11551155

11561156
SetSAtt( I^.SA , 'sdl_colors <' + mecha_colors + '>' );
1157-
end;
1158-
1159-
{ New v0.625- Maybe this item will be on sale! }
1160-
if ( Random( 20 ) = 1 ) then begin
1161-
Discount := ( Random( 5 ) + 1 ) * 5;
1162-
MarkGearsWithNAtt( I , NAG_GearOps , NAS_CostAdjust , -Discount );
1163-
MarkGearsWithSAtt( I , SATT_SaleTag + ' <' + ReplaceHash( MSgString( 'SALETAG_Discount' ) , BStr( Discount ) ) + '>' );
1157+
end;
1158+
1159+
{ New v0.625- Maybe this item will be on sale! }
1160+
if ( Random( 20 ) = 1 ) then begin
1161+
Discount := ( Random( 5 ) + 1 ) * 5;
1162+
MarkGearsWithNAtt( I , NAG_GearOps , NAS_CostAdjust , -Discount );
1163+
MarkGearsWithSAtt( I , SATT_SaleTag + ' <' + ReplaceHash( MSgString( 'SALETAG_Discount' ) , BStr( Discount ) ) + '>' );
11641164
end;
11651165
end;
11661166
var
@@ -1173,13 +1173,13 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
11731173
{ Set the random seed to something less than random... }
11741174
NPCSeed := NAttValue( NPC^.NA , NAG_PErsonal , NAS_RandSeed );
11751175
NPCRestock := NAttValue( NPC^.NA , NAG_PErsonal , NAS_RestockTime );
1176-
if NPCSeed = 0 then begin
1176+
if ( NPCSeed = 0 ) or ( GB^.Comtime > NPCRestock ) then begin
11771177
NPCSeed := Random( 2000000000 ) + 1;
1178-
NPCRestock := Random( 86400 ) + 1;
1178+
NPCRestock := 86400 + GB^.Comtime;
11791179
SetNAtt( NPC^.NA , NAG_PErsonal , NAS_RandSeed , NPCSeed );
11801180
SetNAtt( NPC^.NA , NAG_PErsonal , NAS_RestockTime , NPCRestock );
11811181
end;
1182-
RandSeed := ( ( GB^.ComTime + NPCRestock ) div 86400 ) + NPCSeed;
1182+
RandSeed := NPCSeed;
11831183

11841184
{ We've already got everything loaded from disk, in Standard_Equipment_List. }
11851185
{ Create a component list of legal parts. }
@@ -1279,7 +1279,7 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
12791279

12801280
N := 1;
12811281
while I <> Nil do begin
1282-
msg := FullGearName( I );
1282+
msg := FullGearName( I );
12831283

12841284
{ Add extra information, depending upon item type. }
12851285
if I^.G = GG_Weapon then begin
@@ -1296,10 +1296,10 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
12961296
if ( I^.G <> GG_Mecha ) and ( I^.Scale > 0 ) then begin
12971297
msg := msg + '(SF' + BStr( I^.Scale ) + ')';
12981298
end;
1299-
1299+
13001300
{ Add the sale tag, if it exists. }
1301-
msg2 := SAttValue( I^.SA , SATT_SALETAG );
1302-
if msg2 <> '' then msg := msg + ' (' + msg2 + ')';
1301+
msg2 := SAttValue( I^.SA , SATT_SALETAG );
1302+
if msg2 <> '' then msg := msg + ' (' + msg2 + ')';
13031303

13041304
{ Pad the message. }
13051305
{$IFDEF ASCII}
@@ -1358,8 +1358,8 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
13581358
{ Create the menu. }
13591359
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_ShopMenu );
13601360
RPM^.Mode := RPMNoCleanup;
1361-
1362-
BuildInventoryMenu( RPM , PCInv , True );
1361+
1362+
BuildInventoryMenu( RPM , PCInv , True );
13631363

13641364
AddRPGMenuItem( RPM , MsgString( 'SERVICES_Exit' ) , -1 );
13651365

@@ -1388,11 +1388,11 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
13881388
SERV_Menu := Nil;
13891389
SERV_Info := Nil;
13901390
end;
1391-
1392-
Function ShopkeeperCanRepairMecha( NPC: GearPtr ): Boolean;
1393-
{ Return TRUE if the shopkeeper can repair mecha, or FALSE otherwise. }
1394-
begin
1395-
ShopkeeperCanRepairMecha := ( NPC <> Nil ) and ( NAttValue( NPC^.NA , NAG_Skill , NAS_Repair ) > 5 );
1391+
1392+
Function ShopkeeperCanRepairMecha( NPC: GearPtr ): Boolean;
1393+
{ Return TRUE if the shopkeeper can repair mecha, or FALSE otherwise. }
1394+
begin
1395+
ShopkeeperCanRepairMecha := ( NPC <> Nil ) and ( NAttValue( NPC^.NA , NAG_Skill , NAS_Repair ) > 5 );
13961396
end;
13971397

13981398
Procedure ThisMechaWasSelected( GB: GameBoardPtr; MekNum: Integer; PC,NPC: GearPtr );
@@ -1474,10 +1474,10 @@ procedure PurchaseGearMenu( GB: GameBoardPtr; PC,NPC,Part: GearPtr );
14741474
{ If this gear is a mecha, and it belongs to the PC, }
14751475
{ add it to the menu. }
14761476
if ( NAttValue( Mek^.NA , NAG_Location , NAS_Team ) = NAV_DefPlayerTeam ) and not GearActive( Mek ) then begin
1477-
msg := TeamMateName( Mek );
1478-
1479-
msg2 := SAttValue( Mek^.SA , SATT_SALETAG );
1480-
if msg2 <> '' then msg := msg + ' (' + msg2 + ')';
1477+
msg := TeamMateName( Mek );
1478+
1479+
msg2 := SAttValue( Mek^.SA , SATT_SALETAG );
1480+
if msg2 <> '' then msg := msg + ' (' + msg2 + ')';
14811481

14821482
AddRPGMenuItem( RPM , msg , N );
14831483
end;

0 commit comments

Comments
 (0)