I need a code for an arrow, one tile firing directly from the users icon and continuing until it makes contact with a mob or obj. If it hits the obj then it gets deleted and if it hits a mob the mob losses HP. Also a system that wont allow arrow spamming.
thx for any help
-Medawolf
ID:164280
![]() Jul 1 2007, 12:42 pm
|
|
![]() Jul 1 2007, 1:02 pm
|
|
This demo is pretty good. http://developer.byond.com/hub/Rifthaven/ShootingDemo
|
Let's take these one at a time:
I need a code for an arrow obj/arrow one tile firing directly from the users icon I'm going to assume that you mean that you want an arrow, when you do whatever it is that triggers the firing of one, to appear one tile in front of whoever fired it. We'll accomplish this using the arrow's New() proc, passing the argument of whoever fired it. obj/arrow and continuing until it makes contact with a mob or obj. You're making a mistake, here: the arrow might not ever make contact with a mob or obj. It might hit a turf or, even worse, might fly into the edge of the map. So, instead, let's reword this as "continuing until it can't move." So, we'll write a proc that makes the arrow fly forward continually obj/arrow If it hits the obj then it gets deleted and if it hits a mob the mob losses HP. You've made another mistake here. First of all, saying "the" instead of "a/an". There is no "the obj" or "the mob," we're talking about a mob or an obj. Or, in fact, anything else. Or, in fact, doesn't actually BUMP into anything at all, but merely fails a movement (like my example of flying into the edge of the map). Anyway, once we fail a movement in the fly() proc, we can check for something we might've hit, and if there's anything there we can damage, we can damage it. Then, we can delete the arrow. So, extending the fly() proc... //get the turf in front of us Also a system that wont allow arrow spamming. This is done in pretty much the exact same way that you can restrict movement speed. Just search for that. |
that does not seem to be workin...
what i need is a code that will give the character a verb called "shoot" or w/e and then fires a arrow from directly in front of the user and then if it hits a mob that mob looses 5 HP. I am fairly new to creating byond games so I'm sorry for any incompetence I may be displaying in failing to understand. dream maker keeps telling me that theres 12 errors in your code but its more likely me screwing it up. any help would be great. -Medawolf Edit: I've managed to fire the arrow, but i cant set it to inflict any dmg, nor can i make them del themselves... |
The code you gave me is giving me an error...
error: missing left-hand argument to <. so... any help plz |
He was giving you what you asked for, just not the way you want it (which would be a copy/paste/modify type of code).
|
obj/Arrow This is a pretty good shooting code and It works pretty well.Its the shooting demo I gave you but apparently you didnt look at it.....all you really had to do was modify it to fit your own code |
That's horrible.
- No boolean usage where appropriate - If the variable is reset after 1 tick, really no point for having it in - M.attack is useless because you set it to a value but never used it. - Using usr in procs. |
It "still works" in the situations which you have tested it in. If you were to use it in a somewhat different way (say, create an arrow trap that shoots arrows), it wouldn't work.
|
Actually, that was a small mistake on my part. I forgot the closing tab.
The bigger mistake was the code in my post, because he clearly blindly copy-and-pasted it. |
another nooby question:
how do i go about creating a var for attacked and fired based on the code givin by monkeykid? i am very new to this(started yesterday) and i'm getting the following errors... error:src.fired:undefined var error:M.attacked:undefined var thx for any help... |
Kaiochao2536 wrote:
How about you actually make the variable? /mob/var/attacking and /mob/var/fired would work. tried that, don't work. |
I'm not about to give him everything, he'll learn absolutely nothing that way.
Case in point: Monkey giving him everything he needed, and he learned nothing. Thanks for that, Monkey. |
Well its not even my code it's from a demo and also some people learn from examples but I dunno....I'm just trying to help him and I know you're gonna say "How is he going to learn anything if you just give him all the answers?" well like I said, some people learn from examples.
|
Some people learn from examples. A nice little statement that is technically correct and sounds reasonable. The trouble comes when you realize that "some" could be, you know, two. Two people learn from examples.
However, when you actually MAKE PEOPLE LEARN THINGS, they learn things. When you spoon-feed them what they want, they'll tend to copy it and learn nothing. Stop helping people until you get a clue. |