ID:167564
 
Hi im having a little trouble with my stats.
For example, i have gotten a stat distribution from a tutorial and i put up defense. if i put enough def the monster starts taking -15 dmg or something on me, which heals me. How do u make it so that no matter how much def u get the lowest ammount of dmg it can take is 1 and it cant go under 1.

Problems with agi stat: when i put up agi my evade doesnt go up.

Problems with Accuracy: hit rate doesnt go up

all of these stats dont work and all i can get working is Strength.

Any Help would be appreciated.


if(damage < 0) damage = 1


I hope thats what you meant
In response to A.T.H.K
Nvm i found out where to put it myself. Thanks for all the help! But i still need to fix my accuracy and agi stats. Anyone know how to do it?
In response to A.T.H.K
A.T.H.K wrote:
if(damage < 0) damage = 1

I hope thats what you meant

Except that you probably want if(damage < 1)
In response to Noob360
anyone can help?
In response to Noob360
Oh please, you need to give more detail. We have no idea whatsoever how you made your code, so we have no idea whatsoever how we could fix it.
In response to Mysame
Mysame wrote:
Oh please, you need to give more detail. We have no idea whatsoever how you made your code, so we have no idea whatsoever how we could fix it.

Ok,

I have put this coding so it shows in the stat panel
Stat()
if(statpanel("Statistics"))
stat("Health","[Hp]/[MaxHp]")
stat("Magic","[Mp]/[MaxMp]")
stat("Level","[Level]")
for(var/statobj/s in statobjs)
stat(stat_convert(s.stat), s)
stat("Stat points: ", statpoints)
stat(null)
stat("Gold","[Gold]")
stat("Experience","[Exp]/[ExpReq]")
if(src == usr) statpanel("Inventory",src.contents)


Then i used this Stat Distribution System.

statobj
parent_type = /obj
var
mob/owner
// owner of the stat object
stat
// text string of what value you are increasing
value
// the value of the stat
stat_inc = 1
// how many statpoints it consumes to add 1 to the value


New(l, o, s)
/*
l = loc (null)
o = owner
s = stat name
*/


src.owner = o
src.stat = s

// set the owner, and stat variable

spawn()
Update()


proc
Update()
// call this every time your stats are changed (strength, defense, etc...)
value = owner.vars[stat]
name = "[value]"
suffix = "[stat_inc] points to increase"
/*
Update the value, name, and suffix
*/



StatIncrease(mob/M)
// use this when needed to increase the value by using stat points
if(src.owner == M)
// check if they own the stat object
if(M.statpoints >= stat_inc)
// check if they have enough stat points
M.statpoints -= stat_inc
Increase()

else
M << "You do not have enough stat points to increase your [stat_convert(stat)]."

Increase()
// use this to just increase the value if not neccessarily needing to use statpoints
value ++
owner.vars[stat] = value

if(!(owner.vars["[stat]lv"] % value))
stat_inc ++

Update()
// increase the stat_inc for every statlv it hits, then update


Click()
StatIncrease(usr)

// Increase gets called when clicked



skill
// some example skills used in the demo

parent_type = /obj

attack
name = "Attack"

fireball
name = "Fireball"

quickslash
name = "Quick Slash"

bigslash
name = "Big Slash"

ultimateattack
name = "Ultimate Attack"


mob
var
statpoints = 50000
str = 1
def = 1
int = 1
agi = 1
dex = 1


// for every 5 strength (by default), the stat point requirement increases by one
strlv = 5
deflv = 5
intlv = 5
agilv = 5
dexlv = 5
list
statobjs
// list of stat objects (/statobj)
skills = newlist(/skill/attack)
// skills

// learning skills

Login()
AddStats()
// tell the player to add the stats, and start the stat
// distribution when they log in

world << "[src] has joined the world."
..()

proc
StatDistribute()
var/credits = 10
var/list/stats = list("Strength"="str", "Defense"="def",
"Intelligence"="int", "Agility"="agi","Accuracy"="dex")

while(credits)
var/list/L = formated_stat_list(stats, src)
// create a formatted list to let the user see how much of a stat they have
var/i = input(src, "Customize stats. You have [credits] credits left.", "Stats") \
as null|anything in L
if(!i) break
// let them end whenever they want, if they want to miss out of free points :P
credits --
for(var/statobj/s in statobjs)
if(s.stat == L[i])
s.Increase()
// tell the statobj to increase the value that you inputted






// call this whenever you need to add the statpanels or stats.
// this must be called before StatDistribute, because the objects
// are relied on then.
AddStats()
statobjs = list()
var/list/slist = list("str","def","int","agi","dex")
for(var/i in slist)
src.statobjs += new /statobj (null, src, i)

proc
// the proc that formats the skill list to show its value

formated_stat_list(list/L, mob/M)
var/list/new_list = list()
for(var/i in L)
new_list["[i] -- [M.vars[L[i]]]"] = L[i]
return new_list

// a handy way to use parallel lists to convert stuff back and forth :)

stat_convert(t)
var/list/A = list("Strength","Defense","Intelligence","Agility","Accuracy")
var/list/B = list("str","def","int","agi","dex")
return (A[t] ? B[A.Find(t)] : A[B.Find(t)])

MonsterAttack(var/mob/Player/P,mob/monsters/C)
var/damage = rand (1,10)+usr.str - P.def
if(damage < 0) damage = 1
if(prob(100))
P.Hp -= damage
P<<"<font color= red><b>The enemy did [damage] damage to you!"
if(P.Hp <= 0)
P.Hp = P.MaxHp
world << "<b>[P] got killed by [usr]!"
P.loc = locate(1,1,1)
else
..()
else
P<<"<font color= yellow><b> The [usr] missed you!!!"

mob
verb
Attack()
set category = "Combat"
for(var/mob/M in get_step(usr,usr.dir))//This makes it so you have to be facing your opponent to attack
flick("[usr.icon_state]Combo",src)
if(!M.dead)//Checks to see if the enemy is dead or not
var/dmg = rand (1,10)+usr.str - M.def
if(dmg < 0) dmg = 1
if(prob(100))
usr<<"<font color= yellow><b>You did [dmg] damage to [M]!"
M.Hp -= dmg
if(M.Hp <= 0)
usr.Exp += M.ExpG
usr.Gold += M.GoldG
usr<<"<b>You gained [M.ExpG] exp and [M.GoldG] gold!!!!</b>"
usr.LevelUp()
if(M.player)
return
else
del (M)
return ..()

else
usr<<"<font color= blue><b>You missed [M]!"




But when i increase agility, the hit rate or probability of the monster hitting me doesnt decrease.

and Dex, When i increase it, the hit rate or probablity of me hitting the monster doesnt increase.

Hope that clears things up
In response to Noob360
Anyone got any idea how to fix this?
In response to Noob360
Euhm, yeah.. Don't copy/paste codes?