Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: soldat-game on May 15, 2016, 04:40:30 pm
-
Dont can set health to + 150? player.damage(ID, -1000); dont work this change to max player healt :< and as usual, once it worked now not..
then appeared life bar as 0 but work.. if u decide repair this bug plese the bar to just showed full hp.
-
Somebody added sanity checks at the end of damage functions to prevent the thing you're talking about. Nope, I don't think it's coming back.
If you want player to have more health just store it yourself and just make sure you keep "soldat health" in sync.
Like this:
const
MAXHEALTH = 150; // or 65 if realistic is ON
MYMAXHEALTH = 1337; // whatever
type
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): Integer
begin
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.
-
I came up this, but do not you think it's a little unnecessary code? I do not want argue but it was to be info that work not work now.
-
No, use the code above.
-
unit Test;
interface
implementation
var Decl: byte;
const
FullHeal = 150;
MaxHealth = 65;
var
PlayerHealth: 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;
initialization
begin
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.
Try this code in realistic mode. and step on hurt polygon
https://www.youtube.com/watch?v=Tb9Km823n74
For debug code:
http://pastebin.com/D3T5Q1r8
-
with my test results the polygon hurtful dont send damage to function ondamage. On realistic send 10 damage if is this damage which inflicts damage by killing