ID:146991
 
Umm, I have this repop code, but i cant get it to work.. When i kill something, it dissapears, but wont respawn O.o

This is the code:

mob
proc
MonsterAttack(mob/M)
if(src.attacking == 0)
src.attacking = 1
//var/parrylist = list("High","Middle","Low")
//continu = 1
//else
// continu = 1
//tryagin
//if(continu == 1)

view() << "[M] takes [src.Str] damage from [src]!"
M.Hp -= src.Str
Death(M)
sleep(src.Delay)
src.attacking = 0

mob
proc
Death(mob/M)
if(src.type == /mob/player)
Playerdie()
else
if(src.Hp<=0)
view()<<"[src] has been killed by [usr]!"
del(src)
therepop()
Playerdie(mob/M)
if(src.Hp<=0)
view() << "[usr] Died!"
src.loc = locate(1,1,1)
src.Hp = Max_Hp
therepop()
proc
therepop()
world.Repop()
sleep(150)


mob
proc
NonAggresiveLook() //name of proc
var/mob/player/M //variable M has to be mob/usr
while(src) //while src is stil kickin
if(M in oview(5)) //if M is in oview(5)
if(M.name in src.killlist) //now if M.name is in src.killlist, this has it only attack if attacked!
walk_to(src,M,1,4) //src walks to M until 1 block away, moving 4/10ths of a second
if(M in oview(1)) //if M is in oview(1)
step_towards(src,M) //src steps toward M
else //if usr.name isnt in src.killlist
//src.killlist += M.name
sleep(15)//pauses for 1 and 1/2 seconds
step_rand(src) //step randomly on the field
break //breaks out of the while loop
else //if M isnt in oview(5)
for(M in view(src)) //for all Ms in view(src)
break //breaks out of the while loop
sleep(5) //pauses 1/2 second before redoing loop
spawn(2) // pauses 2/10 of second before redoing proc
NonAggresiveLook() //redoes proc
AggresiveLook() //name of proc
var/mob/player/M //variable M has to be mob/usr
while(src) //while src is stil kickin
if(M in oview(5)) //if M is in oview(5)
if(M.name in src.killlist) //now if M.name is in src.killlist, this has it only attack if attacked!
walk_to(src,M,1,4) //src walks to M until 1 block away, moving 4/10ths of a second
if(M in oview(1)) //if M is in oview(1)
step_towards(src,M) //src steps toward M
else //if usr.name isnt in src.killlist
src.killlist += M.name
sleep(15)//pauses for 1 and 1/2 seconds
step_rand(src) //step randomly on the field
break //breaks out of the while loop
else //if M isnt in oview(5)
for(M in view(src)) //for all Ms in view(src)
break //breaks out of the while loop
sleep(5) //pauses 1/2 second before redoing loop
spawn(2) // pauses 2/10 of second before redoing proc
NonAggresiveLook() //redoes proc
mob/var
Delay = 50
mob
Enemy
Mutant_Mushroom
icon = 'characters.dmi'
icon_state = "49"
Hp = 15
Max_Hp = 15
Delay = 60
Str = 5
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
spawn(1) //wait for 1/10 of a second
NonAggresiveLook() //starts the Look() proc
Bump(mob/M) //when peacefulguy bumps into someone, thing it bumps into is M
if(M.client) //M is a client
if(src.attacking == 0)
MonsterAttack(M) //goes to monsterattack send M
mob
Enemy
WereWolf
icon = 'characters.dmi'
icon_state = "50"
Hp = 30
Max_Hp = 30
Delay = 40
Str = 10
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
spawn(1) //wait for 1/10 of a second
NonAggresiveLook() //starts the Look() proc
Bump(mob/M) //when peacefulguy bumps into someone, thing it bumps into is M
if(M.client) //M is a client
if(src.attacking == 0)
MonsterAttack(M) //goes to monsterattack send M

mob/var
killlist = list("")
attacking = 0

Someone Please help ><
please dont waste time by posting the samething in 2 places.
The problem is in this chunk of the mob/Death() proc:
                if(src.Hp<=0)
view()<<"[src] has been killed by [usr]!"
del(src)
therepop()

When it hit's the "del(src)" line, it deletes the mob and stops executing any procs that belong to it, including this one! You can make an independant global proc and call it just before the del(src) so that it continues even when the mob is gone.
                if(src.Hp<=0)
view()<<"[src] has been killed by [usr]!"
GlobalRepopWithDelay()
del(src)

// ... somewhere else in your project ...

proc/GlobalRepopWithDelay()
/* spawn() is used here so that the proc will return
and Death() may continue without waiting */

spawn(150) // do the following in 15 seconds
world.Repop()

In response to Shadowdarke
Shadowdarke wrote:
The problem is in this chunk of the mob/Death() proc:
>                 if(src.Hp<=0)
> view()<<"[src] has been killed by [usr]!"
> del(src)
> therepop()
>

When it hit's the "del(src)" line, it deletes the mob and stops executing any procs that belong to it, including this one! You can make an independant global proc and call it just before the del(src) so that it continues even when the mob is gone.
>                 if(src.Hp<=0)
> view()<<"[src] has been killed by [usr]!"
> GlobalRepopWithDelay()
> del(src)
>
> // ... somewhere else in your project ...
>
> proc/GlobalRepopWithDelay()
> /* spawn() is used here so that the proc will return
> and Death() may continue without waiting */

> spawn(150) // do the following in 15 seconds
> world.Repop()

ummm, It still wont respawn ><
In response to Takaru
Takaru wrote:
ummm, It still wont respawn ><

Show me the current version of your code.
In response to Shadowdarke
Shadowdarke wrote:
Takaru wrote:
ummm, It still wont respawn ><

Show me the current version of your code.

mob
proc
Death(mob/M)
if(src.type == /mob/player)
Playerdie()
else
if(src.Hp<=0)
view()<<"[src] has been killed by [usr]!"
GlobalRepopWithDelay()
usr.exp += src.expgive
Levelup()
del(src)
Playerdie(mob/M)
if(src.Hp<=0)
view() << "[usr] Died!"
src.loc = locate(1,1,1)
src.Hp = Max_Hp
GlobalRepopWithDelay()

proc/GlobalRepopWithDelay()
/* spawn() is used here so that the proc will return
and Death() may continue without waiting */
spawn(150) // do the following in 15 seconds
world.Repop()


mob
proc
NonAggresiveLook() //name of proc
var/mob/player/M //variable M has to be mob/usr
while(src) //while src is stil kickin
if(M in oview(5)) //if M is in oview(5)
if(M.name in src.killlist) //now if M.name is in src.killlist, this has it only attack if attacked!
walk_to(src,M,1,4) //src walks to M until 1 block away, moving 4/10ths of a second
if(M in oview(1)) //if M is in oview(1)
step_towards(src,M) //src steps toward M
else //if usr.name isnt in src.killlist
//src.killlist += M.name
sleep(15)//pauses for 1 and 1/2 seconds
step_rand(src) //step randomly on the field
break //breaks out of the while loop
else //if M isnt in oview(5)
for(M in view(src)) //for all Ms in view(src)
break //breaks out of the while loop
sleep(5) //pauses 1/2 second before redoing loop
spawn(2) // pauses 2/10 of second before redoing proc
NonAggresiveLook() //redoes proc
AggresiveLook() //name of proc
var/mob/player/M //variable M has to be mob/usr
while(src) //while src is stil kickin
if(M in oview(5)) //if M is in oview(5)
if(M.name in src.killlist) //now if M.name is in src.killlist, this has it only attack if attacked!
walk_to(src,M,1,4) //src walks to M until 1 block away, moving 4/10ths of a second
if(M in oview(1)) //if M is in oview(1)
step_towards(src,M) //src steps toward M
else //if usr.name isnt in src.killlist
src.killlist += M.name
sleep(15)//pauses for 1 and 1/2 seconds
step_rand(src) //step randomly on the field
break //breaks out of the while loop
else //if M isnt in oview(5)
for(M in view(src)) //for all Ms in view(src)
break //breaks out of the while loop
sleep(5) //pauses 1/2 second before redoing loop
spawn(2) // pauses 2/10 of second before redoing proc
NonAggresiveLook() //redoes proc
mob/var
Delay = 50
mob
Enemy
Mutant_Mushroom
icon = 'characters.dmi'
icon_state = "49"
Hp = 15
Max_Hp = 15
Delay = 60
Str = 5
expgive = 3
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
spawn(1) //wait for 1/10 of a second
NonAggresiveLook() //starts the Look() proc
Bump(mob/M) //when peacefulguy bumps into someone, thing it bumps into is M
if(M.client) //M is a client
if(src.attacking == 0)
MonsterAttack(M) //goes to monsterattack send M
mob
Enemy
WereWolf
icon = 'characters.dmi'
icon_state = "50"
Hp = 30
Max_Hp = 30
Delay = 40
Str = 10
expgive = 6
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
spawn(1) //wait for 1/10 of a second
NonAggresiveLook() //starts the Look() proc
Bump(mob/M) //when peacefulguy bumps into someone, thing it bumps into is M
if(M.client) //M is a client
if(src.attacking == 0)
MonsterAttack(M) //goes to monsterattack send M

mob/var
killlist = list("")
attacking = 0
In response to Takaru
You made GlobalRepopWithDelay() a mob proc by indenting it below mob, which means it belongs to the mob and is being cancelled when the mob is deleted. Move it to the section just before the mob declaration and unindent that block until the word "proc" is against the left margin with no indentation.
In response to Shadowdarke
I will proudly give my Repop() code! (To let you modify of course.)

//add this somewhere in your code!

world
proc
Repop_Incriment()
sleep(3000)
world << "<center><font color=white><font size=1>The sun sets, fields are now pitch black. It is now evening."
world.Repop()
sleep(3000)
world << "<center><font color=white><font size=1>The sun rises, fields are now light and active with life. It is now morning."
world.Repop()
Repop_Incriment()
world
New()
..()
Repop_Incriment()


For this code, the default repop time is 5 minutes, and it gives a repop statement telling the world that it repopped. (I did it twice for day and night.) Then you just call the proc again at the end of the code. The bottem code is some extra code that you don't need to modify.