0 Members and 1 Guest are viewing this topic.
const MAXHEALTH = 150; // or 65 if realistic is ON MYMAXHEALTH = 1337; // whatevertype TMyPlayer = record Health: Integer; end;var MyPlayers: array [1..32] of TMyPlayer;... some code to initialize Health on respawn ...function OnDamage(Shooter, Victim: TActivePlayer; Damage: Integer; BulletId: Byte): Integerbegin MyPlayers[Victim.ID].Health := MyPlayers[Victim.ID].Health - Damage; Result := Victim.Health - MyPlayers[Victim.ID].Health * MAXHEALTH / MYMAXHEALTH;end; var i: Byte;begin for i:=1 to 32 do Players[i].OnDamage := @OnDamage;end.
unit Test;interfaceimplementationvar Decl: byte;const FullHeal = 150; MaxHealth = 65;varPlayerHealth: array [1..32] of integer;function HeadShootKill(Shooter, Victim: TActivePlayer; Damage: Integer; Bullet: byte): Integer;var s: integer;begin PlayerHealth[Victim.ID] := (PlayerHealth[Victim.ID] - Damage); S:=FullHeal; if (PlayerHealth[Victim.ID]<1) then Result := (Victim.Health*200) else Result := Round(Victim.Health - (single(PlayerHealth[Victim.ID] * MaxHealth)/single(s)));end;procedure OnAfterRespawn(Player: TActivePlayer);begin PlayerHealth[Player.ID]:=FullHeal;end;procedure AppOnIdleS2(Ticks: integer);var i: byte;begin for i:= 1 to 32 do if (Players[i].Active) then begin if (Players[i].Team<5) then begin if (PlayerHealth[i]>0) then Players[i].BigText(32,'Heal: '+inttostr(Round((PlayerHealth[i]/150.0)*100))+'%',40,$FD3C20,0.055,12,395) else Players[i].BigText(32,'Heal: 0%',40,$FD3C20,0.055,12,395); end; end;end;initializationbegin Game.TickThreshold := 1; Game.OnClockTick := @AppOnIdleS2; for Decl := 1 to 32 do begin Players[Decl].OnDamage := @HeadShootKill; Players[Decl].OnAfterRespawn := @OnAfterRespawn; end;end;finalization;end.