ID:2477856
 
mob/var
list
items
stats
equipment
level
exp; maxexp
mob/Login()
items = new
stats = list(
"HP" = list(10,10),
"STR" = list(1,1),
"DEX" = list(1,1),
"DEF" = list(1,1),
)
equipment = list(
"Mainhand" = null,
"Offhand" = null,
)
level = 1
exp = 0
maxexp = 42
mob/proc
GetStat(i)
return (i in stats) ? stats[i][1] : 0
GetStatMax(i)
return (i in stats) ? stats[i][2] : 0
GetStatBonus(i)
var r = 0
for(var/o in equipment)
if(equipment[o] == null){continue}
r += (i in gitems[equipment[o]]) ? equipment[o][i] : 0
return r
HasItem(i,a=1)
return (i in items) && items[i] >= a ? TRUE : FALSE
GiveItem(i,a=1)
items[i] = HasItem(i) ? items[i]+a : a
DropItem(i,a=1)
if(HasItem(i,a))
items[i] -= a
if(0 >= items[i]){items -= i}
return TRUE
return FALSE
CanEquip(i)
return (i in equipment) && equipment[i] == null ? TRUE : FALSE
GiveExp(a)
exp += a
while(exp >= maxexp)
exp -= maxexp
maxexp = round(maxexp * 1.13)
level++
Equip(i)
if(HasItem(i))
switch(gitems[i]["SLOT"])
if("Hand")
if(CanEquip("Mainhand"))
DropItem(i,1)
equipment["Mainhand"] = i
return TRUE
else if(CanEquip("Offhand"))
DropItem(i,1)
equipment["Offhand"] = i
return TRUE
if("Head")
if(CanEquip("Head"))
DropItem(i,1)
equipment["Head"] = i
return TRUE
return FALSE
Dequip(i)
if((i in gitems) && equipment[gitems[i]["SLOT"]] != null)
GiveItem(i)
equipment[gitems[i]["SLOT"]] = null
return TRUE
return FALSE

var list/gitems = list(
"Dagger" = list("SLOT"="Hand", "STR"=2, "DEX"=5),
"Club" = list("SLOT"="Hand", "STR"=5, "DEX"=2),
"Sword" = list("SLOT"="Hand", "STR"=4, "DEX"=3),
"Axe" = list("SLOT"="Hand", "STR"=4, "DEX"=3),
"Bow" = list("SLOT"="Hand", "STR"=1, "DEX"=6),
//
"Helmet" = list("SLOT"="Head", "DEF"=1),
"Coif" = list("SLOT"="Head", "DEX"=3),
)