ID:155181
 
My issue is this I am usin J_AI as the core for my game cause of the level up and attack system I did ask the developer for help with integrating my current beam code to work with his system and that issue was fixed thanx to him but now I am having trouble getting exp delt out when a enemy is killed with a beam attack i have been workin on this since I started back up on my game today to no avail so I have decided to come here for help so here is the code

Below is the code for the Spirit Gun with the code that the demo developer set up to implement the damage and the death for enemy which should in theory this should give me x amount of exp x being what ever i wanna set the exp for the mob for but its just not happining

obj
Eatk
icon = 'BeamAttacks.dmi'
icon_state = "head"
density = 1
layer = 100
New()
spawn(100)
del src
Bump(A)
CanDamage(Gowner,A,src)
..()

Move()
var/obj/k = new/obj/ETrail(loc)
k:dir = dir
..()

proc/CanDamage(mob/Owner,atom/A,obj/beam)
if(ismob(A))
var/mob/M=A
if(M==Owner) return
var/damage=CuaseDMG(Owner,M)
M.hp-=damage
Owner.J_Death(M)


view(8, Owner)<<"<b><font color = red>[Owner] hit [M] with his Spirit Gun for [damage] damage!"


Owner.firing=0
del(beam)

proc/CuaseDMG(mob/M,mob/P)
var/dmg=M.se - (P.def)
if(dmg<1) dmg=1
return dmg




obj
ETrail
layer = 100
icon = 'BeamAttacks.dmi'
icon_state = "middle"
New()
..()
spawn(8)
del(src)




///////////Enegry Attack Verbs///////////
mob
skill
verb/Spirit_Gun()
set category = "Specil Techs"
if(safe) return
if(se < 10)
src << "<b>Not enough enegry!"
return
if(!firing)
view(8) << "<b>[src]: Spirit Gun"
firing = 1
se -= 10
var/obj/K = new/obj/Eatk(loc)

K.Gowner = src
K.dir = dir
walk(K, dir)

mob/var
tmp/firing=0
tmp/safe = 0
obj
var
b//////Trail


The next 2 pieces of code are for the death and level up the code has no issues compiling or anything

Death

J_Death(mob/killer)

view()<<"\red <center><code>[src.name] has been killed by [killer.name]!!!"


killer.xp += xp_give
killer<<"<small>You have gained [xp_give] experience."
if(killer.xp >= killer.xpmax) killer.J_Level()


killer.target = null
if(killer.target_sign) del(killer.target_sign)
if(!killer.client)
var/mob/Monster/M=killer
M.target=null
M.active=0
M.walk_back=1
M.J_WB()

if(!client)
src.J_dienpc()
else

hp = hpmax



J_update(src)
level up
J_Level()
if(!CAN_NPC_LEVEL)
if(!client) return
if(xp >= xpmax)
xp = 0
xpmax += 100//Increase how much experience is needed to level up agian.
lvl++
//Increase varibles by random digits
hpmax += rand(15, 20)
str += rand(5, 7)
def += rand(4, 6)
att += rand(2, 3)
semax += rand(15,20)

hp = hpmax
src<<"<b>You have been promoted to level [lvl]!"
J_update(src)
if(xp >= xpmax) J_Level()//If you can level up agian do it
im not sure if this would help hut here is the get damage code
J_getdmg(mob/T)
var/dmg=rand( (3*(str+str_boost)) ,(6*(str+str_boost)) )
dmg-=round(rand((0.3*(T.def+T.def_boost)),(0.8*(T.def+T.def_boost))))
if(dmg<0) dmg=0
return dmg
Owner.J_Death(M)

It seems like you're calling the death proc for the person who fired the projectile, and then the killer is M.

Shouldn't this be M.J_Death(Owner) ?
In response to Bravo1
Bravo1 wrote:
Owner.J_Death(M)

It seems like you're calling the death proc for the person who fired the projectile, and then the killer is M.

Shouldn't this be M.J_Death(Owner) ?

I believe it should but now it has made another issue arise the beam attack deals exp after it kills a mob now so that's good bur for some reason its killing in one hit regardless of the enemy's health whereas is should not be able to do this the damage for spirit attacks is supposed to be like this usr.se-m.def so the damage for the spirit attack is based on how high the the users current spirit energy is in this case 50 which is then subtracted from the enemy's defense in this case 10 so it would deal 30 dmg outta the enemy's 1000 hp it should not be able to kill them in 1 hit
In response to Wrath69
Well, it looks like it subtracts health and then calls the death proc regardless. make sure there a if(M.health<=0) in there to make it call the death proc only when they're out of health.
In response to Wrath69
Please take time to type out what you mean with proper punctuation, I nearly lost you in the second sentence.

You really should stop using the colon (:) operator and start typecasting (.); easy mistakes can happen when using : and it may take you a while to find them. And did you define in the object who the Gowner is?

Either way, I am digressing. Your main problem is simple. Once the death() procedure is called, you did not check if the person was still alive! There was no "if(src.hp > 1) return" or the like... once the death() was called, you killed off the /mob.

(PS: It should deal 40 damage, not 30)
In response to GhostAnime
Ok got it fixed thanx all who helped with the post once I did the
if(M.hp <= 0)
M.J_Death(Owner)
it started working
In response to Wrath69
In your Death() procedure, you should have a safety check there as well (stop the proc is the HP > 0).
In response to GhostAnime
k thanx for the info