ID:261719
 
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?
Instead of

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
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)
if(HP<=0)
...
Thus if you had a better-defined DeathCheck(), that line of code I pointed out would look like this:
B.DeathCheck(usr)  // usr is the attacker in this verb
But it's still important to pass on the killer to DeathCheck() as an argument, because no game should count on the killer always being usr.

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
Zap
density = 1 // Important. It explodes when it hits something.
var
owner = null // Make sure the owner of a blank object is blank.
Bump()
for(var/mob/target in locate(get_step(src,dir))) // All mobs in the hit area get touched.
flick('HitMonsters.dmi',target) // Hurting animaation on mob.
target.hp -= target.str // Actual hp hurting on mob.
target << sound('HIT.WAV') // Mob hears noise that says "pain!"
target.deathcheck(owner) // Are you dead yet?
spawn() del(src) // Make sure it's all done, then clean up.
mob
verb
Zap()
set category = "Battling"
if(hp<=0) return // Let's not let dead/bugged players Zap! things.
flick("Slash",src) // Have the player/mob do its animation.
src << sound('ATTACK.WAV') // Player/mob hears attack fun noise.
var /obj/Zap/projectile = new(locate(src)) // Create the projectile.
projectile.dir = src.dir // Projectile goes in the same way player is facing.
projectile.owner = src // Who does this thing belong to, anyway?
walk(projectile, dir, 1) // With my mind I set the projectile in motion...
proc
deathcheck(doer as mob)
if(hp<=0) // Are you really dead?
world << "[src] has been killed by [doer]!" // Tell your friends!


--Tarmas.
No, I did not just post.
In response to Tarmas
Is there a way to do this without using the bump() proc?