Author Topic: Dont can set health to + 150?  (Read 2377 times)

0 Members and 1 Guest are viewing this topic.

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Dont can set health to + 150?
« 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.
« Last Edit: May 15, 2016, 04:43:55 pm by soldat-game »

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Dont can set health to + 150?
« Reply #1 on: May 15, 2016, 05:37:10 pm »
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:
Code: [Select]
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.
« Last Edit: May 15, 2016, 05:42:25 pm by FalconPL »
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: Dont can set health to + 150?
« Reply #2 on: May 16, 2016, 10:10:10 am »
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.
« Last Edit: May 16, 2016, 10:15:30 am by soldat-game »

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Dont can set health to + 150?
« Reply #3 on: May 16, 2016, 12:10:23 pm »
No, use the code above.
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: Dont can set health to + 150?
« Reply #4 on: May 16, 2016, 03:28:44 pm »
Code: [Select]
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
« Last Edit: May 16, 2016, 04:54:34 pm by soldat-game »

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: Dont can set health to + 150?
« Reply #5 on: May 17, 2016, 01:53:09 am »
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
« Last Edit: May 17, 2016, 01:54:56 am by soldat-game »