Author Topic: OnDamage Event Vest ERROR  (Read 5426 times)

0 Members and 1 Guest are viewing this topic.

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
OnDamage Event Vest ERROR
« on: June 27, 2017, 04:01:46 am »
OnDamage Event Vest ERROR
If player have smal vest valute example 1 and will be hit.
Victim.Vest is <=0, But the player's damage is calculate as if the player was still wearing a vest.
Next bug: if player have vest damage isnt is single.
Next bug: if player have vest vest valute isnt is single.

Real Damage:
Code: [Select]
function RealDMG(nonreal:single):single;
var real,real2:string;
begin
real := floattostr(nonreal);
real2 := Copy(GetPiece(real,'.',1),1,2);
Result:=strtofloat(GetPiece(real,'.',0)+'.'+real2);
end;
Code: [Select]
ShootSpeed := sqrt((Map.Bullets[BulletId].VelX*Map.Bullets[BulletId].VelX)+(Map.Bullets[BulletId].VelY*Map.Bullets[BulletId].VelY));
c := RealDMG(WeaponsINI.ReadFloat(GWN(WeaponID),'Damage',0)*ShootSpeed*WeaponsINI.ReadFloat(GWN(WeaponID),'ModifierHead',0));
c2 := RealDMG(WeaponsINI.ReadFloat(GWN(WeaponID),'Damage',0)*ShootSpeed*WeaponsINI.ReadFloat(GWN(WeaponID),'ModifierChest',0));
c3 := RealDMG(WeaponsINI.ReadFloat(GWN(WeaponID),'Damage',0)*ShootSpeed*WeaponsINI.ReadFloat(GWN(WeaponID),'ModifierLegs',0));
if (iif(Victim.Vest>0,Round(RealDMG(0.25*c)),c)=RealDMG(Damage)) then DrawTextEx(Shooter.ID,108,'Headshoot!',120,$F15D70,0.055,12,385) else
if (iif(Victim.Vest>0,Round(RealDMG(0.25*c2)),c2)=RealDMG(Damage)) then DrawTextEx(Shooter.ID,108,'BODY!',120,$F15D70,0.055,12,385) else
if (iif(Victim.Vest>0,Round(RealDMG(0.25*c3)),c3)=RealDMG(Damage)) then DrawTextEx(Shooter.ID,108,'LEGS!',120,$F15D70,0.055,12,385) else begin
WriteLn(Floattostr(c)+'  '+floattostr(Round(0.25*c))+'  '+Floattostr(damage)+'  '+Floattostr(RealDMG(Damage))+'  '+iif(Victim.Vest>0,'1','0')+'  Headshoot');
WriteLn(Floattostr(c2)+'  '+floattostr(Round(0.25*c2))+'  '+Floattostr(damage)+'  '+Floattostr(RealDMG(Damage))+'  '+iif(Victim.Vest>0,'1','0')+' Bodyshoot');
WriteLn(Floattostr(c3)+'  '+floattostr(Round(0.25*c3))+'  '+Floattostr(damage)+'  '+Floattostr(RealDMG(Damage))+'  '+iif(Victim.Vest>0,'1','0')+' Legsshoot');
end;
« Last Edit: June 27, 2017, 04:04:58 am by soldat-game »

Offline NiCeShOoT|GuY

  • Major(1)
  • Posts: 21
Re: OnDamage Event Vest ERROR
« Reply #1 on: June 27, 2017, 05:07:40 am »
May I ask what you were trying to do with function RealDMG(nonreal: single):single ?

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: OnDamage Event Vest ERROR
« Reply #2 on: June 27, 2017, 06:36:49 am »
cuts single example 2.9108281238982 result 2.91 Not rounding

Offline NiCeShOoT|GuY

  • Major(1)
  • Posts: 21
Re: OnDamage Event Vest ERROR
« Reply #3 on: June 27, 2017, 06:58:02 am »
Nice idea, to shrink the annoyingly long single value.

Can also use RoundTo(); .
http://www.askingbox.com/tutorial/delphi-lazarus-3-ways-to-round-a-number-to-x-decimal-places

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: OnDamage Event Vest ERROR
« Reply #4 on: June 27, 2017, 07:25:50 am »
U be idiot?

Offline NiCeShOoT|GuY

  • Major(1)
  • Posts: 21
Re: OnDamage Event Vest ERROR
« Reply #5 on: June 27, 2017, 07:28:54 am »
Victim.Vest is <=0, But the player's damage is calculate as if the player was still wearing a vest.
Next bug: if player have vest, damage isnt single.
Next bug: if player have vest, vest value isnt  single.



Well, you used Round(), round means turn whatever float value into an integer. if value = 7.13245678, Round(value) = 7
https://www.freepascal.org/docs-html/rtl/system/round.html

Code: [Select]
floattostr(Round(0.25*c))

c:single
Calculated damage by yourself, not including vest value in calculation process,
perfectly normal to see digits after Integer (i.e 28.3999)


Damage:Single
calculated by soldat server,
"Soldat Server 2.8.1 now accept damage as Single instead of Integer",
may suggest that in previous version soldat classes only accept damage value as integer, which means soldat health/damage system are all based on rounded values (Integers).
Should not be surprised to see they haven't switch the whole system into using Single only, because it could be a tedious work to do.
So frankly it isn't an Error.


« Last Edit: June 27, 2017, 07:52:35 am by NiCeShOoT|GuY »

Offline NiCeShOoT|GuY

  • Major(1)
  • Posts: 21
Re: OnDamage Event Vest ERROR
« Reply #6 on: June 27, 2017, 07:32:06 am »
Just trying to help.
You could also use Pascal built-in function round() like below:
x := 1.2345;
k := round(x*100)/100;    // 1.23
k := round(x*1000)/1000;  // 1.235


Reference:
http://www.askingbox.com/tutorial/delphi-lazarus-3-ways-to-round-a-number-to-x-decimal-places

 
U be idiot?
« Last Edit: June 27, 2017, 07:55:46 am by NiCeShOoT|GuY »

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: OnDamage Event Vest ERROR
« Reply #7 on: June 27, 2017, 09:13:53 am »
Just trying to help.
You could also use Pascal built-in function round() like below:
x := 1.2345;
k := round(x*100)/100;    // 1.23
k := round(x*1000)/1000;  // 1.235


Reference:
http://www.askingbox.com/tutorial/delphi-lazarus-3-ways-to-round-a-number-to-x-decimal-places

 
U be idiot?
Round and roundto the number is rounded. I do not want to round numbers!

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: OnDamage Event Vest ERROR
« Reply #8 on: June 27, 2017, 09:16:28 am »
Victim.Vest is <=0, But the player's damage is calculate as if the player was still wearing a vest.
Next bug: if player have vest, damage isnt single.
Next bug: if player have vest, vest value isnt  single.



Well, you used Round(), round means turn whatever float value into an integer. if value = 7.13245678, Round(value) = 7
https://www.freepascal.org/docs-html/rtl/system/round.html

Code: [Select]
floattostr(Round(0.25*c))

c:single
Calculated damage by yourself, not including vest value in calculation process,
perfectly normal to see digits after Integer (i.e 28.3999)


Damage:Single
calculated by soldat server,
"Soldat Server 2.8.1 now accept damage as Single instead of Integer",
may suggest that in previous version soldat classes only accept damage value as integer, which means soldat health/damage system are all based on rounded values (Integers).
Should not be surprised to see they haven't switch the whole system into using Single only, because it could be a tedious work to do.
So frankly it isn't an Error.


If a player has a vest, then damage is nott single. The value of the vest is not counted as well single.
https://wiki.soldat.pl/index.php/TPlayer.Vest

Offline NiCeShOoT|GuY

  • Major(1)
  • Posts: 21
Re: OnDamage Event Vest ERROR
« Reply #9 on: June 28, 2017, 12:57:32 am »
Same story, soldat dev team only casted Integer to Single.
Thats why you see 7.000000

As long as the game works, it seems good to me.