hedgewars/uGearsUtils.pas
changeset 9685 7d925e82e572
parent 9561 aab34634a17b
child 9706 5178d2263521
equal deleted inserted replaced
9683:a342837fc875 9685:7d925e82e572
   133                             begin
   133                             begin
   134                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
   134                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
   135                             //AddFileLog('Damage: ' + inttostr(dmg));
   135                             //AddFileLog('Damage: ' + inttostr(dmg));
   136                             if (Mask and EXPLNoDamage) = 0 then
   136                             if (Mask and EXPLNoDamage) = 0 then
   137                                 begin
   137                                 begin
   138                                 if not Gear^.Invulnerable then
   138                                 if Gear^.Hedgehog^.Effects[heInvulnerable] = 0 then
   139                                     ApplyDamage(Gear, AttackingHog, dmg, dsExplosion)
   139                                     ApplyDamage(Gear, AttackingHog, dmg, dsExplosion)
   140                                 else
   140                                 else
   141                                     Gear^.State:= Gear^.State or gstWinner;
   141                                     Gear^.State:= Gear^.State or gstWinner;
   142                                 end;
   142                                 end;
   143                             if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then
   143                             if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then
   146                                 Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, tdX)/(Gear^.Density/_3);
   146                                 Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, tdX)/(Gear^.Density/_3);
   147                                 Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, tdY)/(Gear^.Density/_3);
   147                                 Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, tdY)/(Gear^.Density/_3);
   148 
   148 
   149                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
   149                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
   150                                 if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision);
   150                                 if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision);
   151                                 if not Gear^.Invulnerable then
   151                                 if Gear^.Hedgehog^.Effects[heInvulnerable] = 0 then
   152                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
   152                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
   153                                 Gear^.Active:= true;
   153                                 Gear^.Active:= true;
   154                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear
   154                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear
   155                                 end;
   155                                 end;
   156                             if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) and ((Gear^.State and gstHHDeath) = 0) then
   156                             if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) and (Gear^.State and gstHHDeath = 0) then
   157                                 Gear^.Hedgehog^.Effects[hePoisoned] := 1;
   157                                 Gear^.Hedgehog^.Effects[hePoisoned] := 1;
   158                             end;
   158                             end;
   159 
   159 
   160                         end;
   160                         end;
   161                 gtGrave: begin
   161                 gtGrave: begin
   247                                 end;
   247                                 end;
   248                         inc(i, 5);
   248                         inc(i, 5);
   249                         end;
   249                         end;
   250                     end
   250                     end
   251                 end;
   251                 end;
   252         if ((GameFlags and gfKarma) <> 0) and 
   252         if (GameFlags and gfKarma <> 0) and (GameFlags and gfInvulnerable = 0) and 
   253         ((GameFlags and gfInvulnerable) = 0)
   253            (CurrentHedgehog^.Effects[heInvulnerable] = 0) then
   254         and (not CurrentHedgehog^.Gear^.Invulnerable) then
       
   255             begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   254             begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   256             inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   255             inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   257             CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog;
   256             CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog;
   258             spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
   257             spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
   259             end;
   258             end;
   320         particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
   319         particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
   321         if particle <> nil then
   320         if particle <> nil then
   322             particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480);
   321             particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480);
   323         end;
   322         end;
   324 
   323 
   325     if (Gear^.Invulnerable) then
   324     if ((Gear^.Hedgehog^.Effects[heInvulnerable] <> 0)) then
   326         exit;
   325         exit;
   327 
   326 
   328     //if _0_6 < Gear^.dY then
   327     //if _0_6 < Gear^.dY then
   329     //    PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack)
   328     //    PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack)
   330     //else
   329     //else
   821                         dist:= hwRound(Distance(dx, dy));
   820                         dist:= hwRound(Distance(dx, dy));
   822                         dmg:= ModifyDamage(min(r - dist, 25), t);
   821                         dmg:= ModifyDamage(min(r - dist, 25), t);
   823                         end;
   822                         end;
   824                     if dmg > 0 then
   823                     if dmg > 0 then
   825                         begin
   824                         begin
   826                         if (not t^.Invulnerable) then
   825                         if t^.Hedgehog^.Effects[heInvulnerable] = 0 then
   827                             ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet)
   826                             ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet)
   828                         else
   827                         else
   829                             Gear^.State:= Gear^.State or gstWinner;
   828                             Gear^.State:= Gear^.State or gstWinner;
   830 
   829 
   831                         DeleteCI(t);
   830                         DeleteCI(t);
   917             if (Ammo^.Kind = gtDrill) then
   916             if (Ammo^.Kind = gtDrill) then
   918                 begin
   917                 begin
   919                 Ammo^.Timer:= 0;
   918                 Ammo^.Timer:= 0;
   920                 exit;
   919                 exit;
   921                 end;
   920                 end;
   922             if (not Gear^.Invulnerable) then
   921             if Gear^.Hedgehog^.Effects[heInvulnerable] = 0 then
   923                 begin
   922                 begin
   924                 if (Ammo^.Kind = gtKnife) and (tmpDmg > 0) then
   923                 if (Ammo^.Kind = gtKnife) and (tmpDmg > 0) then
   925                     for j:= 1 to max(1,min(3,tmpDmg div 5)) do
   924                     for j:= 1 to max(1,min(3,tmpDmg div 5)) do
   926                         begin
   925                         begin
   927                         VGear:= AddVisualGear(hwRound(Ammo^.X-((Ammo^.X-Gear^.X)/_2)), hwRound(Ammo^.Y-((Ammo^.Y-Gear^.Y)/_2)), vgtStraightShot);
   926                         VGear:= AddVisualGear(hwRound(Ammo^.X-((Ammo^.X-Gear^.X)/_2)), hwRound(Ammo^.Y-((Ammo^.Y-Gear^.Y)/_2)), vgtStraightShot);