I have this two codes for armor. One is for Shields and the other is for body armor. I want to make the coding like have overlays. So when you equip the shield and then equip the body armor the shield always stays above the body armor. I’ve tried everything but it just wont work can someone help me.
Shield Coding:
obj/Shields
Wooden_Shields
lHand = "Wooden Shield"
leftHandProperties = "None"
leftHandProtection = 0
leftRequirements = "None"
name = "Wooden Shield"
icon = 'Wooden Shield.dmi'
Click()
if(src in oview(1))
usr.contents += src
if(src in oview(15))
walk_to(usr,src)
verb
Equip()
set category = null
if(usr.Sequiped == 0)
if(usr.Type == "Palladian" || "Fighter" || "Theif" || "Mage" )
suffix = "Equiped"
usr.Sequiped ++
usr.LeftHand = lHand
usr.LeftHandProperties = leftHandProperties
usr.LeftHandProtection = leftHandProtection
usr.Protection += leftHandProtection
usr.overlays += 'Wooden Shield.dmi'
Unequip()
set category = null
if(suffix == "Equiped")
suffix = null
usr.Sequiped --
usr.LeftHand = "None"
usr.LeftHandProperties = "None"
usr.LeftHandProtection = 0
usr.Protection -= leftHandProtection
usr.overlays -= 'Wooden Shield.dmi'
Drop()
set category = null
if(suffix != "Equiped")
src.loc = usr.loc
Body Armor Coding:
obj/Body
Iron_Chain_Mail
body = "Iron Chain Mail"
bodyProperties = "None"
bodyProtection = 0
bodyRequirements = "None"
name = "Iron Chain Mail"
icon = 'Iron Chain Mail.dmi'
Click()
if(src in oview(1))
usr.contents += src
if(src in oview(15))
walk_to(usr,src)
verb
Equip()
set category = null
if(usr.Bequiped == 0)
if(usr.Type == "Palladian" || "Fighter" || "Theif")
suffix = "Equiped"
usr.Bequiped ++
usr.Body = body
usr.BodyProperties = bodyProperties
usr.BodyProtection = bodyProtection
usr.Protection += bodyProtection
usr.overlays += 'Iron Chain Mail.dmi'
Unequip()
set category = null
if(suffix == "Equiped")
suffix = null
usr.Bequiped --
usr.Body = "None"
usr.BodyProperties = "None"
usr.BodyProtection = 0
usr.Protection -= bodyProtection
usr.overlays -= 'Iron Chain Mail.dmi'
Drop()
set category = null
if(suffix != "Equiped")
src.loc = usr.loc
ID:148141
![]() Jun 25 2003, 7:26 am
|
|
I would recomment to use Blend()
(look it up) That way you want have to think about saving and i find it more usefull than overlays. Make a equip proc and a unequip proc Use armor types (body, head, hands, feet ect) Lets say you make 2 armor types. Then make 2 vars called something like icon_head and icon_body (head and body replaced with your armor types) Make a nother icon with your basic char icon. Now if you want to equip a helm you first make sure you have a basic char icon. Then Blend on te helm icon. Afther that you bland together the original icon and the icon_head and the icon_body. A well , not good explaned but just use blend and make icons for each armor type and blend em together each time you equip or unequip something. |
Kalzimere has the right idea, but you need to add the object to the overlays list, rather than an icon, in order to have the layer take effect.
So instead of: <code>usr.overlays += 'Iron Chain Mail.dmi'</code> Do: <code>usr.overlays += src</code> And the same for the shield. Don't forget to set the layer var, of course. <code>obj/Shields layer=5 //Because this is applied to obj/Shields, all shields will have this layer obj/Body layer=4 //Because this is applied to obj/Body, all sub-types of obj/Body will have this layer</code> You do have another major problem, though. The following line isn't going to work at all. <code>if(usr.Type == "Palladian" || "Fighter" || "Theif" || "Mage" )</code> When you use || on multiple text strings, the result is the last text string; in this case, "Mage". So you're actually checking to see if usr.Type=="Mage". As you're using "usr.Type", I assume you've made a var called "Type" (the case is important) that contains a text string with the player's class. If you haven't, then tell me and I'll elaborate. =) The easiest way to check if a string is equal to any one of number of things is to use a list, like so: <code>if (usr.Type in list("Palladian","Fighter","Theif","Mage"))</code> Use that line instead of your <code>if(usr.Type=="Palladian"||"Fighter"||"etc.")</ code> line. You also spelt "Paladin" and "Thief" incorrectly. =) |
Are there any demos/tutorials which show how blend works? I kind of understand it but I never have seen it used. I read about it in the help section on dream maker but I still have no idea how to make it work.
|
Did you change the corresponding line in Unequip()?
<code>usr.overlays -= 'Iron Chain Mail.dmi'</code> //This needs to be replaced... <code>usr.overlays -= src</code> // ....with this |
Armor
icon_state="armor"
layer=4
shield
icon_state="shield"
layer=5
Sense the shield layer is higher it will be placed above the armor. I think thats all you need . Hope it helps.
-Kalzimere