ID:155584
May 17 2011, 3:16 am
|
|
More specifically, used in a mob tree. I have weapons that i set to augment a variable for dmg done by a mob. How do i 'call' the obj/var/Weapon_dmg variable into a verb in the mob tree? I have a melee attack verb and want to add the variable of Weapon_dmg to the mathmatics defining damage for a melee attack.
|
May 17 2011, 4:00 am
|
|
Depends what reference the mob has to a weapon. Does it have a weapon in some variable?
|
In response to Stephen001
|
|
hmmm, no, i suppose it doesnt. I was just setting up the items for my obj tree and wondered how to link a sword or in this case a knife to a mobs melee attack. i would have to define a weapon variable for a mob as well then? Not just have an equip feature in the obj tree? This may be a little advanced for my current working knowledge, but i must learn =P.
|
In response to Kentos123
|
|
Can you post your two codes so I can see what you are exactly asking for?
|
In response to Xirre
|
|
its real basic right now, im not done coding the weapon.
Items Weapons Knife Equip_Weapon() Weapon_dmg += 10 Thats the basic code for a weapon when i ran into trouble, here is where i want it. V this is under mob/verb V melee_attack(mob/M as mob in oview(1)) var MeleeDamage = usr.Strength + (Weapon_dmg) - (M.Armor * 2) if(MeleeDamage <= 0) icon_state = "Melee Attack" usr << "Your attack could not bypass the armor of [M]" M << " Your Armor has deflected a strike by [usr] " sleep(2) icon_state = " " else M.Health -= MeleeDamage icon_state = "Melee Attack" usr << " You have done <font color = red >[MeleeDamage] <font color = black>Damage to [M] " M:Knock_out() M:Kill() sleep(2) icon_state = " " |
In response to Kentos123
|
|
Please try to use dm tags for displaying code.
As far as the problem goes, I would have the weapon equipped to a variable and retrieve it with the strength using a proc to add them up in advance.: obj |
In response to Pirion
|
|
usr.w = src comes up as an undefined definition. Isnt it being defined in that line?
|
In response to Kentos123
|
|
Kentos123 wrote:
usr.w = src comes up as an undefined definition. Isnt it being defined in that line? That's an assignment, not a definition. For that line to work correctly, the /mob type has to have var/w defined. If you only defined w for /mob/player or something like that, you'll get a compiler error because usr is only known to be a /mob. Just as a style note I would recommend not having different equip verbs for each type (weapon, armor, etc.) but just having the same verb called Equip for all of them. Lummox JR |
In response to Lummox JR
|
|
Thank you, im still unsure how to define w in this code, should be defined as text? and i should place it as a general var under mob, not something like mob/player right?
And my thoughts exactly on the equip/unequip verb. |
In response to Kentos123
|
|
It should be defined under /mob instead of /mob/player, yes, mostly for simplicity. That way usr has access to it, and it's probably relevant to monsters as well. However I would recommend giving it a longer name, and even better I would recommend giving it a type.
mob Now you'll have a var named weapon, which is of type /obj/item/weapon. You can define Get() and Drop() verbs under /obj/item, and Equip() and Unequip() under the various equippable subtypes. At any given time, the weapon var will show which weapon the mob in question is wielding. Lummox JR |
In response to Lummox JR
|
|
alright, but im still having the basic problem of using this variable in an equation for dmg and its still coming up as undefined in the items dm. ( I have different a different dm file for items, turf, player etc. )
proc this shows- undefined type: weapon.Weapon_dmg And... verb usr.weapon = src still is considered undefined. perhaps im missing something important thats not in the codes above, chances are i might not be cut out for coding but ill be damned if i dont at least try and get things right. I thank you all for you input, but for some reason this is not working for me. |
In response to Kentos123
|
|
melee_attack(mob/M as mob in oview(1)) Tell me if there anything you need. |