I'm working on the inventory and equipment issue right now.
I need a click proc where it equips or unequip something when you click on it on the inventory panel.
Here's what i have :
obj/weapons
var
attack
basetype
Click()
set src in usr
if(usr.rhand == "")
usr.rhand = src
usr.rhandtype = src.basetype
usr.attack += src.attack
else
alert("Something is equip!","Oops")
return 0
if(usr.rhand == src)
usr.rhand = ""
usr.rhandtype = ""
usr.attack -= src.attack
else
alert("Don't have it equip!","Oops")
return 0
As you can see, it probably the buggiest thing you have ever seen.
Some bugs:
-I can equip a weapon when it's still on the ground.
(When it isn't in my inventory panel)
-I can equip more than 1 weapons; it shows the icon of one of them on the panel, but my power keeps getting up.
Any suggestions,ideas ?
THX.
ID:179658
Nov 23 2001, 6:44 pm
|
|
In response to Lummox JR
|
|
lol. I had to remove some words from the alert proc so it would be easier to read the code (removed the -ed at the same time).
I'm not an anime fan, so i didn't know what you were talking about there. Thx for your help. It works now. Also, can you give me an example of a weapon restriction code for each class ? Someone told me to go with istype(), but i learn better with an example. |
In response to Cravens
|
|
istype() would be one way to go
example mob wizard mob warrior obj sword verb equip() if(istype(usr,/mob/warrior)) usr << "You equip da sword foo!" else usr << "You arent a warrior get outta here!" |
In response to FIREking
|
|
hmm.. Thx, but there's a few prob with my code.
First, i don't have an Equip verb. I have a click proc that equips. Here's my code: obj/weapons var attack basetype Click() if(src in usr) if(usr.rhand == "") usr.rhand = src usr.rhandtype = src.basetype usr.attack += src.attack usr<<"[src.name] has been equipped." else if(usr.rhand == src) usr.rhand = "" usr.rhandtype = "" usr.attack -= src.attack usr<<"[src.name] unequipped" else alert("Something is Equip!","Sorry") return 0 obj/weapons Knife basetype = "weapons" attack = 3 price = 20 icon = 'weapons.dmi' icon_state = "knife" Now,as you can see, ALL the weapons are in one single um... obj/ thingy... (sorry, forgot the word). I don't have a obj/sword, obj/bow, obj/hammer. So if i do it your way, there's only going to be one class that can equip weapons. Any suggestions? THX. (Sorry about my post. It's 3am here and i'm watching "True Lies") |
In response to Cravens
|
|
it doesnt matter if you have an equip verb, i showed you an example. Look at the example, and figure out how you will use something similair in your game.
|
In response to Cravens
|
|
What you probably want to do is to make all your weapons of a class /obj/weapon or /obj/item/weapon, then for /obj/weapon define a proc, CanEquip(), to check to see if the weapon can be equipped or not.
obj/item/weapon Now to use this, you'll have to include a call to src.CanEquip(usr). (The src. part is redundant, but I just put it in to show that this proc belongs to the weapon.) A line like this would work: ... Lummox JR |
In response to Lummox JR
|
|
Wow, it works !
Since i have a lot of mobs, it will take some time to put them all. If i have a lot of different colors for each kind of class, is it possible to put their stats in a single mob ? Here's what i mean : mob bluewizard icon = 'wizard.dmi' icon_state = "blue" hp = 20 attack = 1 redwizard icon = 'wizard.dmi' icon_state = "red" hp = 20 attack = 1 blueknight icon = 'knight.dmi' icon_state = "blue" hp = 40 attack = 2 redknight icon = 'knight.dmi' icon_state = "red" hp = 40 attack = 2 Would something like this give me the same result ? mob wizard bluewizard icon = 'wizard.dmi' icon_state = "blue" redwizard icon = 'wizard.dmi' icon_state = "red" hp = 20 attack = 1 I want to put each class in one single mob block. |
In response to Cravens
|
|
Cravens wrote:
Wow, it works !no, but mob wizard bluewizard icon = 'wizard.dmi' icon_state = "blue" redwizard icon = 'wizard.dmi' icon_state = "red" hp = 20 attack = 1 would its called inheritence. |
In response to Cravens
|
|
Would something like this give me the same result ? That's close to what you'd want, but I'd do it like this: mob You'd want to put as much in the main wizard block as you could, and just use the subclasses like red and blue to change as little as possible. Lummox JR |
Lummox JR