stat
parent_type = /obj // make this an atomic object so it is clickable and has a suffix in the stat panel
var
mob/owner
statname = "" // text string of what value you are increasing
value = 1 // the value of the stat
stat_inc = 1 // how many statpoints it consumes to add 1 to the value
New(location, _owner, _stat)
// set the owner, and stat variable when created
src.owner = _owner
src.statname = _stat
spawn()
Update()
proc
Update() // call this every time your stats have changed (strength, defense, etc...)
value = owner.vars[statname]
name = "[value]"
suffix = "\[[stat_inc]\]"
// 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(statname)]."
Increase() // use this to just increase the stat value by one if not neccessarily needing to use statpoints
value++
owner.vars[statname] = value
stat_inc = round((owner.vars[statname] - 1)/ 10) + 2
Update()
Reset()
value = 1
Update()
Click()
var/amount = input("How much do you want to increase this","Increase",1) as num|null
if(amount >= 255) amount = 255
for(var/i = 1,i <= amount,i++)
StatIncrease(usr) // StatIncrease() gets called when clicked
mob
var
statpoints = 0 // the credit used to increase stats
maxstatpoints = 0 // the credit used to increase stats
str = 1
def = 1
int = 1
agi = 1
dex = 1
luk = 1
vit = 1
list
statobjs // list of stat objects (/statobj)
Stat()
..()
if(statpanel("Statistics"))
for(var/stat/s in statobjs)
stat(stat_convert(s.statname), s)
stat("Stat points: ", statpoints)
stat(null)
Updatestats()
stat("Level",level)
stat("Health","[health]/[healthmax]")
stat("Reiatsu","[reiatsu]/[reiatsumax]")
stat("Atk",src.atk)
stat("Def",src.def)
stat("M-Atk","[matkmin]~[matkmax]")
stat("M-Def",mdef)
stat("Accuracy",acc)
stat("Dodge",dodge)
stat("Experience","[round(experience/Exptable[level]*100)]%")
proc
AddStats()
statobjs = list()
var/list/slist = list("str","agi","int","vit","dex","luk")
for(var/i in slist)
src.statobjs += new /stat (null, src, i)
verb
Statreset()
src.statpoints = 0
src.statpoints += src.maxstatpoints
src.maxstatpoints = src.statpoints
proc
// returns the new formatted list as an associative list: list("stat name and value" = "actual stat")
formatted_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]
// make an item that represents the stat and the actual amount, and
// set the association to the stat name that is going to be increased
return new_list
stat_convert(t) // a function that returns a converted form of wording (abbreviated to full)
var/list/A = list("Strength","Defense","Intelligence","Agility","Dexterity","Vitality","Luck")
var/list/B = list("str","def","int","agi","dex","vit","luk")
// a handy way to use parallel lists to convert stuff back and forth
// if the text is found in the A list, return the item in the same
// placement in the B list
return (t in A) ? B[A.Find(t)] : A[B.Find(t)]
// The ? operator is used for readability and compactness for some people,
// but the operator may obfusicate the reader of the code when mishandled
// However, the above line is equivalent to the following:
/*
if(t in A) // if t is found in A
return B[A.Find(t)] // return the value in the same placement of A from the B list
else
return A[B.Find(t)] // return the value in the same placement of B from the A list
*/
This is Unknown Persons stat distribution. And i can't find away to make the values reset to 1.