Author Topic: Problem with bots and additional HP.  (Read 830 times)

0 Members and 3 Guests are viewing this topic.

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
Problem with bots and additional HP.
« on: March 13, 2010, 09:28:10 pm »
I made a RPG mod for Dodgeball, I have there a bot with 10k HP. It all works great as long as bot is getting hit with knives, plain bullets, etc....
BUT when he's hit with m79 grenade and base Damage exceeds 150 (standard amount of Health) he is getting instantly killed. I've tried modifying OnPlayerDamage() in many different ways even changing Damage and Result to 0 but he's still getting killed. It's like server is totally skipping OnPlayerDamage() and killing bot regardless of any damage modifications.

Code: [Select]

tmpDmg:=Damage;

...

Lots of tmpDmg modifications according to classes, skills, etc.

...

if(Victim=Boss)then
begin
if(round(tmpDmg)<=Players[Victim].HP)then
begin
Players[Victim].HP:=Players[Victim].HP-round(tmpDmg);
Result:=0;
end
else
begin
NewDmg:=round(tmpDmg)-Players[Victim].HP;
Players[Victim].HP:=0;
Result:=NewDmg;
end;
end;

After that shot with m79 bot's HP is decreased by the tmpDmg amount but his real Health drops to -400. I repeat: it only happens on m79 grenade hit (and maybe some other explosives but I do not use them in my mod) and when Damage >=150 even when OnPlayerDamage() Result=0.

Any ideas?

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Problem with bots and additional HP.
« Reply #1 on: March 14, 2010, 04:03:49 am »
try putting this right in the beginning of onplayerdamage (straight after 'begin')

Code: (pascal) [Select]
  if (Damage > 4000) then
    Damage := 200;

this has worked for me, and im comfortable with having m79/law damage as 200. But if you want it to be different... maybe you'll find some better dark magic that suits your needs

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Problem with bots and additional HP.
« Reply #2 on: March 14, 2010, 05:44:05 am »
Yeah, if you wanna reduce the M79/LAW damage go with dnmr's code.
If you want to prevent M79/LAW instakills use some way of this:
Code: (pascal) [Select]
var PreventDamage: boolean;
begin

  PreventDamage := false;

  if Damage > 4000 then // You can also check if the Shooter carrys a M79/LAW, but that's not that good since he can change the weapons
    PreventDamage := true;

  // Here goes the fake HP calculating

  if PreventDamage then
    Result := -1337
  else Result := Damage;

end;
I think you get what I mean :D

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Problem with bots and additional HP.
« Reply #3 on: March 14, 2010, 06:27:29 am »
Code: (pascal) [Select]
var PreventDamage: boolean;
begin

  PreventDamage := false;

  if Damage > 4000 then // You can also check if the Shooter carrys a M79/LAW, but that's not that good since he can change the weapons
    PreventDamage := true;

  // Here goes the fake HP calculating

  if PreventDamage then
    Result := -1337
  else Result := Damage;

end;
Code: [Select]
if Damage > 4000 then Result:= -1337 else Result:= Damage;

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
Re: Problem with bots and additional HP.
« Reply #4 on: March 15, 2010, 01:24:34 pm »
Setting Result to negative value seems to work. Thx.