obj/Inventory
proc
OnGet()//This determines what happens when the player succesfully gets src
..()
OnDrop()//This determines what happens when the player succesfully drops src
..()
//By default, all the following Allow...() procs return 1
AllowGet()//If this returns 1, then an object can be taken. If not, then it can't.
return 1
AllowDrop()//If this returns 1, then an object can be dropped. If not, then it can't.
return 1
AllowEquip()//If this returns 1, then an object can be equipped. If not, then it can't.
return 1
AllowUnequip()//If this returns 1, then an object can be unequiped. If not, then it can't.
return 1
verb
Get_Something()
set name="Get"//Set the name of the verb
set src in usr.loc
var/mob/Player/P=usr//Type Casting
P.Get(src)//Get it!!
Drop_Something()
set name="Drop"
set src in usr//Short for set src in usr.contents.
var/mob/Player/P=usr//Type Casting
P.Drop(src)//Drop it
Equipment
var
identifier//A text string that identifies the type of equipment it is.
EStr//The strength bonus that a piece of equipment will give to its owner
EDef//The defense bonus that a piece of equipment will give to its owner
Click()//Just to set up an alternate method of Equipping something
if(ismob(src.loc))
if(src.loc && src.loc.vars["[src.identifier]"]==src)//If src has an owner, and the owner has src equipped
src.Unequip_Something()//Unequip it
else//If it's not already equipped
src.Equip_Something()//Unequip it
verb
Equip_Something()
set name="Equip"//Set the name of the verb
set src in usr
var/mob/Player/P=usr//Type Casting
P.Equip(src)
Unequip_Something()
set name="Unequip"
set src in usr
var/mob/Player/P=usr//Type Casting
P.Unequip(src)//Unequip it
proc
OnEquip()//This determines what happens when something is equipped
OnRemoval()//We'll call this one whenever equipment is unequipped.
Weapon
identifier="sword"
Sword
proc
Slash(mob/Victim as mob in oview(1))
usr << "You slash [Victim]!"
OnEquip()//The sword's personal action to take when it's equipped
if(istype(src.loc,/mob/Player))//Just for safety
var/mob/Player/P=loc//Type Cast
P.verbs+=/obj/Inventory/Equipment/Weapon/Sword/proc/Slash//We can use it to add verbs...
P.Str+=src.EStr//And more usefully, we can use it to add any stat bonuses the weapon may have.
OnRemoval()//The sword's personal action to take when it's unequipped
if(istype(src.loc,/mob/Player))//Just for safety
var/mob/Player/P=loc//Type Cast
P.verbs-=/obj/Inventory/Equipment/Weapon/Sword/proc/Slash
P.Str-=src.EStr
Excalibur
icon='Swords.dmi'
icon_state="excalibur"
EStr=10//This sword, when equipped, will give its owner a bonus of 10 strength
Fire_Sword
icon='Swords.dmi'
icon_state="fire sword"
EStr=12//This sword, when equipped, will give its owner a bonus of 12 strength
AllowDrop()
loc << "This sword is cursed: You can't drop it!"
return 0//Don't allow the player to drop it
Shield
identifier="shield"
Space_Shield
icon='Shields.dmi'
icon_state="space shield"
EDef=8//This shield, when equipped, will give its owner a bonus of 8 defense
OnEquip()//The shield's personal action to take when it's equipped
if(istype(src.loc,/mob/Player))//Just for safety
var/mob/Player/P=loc//Type Cast
P.Def+=src.EDef
OnRemoval()//The shield's personal action to take when it's unequipped
if(istype(src.loc,/mob/Player))//Just for safety
var/mob/Player/P=loc//Type Cast
P.Def-=src.EDef
mob/Player
var
obj/Inventory/Equipment
Weapon/sword//A variable to store the player's equipped weapon in. Notice that it has the same name as its identifier
Shield/shield//A variable to store the player's equipped shield in. Notice that it has the same name as its identifier
proc
Equip(obj/Inventory/Equipment/E)
if(!istype(E) || !E.AllowEquip() || !(E.identifier in src.vars) || src.vars["[E.identifier]"])//If it's not really an obj/Inventory/Equipment, its AllowEquip() returns 0, E's identifier isn't defined, or the player already has something of the same type equipped
return 0//Then end the current proc, doing nothing and returning 0.
E.OnEquip()
src << "You equip \a [E]."//Tell the player
src.vars["[E.identifier]"]=E//Put E into the correct category of the player's Equipment list.
E.suffix="Equipped"//atom/var/suffix represents those little blue letters that appear next to things in statpanels
Unequip(obj/Inventory/Equipment/E)
if(!istype(E) || !E.AllowUnequip() || !(E.identifier in src.vars) || src.vars["[E.identifier]"]!=E)//If E isn't equipped, E.AllowUnequip() returns 0, E's identifier isn't defined, or E isn't really a /obj/Inventory/Equipment
return 0//Then end the current proc, doing nothing and returning 0.
E.OnRemoval()
src << "You unequip your [E]."//Tell the player
src.vars["[E.identifier]"]=null//Then set the correct slot to null: They don't have one equipped anymore
E.suffix=""//atom/var/suffix represents those little blue letters that appear next to things in statpanels
Get(obj/Inventory/E)
if(istype(E) && E.AllowGet())//If it can be added to the inventory
src << "You get \a [E]!"//Tell the player.
E.Move(src)//Then add it!
E.OnGet()
Drop(obj/Inventory/Equipment/E)
if(istype(E,/obj/Inventory) && E.AllowDrop())
if(src.vars["[E.identifier]"]==E)//If E is currently equipped
Unequip(E)//Then unequip it!
src << "You drop the [E]."//Inform the player of the removal.
E.Move(locate(src.x,src.y,src.z))//Actually remove it from the player onto the turf on which the player is standing.
E.OnDrop()
Problem description:
I`m useing Wizkidd`s Equipment demo but i have changed some things and it wont work it says
runtime error: undefined proc or verb /mob/Get().
proc name: Get (/obj/Inventory/verb/Get_Something)
usr: Q (/mob)
src: Excalibur (/obj/Inventory/Equipment/Weapon/Sword/Excalibur)
call stack:
Excalibur (/obj/Inventory/Equipment/Weapon/Sword/Excalibur): Get()
When i want to pick up somting i dont even changed somthing on get ??