ID:147239
 
i decided to make a random battle system but a little different, it works so far(not yet done) except when the monster gets to close, i move to random squares on the map(only once per turn) for some reason =/ well heres the code:
turf
randombattles
forest
Enter()
usr << "test"
spawn()usr.battlearea = "ba1"


mob/var/battlearea
mob
var
lastx
lasty
lastz
newbie = 1
mob
verb
test()
usr.random1()
var/mob/monster/M = new/mob/monster()
M.npcrandom1(usr)
mob
proc
random1()
var/x = rand(1,world.maxx-1)
var/y = rand(1,world.maxy-1)
usr.lastx = usr.x
usr.lasty = usr.y
usr.lastz = usr.z
if(forest1 == 0)
src.loc = locate(1,1,2)
src.battlearea = null
sleep(1)
src.x = x
src.y = y
src.inbattle = 1
forest1 = 1
src.turns = 4

npcrandom1(mob/M)
var/x = rand(1,world.maxx)
var/y = rand(1,world.maxy)
src.loc = locate(1,1,2)
sleep(1)
src.owner = M
src.x = x
src.y = y
src.turns = 4
ka_AI()
var/mob/M
for(M in world)
sleep(10)
if(src.owner == M)
if(M.in oview(1))
spawn() ka_AIattack(M)
else
if(src.turns > 0)
src.turns --
step_towards(src,M)
if(src.turns == 0)
M.turns = 4
M << "Your turn"
M.moveable = 1
src.moveable = 0
else
sleep(10)
src.ka_AI()
ka_AIattack(mob/M)
var/dmg = src.str - M.def+3
if(dmg > 0)
M.hp -= dmg
M << "[src] hit you for [dmg] damage"
death(M,src)

death(mob/M,mob/killer)
if(M.hp <= M.mhp)
M << "You died!!!"
M.loc = locate(M.lastx,M.lasty,M.lastz)
if(usr.newbie == 1)
M << "Since this is your first death you wont be charged any health, but next time you will lose half! be warned"
M.newbie = 0
else
M.hp = M.mhp*2.5
del(killer)

please help =)
--thanks in advance
Your death() proc is completely wrong. You don't need two mob arguments because only the killer needs to be sent. src, not anything else, should be the thing that dies. And the thing you delete at the end should be src, not the killer.

Lummox JR
In response to Lummox JR
A.) thats not my problem
B.) i WANT killer to die(so it doesnt stay there after i die)
C.)can anyone acually help?
In response to Lummox JR
You didn't notice that he was using usr in Enter().

Or at least, you didn't mention it.
In response to Kablez
Kablez wrote:
A.) thats not my problem
B.) i WANT killer to die(so it doesnt stay there after i die)
C.)can anyone acually help?

The killer should be the mob committing a kill. There's no other meaningful use for a var with that name. If you mean a projectile or weapon, this is entirely the wrong place to delete it: The weapon should handle deleting itself when it delivers the blow.

Lummox JR
In response to Lummox JR
I think he has a system where the monster only exists for the length of the fight.
In response to Garthor
your right, but id like some help on it =P