The following code has a problem:
mob
verb
Zap()
set category = "Battling"
if(!HP) return
if(!src.dir) return
if(!usr.dir) return
var/obj/battleobjs/A = new /obj/battleobjs/Magic/Zap (get_step(src,src.dir))
A.dir = src.dir
walk(A,dir,1)
flick("Slash",src)
for(var/mob/B in A.loc)
src << sound('ATTACK.WAV')
flick('HitMonsters.dmi',B)
B.HP -= src.Str + A.Str
B << sound('HIT.WAV')
B:DeathCheck(B)
sleep(100)
del(A)
It does damage but it only does it if you are 1 tile away from the person you are attacking. How can i make it work so it attacks the person from any distance?
ID:261719
Feb 2 2003, 2:50 am
|
|
In response to Nick231
|
|
I only want it to be attacked when the mob is in A's location, not in it's oview()
|
In response to Unknown Person
|
|
im not quite sure what you mean... A is the Zap icon thing.. so I am not sure exactly what you mean.. the way the code you put should work is that if A's location has a mob in it, it does the stuff within the for statement.. I think you are looking for how to attack only mobs that are a certain distance from the usr who is using the attack...
set src in oview(#) that might be what you are looking for.. just stick that right under the verb name... |
In response to Nick231
|
|
Maybe i have to repeat a proc... ANYWAYS
When i used that, and i got near an enemy, IT shot the zap. Then it ddn't do the damage. So i guess i have to repeat proc, anybody know how to do that? |
Unknown Person wrote:
B:DeathCheck(B) I have two problems with this line. First, why are you using the : operator? If DeathCheck() does not belong to all mobs, then you should define B as a more specific type, like var/mob/player/B. There's no excuse for using : here. Second, why are you passing B as an argument when it'll be src for the DeathCheck() proc? The correct way to right a death check is like this: mob/proc/DeathCheck(mob/killer)
B.DeathCheck(usr) // usr is the attacker in this verb
Lummox JR |
In response to Lummox JR
|
|
Thanks for the DeathCheck() help. But you didn't fully answer my question. How could i make it so that my verb attacks anything that is in the Zap's location? Because it only works when the mob is 1 tile away.
|
If what you're trying to do is fire a projectile.. A nice way to do it would be to create a seperate object and just fire it, using <code>bump()</code> to see if it hits something.
Like so...? (This is untested. Just whipped it up because I am bored.) obj --Tarmas. No, I did not just post. |
In response to Tarmas
|
|
Is there a way to do this without using the bump() proc?
|
for(var/mob/B in A.loc)
Use
for(var/mob/B in oview(#))
Just replace # with a number for however many tiles away you want the attack to effect people