ID:155088
 
I'm a new programmer that literally started yesterday and want to make a chatroom where me and my friends can hang out and kill each other. how would I put a chest full of weapons in, and have the weapons do damage?
obj
chest
Click()
usr.contents+=new/obj/sword
usr.contents+=new/obj/plasmagun
sword
icon='sword.dmi'
plasmagun
icon='plasmagun.dmi'

mob
verb
attack(mob/m in oview(1))
if(sword in src.contents)
usr.strength+=300
else
var/damage=rand(10,30)
usr<<"You hit [M] for [damage]
M.hp-=damage
M.Deathcheck()
mob
proc
Deathcheck()
if(usr.hp<=0)
addd in teleport to w/e




In response to Mastergamerxxx
using usr in proc is not good it would be better like this
obj
chest
Click()
usr.contents+=new/obj/sword
usr.contents+=new/obj/plasmagun
sword
icon='sword.dmi'
plasmagun
icon='plasmagun.dmi'

mob
verb
attack(mob/m in oview(1))
if(sword in src.contents)
src.strength+=300
else
var/damage=rand(10,30)
src<<"You hit [M] for [damage]
M.hp-=damage
M.Deathcheck()
mob
proc
Deathcheck()
if(src.hp<=0)
addd in teleport to w/e
In response to Mastergamerxxx
using usr in proc is not good it would be better like this
obj
chest
Click()
usr.contents+=new/obj/sword
usr.contents+=new/obj/plasmagun
sword
icon='sword.dmi'
plasmagun
icon='plasmagun.dmi'

mob
verb
attack(mob/m in oview(1))
if(sword in src.contents)
src.strength+=300
else
var/damage=rand(10,30)
src<<"You hit [M] for [damage]
M.hp-=damage
M.Deathcheck()
mob
proc
Deathcheck()
if(src.hp<=0)
addd in teleport to w/e