ID:273479
 
Greetings!

I have troubles with Deadron's pathfinding.

It conflicts with my:

client/New()
var/i
if(key in SuperUsers)
usr = new/mob/DM()
if(!usr.loc)
usr.loc = locate(/turf/ground_start)
usr.name = key
usr.key = key //connect the player
for(i=1,i<=6,i++)
usr.equipment[i]="<empty>"
usr << "<font color=cyan><b>\[STARTINFO\]: [debug_lightsourcecount] lightsources total.</b></font>" //Debug Info
usr << "<font color=cyan><b>\[STARTINFO\]: [debug_litcount] lights were lit.</b></font>" //Debug Info
usr << "<font color=Red><b>Hello, master!</b></font>"
else
usr = new/mob/player()
if(!usr.loc)
usr.loc = locate(/turf/ground_start)
usr.name = key
usr.key = key //connect the player
for(i=1,i<=6,i++)
usr.equipment[i]="<empty>"


I can't find the issue. I thought it has something to do with other stuff, but a simple test like putting it in client/respawn() and putting it in New() like this:
Client/New()
..()
sleep(30)
respawn()

shows that pathfinding works before, but after 3 sec I "respawn" and it doesn't work.

I test it with Click() provided by Demo in download.
#include <deadron/pathfinding>
#include <deadron/eventloop>


client
Click(atom/movable/object, location)
// When the player clicks on something, this client.Click() function is called.
// object is the thing they clicked on, location is the turf or the name of the
// statpanel where the click occurred.

// Set the player's destination to what they clicked.
mob.destination = object
return ..()


mob

var/tmp
destination
next_walk_time // When is the next time for us to walk?
walking_delay = 10 // How long between movement?
movement_percent = 50 // What percentage of the time should it move?

Login()
src << "<H2>Click any spot to move there.</H2>"
src << "<H2>The amazing PathFinding library will avoid all obstacles.</H2>"
return ..()

base_EventCycle()
// This gets called once each tick.

if (next_walk_time <= world.time)
// It's time to walk if we clicked on something.
if (destination)
var/reached_dest = base_StepTowards(destination)
if (reached_dest)
// We're there!
src << "Reached destination!"
destination = null

// Set the next walk time.
next_walk_time = world.time + walking_delay
return


If I click after I respawn() nothing happens.
The problem was that the new mobs created for players were not added to the GameController list.

I've solved it by adding GameController.AddEventCycleReceiver(usr) to the end of my code.

Anyone who knows this library good, can you tell me why didn't it assign the new mobs to the list?