The problem is, there's a declared varible, that nothing can pick up. I was hoping someone could look at my code and suggest a possible solution. That variable is weapon.attack.
In globalmob.dm (attack code)
verb
attack(mob/m as mob in oview(1))
var d
if(equip_weapon == 1)
d = str + weapon.attack(Variable I'm having issues with)
m.damage(d)
usr<< "You did [d] damage!"
oview()<< "[usr] did [d]damage to [m]!"
m.deathcheck()
else
d = str + rand(1,4)
m.damage(d)
usr<< "You did [d] damage to [m]"
oview()<< "[usr] punches [m]!"
m.deathcheck()
In player.dm (Equip code, I've tried both the commented out lines and the non-commented lines. Both have the same result.
proc
equip(e as obj)
weapon = e
usr.attack = e.attack
// equipped_weapon -= equipped_weapon[1]
// equipped_weapon += e
// equip_weapon = 1
// weapon = equipped_weapon[1]
// usr.attack = weapon.attack
And finally, the obj declaration. (sword, under weapon.)
var attack
zodbolt
icon = 'fireball.dmi'
var value
weapon
//var attack
var hit
var damage_type
sword
damage_type = "slash"
name = "Sword of ZOD"
attack = 99
ID:167112
Apr 28 2006, 6:28 am
|
|
First off, I would just like to say that this is in the wrong section. This should be in Code Problems, because you have code, and there is a problem with it.
Secondly, the problem is that you are not telling us what weapon.attack is. Is this a variable that the players have? I am going to go ahead and make some assumptions, and I am going to start off just by cleaning up your code, because it is in shambles. mob When playing with procs that players will be the sole users of, src should suffice just fine. If you are unsure whether or not src will be the desired target, simply add "world<<src" as the first line. That will show you who/what the src is. The way the equip proc is set up, you would be better off making it a verb, however, you would then be able to equip any item that you have made in the game. I will show a better example at the bottom. proc That is a much better looking code in general now. As for the better way to do an equip variable: mob I hope that this helps you, and that you understand what I did. If this doesn't work, you can just post and say that it didn't work, and try to give more detail when posting. If it does work, it is good to let people know, so that they don't post when you have already solved the problem. One last thing though, I did not make any checks to see if you already have a weapon equipped or not. I am leaving that up to you to figure out how to do it. Good Luck. p.s. I didn't go over the code too well because I am in a hurry, but it should all work fine. §atans§pawn |
In response to Satans Spawn
|
|
Thanks for the help, I know I've got a lot of ugly code, My brain is still trying to write in C++. I'm working on it. Thank you for helping a newbie. I meant to post it in code problems, just clicked the wrong link and didn't notice.
Weapon.attack is an object varible of the equipped weapon, in theory. I've got a bad habit of not clearly commenting my code, and I've rewritten it so many times. |
In response to NeoKannon
|
|
C++ is *ugly*, and BYOND is only a little better. I'm in love with Scheme/LISP's syntax. <3
|
In response to PirateHead
|
|
Not as ugly as VB.
I saw some code for the MS Speech SDK in VB and it made me feel physically sick. How can you use such an ugly language? I think that the same reason C++ (and other heavily structured languages) appeal to me - brackets, tabs, semicolons - everything is clear (programatically, not clear to read). Blocks? Clear start and end. Procedures? Clear start and end. Lines? Clear end. You get my point. This is another reason BYOND is so great - use braces or semicolons, whenever you want. Got a for() loop with only two short statements? Stick em in braces and semicolon it! Bonus points if you use that method for size-restricted challenges (4k, 8k etc). |
In response to Hazman
|
|
Braces and semicolons are better than not, but in LISP-like syntax, there are only lovely parenthesis. There are few wierd "syntax quirks"; it's mostly just (procedure argument).
|
Also, you've got lots of ugly code and boolean variables there. (True/False Values = if(var) or if(!var), not ==0/1)
I suggest you'd start with ZBT's RPG tutorial and after that of course the lovely and most wonderful DM Guide.