hedgewars/uGearsUtils.pas
changeset 12937 a84a05719454
parent 12920 21827fc9ca98
child 13148 ec165591a1ee
equal deleted inserted replaced
12936:b9904380ce26 12937:a84a05719454
    29 
    29 
    30 function  ModifyDamage(dmg: Longword; Gear: PGear): Longword;
    30 function  ModifyDamage(dmg: Longword; Gear: PGear): Longword;
    31 procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
    31 procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
    32 procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword);
    32 procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword);
    33 procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource);
    33 procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource);
       
    34 procedure HHHeal(Hedgehog: PHedgehog; healthBoost: Longword; showMessage: boolean; vgTint: Longword);
       
    35 procedure HHHeal(Hedgehog: PHedgehog; healthBoost: Longword; showMessage: boolean);
    34 procedure CheckHHDamage(Gear: PGear);
    36 procedure CheckHHDamage(Gear: PGear);
    35 procedure CalcRotationDirAngle(Gear: PGear);
    37 procedure CalcRotationDirAngle(Gear: PGear);
    36 procedure ResurrectHedgehog(var gear: PGear);
    38 procedure ResurrectHedgehog(var gear: PGear);
    37 
    39 
    38 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline;
    40 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline;
   261 else
   263 else
   262     ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_01);
   264     ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_01);
   263 end;
   265 end;
   264 
   266 
   265 procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
   267 procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
   266 var s: ansistring;
   268 var vampDmg, tmpDmg, i: Longword;
   267     vampDmg, tmpDmg, i: Longword;
       
   268     vg: PVisualGear;
   269     vg: PVisualGear;
   269 begin
   270 begin
   270     if Damage = 0 then
   271     if Damage = 0 then
   271         exit; // nothing to apply
   272         exit; // nothing to apply
   272 
   273 
   286                 if vampDmg >= 1 then
   287                 if vampDmg >= 1 then
   287                     begin
   288                     begin
   288                     // was considering pulsing on attack, Tiy thinks it should be permanent while in play
   289                     // was considering pulsing on attack, Tiy thinks it should be permanent while in play
   289                     //CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric;
   290                     //CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric;
   290                     inc(CurrentHedgehog^.Gear^.Health,vampDmg);
   291                     inc(CurrentHedgehog^.Gear^.Health,vampDmg);
   291                     s:= IntToStr(vampDmg);
       
   292                     AddCaption(FormatA(trmsg[sidHealthGain], s), CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
       
   293                     RenderHealth(CurrentHedgehog^);
   292                     RenderHealth(CurrentHedgehog^);
   294                     RecountTeamHealth(CurrentHedgehog^.Team);
   293                     RecountTeamHealth(CurrentHedgehog^.Team);
   295                     i:= 0;
   294                     HHHeal(CurrentHedgehog, vampDmg, true, $FF0000FF);
   296                     while (i < vampDmg) and (i < 1000) do
       
   297                         begin
       
   298                         vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot);
       
   299                         if vg <> nil then
       
   300                             with vg^ do
       
   301                                 begin
       
   302                                 Tint:= $FF0000FF;
       
   303                                 State:= ord(sprHealth)
       
   304                                 end;
       
   305                         inc(i, 5);
       
   306                         end;
       
   307                     end
   295                     end
   308                 end;
   296                 end;
   309             if (GameFlags and gfKarma <> 0) and (GameFlags and gfInvulnerable = 0) and
   297             if (GameFlags and gfKarma <> 0) and (GameFlags and gfInvulnerable = 0) and
   310                (CurrentHedgehog^.Effects[heInvulnerable] = 0) then
   298                (CurrentHedgehog^.Effects[heInvulnerable] = 0) then
   311                 begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   299                 begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   353     tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color
   341     tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color
   354 AllInactive:= false;
   342 AllInactive:= false;
   355 HHGear^.Active:= true;
   343 HHGear^.Active:= true;
   356 end;
   344 end;
   357 
   345 
       
   346 // Play effects for hurt hedgehog
   358 procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource);
   347 procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource);
   359 begin
   348 begin
   360 if Hedgehog^.Effects[heFrozen] <> 0 then exit;
   349 if Hedgehog^.Effects[heFrozen] <> 0 then exit;
   361 
   350 
   362 if (Source = dsFall) or (Source = dsExplosion) then
   351 if (Source = dsFall) or (Source = dsExplosion) then
   375         0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack);
   364         0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack);
   376         1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack);
   365         1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack);
   377         2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack);
   366         2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack);
   378         3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack);
   367         3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack);
   379     end
   368     end
       
   369 end;
       
   370 
       
   371 {-
       
   372 Show heal particles and message at hog gear.
       
   373 Hedgehog: Hedgehog which gets the health boost
       
   374 healthBoost: Amount of added health added
       
   375 showMessage: Whether to show announcer message
       
   376 vgTint: Tint of heal particle
       
   377 -}
       
   378 procedure HHHeal(Hedgehog: PHedgehog; healthBoost: Longword; showMessage: boolean; vgTint: Longword);
       
   379 var i: LongInt;
       
   380     vg: PVisualGear;
       
   381     s: ansistring;
       
   382 begin
       
   383     if healthBoost < 1 then
       
   384         exit;
       
   385 
       
   386     if showMessage then
       
   387         begin
       
   388         s:= IntToStr(healthBoost);
       
   389         AddCaption(FormatA(trmsg[sidHealthGain], s), Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo)
       
   390         end;
       
   391 
       
   392     i:= 0;
       
   393     // One particle for every 5 HP. Max. 200 particles
       
   394     while (i < healthBoost) and (i < 1000) do
       
   395         begin
       
   396         vg:= AddVisualGear(hwRound(Hedgehog^.Gear^.X), hwRound(Hedgehog^.Gear^.Y), vgtStraightShot);
       
   397         if vg <> nil then
       
   398             with vg^ do
       
   399                 begin
       
   400                 Tint:= vgTint;
       
   401                 State:= ord(sprHealth)
       
   402                 end;
       
   403         inc(i, 5)
       
   404         end;
       
   405 end;
       
   406 
       
   407 // Shorthand for the same above, but with tint implied
       
   408 procedure HHHeal(Hedgehog: PHedgehog; healthBoost: Longword; showMessage: boolean);
       
   409 begin
       
   410     HHHeal(Hedgehog, healthBoost, showMessage, $00FF00FF);
   380 end;
   411 end;
   381 
   412 
   382 procedure CheckHHDamage(Gear: PGear);
   413 procedure CheckHHDamage(Gear: PGear);
   383 var
   414 var
   384     dmg: LongInt;
   415     dmg: LongInt;