hedgewars/uGears.pas
changeset 3443 14d12df0d363
parent 3442 69898c6ede14
child 3450 c250116b9136
equal deleted inserted replaced
3442:69898c6ede14 3443:14d12df0d363
   217     Gear^.PrevGear^.NextGear:= Gear^.NextGear
   217     Gear^.PrevGear^.NextGear:= Gear^.NextGear
   218 else
   218 else
   219     GearsList:= Gear^.NextGear
   219     GearsList:= Gear^.NextGear
   220 end;
   220 end;
   221 
   221 
       
   222 procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword);
       
   223 var tag: PVisualGear;
       
   224 begin
       
   225 tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg);
       
   226 tag^.Hedgehog:= PHedgehog(HHGear^.Hedgehog); // the tag needs the tag to determine the text color
       
   227 tag^.doStep(tag,1); // do this now because the Gear could already be deleted on next step call
       
   228 tag^.Hedgehog:= nil;
       
   229 AllInactive:= false;
       
   230 HHGear^.Active:= true;
       
   231 end;
       
   232 
   222 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
   233 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
   223 const Counter: Longword = 0;
   234 const Counter: Longword = 0;
   224 var gear: PGear;
   235 var gear: PGear;
   225 begin
   236 begin
   226 inc(Counter);
   237 inc(Counter);
   513         if (hwRound(Gear^.Y) >= cWaterLine) then
   524         if (hwRound(Gear^.Y) >= cWaterLine) then
   514             begin
   525             begin
   515             t:= max(Gear^.Damage, Gear^.Health);
   526             t:= max(Gear^.Damage, Gear^.Health);
   516             Gear^.Damage:= t;
   527             Gear^.Damage:= t;
   517             if (cWaterOpacity < $FF) and (hwRound(Gear^.Y) < cWaterLine + 256) then
   528             if (cWaterOpacity < $FF) and (hwRound(Gear^.Y) < cWaterLine + 256) then
   518                 AddVisualGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), vgtHealthTag, t)^.Hedgehog:= Gear^.Hedgehog;
   529                 spawnHealthTagForHH(Gear, t);
   519             uStats.HedgehogDamaged(Gear)
   530             uStats.HedgehogDamaged(Gear)
   520             end;
   531             end;
   521 
   532 
   522         team:= PHedgehog(Gear^.Hedgehog)^.Team;
   533         team:= PHedgehog(Gear^.Hedgehog)^.Team;
   523         if CurrentHedgehog^.Gear = Gear then
   534         if CurrentHedgehog^.Gear = Gear then
   574                 not PHedgehog(Gear^.Hedgehog)^.King and
   585                 not PHedgehog(Gear^.Hedgehog)^.King and
   575                 not PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] and
   586                 not PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] and
   576                 not SuddenDeathDmg then
   587                 not SuddenDeathDmg then
   577                 Gear^.State:= Gear^.State or gstLoser;
   588                 Gear^.State:= Gear^.State or gstLoser;
   578 
   589 
   579             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
   590             spawnHealthTagForHH(Gear, dmg);
   580                     vgtHealthTag, dmg)^.Hedgehog:= Gear^.Hedgehog;
       
   581 
   591 
   582             RenderHealth(PHedgehog(Gear^.Hedgehog)^);
   592             RenderHealth(PHedgehog(Gear^.Hedgehog)^);
   583             RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
   593             RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
   584 
   594 
   585             end;
   595             end;
   895         if ((GameFlags and gfKarma) <> 0) and
   905         if ((GameFlags and gfKarma) <> 0) and
   896            ((GameFlags and gfInvulnerable) = 0) and
   906            ((GameFlags and gfInvulnerable) = 0) and
   897            not CurrentHedgehog^.Gear^.Invulnerable then
   907            not CurrentHedgehog^.Gear^.Invulnerable then
   898            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   908            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   899            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   909            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   900            AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X),
   910            spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
   901                    hwRound(CurrentHedgehog^.Gear^.Y),
       
   902                    vgtHealthTag, tmpDmg)^.Hedgehog:= CurrentHedgehog;
       
   903            end;
   911            end;
   904         end;
   912         end;
   905     end;
   913     end;
   906     inc(Gear^.Damage, Damage);
   914     inc(Gear^.Damage, Damage);
   907 end;
   915 end;