diff -r 92535bc7e928 -r 15c3fb4882df hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Fri Jul 13 13:21:52 2012 +0400 +++ b/hedgewars/uGearsHedgehog.pas Sat Jul 14 23:19:09 2012 -0400 @@ -28,6 +28,7 @@ procedure doStepHedgehogMoving(Gear: PGear); procedure HedgehogChAngle(HHGear: PGear); procedure PickUp(HH, Gear: PGear); +procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); implementation uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, @@ -565,15 +566,41 @@ end end; +procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); +var s: shortstring; + vga: PVisualGear; +begin + PlaySound(sndShotgunReload); + if cnt <> 0 then AddAmmo(HH, ammo, cnt) + else AddAmmo(HH, ammo); + + if (not (HH.Team^.ExtDriven + or (HH.BotLevel > 0))) + or (HH.Team^.Clan^.ClanIndex = LocalClan) + or (GameType = gmtDemo) then + begin + if cnt <> 0 then + s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(cnt) + ')' + else + s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(Ammoz[ammo].NumberInCase) + ')'; + AddCaption(s, HH.Team^.Clan^.Color, capgrpAmmoinfo); + + // show ammo icon + vga:= AddVisualGear(X, Y, vgtAmmo); + if vga <> nil then + vga^.Frame:= Longword(ammo); + end; +end; + //////////////////////////////////////////////////////////////////////////////// procedure PickUp(HH, Gear: PGear); var s: shortstring; a: TAmmoType; i: LongInt; vga: PVisualGear; + ag: PGear; begin Gear^.Message:= gmDestroy; -PlaySound(sndShotgunReload); if (Gear^.Pos and posCaseExplode) <> 0 then if (Gear^.Pos and posCasePoison) <> 0 then doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned) @@ -585,39 +612,24 @@ case Gear^.Pos of posCaseUtility, posCaseAmmo: begin - if Gear^.AmmoType <> amNothing then a:= Gear^.AmmoType + if Gear^.AmmoType <> amNothing then + begin + AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y)); + end else begin - for i:= 0 to GameTicks and $7F do - GetRandom(2); // Burn some random numbers - if Gear^.Pos = posCaseUtility then - a:= GetUtility(HH^.Hedgehog) - else - a:= GetAmmo(HH^.Hedgehog) +// Add spawning here... + AddRandomness(CheckSum xor GameTicks); + for i:= 0 to GetRandom(50)+50 do + AddGear(GetRandom(rightX-leftX)+leftX, GetRandom(LAND_HEIGHT-topY)+topY, gtGenericFaller, + gstInvisible, _90-(GetRandomf*_360), _90-(GetRandomf*_360), GetRandom(500)); + ag:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAddAmmo, gstInvisible, _0, _0, GetRandom(200)+100); + ag^.Pos:= Gear^.Pos; + ag^.Power:= Gear^.Power end; - if Gear^.Power <> 0 then AddAmmo(HH^.Hedgehog^, a, Gear^.Power) - else AddAmmo(HH^.Hedgehog^, a); -// Possibly needs to check shared clan ammo game flag once added. -// On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up - if (not (HH^.Hedgehog^.Team^.ExtDriven - or (HH^.Hedgehog^.BotLevel > 0))) - or (HH^.Hedgehog^.Team^.Clan^.ClanIndex = LocalClan) - or (GameType = gmtDemo) then - begin - if Gear^.Power <> 0 then - s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Gear^.Power) + ')' - else - s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')'; - AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); - - // show ammo icon - vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo); - if vga <> nil then - vga^.Frame:= Longword(a); - end; - end; posCaseHealth: begin + PlaySound(sndShotgunReload); inc(HH^.Health, Gear^.Health); HH^.Hedgehog^.Effects[hePoisoned] := 0; str(Gear^.Health, s); @@ -1224,6 +1236,7 @@ land: Word; *) var slope: hwFloat; begin +CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel; if (Gear^.Message and gmDestroy) <> 0 then begin DeleteGear(Gear);