ID:139180
 
mob/verb
melee_attack(mob/M as mob in oview(1))
var
MeleeDamage = usr.GetMeleeDamage() - (Armor * 2)


this shows the basic variable im using when defining dmg in a melee attack.

mob
proc

GetMeleeDamage()
return Weapon_dmg + usr.Strength

this is the proc im trying to use to call Weapon_dmg, which im trying to define under the obj/Items/Weapons/(weapon, aka knife in this case) file

    Weapons
var

Weapon_dmg

Knife
icon = 'Knife.dmi'
Weapon_dmg = 10


the problem im having is that in the proc of GetMeleeDamage() Weapon_dmg is coming up as undefined. I need to know how to 'transplant' the var amount(in this case the 10 weapon damage) to the proc in the mob file. I intend to define Weapon_dmg differently for each weapon i code. If there is a better way to do this please feel free to suggest another method of defining the variable, but the basic problem im having is the variable is coming up undefined in the mob/proc. and please, if there is any suggestions, corrections, anything that looks off or sloppy please correct me with a full explanation so i know exactly what to do in the future. I'm just beginning to code things in my test game, which if i get things set up right will turn into my larger project, but I'm a newb to all this and i only have a very, very elementary understanding of things. As i await any response i will be re-reading the DM guide trying to better grasp some of the code in it.

You can set it up like is:
mob
proc

GetMeleeDamage()
for(var/obj/Weapons/W in src.contents)
if(W.equip == 1)
var/dam = W.Weapon_dmg + usr.Strength
return
obj
Weapons
var
equip = 0
Weapon_dmg

Knife
icon = 'Knife.dmi'
Weapon_dmg = 10
proc/Equip()
set src in usr.contents
if(src.equip==0)
src.equip = 1
return

This allow you change the amount of the Weapon_dmg variable with out rewrite your proc code
In response to Prf X (#1)
You sure? it comes up with errors and warnings
I already have an equip() verb for equiping, i may have to change this to a proc? I dont want it to automatically be equipped, i want the user to be able to choose to equip or not. this all may make more sense if i re read some stuff. Unless i get better descriptions of how to use the code and what to put in the code i think i may put this on the back burner for a while....
In response to Kentos123 (#2)
I use the wrong word, I meant to put verb/Equip()
May I see your equip code?
In response to Prf X (#3)
yes you may, but the problem im having is with the W variable. It says it is an undefined type. Ill show you here.

verb/Equip_Weapon()

set src in usr.contents
if(src.Weapon_equipped == 1 )
usr << "You already have a weapon equipped."

else
if(src.Weapon_equipped == 0)
Weapon_equipped = 1
usr << " You have equipped a weapon "
return


the problem doesnt seem to lie in the equip code, what im having trouble with is the W in the above code which i changed to Weapon, changed to W thinking it might be some preset variable in the DM language which i dont think it is.

    mob/proc

GetMeleeDamage()
for(var/obj/Items/Weapons/W in src.contents)
if(W.Weapon_equipped == 1)
var/Melee_Damage = W.Weapon_dmg + usr.Strength

Player.dm:37:error: W: undefined type: W
Player.dm:38:error: W.Weapon_equipped: undefined type: W.Weapon_equipped
Player.dm:39:error: W.Weapon_dmg: undefined type: W.Weapon_dmg
Player.dm:37:warning: W: variable defined but not used
Player.dm:39:warning: Melee_Damage: variable defined but not used

In response to Kentos123 (#4)
In previous codes the path for weapons is /obj/Weapons not /obj/Items/Weapons. Assuming it's the same now as it was then, you need to change the variable type path in your loop.
In response to F0lak (#5)
ahhhh i see, i did not realize this posed a problem. Thank you for your input, trying it now.
In response to Kentos123 (#4)
Try this:
mob/verb
melee_attack(mob/M as mob in oview(1))
var
MeleeDamage = usr.GetMeleeDamage(Melee_Damage) - (Armor * 2)
mob/proc

GetMeleeDamage(Melee_Damage as num)
for(var/obj/Items/Weapons/W in usr.contents)
if(W.Weapon_equipped == 1)
Melee_Damage = W.Weapon_dmg + usr.Strength
return Melee_Damage

In response to Prf X (#7)
That takes Melee_Damage as an argument. You would want to define it inside the procedure.
In response to Kentos123 (#6)
Well, problem solved, however there is a drawback....

Normal Melee attacks without a weapon have a value less the 2, im guessing its set to 0 for some reason. It should be at least 10 as that is how much str my mobs haves to begin with.

mob/var
Strength = 10


and...

    mob/proc

GetMeleemod()
for(var/obj/Weapons/W in src.contents)
if(W.Weapon_equipped == 1)
var/Melee_dmg = W.Weapon_dmg + usr.Strength

return Melee_dmg

Should not the equation always be atleast 10 if the variable Strength is defined as being 10? Perhaps im missing something again.