ID:1436031
 
i was using the referance trying to figure out how to use and create overlays.
im not sure where my problem is but it wont place the overlay icon over the mob. i maybe just forgeting something.
//equip items(armor,weapons)
mob
var
equip_weapon=0
equip_armor=0
//overlays
//var
// const
// ARMOR_LAYER=MOB_LAYER+1
// WEAPON_LAYER=MOB_LAYER+1


//when we add overlays make icon_state=player icon state
obj
verb //every obj gets the verbs
get()
set src in usr.loc
loc=usr
drop()
set src in usr
loc=usr.loc
equip()//make it equip work as equip&unequp
if(usr.equip_armor==0)
//add overlays
overlay+=/obj/overlay/armors//
//add stats
//equip_weapon=+1
// usr << "equiped the item"
// if(usr.equip_weapon==1)
// usr<<"somethings already equiped there"


any help on this is welcome. if there is a tutorial on overlays just link me to it and ill repost if i get it or not

Please Read All
Im going to help you out and attempt to provide as much information as possible. I don't mean this to sound rude, but you really should check out the tutorials on BYOND. Overlays are very basic, and therefore I feel you are not currently ready to start making games just yet.

Link to some excellent tutorials: http://www.byond.com/forum/?post=326846

Now onto a method to making an equipment system.

First off, you want to define a base path for your mobs that is unique, this way any variable that players (and only players) will use won't be applied to all mobs. When you assign a variable to a base path, you use up a lot of RAM, which can cause constant server lag.

Secondly, I've heard binary switches are the way to go. Me personally, I have never used them, but I have also not made a game in some time.

//These are define preprocessors. They replace given defines with whatever you desire before compiling the world.
//They are idea to change a value to a more readable one, as this example does.

#define ARMOR 0
#define WEAPON 1
#define HELM 2

world/mob=/mob/Attackable/Player//This will define the mob that players are assigned when they login.

mob
Attackable
var
strength=1
defense
//Whatever else you want both players and monsters to have as varialbes
Player
var
list/equipList//Me personally, I like to keep all lists null unless being used. Although, since we are using path specification, it shouldn't really be neccessary.
Monster
var//Just random examples really.
target

obj
Equipment
var
equipment_type//This will be what controls the field the item is concidered.
strength_boost
defense_boost
equip//Track whether it's being worn or not.
overlay//The object that is added and removed to overlays
verb
get()
set src in usr.loc
Move(usr)//Move is idea to use for item placement because it naturally manages content and it can also be used for item stacking systems and inventory cap systems.
drop()
set src in usr
Move(usr.loc)
Click()
//To explain, in path driven processes, src is not needed since it is the natural source. Therefore, instead of usr.strength+=src.strength_boost, you can simply put usr.strength+=strength_boost
var/mob/Attackable/Player/M=usr//Just to make things fit
if(istype(M,/mob/Attackable/Player))//Reassure the thing clicking the object is in-fact the right path (Not likely that it won't be, but abusive admins can cause anything to happen if given time).
if(!istype(M.equipList,/list))//Go ahead and set their equipList to a list if it isn't already one
M.equipList=new/list
if(!equip)//If item is not equip
if(!(equipment_type in M.equipList))//If equipment_type is not in list
M.equipList+=equipment_type//Add it to our list.
//Just simple buffs to add if avalable
if(strength_boost)
M.strength+=strength_boost
if(defense_boost)
M.defense+=defense_boost
M.overlays+=overlay//You can actually use a number of methods, but this method is the one I find to be most useful. I could be wrong though.
equip=1
else
M.equipList-=equipment_type
if(strength_boost)
M.strength-=strength_boost
if(defense_boost)
M.defense-=defense_boost
M.overlays-=overlay
equip=null

//Some equipment examples
Rusty_Armor
equipment_type=ARMOR//Using our define, when compiled this value will actually equal 0
defense_boost=2
overlay=/equipmentOverlays/Rusty_Armor//This specifies an object that we are using a datum for, the script for these are below.
Rusty_Dagger
equipment_type=WEAPON
strength_boost=2
overlay=/equipmentOverlays/Rusty_Dagger
Rusty_Helm
equipment_type=HELM
defense_boost=1
overlay=/equipmentOverlays/Rusty_Helm


/*
Below is a datum that has it's parent type assigned to /obj.
In essence, it will be an obj but by doing it as we have they will not clutter our obj section of the object tree, which is idea for mapping.
In the since that because these objects are essentually just means of having greater control over overlays, they don't typically get mapped in.
*/

equipmentOverlays
parent_type=/obj
layer=MOB_LAYER+1
Rusty_Armor
icon='Rusty Armor.dmi'
Rusty_Dagger
icon='Rusty Dagger.dmi'
Rusty_Helm
icon='Rusty Helm.dmi'
which tutorials to you personally recommend form that list?in any order?

I understood everything you wrote,surprisingly. Maybe i think too simple for programing. Your right, i know part of the language, i might not be ready to make a full game.

In my defense reading a learning book is one thing but if the book dont challenge you, or give practice activities how do you fully learn.
I agree with you entirely. I actually learned from downloading demos and altering them, perhaps that's what you should try?

Honestly, because of how I learned the language I can't tell you which of the tutorials I've given a link to are better. Simply because I've never actually looked at any of them.

However, although all of the programmers on the list are excellent ones, I would suggest some of Deadron's stuff (he's on the list). Forum_account is a very skilled programmer as well, but his works may be too advanced (I haven't looked at them). IainPeregrine and Lummox JR are also very skilled.

Essentially, my concern for you isn't simply learning to program, because anyone can do that, but learning to program "efficiently." Even I myself struggle with such a concept, but if you truly address the issue early on in your stages of learning the language then you will find it to be worth while. Without efficiency you could create the best game on BYOND, but no one would play it because it 1) lagged too much, 2) had too many errors, and 3) didn't fit together right.

But, for now, I suppose learning should take precedence. I suppose you could either check out the tutorials by the people I've mentioned, or use the Resources available on BYOND (pretty much tens of thousands of demos and libraries. Or, at least it would seem).

I'll explain overlays for you, instead of spitting out some crude random script.

Overlays can either be objs or turfs(not too sure about mobs), images, or icons. You can apply an overlay in numerous ways.

First, you have apply a direct file to overlays.
overlays+='Overlay.dmi'


The direct file method is simple and effective, however it does not allow for dynamic layering. Therefore, it does have it's flaws. It also does not allow for offsets either.

So, for more control over your overlays, you can use an obj instead (or even an image, but images can't be altered like an icon can, so this method isn't frequented too much, although I think I'll revisit the concept myself).

obj example:
var/obj/o=new
o.icon='Overlay.dmi'
o.pixel_x=32//Make it 32 pixels to the right
o.pixel_y=32//Make it 32 pixels up
o.layer=MOB_LAYER//Because it's an object you MUST alter it's layer elsewise it will be underneath the mob it's applied to.
overlays+=o


Above is an example of how versatile obj's are compared to icons.

And then images just for the sake of it:
overlays+=image('Overlays.dmi')


Now, images can be used as overlays, but their primary usefulness lies in the fact that images can be set to be viewed by certain people, and not viewed by others. If you look inside the Help On in dream seeker and check out image, you can get an idea of how this is done.

Like objects, images can also have their features altered to add displacement.

var/image/I=image('Overlays.dmi')
I.pixel_x=32
I.layer=MOB_LAYER-1
overlays+=I


And to remove an overlays you simply do like so:
overlays-='Overlays.dmi'//for icon


If the overlay was an obj, icon, or image, then you need some method of storing it so you can remove it later, variables are typically used for such things.

Icon method with remove example:
var/icon/I=icon('Overlay.dmi')
I.Blend(rgb(100,100,100),ICON_ADD)//Change the color
overlays+=I
alert("Click ok to remove overlay")
overlays-=I


And an example of adding then removing later:
mob/var/overlayTracker

mob/verb/AddOverlay()
var/icon/I=icon('Overlay.dmi')
I.Blend(rgb(100,100,100),ICON_ADD)
overlayTracker=I
overlays+=I

mob/verb/RemoveOverlay()
overlays-=overlayTracker


The problem with your question is there are just too many ways to do it. My advice would be to check out demos, check out those tutorials, and simply tinker around with things.

P.S. I apologize for the exhaustingly long posts I've mode on this thread.