ID:1325200
 
(See the best response by DarkCampainger.)
Hi to all !

My name is Lucas Araújo, i'm a brazilian game designer(originaly a pixel-artist) and also a C# programer majoring in information systems.

I have started to code on byond a little time ago, and started a project called "Infected Online" with my team(Pixel SoftWorks). I have coded the basic AI and the basic Spawner System, the problem is :

* When i'm using the Dream Maker to compile and run my project, the game runs fine the spawner system works and also the AI system. But when I start my server with Dream Daemon the two systems doesn't work.

I think some of you guys that have a lot more experience than I should be able to give me a hand !

I have recorded a video about the bug :

http://www.youtube.com/watch?v=YsFTTGsbxLM

And here is the codes :

Spawner :
obj
proc
Spawn(mob/Jogador/J in oview(100, src)) //Define que mob/Jogador/J(Variável) é um mob no campo de visão de 100 tiles.
var/Contador = 0
for(J) //Para J, ou seja, a condição acima :
if(get_dist(src, J) <= 10) //Se a distância de J para o spawn for menor ou igual a 10 tiles :
while(Contador < 5) //Enquanto o contador for menor que 5 :
new/mob/Inimigos/Zumbi(src.loc) //Spawna um novo Zumbi, no local em que o spawner foi colocado.
sleep(50) //Aguarda 50 mileseconds :
Contador++ //Adciona +1 ao contador
sleep(1000) //Aguarda 1000 mileseconds :
Contador = 0 //Zera o contador para que processo de spawn seja recomeçado.
Spawn() //Chama recursivamente o proc spawner.
else if(get_dist(src, J) > 10) //Se a distância for maior que 10 tiles.
sleep(10) //Descansa 10 mileseconds.
Spawn() //Chama recursivamente o proc Spawn()
sleep(10) //Descansa 10 mileseconds.
Spawn() //Chama recursivamente o proc Spawn()


AI system :
mob/Inimigos
proc
AI(mob/Jogador/J as mob in oview(1000, src)) //Define que mob/Jogador/J(Variável) é um mob no campo de visão de 1000 tiles.
for(J) //Para J, ou seja, a condição acima :
if(get_dist(src, J) <= 10) //Se J estiver a menos de 10 tiles ou a 10 tiles do zumbi, o zumbi vai persegui-lo.
walk_towards(src, J, 0, 2) //Persegue o jogador.
if(get_dist(src, J) <= 2) //Se J estiver a menos de 2 tiles ou a 2 tiles do zumbi :
Atacar(J) //O zumbi ataca J.
sleep(10) //Delay de 10 mileseconds.
AI() //Chama recursivamente o proc AI(), para que checagens sejam feitas denovo.
else if(get_dist(src, J) >= 10 && get_dist(src, J) < 20) //Se não, se a distância de J para o Zumbi for igual a 10 tiles e menor que 20 tiles :
walk_rand(src, 0,2) //Zumbi anda randomicamente.
sleep(10) //Delay de 10 mileseconds.
AI() //Chama recursivamente o proc AI(), para que chegagens sejam feitas denovo.
else if(get_dist(src, J) > 20) //Se não, se a distância de J para o Zumbi for maior que 20 tiles :
del(src) //Deleta o mob para que seja evitada sobrecarga no servidor.
sleep(10) //Aguarda 10 mileseconds :
AI() //Chama recursivamente o proc para verificar erros na IA e corrigi-los.
You're missing the part of your code that starts the process.
AI :
//Inicio das definições do Mob :
mob/Inimigos
Zumbi
name = "Rotting Corpse"
icon = 'Zumbi.dmi'
icon_state = "Parado"
density = 1

New()
underlays += image('Sombra.dmi', pixel_x = 3)
spawn(1)
AI()
//Sons()


Spawner :
//Definição do objeto spawner :
obj
Spawner
icon = 'Spawns.dmi'
icon_state = "Mob_Spawn"

New()
spawn(1)
Spawn()
You're saying this works in single-player mode but not multiplayer-mode? Are you hosting the right files?
Yes man, in the video you can see what i'm saying.
So the AI system is fine.. It's just they don't get Spawned... right?
I think if I can make one of them work I can do the other, because the principie is the same in the two procs.
Best response
Tacurumin wrote:
obj
proc
Spawn(mob/Jogador/J in oview(100, src)) //Define que mob/Jogador/J(Variável) é um mob no campo de visão de 100 tiles.
var/Contador = 0
for(J) //Para J, ou seja, a condição acima :


Your issue is the for(J). If there aren't any players in the world (ie the world just started up from Dream Daemon), this will never run and the Spawn() proc will end before you even join the game.

You should just be using a while(true) loop:
obj
Spawner
proc
Spawn()
while(true)
for(var/client/C)
var/mob/Jogador/J = C.mob
if(istype(J) && get_dist(src,J) <= 10)
for(var/Contador = 0, Contador < 5, Contador++) //Enquanto o contador for menor que 5 :
new/mob/Inimigos/Zumbi(src.loc) //Spawna um novo Zumbi, no local em que o spawner foi colocado.
sleep(50) //Aguarda 5 seconds :
sleep(1000) //Aguarda 100 seconds :
break

sleep(10) //Descansa 1 seconds.


I updated it to be defined under the /obj/Spawner type, to use a while() loop, and to loop through clients instead of mobs.

I also removed the mob/Jogador/J in oview(100, src) argument. Unlike verbs, proc arguments don't accept restrictions like "in oview(*)". You have to pass the value you want to it (which you don't need in this particular situation).

If you want to know the specifics of any change, let me know.

Also, sleep() is measured is 1/10th's of a second, not milliseconds.