Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: y0uRd34th on February 28, 2009, 03:04:20 pm

Title: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on February 28, 2009, 03:04:20 pm
Whats the best way for Damage Multipliers (Input/Output)?
Code: [Select]
Result := Damage * Output[ID] * Input[ID];
 or
Result := Damage * (Output[ID] - Input[ID]);
Something like that, but should i use Single or Integers, what's better?
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: Hacktank on February 28, 2009, 04:49:51 pm
Code: [Select]
Result := round(MULTIPLYER * strtofloat(inttostr(Damage)));Use singles for the multiplyer.
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: iDante on February 28, 2009, 09:07:18 pm
What are you trying to do?
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on March 01, 2009, 04:16:56 am
A little Zombie script, maybe i make a Survival.
Wanna make better Bots but for that i need the Multiplier thing and i was not sure what's the best way is..

Quote from: Hacktank
Code: [Select]
Result := round(MULTIPLYER * strtofloat(inttostr(Damage)));Use singles for the multiplyer.

Why so Complex, why you don't use 'IntToFloat'? :D
But my other Problem is that i want to make Input and Output, and im not sure how..
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: tk on March 01, 2009, 04:21:36 am
Quote
Result := round(MULTIPLYER * strtofloat(inttostr(Damage)));
you dont have to use these functions
Result := Round(MULTIPLER * Damage) is enough.

use singles
for example:
Output[shooter] := 1.12;
Input[victim] := 0.93;
Result := Round(Damage * Output[shooter] * Input[victim]);
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on March 01, 2009, 05:14:41 am
Thanks will try it out directly!

Umm, tried some things but whenever I do:
Code: [Select]
...
if Damage < 5000 then
dec(HealthLeft[Victim],Round(Damage * Bot[Shooter].DamageOutput * Bot[Victim].Input));
else
dec(HealthLeft[Victim],Round(Damage * Bot[Shooter].DamageOutput * Bot[Victim].Input / 75));
...

It won't work Damage always goes to 0...
I don't know why, any ideas?
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: danmer on March 01, 2009, 04:21:09 pm
first of all, if you have "else" after a single line, there should be no semicolon. Secondly, we have no idea what HealthLeft[] is, so please tell us.
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on March 02, 2009, 08:07:30 am
-> HealthLeft: Array [1..32] of Integer;
I've made a script which makes Bots stronger (Like Gizd Special Bots Script: Found here (http://forums.soldat.pl/index.php?topic=30292.0))

Quote from: danmer
first of all, if you have "else" after a single line, there should be no semicolon.
Yes, I often forget it^^

But my Problem is that it deals 0 Damage to the Bots and for me all.



Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: Gizd on March 02, 2009, 09:04:10 am
Paste whole script, because this part is just decreasing bot's fake hp which doesn't affect damage...
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: danmer on March 02, 2009, 09:47:15 am
you have to have this line in the end of onplayerdamage (just a guess since we dont have the whole procedure yet):
Code: [Select]
result := damage;since if you dont have that string, onplayerdamage will do no actual damage :|
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on March 02, 2009, 12:27:53 pm
I have but the Bots have more Health then 150 i set up some things and i want to decrease it and that wont work, also it works but ingame it wont decrease their Health.

->dec(HealthLeft[Victim],Round(Damage * Bot[Shooter].DamageOutput * Bot[Victim].Input));
And I'm more than sure that this correct is!

Code: [Select]
function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
begin
   Result := Damage;
   if Assignable(Victim) then begin
    if HealthLeft[Victim] > 0 then begin
      Result := -Damage;
      if Damage < 5000 then begin
        dec(HealthLeft[Victim],Damage);
      end else begin
        dec(HealthLeft[Victim],Round(Damage/75));
      end;
      if Bot[Victim].ShowHealth then ShowHealth(Victim,Shooter);
      if HealthLeft[Victim] < 1 then DoDamageBy(Victim,Shooter,500);
    end;
  end;
end;
That's the actually one i use..
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: danmer on March 02, 2009, 02:40:11 pm
well... since you do DoDamageBy() in the end of onplayerdamage, it just call onplayerdamage again and just decreases the fake health variable again and again without actually damaging the bot. Make it something like Damage := 4000 instead, so the onplayerdamage function actually kills the bot when it finishes running
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on March 03, 2009, 07:28:55 am
Yes, but it's only killing it when his HP < 1 and not bigger.
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: danmer on March 04, 2009, 06:24:22 am
its not killing, its just making the function call itself again without doing any *actual* damage
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on March 04, 2009, 08:39:41 am
hmm, i don't think so because without these dmgmultipliers its working >.<
The Problem is that the HealthLeft[] will not decreased if i modify the dmg ;/
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: iDante on March 04, 2009, 10:25:31 am
Take a look at this very simple script that I wrote. I think it has what you are trying to do in it, if not then at least that is how I do it.
http://soldatcentral.com/index.php?page=script&f=6
Title: Re: Damage Multipliers - What's the best Way to do it?
Post by: y0uRd34th on March 04, 2009, 11:27:25 am
Ya, very simple one, but youre only adding Damage and I want to multiple it with a Single also percentes. Although Thanks iDante.