ID:176873
 
ok so now im trying something new with my phaser beam I want it to kill a whole different type of enemy. so this is what I thought would work.

obj
phaser
icon = 'phaser.dmi'
icon_state = "phaser"
verb/fire_phaser()
var/obj/phaserbeam/P = new(locate(usr.x,usr.y,usr.z))
walk(P,usr.dir,1)


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

if(istype(A,/mob/romulan))
var/mob/romulan/M = A
var/mob/Warrior/W = A
W.hp -= 5
M.rh -= 5
del(src)
if(!ismob(A))
del(src)
if(key)
del(src)
else del(src)
please note that the new part of this code is the var/mob/Warrior/W = A here is the warrior code.

mob
Warrior
var/mob/target
icon = 'person.dmi'
icon_state = "darian"
density = 1
hp = 10
New()
..()
spawn(20)
WarriorAI()
New()
..()
spawn(20)
DeathCheck()
verb
fight(var/mob/M in view(1))
set src in view(1)
if(usr.str >=1)
M.hp -= usr.str
usr<< "you hit the warrior"
if(M.hp ==0)
usr << "you knocked him out"
sleep(3000)
M.hp = 10
proc
WarriorAI()
set src in view(1)
for(var/mob/M in view(7))
if(M.client !=null)
src.target = M
for(var/mob/M in view(1))
if(M.client !=null)
src.target = M
M << "The Warrior atacks you"
M.hp -=1
if(M.hp==0) M.end()
step_towards(src, src.target)

spawn(10)
if(src.hp >= 1)
WarriorAI()
proc
DeathCheck()
if(src.hp <=0)
del(src)
usr<<"you killed the warrior! this is against starfleet orders!"
darianrelation -= 5
spawn(10)
DeathCheck()

please take a look at the deathcheck() im not sure what is going wrong.

WHATS SUPPOSED TO HAPPEN
when the phaser beam hits the warrior its supposed to take away 5 hp when the warrior reaches 0 hp its supposed to del the warrior print a meesage to the usr and cause a global var to decrease

WHAT IS HAPPENING
noithing. the phaser beam hits the warrior and del its self but the warrior still keeps comming.

please help.
You're not calling M.DeathCheck.
In response to Garthor
Garthor wrote:
You're not calling M.DeathCheck.

I dont understand what you mean. could you elaborate?
In response to Treasurecat
In a new line, after each of the HP -= stuff, just put M.DeathCheck() or whatever it was.
Treasurecat wrote:
ok so now im trying something new with my phaser beam I want it to kill a whole different type of enemy. so this is what I thought would work.

You have another problem here:

proc
DeathCheck()
if(src.hp <=0)
del(src)
usr<<"you killed the warrior! this is against starfleet orders!"
darianrelation -= 5
spawn(10)
DeathCheck()

please take a look at the deathcheck() im not sure what is going wrong.

One thing you definitely did wrong: You called del(src) too soon. Nothing after that will be executed. Put del(src) at the end of that if() block.

I also have no idea why you're respawning the proc every second; it should be called only when damage is done.

Lummox JR
In response to Lummox JR
I also have no idea why you're respawning the proc every second; it should be called only when damage is done.

Lummox JR

because I dont know what code I would use to impliment that I also dont know the benifits to that.

also be advised that moving the del(src) did not help.
In response to Treasurecat
Treasurecat wrote:
I also have no idea why you're respawning the proc every second; it should be called only when damage is done.

because I dont know what code I would use to impliment that I also dont know the benifits to that.

How can you not know that? Call something like target.DeathCheck(attacker). Very simple.

The only reason for respawning the proc every second would be if there was some purpose in constantly polling its status, but there isn't because the status only changes after an attack. Besides, the proc has to be called in the first place anyway.

also be advised that moving the del(src) did not help.

It wouldn't yet, because as has been noted already, you haven't actually called this proc correctly. The bug caused by the misplaced del(src) is being masked by the fact that the proc is called wrong or not at all. However, moving del(src) is still the right thing to do.

Lummox JR
In response to Lummox JR
but I still have the problem of not being able to kill the warrior with the phaser beam
In response to Treasurecat
<code>if(istype(A,/mob/romulan)) var/mob/romulan/M = A var/mob/Warrior/W = A</code>

Notice anything? Specifically, the first line of those three.