Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 13 Jan 2014 08:59 PM |
Basically, it uses a function called findStatuses() that checks to see if the enemy contains any stringvalues called 'Effect', and if they do, it adds their values to a table. Based on that table, it modifies the damage accordingly.
Example: Base damage is 10 Enemy has an Effect with the value '40dmgpercinc' - 40% damage percentage increase Damage is now 14 Player has an Effect with the value '10damageup' - +10 flat damage increase Damage is now 24 Function returns 24.
Basically how it works. What I want is a more efficient way to do this, but there might not be IMO If you know a way, please reply
function damageModifiers(dmg, targ) local critcalc = math.ceil(math.random(1, 100)) if critcalc <= critprob then dmg = dmg*2.5; print("Critical Hit") end local effs = findStatuses(targ) local myeffs = findStatuses(char.Humanoid) local reflectFactor = 0 if effs ~= "Normal" then for _,v in pairs(effs) do if v == "Shielded" then dmg = math.ceil(dmg/2) end if v == "SuperShielded" then dmg = math.ceil(dmg/4) end if string.match(string.lower(v), "dmgpercreduc") then dmg = math.floor(dmg - (dmg*tonumber(string.sub(v, 1, 3))/100)) end if string.match(string.lower(v), "dmgpercinc") then dmg = math.ceil(dmg + (dmg*tonumber(string.sub(v, 1, 3))/100)) end if string.match(string.lower(v), "dmginc") then dmg = math.ceil(dmg + tonumber(string.sub(v, 1, 3))) end if string.match(string.lower(v), "dmgdec") then dmg = math.floor(dmg - tonumber(string.sub(v, 1, 3))) end if string.match(string.lower(v), "dmgrefl") then reflectFactor = math.ceil((string.sub(v, 1, 3))/100) end end end if myeffs ~= "Normal" then for _,v in pairs(myeffs) do if string.match(string.lower(v), "dmgpercup") then dmg = math.ceil(dmg + (dmg*tonumber(string.sub(v, 1, 3))/100)) end if string.match(string.lower(v), "dmgpercdown") then dmg = math.floor(dmg - (dmg*tonumber(string.sub(v, 1, 3))/100)) end if string.match(string.lower(v), "dmgup") then dmg = math.ceil(dmg + tonumber(string.sub(v, 1, 3))) end if string.match(string.lower(v), "dmgdown") then dmg = math.floor(dmg - tonumber(string.sub(v, 1, 3))) end end end if reflectFactor > 0 then char.Humanoid:TakeDamage(math.ceil(dmg*reflectFactor)) end return dmg end |
|
|
| Report Abuse |
|
|
transIate
|
  |
| Joined: 20 Jun 2013 |
| Total Posts: 2699 |
|
| |
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 13 Jan 2014 09:01 PM |
| 25th letter of the alphabet |
|
|
| Report Abuse |
|
|
Thaeh
|
  |
| Joined: 05 Feb 2011 |
| Total Posts: 7685 |
|
|
| 13 Jan 2014 09:02 PM |
the way you're doing it, no. there are simpler ways to do this, but you took the long route. |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 13 Jan 2014 09:03 PM |
I mean, it works fine and all I'm just lazy, so if you know a way, please explain |
|
|
| Report Abuse |
|
|
Thaeh
|
  |
| Joined: 05 Feb 2011 |
| Total Posts: 7685 |
|
|
| 13 Jan 2014 09:04 PM |
| you use a ton of functions for something that can be preset |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 13 Jan 2014 09:05 PM |
The idea is that the effects are never permanent Well, usually
Like, person drinks potion Gains 10% reduced damage effect
Not really sure how else I can do it Translate to 'dumb' for me if you can |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 13 Jan 2014 09:08 PM |
Or you can have number values within the character like:
dmgincrease.Value = 1.25
|
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 13 Jan 2014 09:09 PM |
Then I'd have to search for values of different names Makes one function shorter and the rest longer |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 13 Jan 2014 09:14 PM |
| I've done damage multiplier and nerfers, and your function looks ugly tbh. |
|
|
| Report Abuse |
|
|