45 Hedgehog: pointer; |
45 Hedgehog: pointer; |
46 Health, Damage: integer; |
46 Health, Damage: integer; |
47 CollIndex: Longword; |
47 CollIndex: Longword; |
48 Tag: integer; |
48 Tag: integer; |
49 Surf: PSDL_Surface; |
49 Surf: PSDL_Surface; |
|
50 Z: Longword; |
50 end; |
51 end; |
51 |
52 |
52 function AddGear(X, Y: integer; Kind: TGearType; State: Longword; const dX: Double=0.0; dY: Double=0.0; Timer: LongWord=0): PGear; |
53 function AddGear(X, Y: integer; Kind: TGearType; State: Longword; const dX: Double=0.0; dY: Double=0.0; Timer: LongWord=0): PGear; |
53 procedure ProcessGears; |
54 procedure ProcessGears; |
54 procedure SetAllToActive; |
55 procedure SetAllToActive; |
55 procedure SetAllHHToActive; |
56 procedure SetAllHHToActive; |
56 procedure DrawGears(Surface: PSDL_Surface); |
57 procedure DrawGears(Surface: PSDL_Surface); |
57 procedure FreeGearsList; |
58 procedure FreeGearsList; |
58 procedure AddMiscGears; |
59 procedure AddMiscGears; |
|
60 procedure AddClouds; |
59 procedure AssignHHCoords; |
61 procedure AssignHHCoords; |
60 |
62 |
61 var CurAmmoGear: PGear = nil; |
63 var CurAmmoGear: PGear = nil; |
62 GearsList: PGear = nil; |
64 GearsList: PGear = nil; |
63 |
65 |
117 doStepAirBomb |
119 doStepAirBomb |
118 ); |
120 ); |
119 |
121 |
120 function AddGear(X, Y: integer; Kind: TGearType; State: Longword; const dX: Double=0.0; dY: Double=0.0; Timer: LongWord=0): PGear; |
122 function AddGear(X, Y: integer; Kind: TGearType; State: Longword; const dX: Double=0.0; dY: Double=0.0; Timer: LongWord=0): PGear; |
121 const Counter: Longword = 0; |
123 const Counter: Longword = 0; |
|
124 var tmp: PGear; |
122 begin |
125 begin |
123 inc(Counter); |
126 inc(Counter); |
124 {$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF} |
127 {$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF} |
125 New(Result); |
128 New(Result); |
126 {$IFDEF DEBUGFILE}AddFileLog('AddGear: handle = '+inttostr(integer(Result)));{$ENDIF} |
129 {$IFDEF DEBUGFILE}AddFileLog('AddGear: type = '+inttostr(ord(Kind))+'; handle = '+inttostr(integer(Result)));{$ENDIF} |
127 FillChar(Result^, sizeof(TGear), 0); |
130 FillChar(Result^, sizeof(TGear), 0); |
128 Result.X:= X; |
131 Result.X:= X; |
129 Result.Y:= Y; |
132 Result.Y:= Y; |
130 Result.Kind := Kind; |
133 Result.Kind := Kind; |
131 Result.State:= State; |
134 Result.State:= State; |
136 Result.CollIndex:= High(Longword); |
139 Result.CollIndex:= High(Longword); |
137 Result.Timer:= Timer; |
140 Result.Timer:= Timer; |
138 if CurrentTeam <> nil then |
141 if CurrentTeam <> nil then |
139 Result.Hedgehog:= @CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog]; |
142 Result.Hedgehog:= @CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog]; |
140 case Kind of |
143 case Kind of |
|
144 gtCloud: Result.Z:= High(Result.Z); |
141 gtAmmo_Bomb: begin |
145 gtAmmo_Bomb: begin |
142 Result.Radius:= 4; |
146 Result.Radius:= 4; |
143 Result.Elasticity:= 0.6; |
147 Result.Elasticity:= 0.6; |
144 Result.Friction:= 0.995; |
148 Result.Friction:= 0.995; |
145 end; |
149 end; |
146 gtHedgehog: begin |
150 gtHedgehog: begin |
147 Result.Radius:= cHHRadius; |
151 Result.Radius:= cHHRadius; |
148 Result.Elasticity:= 0.35; |
152 Result.Elasticity:= 0.35; |
149 Result.Friction:= 0.999; |
153 Result.Friction:= 0.999; |
150 Result.Angle:= cMaxAngle div 2; |
154 Result.Angle:= cMaxAngle div 2; |
|
155 Result.Z:= 1000; |
151 end; |
156 end; |
152 gtAmmo_Grenade: begin |
157 gtAmmo_Grenade: begin |
153 Result.Radius:= 4; |
158 Result.Radius:= 4; |
154 end; |
159 end; |
155 gtHealthTag: begin |
160 gtHealthTag: begin |
156 Result.Timer:= 1500; |
161 Result.Timer:= 1500; |
|
162 Result.Z:= 2000; |
157 end; |
163 end; |
158 gtGrave: begin |
164 gtGrave: begin |
159 Result.Radius:= 10; |
165 Result.Radius:= 10; |
160 Result.Elasticity:= 0.6; |
166 Result.Elasticity:= 0.6; |
161 end; |
167 end; |
222 gtFirePunch: begin |
228 gtFirePunch: begin |
223 Result.Radius:= 15; |
229 Result.Radius:= 15; |
224 Result.Tag:= Y |
230 Result.Tag:= Y |
225 end; |
231 end; |
226 gtAirBomb: begin |
232 gtAirBomb: begin |
227 Result.Radius:= 3; |
233 Result.Radius:= 10; |
228 end; |
234 end; |
229 end; |
235 end; |
|
236 |
230 if GearsList = nil then GearsList:= Result |
237 if GearsList = nil then GearsList:= Result |
231 else begin |
238 else begin |
232 GearsList.PrevGear:= Result; |
239 // WARNING: this code assumes that the first gears added to the list are clouds (have maximal Z) |
233 Result.NextGear:= GearsList; |
240 tmp:= GearsList; |
234 GearsList:= Result |
241 while (tmp <> nil) and (tmp.Z < Result.Z) do |
|
242 tmp:= tmp.NextGear; |
|
243 |
|
244 if tmp.PrevGear <> nil then tmp.PrevGear.NextGear:= Result; |
|
245 Result.PrevGear:= tmp.PrevGear; |
|
246 tmp.PrevGear:= Result; |
|
247 Result.NextGear:= tmp; |
|
248 if GearsList = tmp then GearsList:= Result |
235 end |
249 end |
236 end; |
250 end; |
237 |
251 |
238 procedure DeleteGear(Gear: PGear); |
252 procedure DeleteGear(Gear: PGear); |
239 var team: PTeam; |
253 var team: PTeam; |
280 if Gear.Damage <> 0 then |
294 if Gear.Damage <> 0 then |
281 begin |
295 begin |
282 Result:= false; |
296 Result:= false; |
283 if Gear.Health < Gear.Damage then Gear.Health:= 0 |
297 if Gear.Health < Gear.Damage then Gear.Health:= 0 |
284 else dec(Gear.Health, Gear.Damage); |
298 else dec(Gear.Health, Gear.Damage); |
285 AddGear(Round(Gear.X), Round(Gear.Y) - 32, gtHealthTag, Gear.Damage).Hedgehog:= Gear.Hedgehog; |
299 AddGear(Round(Gear.X), round(Gear.Y) - cHHRadius - 12 - PHedgehog(Gear.Hedgehog)^.HealthTag.h, |
|
300 gtHealthTag, Gear.Damage).Hedgehog:= Gear.Hedgehog; |
286 RenderHealth(PHedgehog(Gear.Hedgehog)^); |
301 RenderHealth(PHedgehog(Gear.Hedgehog)^); |
287 RecountTeamHealth(PHedgehog(Gear.Hedgehog)^.Team); |
302 RecountTeamHealth(PHedgehog(Gear.Hedgehog)^.Team); |
288 |
303 |
289 Gear.Damage:= 0 |
304 Gear.Damage:= 0 |
290 end; |
305 end; |
578 end; |
593 end; |
579 |
594 |
580 procedure AddMiscGears; |
595 procedure AddMiscGears; |
581 var i: integer; |
596 var i: integer; |
582 begin |
597 begin |
583 for i:= 0 to cCloudsNumber do |
|
584 AddGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -140, gtCloud, random(4), |
|
585 (0.5-random)*0.1, ((i mod 2) * 2 - 1) * (0.005 + 0.015*random)); |
|
586 AddGear(0, 0, gtATStartGame, 0, 0, 0, 2000); |
598 AddGear(0, 0, gtATStartGame, 0, 0, 0, 2000); |
587 if (GameFlags and gfForts) = 0 then |
599 if (GameFlags and gfForts) = 0 then |
588 for i:= 0 to 3 do |
600 for i:= 0 to 3 do |
589 FindPlace(AddGear(0, 0, gtMine, 0), false, 0, 2048); |
601 FindPlace(AddGear(0, 0, gtMine, 0), false, 0, 2048); |
|
602 end; |
|
603 |
|
604 procedure AddClouds; |
|
605 var i: integer; |
|
606 begin |
|
607 for i:= 0 to cCloudsNumber do |
|
608 AddGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -140, gtCloud, random(4), |
|
609 (0.5-random)*0.1, ((i mod 2) * 2 - 1) * (0.005 + 0.015*random)) |
590 end; |
610 end; |
591 |
611 |
592 procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); |
612 procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); |
593 var Gear: PGear; |
613 var Gear: PGear; |
594 dmg: integer; |
614 dmg: integer; |