hedgewars/uGearsHedgehog.pas
changeset 7389 15c3fb4882df
parent 7375 16ae2e1c9005
child 7391 588eabb4b384
equal deleted inserted replaced
7388:92535bc7e928 7389:15c3fb4882df
    26 procedure AfterAttack; 
    26 procedure AfterAttack; 
    27 procedure HedgehogStep(Gear: PGear); 
    27 procedure HedgehogStep(Gear: PGear); 
    28 procedure doStepHedgehogMoving(Gear: PGear); 
    28 procedure doStepHedgehogMoving(Gear: PGear); 
    29 procedure HedgehogChAngle(HHGear: PGear); 
    29 procedure HedgehogChAngle(HHGear: PGear); 
    30 procedure PickUp(HH, Gear: PGear);
    30 procedure PickUp(HH, Gear: PGear);
       
    31 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
    31 
    32 
    32 implementation
    33 implementation
    33 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, 
    34 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, 
    34     uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
    35     uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
    35     uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, 
    36     uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, 
   563     Gear^.Pos:= 0;
   564     Gear^.Pos:= 0;
   564     Gear^.Timer:= timertime
   565     Gear^.Timer:= timertime
   565     end
   566     end
   566 end;
   567 end;
   567 
   568 
       
   569 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
       
   570 var s: shortstring;
       
   571     vga: PVisualGear;
       
   572 begin
       
   573     PlaySound(sndShotgunReload);
       
   574     if cnt <> 0 then AddAmmo(HH, ammo, cnt)
       
   575     else AddAmmo(HH, ammo);
       
   576 
       
   577     if (not (HH.Team^.ExtDriven 
       
   578     or (HH.BotLevel > 0)))
       
   579     or (HH.Team^.Clan^.ClanIndex = LocalClan)
       
   580     or (GameType = gmtDemo)  then
       
   581         begin
       
   582         if cnt <> 0 then
       
   583             s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(cnt) + ')'
       
   584         else
       
   585             s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(Ammoz[ammo].NumberInCase) + ')';
       
   586         AddCaption(s, HH.Team^.Clan^.Color, capgrpAmmoinfo);
       
   587 
       
   588         // show ammo icon
       
   589         vga:= AddVisualGear(X, Y, vgtAmmo);
       
   590         if vga <> nil then
       
   591             vga^.Frame:= Longword(ammo);
       
   592         end;
       
   593 end;
       
   594 
   568 ////////////////////////////////////////////////////////////////////////////////
   595 ////////////////////////////////////////////////////////////////////////////////
   569 procedure PickUp(HH, Gear: PGear);
   596 procedure PickUp(HH, Gear: PGear);
   570 var s: shortstring;
   597 var s: shortstring;
   571     a: TAmmoType;
   598     a: TAmmoType;
   572     i: LongInt;
   599     i: LongInt;
   573     vga: PVisualGear;
   600     vga: PVisualGear;
       
   601     ag: PGear;
   574 begin
   602 begin
   575 Gear^.Message:= gmDestroy;
   603 Gear^.Message:= gmDestroy;
   576 PlaySound(sndShotgunReload);
       
   577 if (Gear^.Pos and posCaseExplode) <> 0 then
   604 if (Gear^.Pos and posCaseExplode) <> 0 then
   578     if (Gear^.Pos and posCasePoison) <> 0 then
   605     if (Gear^.Pos and posCasePoison) <> 0 then
   579         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned)
   606         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned)
   580     else
   607     else
   581         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound)
   608         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound)
   583     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage)
   610     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage)
   584 else
   611 else
   585 case Gear^.Pos of
   612 case Gear^.Pos of
   586        posCaseUtility,
   613        posCaseUtility,
   587        posCaseAmmo: begin
   614        posCaseAmmo: begin
   588                     if Gear^.AmmoType <> amNothing then a:= Gear^.AmmoType 
   615                     if Gear^.AmmoType <> amNothing then 
       
   616                         begin
       
   617                         AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y));
       
   618                         end
   589                     else
   619                     else
   590                         begin
   620                         begin
   591                         for i:= 0 to GameTicks and $7F do
   621 // Add spawning here...
   592                             GetRandom(2); // Burn some random numbers
   622                         AddRandomness(CheckSum xor GameTicks);
   593                         if Gear^.Pos = posCaseUtility then
   623                         for i:= 0 to GetRandom(50)+50 do
   594                             a:= GetUtility(HH^.Hedgehog)
   624                             AddGear(GetRandom(rightX-leftX)+leftX, GetRandom(LAND_HEIGHT-topY)+topY, gtGenericFaller,
   595                         else
   625                                     gstInvisible, _90-(GetRandomf*_360), _90-(GetRandomf*_360), GetRandom(500));
   596                             a:= GetAmmo(HH^.Hedgehog)
   626                         ag:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAddAmmo, gstInvisible, _0, _0, GetRandom(200)+100);
       
   627                         ag^.Pos:= Gear^.Pos;
       
   628                         ag^.Power:= Gear^.Power
   597                         end;
   629                         end;
   598                     if Gear^.Power <> 0 then AddAmmo(HH^.Hedgehog^, a, Gear^.Power)
       
   599                     else AddAmmo(HH^.Hedgehog^, a);
       
   600 // Possibly needs to check shared clan ammo game flag once added.
       
   601 // On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up
       
   602                     if (not (HH^.Hedgehog^.Team^.ExtDriven 
       
   603                     or (HH^.Hedgehog^.BotLevel > 0)))
       
   604                     or (HH^.Hedgehog^.Team^.Clan^.ClanIndex = LocalClan)
       
   605                     or (GameType = gmtDemo)  then
       
   606                         begin
       
   607                         if Gear^.Power <> 0 then
       
   608                             s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Gear^.Power) + ')'
       
   609                         else
       
   610                             s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')';
       
   611                         AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
       
   612 
       
   613                         // show ammo icon
       
   614                         vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo);
       
   615                         if vga <> nil then
       
   616                             vga^.Frame:= Longword(a);
       
   617                         end;
       
   618 
       
   619                     end;
   630                     end;
   620      posCaseHealth: begin
   631      posCaseHealth: begin
       
   632                     PlaySound(sndShotgunReload);
   621                     inc(HH^.Health, Gear^.Health);
   633                     inc(HH^.Health, Gear^.Health);
   622                     HH^.Hedgehog^.Effects[hePoisoned] := 0;
   634                     HH^.Hedgehog^.Effects[hePoisoned] := 0;
   623                     str(Gear^.Health, s);
   635                     str(Gear^.Health, s);
   624                     s:= '+' + s;
   636                     s:= '+' + s;
   625                     AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
   637                     AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
  1222 var x,y,tx,ty: LongInt;
  1234 var x,y,tx,ty: LongInt;
  1223     tdX, tdY, slope: hwFloat; 
  1235     tdX, tdY, slope: hwFloat; 
  1224     land: Word; *)
  1236     land: Word; *)
  1225 var slope: hwFloat; 
  1237 var slope: hwFloat; 
  1226 begin
  1238 begin
       
  1239 CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel;
  1227 if (Gear^.Message and gmDestroy) <> 0 then
  1240 if (Gear^.Message and gmDestroy) <> 0 then
  1228     begin
  1241     begin
  1229     DeleteGear(Gear);
  1242     DeleteGear(Gear);
  1230     exit
  1243     exit
  1231     end;
  1244     end;