In response to RedlineM203
I've told you.
Replace
usr.overlays+=src
to
usr.Overlays+=src
usr.update()

------------------

Replace
usr.overlays-=src
to
usr.Overlays-=src
usr.update()

Remove the thing at logout(), and voila. I seriously can not understand how the heck you're still having troubles, and let me tell you, PLENTY of them cover overlays.
In response to Mysame
Well then, I haven't seen them, and I looked at "every" equip system in the book.


And it STILL DON'T WORK DAMN IT!

Do I have to post my whole damn game?

    verb/EquipUnequip()
if (src.Equiped == 0)
if (src.weapon == 1)
if (usr.weapon == "Melee Ability")
src.Equiped = 1
src.layer = 8
usr.Overlays+=src
usr.update()
usr.weapon = "[src]"
usr.attack += src.attack
usr << "You equip the [src]."
src.suffix="Equiped" // It's called suffix
else
usr << "You have a weapon equiped! Unequip your [usr.weapon]."
else
if (src.shield == 1)
if (usr.shield == "")
src.Equiped = 1
src.layer = 7
usr.Overlays+=src
usr.update()
usr.shield = "[src]"
usr.defence += src.defence
usr << "You equip the [src]."
src.suffix="Equiped" // It's called suffix
else
usr << "You have a shield equiped! Unequip your [usr.shield]."

else
if (Equipable == 1)
src.Equiped = 1
src.layer = 6
usr.Overlays+=src
usr.update()
usr << "You equip the [src]."
src.suffix="Equiped" // It's called suffix
else
usr << "You can't equip this."
else
if (src.weapon == 1)
if (usr.weapon == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix)
usr.overlays-=src
usr.update()
usr.attack -= src.attack
usr.weapon = "Melee Ability"
usr << "You unequip the [src]."
else
if (src.shield == 1)
if (usr.shield == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix
usr.overlays-=src
usr.update()
usr.defence -= src.defence
usr.shield = ""
usr << "You unequip the [src]."
else
src.Equiped = 0
src.suffix="" // It's called suffix
usr.overlays-=src
usr.update()
usr << "You unequip the [src]."
In response to RedlineM203
You still have 'overlay' at times. ctrl+F and look for 'overlay' (switch on that little box in the corner, too) and look for ever overlay and change it into Overlay
In response to Mysame
You pick up the 1337 PH450R.
You equip the 1337 PH450R.
runtime error: type mismatch
proc name: EquipUnequip (/obj/verb/EquipUnequip)
source file: Fighter.dm,354
usr: Redline (/mob)
src: 1337 PH450R (/obj/RTwinS)
call stack:
1337 PH450R (/obj/RTwinS): EquipUnequip()
(No Suffix... and no warning of equiping.)
You have a weapon equiped! Unequip your 1337 PH450R.



Its a cruel cruel world... I replaced all non-capped "overlays" with Overlays.
In response to RedlineM203
And what the hell is like 354.
Clearly your biggest problem here is that this is a horrible, horrible equipment system. You need to rewrite that piece of crap from the ground up to get it to work right.

Two tenets you must always follow when writing any equipment system:

  • The mob itself should keep track of which items are equipped, by having vars or an associative list that points to those items. You're partway there but you're setting the appropriate var (weapon, shield, etc.) to a string instead of the actual item.
  • Items should not have a var to signify their equipment status. They should ascertain that by checking loc, seeing if it is a mob, and then checking whether the approrpiate var (or list entry) is set to src. Ditch the Equiped var, which should not exist, is spelled wrong, and is capitalized which violates all good naming conventions.

    And of course for robust coding purposes, you should never ever use if(var==1) or if(var==0) to check on true/false values, but if(var) and if(!var) instead.

    Once you've razed this code and written completely new code that works properly, you can add overlays more easily. Another tip: Don't screw with src's settings in the overlay process. Create a temporary obj, give it the icon and state and layer that you want, and add that as the overlay. You should probably have a separate proc create the overlay, so you can call that right after loading a character to recreate all the overlays.

    Lummox JR
In response to Mysame
The line number. Have you coded before or are you ripping it?
In response to Lummox JR
That horrible, horrible system you call it is the best damn home made thing I made, so shut up.

(Yes.. I'm offended.)
In response to RedlineM203
RedlineM203 wrote:
That horrible, horrible system you call it is the best damn home made thing I made, so shut up.

(Yes.. I'm offended.)

Don't be offended except by that code. It reflects poorly on you. Ditch it and start over.

There are actually good examples out there of how to write an equipment system, such as Wizkidd0123's demo, or you could search the forums for systems written by reputable programmers as well as tips on how not to write one. I came down on your code because it had all the earmarks of having been cobbled from parts of a bad demo. For homemade it's not bad as a first effort, but it's definitely wrong; once you learn (as you now have) how to do better, you should rewrite it.

Lummox JR
In response to Lummox JR
The code definatly works alright, but theres a essence of crap (or bad crashing anyway) somewhere I don't know. If it works perfect somewhere else then it should work perfect here.

I'll take a look around... once more.
In response to RedlineM203
RedlineM203 wrote:
The line number. Have you coded before or are you ripping it?
Ripping that buggedthing? It was a TYPO. Replace the 'like' by 'line'. Ripping that? Really, get brains. I thought you said you LEARNED from your MISTAKES? To me it looks like you don't accept anyone's help, and then say you can do better.
In response to Mysame
I did say that? I said I learn from coding.

So if you handed over a full clean code with nothing between I'll learn.

And when did I say I can do it better then you?
In response to RedlineM203
RedlineM203 wrote:
I did say that? I said I learn from coding.

So if you handed over a full clean code with nothing between I'll learn.

You may think that's true, but it's not. You don't learn from just seeing code; you can learn by studying it, but only if it's done well and commented properly.

Lummox JR
In response to Lummox JR
What I mean is that I can point out key bits in the correct code, and see what it up with the bad one.
In response to RedlineM203
RedlineM203 wrote:
The code definatly works alright, but theres a essence of crap (or bad crashing anyway) somewhere I don't know. If it works perfect somewhere else then it should work perfect here.

No it shouldn't. One of the hallmarks of brittle code, which yours is, is that it fails when transplanted.

The code you've got now simply isn't any good. It violates the two biggest duh principles of equipment systems. The result is a brittle, unmanageable mess. It is, however, easy to rewrite from scratch correctly.

Lummox JR
In response to Mysame
mob/var/list/Equipment=list("Weapon","Armor","Shield")
obj/Equipment
var/Slot
verb/Equip()
if(usr.Equipment[Slot]) //if there is something equipped in the corresponding slot
usr.Equipment[Slot]=null //Make the slot null
var/obj/Equipment/E=locate(usr.Equipment[Slot]) //Make a new variable and set it to the slot
/*Remove all the bonuses of E from the player*/
E.suffix=null //Make E's suffix equal null
/*You should add all your weapon bonuses here,
stuff like 'usr.Str+=StrAdd' or something*/


usr<<"You equip the [src]!" //give out a message
usr.Equipment[Slot]=src //Equip the item to the slot
suffix="Equipped" //Set the suffix"
usr.overlays+=src //Add an overlay

verb/Unequip()
if(!usr.Equipment[Slot]||usr.Equipment[Slot]!=src) //If nothing is equipped, or if the equipped item is not src
return //Stop the verb

/*Then here, you should take away all of the stat bonuses*/

usr<<"You remove the [src]!"
usr.Equipment[Slot]=null //Make the slot null
suffix=null //Make src's suffix null
usr.overlays-=src //Remove the overlay

Weapons
Type="Weapon"
SUP3R_1337_W34P0N


Here's an equipment system using associative lists. Short and clean. (I'm at school right now so I can't find out if it works.)
In response to Lummox JR
Well, heres the new one... simple crap.

    verb/Equip()
if(usr.weapon!="Melee Ability")
usr << "You cannot equip this!"
else
if(src.weapon==1)
usr.weapon = "[src]"
usr.attack += src.attack
if(src.shield==1)
usr.weapon = "[src]"
usr.defence += src.defence
suffix = "Equipped"
usr.overlays += src
usr << "[src] Equiped."
src.Equiped = 1
usr.update()
verb/Unequip()
if(src.Equiped==0)
usr << "You do not have this equipped."
else
suffix = null
usr.overlays -= src
if(src.weapon ==1)
usr.weapon = "Melee Ability"
usr.attack -= src.attack
if(src.shield==1)
usr.shield = ""
usr.defence -= src.defence
usr << "[src] Unequiped."
src.Equiped = 0
usr.update()


Yet same old problem. The good thing now is I can make a weapon like a 2-Handed Sword in Runescape. Infact, that crappy code worked in my "Runescape" clone. Thats where I taken and worked on.


EDIT: Oops.. I spotted something.
In response to Mega fart cannon
Minor quibbles:

  • Instead of "the [src]" just use "[src]" instead.
  • Type is a bad var name because of confusion with type; you should use something like slot instead. Also you should not be capitalizing the type paths or other vars in use, such as Equipment. That's bad naming convention.
  • Don't bother telling the player that they can't unequip nothing. Just fail silently.
  • Never fail the equip verb just because something else is already equipped; unequip the other item automatically. Only fail if this is impossible (e.g. cursed items).
  • Check to see if your item actually has a slot before allowing equipping or unequipping.

    Lummox JR
In response to RedlineM203
RedlineM203 wrote:
Well, heres the new one... simple crap.

Indeed it is! You're still using strings as the mob.weapon, mob.shield, etc. vars, and you've still got an equivalent of the old Equiped var with the new item.weapon, item.shield, etc. vars.

Like I said, go actually check out how it's supposed to be done. Wizkidd0123's demo will point you in the right direction. So will my first post on this thread, which contains the two basic principles of an equipment system that you just blithely ignored.

Lummox JR
In response to Lummox JR
Weapon and Shield is used in the statpanel.


Equipped Weapon: 1337 PH450R
Equipped Shield:

(Nothing)

It was a Double equip demo while searching "Equip".
Page: 1 2 3