Author Topic: procent function needed for dmage incrase  (Read 1756 times)

0 Members and 3 Guests are viewing this topic.

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
procent function needed for dmage incrase
« on: April 18, 2009, 04:43:44 am »
Hi there!

I am writing a big zombie script, and now using normal
Code: [Select]
Result := Damage + DI[Shooter]; // DI = Damage IncraseI wanted to change this to procent, like: "Result := Damge + (DI procent of Damage);

Somebody know howto use '%' or is there any function mde by you ?

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: procent function needed for dmage incrase
« Reply #1 on: April 18, 2009, 05:00:46 am »
Just need a bit math. Nothing else.
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: procent function needed for dmage incrase
« Reply #2 on: April 18, 2009, 05:07:29 am »
You're 17 xmRipper, so i think you made school already. Look at Sin & Cos, it comes with the 9 Class or not?

Here we go:
Code: [Select]
Damage := Damage + Round(Damage * DI[Shooter] / 100);Should work.

If you want to do sth. in percent just divide it through 100.
1% of 100: 100/100 = 1^^
Took me some Time to find that out some time ago..

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: procent function needed for dmage incrase
« Reply #3 on: April 18, 2009, 05:14:17 am »
simple and useful method for damage multipliers:

var OutputPercent, InputPercent: array [1..32] of integer; //global var

//...
  OutputPercent[1] := 132; //%
  InputPercent[2] := 87; //%
//...


function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Result := Round(Damage * OutputPercent[shooter] * InputPercent[victim] / 10000);
end;

If player 1 does for example 16 dmg to player 2, Damage will be 16 * 132 * 87 / 10000 = ~18

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: procent function needed for dmage incrase
« Reply #4 on: April 18, 2009, 05:19:25 am »
Since we already by this theme, how to do 132,7 as Damage Modifier?

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: procent function needed for dmage incrase
« Reply #5 on: April 18, 2009, 05:55:36 am »
i think its not possible.
You have to save this in other var, and for output use Round(Value: Single): Integer;
and thanks for your function :) ;)
« Last Edit: April 18, 2009, 05:57:22 am by LORD KILLA »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: procent function needed for dmage incrase
« Reply #6 on: April 18, 2009, 07:12:50 am »
It is possible -> Avarax & Dnmr's Hexer Mod.
Maybe using Single instead of the Integers there:
Code: [Select]
  OutputPercent[1] := 132; //%
  InputPercent[2] := 87; //%
....
  Result := Round(Damage * OutputPercent[shooter] * InputPercent[victim] / 10000);
When i have some time i test it.
« Last Edit: April 18, 2009, 12:57:37 pm by y0uRd34th »

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: procent function needed for dmage incrase
« Reply #7 on: April 18, 2009, 07:27:25 am »
@ swompie: you could do it either way (by using singles or having the percentage numbers 10 times higher and then dividing by 100 times more)


tk's way is by far the most simple and efficient i've seen. Except that you could do this to (i guess) save some cpu time ::)

Result := Damage * OutputPercent[shooter] * InputPercent[victim] DIV 10000;


Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: procent function needed for dmage incrase
« Reply #8 on: April 18, 2009, 01:16:25 pm »
Good to know. Thanks.
But:
Code: [Select]
Result := Damage * OutputPercent[shooter] * InputPercent[victim] DIV 10000;
Does div Round?
Just searched a bit and found that it rounds :D

I got totally stuck while calculating that:
Code: [Select]
Damage = 100  //base damage
Out    = 150    //150%
In     =  50      //50%

Damage * Out * In / 10.000
750.000 / 10.000 = 75
Quote
..10 times higher and then dividing by 100 times more
Code: [Select]
Damage = 100  //base damage
Out    = 1.500  // 150%
In     = 500      // 50%

Damage * Out * In / 1.000.000
75.000.000 / 1.000.000 = 75
(The points are just for a better overview)
How can the Result 75 if Output is 150% and Input 50%.
also both must give +0damage.
I calculated that 3 times..
Do i think wrong or eh?
« Last Edit: April 18, 2009, 01:19:14 pm by y0uRd34th »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: procent function needed for dmage incrase
« Reply #9 on: April 18, 2009, 01:52:56 pm »
50% from 150 is 75

Advanced calculations:
50% from 100 is 50.
150% from 50 is 50 + half from 50 = 50 + 25 = 75.

Code: [Select]
Damage * (Out - In)
« Last Edit: April 18, 2009, 01:58:53 pm by Gizd »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: procent function needed for dmage incrase
« Reply #10 on: April 18, 2009, 02:03:07 pm »
Ok i think i got it.

dnmr:
 If i do: 100 * 1009 * 1000 div 1000000
 It ouputs 100, which normally should be 101 -> 100,9%
 Is it just the scriptcore which rounds false?
 
« Last Edit: April 18, 2009, 02:28:47 pm by y0uRd34th »

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: procent function needed for dmage incrase
« Reply #11 on: April 18, 2009, 05:52:42 pm »
nah, just looks like integers are always rounded down

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: procent function needed for dmage incrase
« Reply #12 on: April 19, 2009, 02:55:14 am »
hmm bad  :-\

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: procent function needed for dmage incrase
« Reply #13 on: April 19, 2009, 06:10:26 am »
OK.
My 700 lines script works so far very well
I just have to add some skills, and thanks for your help (I've choosen INI save/load and it works ;) )

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: procent function needed for dmage incrase
« Reply #14 on: April 19, 2009, 08:03:26 am »
hmm bad  :-\

No not bad, standard programming. A simple conversion from a float type to an integer type will always be truncated. A very easy solution is to add .5 before converting (probably what round does for you).
Come join: EliteCTF
Listen to: My Music

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: procent function needed for dmage incrase
« Reply #15 on: April 22, 2009, 11:47:53 am »
I think i should post the script i made.
My script has got already over 1000 lines, and you can join it here: 84.248.57.44:60001
But i am not sure about to post it compiled/uncompiled   =\
Say me some good reasons...
« Last Edit: April 22, 2009, 11:50:42 am by LORD KILLA »

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: procent function needed for dmage incrase
« Reply #16 on: April 22, 2009, 02:06:30 pm »
How would you like to post "compiled" script?

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: procent function needed for dmage incrase
« Reply #17 on: April 22, 2009, 05:07:04 pm »
You can only post uncompiled scripts, as (afaik) there is no way to get the compiled stuff from the server.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: procent function needed for dmage incrase
« Reply #18 on: April 22, 2009, 07:06:54 pm »
How would you like to post "compiled" script?
Yeah, what iDante said
but if you want to post it compiled so the source is unavailable, I believe you can contact EnEsCe to get your script encrypted if you wish.

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: procent function needed for dmage incrase
« Reply #19 on: April 23, 2009, 01:01:19 pm »
I have heard somewhere its able somehow to compile it and share it that way.
Nevermind.