ID:177322
 
maybe im going at this the wrong way but I wanted one projectile to kill the usr and another to kill the npc. ive tried a few things to make these two projectiles different but the disruptor kills the npc instead of the usr can someone help.
thanks.

phaserbeam
var
cl=-1
Bump(atom/A)

if(ismob(A))
var/mob/romulan/M = A

M.hp -= 5
del(src)
if(!ismob(A))
del(src)
else return 0
disruptor
var
cl=-1
Bump(atom/A)

if(ismob(A))
var/mob/M = A

M.hp -= 5
del(src)
if(!ismob(A))
del(src)
else return 0
ok I tried moving the obj/disruptor to where it is defined and its not killing the npc anymore but its also not killing the player and the del(src) isnt working.

obj/disruptor
icon = 'projectile.dmi'
icon_state = "disruptor"
name = "disruptor"
density = 1
disruptor
var
cl=-1
Bump(atom/A)

if(ismob(A))
var/mob/M = A

M.hp -= 5
del(src)
if(!ismob(A))
del(src)
else return 0

and here is the proc() that calls it

proc/disruptor()
for(var/mob/M in view(5,src))
M << "no"
var/obj/disruptor/D = new(locate(src.x,src.y,src.z))
walk(D,src.dir,1)

the npc is firing the weapon and its traveling across the screen the problem comes when it hits something it just stays there. my phaser() is working just how I want it to.

can someone please help?
In response to Treasurecat
Because the Bump() is for obj/disruptor/disruptor, not obj/disruptor.
In response to Garthor
Garthor wrote:
Because the Bump() is for obj/disruptor/disruptor, not obj/disruptor.

I dont understand
In response to Treasurecat
Treasurecat wrote:
Garthor wrote:
Because the Bump() is for obj/disruptor/disruptor, not obj/disruptor.

I dont understand

What's not to understand?
obj/disruptor
icon = 'projectile.dmi'
icon_state = "disruptor"
name = "disruptor"
density = 1
disruptor
var
cl=-1
Bump(atom/A)

That "disruptor" line just before the last 3 lines means you're now dealing with /obj/disruptor/disruptor, not /obj/disruptor. Get rid of that line and unindent everything under it. And this Bump() proc is seriously messed up:
Bump(atom/A)
if(ismob(A))
var/mob/M = A
M.hp -= 5
del(src)
if(!ismob(A))
del(src)
else return 0

The else line is totally nonsensical. If the first if() is false, the second is true; one of them will work, so del(src) will be called, and that else is never reached. But you don't need the second if() at all. Since you want to del(src) no matter what, that should be outside the if.
Bump(atom/A)
if(ismob(A))
var/mob/M = A
M.hp = max(M.hp-5,0)
if(!M.hp) M.Die() // you need some kind of death check
del(src) // look ma, no indent!

Lummox JR
In response to Lummox JR
thank you. Im not sure where to put my death check for my player

mob
icon = 'person.dmi'
var
hp = 10
cp = 0
cl = 0
pow = 3
proc/end()
if (hp <=0)
usr.loc = locate(12,20,3)
usr.hp += 10

obj/disruptor
icon = 'projectile.dmi'
icon_state = "disruptor"
name = "disruptor"
density = 1

var
cl=-1
Bump(atom/A)
if(ismob(A))
var/mob/M = A
M.hp = max(M.hp-5,0)
if(!M.hp) M.end()
del (src)

doesnt this tell the compiler to run the end() if the disruptor hits anything but M. and why M.hp why not just M


thanks for your help I just ordered the blue book I hope that will make this at least a little easier.
In response to Treasurecat
Treasurecat wrote:
Bit of an inconsistent indent problem here (visible in your post):
proc/end()
if (hp <=0)
usr.loc = locate(12,20,3)
usr.hp += 10

Also a bit of a usr problem. DO NOT use usr in procs. That should be src--or omitted, since src is redundant.
I don't see why you're adding 10 to hp instead of just setting it to 10, though, unless you want the "new" ship to retain extra damage from the old.

Bump(atom/A)
if(ismob(A))
var/mob/M = A
M.hp = max(M.hp-5,0)
if(!M.hp) M.end()
del (src)

doesnt this tell the compiler to run the end() if the disruptor hits anything but M. and why M.hp why not just M

That doesn't make any sense. M is A, which is what the disruptor hit. There's no way the disruptor hit anything but M, because that's exactly what M is.

The if() tells DS to run end() if the mob the disruptor hit has just lost all its hit points--that is, if hp==0. By the time we get to the if(!M.hp) line, we know M==A, and A is a mob. But since your mob.end() proc already checks hp, you can just get rid of the if() there and call M.end() directly anyway.

Lummox JR
In response to Lummox JR
ok this is what I did.

Bump(atom/A)
if(ismob(A))
var/mob/M = A
M.hp = max(M.hp-5,0)
if(M.hp<=1) M.end()
del(src)

whats happening is that the romulans hp is being lowered by 5 also when they get hit its causing a friendly fire effect which I dont want one thing I did that I thought solved the problem is I changed the romulan var/hp to rh
this stopped them from dying but when this end() is called it effects the romulans when I just wanted it to effect the player only

proc/end()
if (hp <=1)
loc = locate(12,20,3)
hp += 10

I removed the usr and this got rid of the runtime error and made the proc work like I wanted it to but like I said its working for the romulans to

I dont know how to make the end() only work for the player
please help

thanks for you help.
In response to Treasurecat
Treasurecat wrote:
ok this is what I did.

Bump(atom/A)
if(ismob(A))
var/mob/M = A
M.hp = max(M.hp-5,0)
if(M.hp<=1) M.end()
del(src)

Uh... why are you using <=1? Then if you're down to 1 HP, you die, even though there's health left. That should be <=0.

whats happening is that the romulans hp is being lowered by 5 also when they get hit its causing a friendly fire effect which I dont want

I don't see how; the beam should only bump one thing and then get deleted.
Please punctuate your sentences, too. It's difficult to read through your problem if everything's a run-on sentence.

one thing I did that I thought solved the problem is I changed the romulan var/hp to rh
this stopped them from dying but when this end() is called it effects the romulans when I just wanted it to effect the player only

proc/end()
if (hp <=1)

Again should be <=0, not 1.

loc = locate(12,20,3)
hp += 10

And you've still got the +=10 in instead of =10. Is there some reason you're doing that?

I removed the usr and this got rid of the runtime error and made the proc work like I wanted it to but like I said its working for the romulans to

That shouldn't be happening to both, unless you're firing at both. If you're firing at both, the problem is in another proc.

I dont know how to make the end() only work for the player
please help

end() does only work for whoever's hit (not necessarily the player, but only one mob at a time); the problem lies elsewhere.

Lummox JR