I don't know if this question can be a simple, "How do I do this?", "This is how.", but any help would be appreciated. My MSN is [email protected] if you want to offer in-depth help.
I am attempting to code a usable object, that you can throw. When and if the object bumps another player, I run into trouble, because I cannot get the object to recognize the relevant vars of the thrower, and the mob hit. I want to take the values of the mob hits defense, and other relevant variables, subtract them from the value of the "damage" relevant variables from the thrower, to get a total damage value.
When I try to code them, I can't get it to recognize the variables of the target mob without putting the variables into the object itself, and even if I were to do that, I don't know how I would make the objects variables equal to the target and attackers values.
Thanks for your time.
ID:160817
Jul 20 2008, 1:39 am (Edited on Jul 20 2008, 3:38 am)
|
|
Jul 20 2008, 7:06 am
|
|
That's easy. For the basic part you just have to do the same you'd do for any projectile system. You need to have a variable on the projectile (the thrown object) that keeps a reference to the mob who threw it, so it can know who that mob is later. The gist of it would be:
|
In response to Kaioken
|
|
Hmm, that gets rid of the majority of the errors I was having, when I tried it that way. There's still a problem though, during the Bump(mob/M) I attempt to use M's variables, such as defense to influence the change in M's health. When I call any of M's variables it says they are undefined, and I can't think of a fix.
Thank you for that though, it really helped. Here is the code I have for my object as of now, with the errors. obj The only error I get is the M.Defense, for some reason it recognizes M.Health, though I am not sure it will work out. |
In response to Pikkon53
|
|
Pikkon53 wrote:
Hmm, that gets rid of the majority of the errors I was having, when I tried it that way. There's still a problem though, during the Bump(mob/M) I attempt to use M's variables, such as defense to influence the change in M's health. When I call any of M's variables it says they are undefined, and I can't think of a fix. obj The only error I get is the M.Defense, for some reason it recognizes M.Health, though I am not sure it will work out. That just means you haven't declared the variable Defense in the mob type. Or M is not of mob type. Or maybe the value of Defense is not what the compiler expects. http://www.byond.com/members/ DreamMakers?command=view_post&post=37193 That page might help. |
In response to Pikkon53
|
|
Maybe you misspelled "Defense" on your definition.
|
In response to Green Lime
|
|
When using a Bump proc, I find it best to redefine the contacted object.
Bump(M) I found that many times, even though the (ismob) statement is in effect, the proc will "Forget" what's going on. This has happened to me many times but using the transfer from M to var/mob/a works best in defeating that issue. I've never had a problem with Bump() since I started using that. |
In response to Bravo1
|
|
Thank you all for your help. I'm kind of embarrased, Jemai was right, in the Shuriken I told it to use "M.Defense", while my mob has the stat listed as "defense". I'll be sure to check my punctuation and capitalization before asking for help, thank you everyone.
|
In response to Bravo1
|
|
The procedure/compiler doesn't "forget" what's going on, it simply doesn't care. DM is a language that assumes you know what you're doing. This is why if you override Bump(M), then it'll go by the type /M even if you precede your code with if(ismob(M)). Likewise, this is also why if you override Bump(mob/M), M can still be any dense object.
|