generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Damage formula for RPG (math problem)

Previous Thread :: Next Thread 
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
31 Jul 2013 01:28 PM
I am currently working on an RPG where you gain exp by killing mobs.
When you gained enough exp you will gain a level and get 3 skill points.
With the skill points people can improve their skills which are hitpoints, strenght, magic, ranged, defence (I will just start with just strenght, hitpoints and defence for an open alpha which might be open in a month or something).

Also as in every RPG you can buy swords, swords require a level to be equipped and do a different amount of damage.

Now the damage the weapon does must be a formula between the base damage of the sword and the strenght of the wearer.

This is my current formula:
damage.Value = basedmg.Value + (basedmg.Value * ( 1 + strenght.Value / 99 ) )

Example:
If the base dmg is 10 and the strenght is 0 (will be 1 at start) then you would hit 10.
If your strenght is 99 then you will hit 20.

My problem is that I don't want them to be strenght 99 before they hit 20.
They should be able to hit that amount if their strenght is 8 and if they are higher level they keep hitting 20.
So how could I make this formula so it has a max damage of 20 which he hits at lvl 8 strenght. (should use a value called maxlevel and the max damage is always twice the basedmg)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 01:35 PM
base damage * 1.05 ^ (strength/defence)?

There will most likely be better curves than this.
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
31 Jul 2013 01:59 PM
defence shouldn't be evolved.
Only the base damage, max damage and strenght.

I am not really wanting a curve but a straight one that ends flat.
Level 1 = 10 damage
Level 4 = 15 damage
Level 8 = 20 damage
Level 9 = 20 damage
Level 5645 = 20 damage
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:01 PM
Oh. I don't know. Nothing ever explains these things...
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
31 Jul 2013 02:02 PM
I know that it is possible to be put in a formula, I just don't find how lol
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
31 Jul 2013 02:04 PM
If you find it please reply, I will try seek it on my TI-84 calculator
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:07 PM
x = tan y would be sec^2(x)/20, I think...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:07 PM
or maybe its 20sec^2x

IDK. But its one of those.

sec = 1/cos(x)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:08 PM
damage = base * maxmultiplier * (1/cos(damage))^2
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:09 PM
d/dx tan(x)

Oh, it peaks at pi/2. Factor that in.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:12 PM
Or maybe its

damage = base * pi * (1/cos(pi * damage / (maxMultiplier * 2)))^2 / (maxMultiplier * 2)

...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:12 PM
http://www.wolframalpha.com/input/?i=d%2Fdx+tan%28x%2F%2820%2F%28pi%2F2%29%29%29+from+0+to+20
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
31 Jul 2013 02:17 PM
It is heading in the right direction but still not correct as it should be.

On my calculator I managed him to plot the correct graph of the damage.
I just can't find the right function to find the formula. We only learned to work with curves and straight ones, not straight ones changing slope at a point...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:22 PM
I have no idea, sorry...
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
31 Jul 2013 02:25 PM
Thanks for help anyways
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:28 PM
(str - damage) / (2 ^ (str - damage)) + damage ^ 2

Try that.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:31 PM
...Although it goes to mega negatives...

:/

I am stumped... I need a good formula, too, and need to know.
Report Abuse
clc02 is not online. clc02
Joined: 30 Dec 2007
Total Posts: 7393
31 Jul 2013 02:35 PM
Let strength start at 0 (one in your game)
let damage at 7 (eight in your game) be the max, with a damage of 20.
str = 0 --This can be any number
damage = 10+str*10/7
if damage >20 then damage=20 end


It's a pointwise function/slope.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:36 PM
base * (1 + (strength/(strength+1)) --Maximum 2x damage when strength is infinite.
Report Abuse
clc02 is not online. clc02
Joined: 30 Dec 2007
Total Posts: 7393
31 Jul 2013 02:36 PM
If you actually do start at one just change it to damage = (str-1)*10/7
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:37 PM
base * (1 + (strength/(strength+1)))

I wish the forums had the red underline...
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
31 Jul 2013 02:41 PM
d/dx[tan(x)] is sec^2 x, or 1/math.cos(x)^2. I just graphed that, Notunknown99, it is definitely not accommodated to his liking.
Seriously, someone should have just called me for this.
Discontinuity would do just fine, honestly.

if (lvl < 4) then y=(-1/10) * x^2 + 1.5 * x + 8.7 end
if (lvl > 3) then y=(-1/58) * x^2 + 1.5 * x + 8.7 end
if (lvl >= 9) then y=20 end

I can't make it all one function without implicit antiderivation.
Report Abuse
DaneelOlivaw is not online. DaneelOlivaw
Joined: 14 Apr 2012
Total Posts: 661
31 Jul 2013 02:41 PM
If I read your first post correctly, then you're not looking for just math, but a comparison as well. Like "if playerLVL => swordLVL then".

The math I think would be something like below if the max damage would always be double the base damage.

DMG = BaseDMG + (BaseDMG * ((playerLVL - swordLVL) / (swordLVL - maxLVL))
if DMG > BaseDMG * 2 then DMG = BaseDMG * 2

It's a little bit rough, but I think that would work out. I'm not quite sure how you want to implement strength, though...
Report Abuse
clc02 is not online. clc02
Joined: 30 Dec 2007
Total Posts: 7393
31 Jul 2013 02:41 PM
Notunknown, that's not what he asked for. That would gradually approach 2x the base with diminishing returns. He just wants any progress to stop after 2x the damage at strength 7 (8)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
31 Jul 2013 02:43 PM
You can do

base * (0.5 + (strength/(strength + defence))) if you want it to be 0.5 damage when strength == 0 and defence ~= 0, 1.5 when strength ~= 0 and defence == 0 and 0 < mult < 1 when strength ~= 0 and defence ~= 0, if defence is later factored in.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image