ID:2478391
 
(See the best response by Kozuma3.)
Hey, thanks for reading and checking my problem out. I'm trying to do two things currently and I'm fairly new to using Byond to program anything besides on other's datums, where it was easier to replicate what was done before. (Not ripping, but assisting.) This is what I want the first skill to do: -Boost the User's Stats by a % (relative to the DL var) -Last for, let's say, 60 seconds. -Drain MP over time. -Revert if, MP runs out, they use the 'Revert' skill. -Can't be stacked. Super Bonus Points if you show me: -How it can grant skills that are taken away when not in the form. -How it can increase/decrease movement speed. -How it can deduct damage by a %, rather than a fixed number. But those seem a lot more complicated, I dunno. Here's what I think I've got a grasp on. Code:
mob/var //just a random guy
MaxHP=100
MaxMP=50
HP=100
MP=50
DL=3 //the variable we want to boost the other stats with.
Str=50
Def=50
Weapon=0 //used later in the equipment segement, to determine if you have a weapon
//equipped

mob/verb/Buffskill()
set category="Techniques" //This is just for my tabs.
if (usr.manacheck(src)) //so they cant initially use it with 0 MP, mana check works fine for single cast, but not concentrated skills.
usr.Buff



mob/proc/Buff(mob/M)
M.MaxHP+= ((M.MaxHP/100) * DS) //MaxHP/100 finds 1% of their max HP. It is then
//multiplied by DS, to find a %, in this case, 3%. Then it adds 3% of their Max HP to their Max HP while it's active.
//At least, that's how I want it to work.)
M.MaxMP+= ((M.MaxMP/100) * DS)
HP+=min(M.MaxHP, M.HP+((M.MaxHP/100) *DS)) //M.HP is increased by a number found from a % of max HP.
//just going to have these ones since the rest would just be repeats.
//The skill does NOt boost DL.
//I don't know how to make it revert by time, drain mana or revert when you have no mana.

obj/weapons
icon='doesntmatter.dmi'
Wooden Sword
icon_state="sword"
verb/Equip()
if(Weapon=1)
usr<<"You have a weapon equipped!" //Weapon=1 is the variable I'm using when a weapon is equipped in that spot.
return //If something's there, don't equip it!
else //If Weapon is equal to 0, since getting it to 2 should be impossible.)
set src in usr
usr.Str+5 //raise the user's strength.)
usr<<"You equipped the Wooden Sword!"
usr.Weapon+1 //So they cant equip the same weapon multiple times/another one.
new/verb/Unequip() //gives you the ability to unequip it.
set src in usr
usr.Str-5 //takes away the boost
usr<<"You unequipped the Wooden Sword!"
usr.Weapon-1 //no weapon in hand
del/verb/Unequip() //so you can't accidentally deduce your stats by unequipping 90 times.




I just dunno what to do, spent like 7 hours rebuilding and rebuilding and I'm at an impass with my current knowledge. Halp!
Problem description:
Best response
This is how I'd go about it.

mob/var
// Equipment Slots
list/equipment = list(
"Weapon",
"Shield",
)
// Stats Below
health; max_health
strength
defense

mob/proc/max_health()
var value = 0
for(var/slot in equipment)
if(equipment[slot]==null){continue}
value += equipment[slot].max_health
return max_health + value

mob/proc/strength()
var value = 0
for(var/slot in equipment)
if(equipment[slot]==null){continue}
value += equipment[slot].strength
return strength + value

mob/proc/defense()
var value = 0
for(var/slot in equipment)
if(equipment[slot]==null){continue}
value += equipment[slot].defense
return defense + value

obj/items/var
max_health
strength
defense

obj/items
WoodenSword
strength = 4
My Lego Stats demo shows a simple way to go about handling stats that involve modifiers and multipliers. Combine that with an item/equipment system that can identify those aspects and you'll be good to go.
http://www.byond.com/developer/Legobumb/LegoStats
@Kozuma, That's a great way to handle static number increases from equipment and I see how I can further implement other things using a similar system. Thanks! How would you handle the verb for equipping/unequipping the wooden sword?

I like this basic way to do it cause some references I checked had stringy coding with weird workarounds and it really sent me down a weird rabbit hole of how to do stuff for this lmao.
obj/items/var/slot

mob/var/list/inventory = new

mob/proc/equip(/obj/items/i)
if(i && (i in inventory) && i.slot != null)
inventory -= i
equipment[i.slot] = i
return TRUE
return FALSE

obj/items
WoodenSword {name = "Wooden Sword"; slot = "Weapon"; strength = 4}
WoodenSheild {name = "Wooden Shield"; slot = "Shield"; defense = 2}
I don't know if I'm just dumb but how condensed that is, is magnificent. I'm gonna go do a bunch of stuff now. Thank you! You've been a big help.
No problem bro :)

Login to reply.