hedgewars/uGearsList.pas
changeset 10643 8d6063af793a
parent 10641 802589828f99
child 10645 b8c73bacb31e
equal deleted inserted replaced
10642:8fdfa2b77d83 10643:8d6063af793a
    21 
    21 
    22 interface
    22 interface
    23 uses uFloat, uTypes, SDLh;
    23 uses uFloat, uTypes, SDLh;
    24 
    24 
    25 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    25 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    26 procedure DeleteGear(Gear: PGear);
    26 procedure DeleteGear(Gear: PGear); inline;
       
    27 procedure DeleteGearStage(Gear: PGear; cleanup: boolean);
    27 procedure InsertGearToList(Gear: PGear);
    28 procedure InsertGearToList(Gear: PGear);
    28 procedure RemoveGearFromList(Gear: PGear);
    29 procedure RemoveGearFromList(Gear: PGear);
    29 
    30 
    30 var curHandledGear: PGear;
    31 var curHandledGear: PGear;
    31 
    32 
   627 AddGear:= gear;
   628 AddGear:= gear;
   628 
   629 
   629 ScriptCall('onGearAdd', gear^.uid);
   630 ScriptCall('onGearAdd', gear^.uid);
   630 end;
   631 end;
   631 
   632 
   632 procedure DeleteGear(Gear: PGear);
   633 procedure DeleteGear(Gear: PGear); inline;
       
   634 begin
       
   635 DeleteGearStage(Gear, false)
       
   636 end;
       
   637 
       
   638 procedure DeleteGearStage(Gear: PGear; cleanup: boolean);
   633 var team: PTeam;
   639 var team: PTeam;
   634     t,i: Longword;
   640     t,i: Longword;
   635     k: boolean;
   641     k: boolean;
   636 begin
   642 begin
   637 
   643 
   658         CurAmmoGear^.Message:= gmDestroy;
   664         CurAmmoGear^.Message:= gmDestroy;
   659         exit
   665         exit
   660         end
   666         end
   661     else*)
   667     else*)
   662         begin
   668         begin
   663         if ((CurrentHedgehog = nil) or (Gear <> CurrentHedgehog^.Gear)) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then
   669         team:= Gear^.Hedgehog^.Team;
   664             Gear^.Hedgehog^.Team^.Clan^.Flawless:= false;
   670         if not cleanup then
   665         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
       
   666             begin
   671             begin
   667             t:= max(Gear^.Damage, Gear^.Health);
   672             if ((CurrentHedgehog = nil) or (Gear <> CurrentHedgehog^.Gear)) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then
   668             Gear^.Damage:= t;
   673                 Gear^.Hedgehog^.Team^.Clan^.Flawless:= false;
   669             if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then
   674             if not CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
   670                 spawnHealthTagForHH(Gear, t);
   675                 begin
       
   676                 t:= max(Gear^.Damage, Gear^.Health);
       
   677                 Gear^.Damage:= t;
       
   678                 if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then
       
   679                     spawnHealthTagForHH(Gear, t);
       
   680                 end;
       
   681 
       
   682             // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
       
   683             // same stand for CheckHHDamage
       
   684             if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then
       
   685                 uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
       
   686             else if CurrentHedgehog <> nil then
       
   687                 uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
       
   688 
       
   689             inc(KilledHHs);
       
   690             RecountTeamHealth(team);
       
   691             if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0)  and
       
   692             //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
       
   693             (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
       
   694                 with CurrentHedgehog^ do
       
   695                     begin
       
   696                     inc(Team^.stats.AIKills);
       
   697                     FreeAndNilTexture(Team^.AIKillsTex);
       
   698                     Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
       
   699                     end
   671             end;
   700             end;
   672 
   701 
   673         team:= Gear^.Hedgehog^.Team;
       
   674         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear = Gear) then
   702         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear = Gear) then
   675             begin
   703             begin
   676             AttackBar:= 0;
   704             AttackBar:= 0;
   677             FreeActionsList; // to avoid ThinkThread on drawned gear
   705             FreeActionsList; // to avoid ThinkThread on drawned gear
   678             if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0)
   706             if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0)
   693                     begin
   721                     begin
   694                     team^.Clan^.Teams[i]^.hasGone:= true;
   722                     team^.Clan^.Teams[i]^.hasGone:= true;
   695                     TeamGoneEffect(team^.Clan^.Teams[i]^)
   723                     TeamGoneEffect(team^.Clan^.Teams[i]^)
   696                     end
   724                     end
   697             end;
   725             end;
   698 
       
   699         // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
       
   700         // same stand for CheckHHDamage
       
   701         if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then
       
   702             uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
       
   703         else if CurrentHedgehog <> nil then
       
   704             uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
       
   705 
       
   706         inc(KilledHHs);
       
   707         RecountTeamHealth(team);
       
   708         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0)  and
       
   709         //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
       
   710         (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
       
   711             with CurrentHedgehog^ do
       
   712                 begin
       
   713                 inc(Team^.stats.AIKills);
       
   714                 FreeAndNilTexture(Team^.AIKillsTex);
       
   715                 Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
       
   716                 end
       
   717         end;
   726         end;
   718 with Gear^ do
   727 with Gear^ do
   719     begin
   728     begin
   720     AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   729     AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   721     AddRandomness(X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac)
   730     AddRandomness(X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac)