The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to move NPCs at night to "go home", I blame sectorsleep.
Author Message
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #1
Trying to move NPCs at night to "go home", I blame sectorsleep.
I am trying to force my NPCs to "go home" at night, and return to their stores in the daytime. I setup a basic test script attached to my test vendor's event, and the script works fine and WILL fire even if a player is not around, but the NPC won't move unless there is a player in the area.

I find it odd that the timer will still fire even if a player is no where in the area, but the NPC won't teleport/walk back to his home/store until after a player walks near the NPC.

The only thing I can think of, is the timer is still ticking when the sector is sleeping but the NPC himself won't move until the sector is woken up.

So, is there anyway to "wake up" a sector when the memory timer fires? Really, I'd like to disable sectorsleep entirely, but that doesn't seem like an option for some strange reason.

Code:
[EVENTS e_AI_Vendor]
ON=@NPCLookAtChar  //Just the initial first-time setup.
IF (<RESTEST i_mem_vendor_home>)
ELSE
   SERV.NEWITEM i_mem_vendor_home
   EQUIP <NEW>
   NEW.TIMER=5
ENDIF

[ITEMDEF i_mem_vendor_home]
ID=i_memory
NAME=Test
TYPE=t_eq_script
on=@equip
LINK=<SRC.UID>

on=@timer
if <sector.isdark>
LINK.SAY Time to go home! //Test-fire to make sure it works.
LINK.HOME 2537,2154,0 //Changes "Home" to his house, making him walk to or teleport to it.
ELSE
LINK.SAY Open the store!
LINK.HOME 2460,2062,0 //Same as above, for the store
ENDIF
TIMER=10 //reset the timer to check the area again.
RETURN 1

Note: I have tried using @EnvironChange, it won't work when a sector is sleeping. That's why I opted to use a timer instead. Smile

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
(This post was last modified: 08-10-2012 02:49 PM by Rayvolution.)
08-10-2012 02:47 PM
Find all posts by this user Like Post Quote this message in a reply
Shaklaban
Master
**

Posts: 378
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Mar 2012
Reputation: 8

DOT

Post: #2
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
if there is no player in the area then you can just teleport it to its house, since no one is seeing the npc there is no difference between walking and teleporting.

also you can try to use goto function:

"GOTO" location Begins moving the NPC towards the specified location.
08-10-2012 03:37 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #3
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
(08-10-2012 03:37 PM)Shaklaban Wrote:  if there is no player in the area then you can just teleport it to its house, since no one is seeing the npc there is no difference between walking and teleporting.

also you can try to use goto function:

"GOTO" location Begins moving the NPC towards the specified location.

Tried GO, GOTO and P already. None of them will fire unless a player is near the NPC. :/

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
08-10-2012 11:06 PM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #4
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
If the sector sleep, they will do nothing...
You can check if they must be in their home when the sector awake, them move them to their home.
Or, if they must be in home, but near a player, they walk to home, using GOTO <HOME>.
Thats a nice script, your server could be very good if you spent some time in.

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
08-11-2012 12:32 AM
Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #5
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
Well, whats strange is LINK.P *should* work even if the sector is asleep, because that just tells the sphere on the server level to relocate the NPC to the new location, it shouldn't matter if it's current location is sleeping or not. It just rewrites the character's location in the save file to the new spot, so it *should* just magically appear where I tell it to. :/

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
08-11-2012 02:10 AM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #6
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
Why would the NPC teleport home when there is no player if the entire function is under @NPCLookatChar?

How do you expect it to fire to send an NPC home with no player present? Your script will only run if that trigger is... triggered.
What you should do is have it look at the time of day in the gameworld, or a lightlevel to do the teleport home function. Of course then you will have to script it so that before it teleports it looks to see if it can indeed be seen by a player.

Further more is the trigger not @NPCSeeNewPlayer on @SeeNewPlayer? It's been a while since I did any serious scripting with sphere so I don't know whether your trigger is one they added or one I forget, but I don't recall seeing it before.

[Image: 2nis46r.jpg]
(This post was last modified: 08-11-2012 03:01 AM by Mordaunt.)
08-11-2012 02:43 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #7
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
(08-11-2012 02:43 AM)Mordaunt Wrote:  Why would the NPC teleport home when there is no player if the entire function is under @NPCLookatChar?

How do you expect it to fire to send an NPC home with no player present? Your script will only run if that trigger is... triggered.
What you should do is have it look at the time of day in the gameworld, or a lightlevel to do the teleport home function. Of course then you will have to script it so that before it teleports it looks to see if it can indeed be seen by a player.

Further more is the trigger not @NPCSeeNewPlayer on @SeeNewPlayer? It's been a while since I did any serious scripting with sphere so I don't know whether your trigger is one they added or one I forget, but I don't recall seeing it before.

NPCLookAtChar is only for initiation to creation/equip of the memory. For some reason you can't seem to tell an NPC to equip a memory on @create or @npcrestock. Since the NPC's initially is in the store the players will naturally trigger the memory to be created when they get near the store, if for some reason the NPC dies and needs to respawn. It'll actually work when the NPC looks at *any* character, but inside a small store thats unlikely.

Once the memory is created, the timer goes off and it checks the light level and triggers as required, then resets the timer back to 10. So, once the memory is created the script will run completely indepentantly of the NPCLookAtChar trigger.

Chances are once I clean up the script I'll just have the NPCs all have one common random item that actually holds the trigger, like an invisible ring or something. That way I can skip the NPCLookAtChar function. But I havent gotten past the sectorsleep problem.

An idea im going to try when I get home is make the "serv" run a P function instead, it could be that the NPC isnt firing LINK.P because he isnt awake, but if I can do a serv.link.p (I know thats not a correct command Tongue) instead it might fire it even if the sector is asleep, and since P is just writing the coordinates of the NPC to a new location, not actually teleporting him, it should work.

Then with their "Home" changed at the same time to the same location, they should stay there.

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
(This post was last modified: 08-11-2012 04:16 AM by Rayvolution.)
08-11-2012 04:06 AM
Find all posts by this user Like Post Quote this message in a reply
Anarch Cassius
Master
**

Posts: 273
Likes Given: 19
Likes Received: 10 in 9 posts
Joined: Mar 2012
Reputation: 2



Post: #8
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
Mordaunt. @NPCLookatChar is NOT @NPCSeeNewPlayer as Rayvolution says.

The big problem is that sleeping sectors don't have their NPCs move. They are supposed to be moving at a reduced ratio not never: If SECTORSLEEP is 10 then a NPC in a slept sector should be taking one step for every 10 an NPC would if the sector weren't asleep.

This seems to work for everything but the movement and causes issues like this and NPCs being found clustered at spawn points.

Current Projects: Necromancy SCP overhaul. Custom Faction AI/System. Imbuing.
(This post was last modified: 08-11-2012 05:06 AM by Anarch Cassius.)
08-11-2012 05:01 AM
Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #9
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
(08-11-2012 05:01 AM)Anarch Cassius Wrote:  Mordaunt. @NPCLookatChar is NOT @NPCSeeNewPlayer as Rayvolution says.

The big problem is that sleeping sectors don't have their NPCs move. They are supposed to be moving at a reduced ratio not never: If SECTORSLEEP is 10 then a NPC in a slept sector should be taking one step for every 10 an NPC would if the sector weren't asleep.

This seems to work for everything but the movement and causes issues like this and NPCs being found clustered at spawn points.

Hrm, is there anyway to fix this or is it a hardcoded issue in 56b we're stuck with?

I don't recall ever having that problem in 51a or 55i and my forests animals were all set to distance 0, with only 4-5 spawngems per large area of forest.

It might not matter for my new server because I'm having region-specific animals and I can't let them roam free, so chances are I'll have a ton of spawns set to distance 40-50 this time around. But it still sounds like that could be a problem in certain situations.

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
08-11-2012 05:37 AM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #10
RE: Trying to move NPCs at night to "go home", I blame sectorsleep.
Worked perfectly.
Code:
[EVENTS E_NPCHOMEATNIGHT]
ON=@NPCLOOKATCHAR
IF !<FINDID.I_MEM_VENDOR_HOME>
LOCAL.OLDNEW <NEW>
SERV.NEWITEM I_MEM_VENDOR_HOME
EQUIP <NEW>
NEW.TIMER 1
NEW <LOCAL.OLDNEW>
ENDIF
IF <SECTOR.ISDARK>
IF <DISTANCE <HOME>> > 2
  FINDID.I_MEM_VENDOR_HOME.TIMER 1
  //SAY @,,1 It's night, I'm going home...
  HOMEDIST 2
  GOTO <HOME>
ENDIF
ENDIF

[ITEMDEF I_MEM_VENDOR_HOME]
ID I_MEMORY
TYPE T_EQ_SCRIPT
NAME Vendor Home Memory
ON=@CREATE
ATTR 010
ON=@TIMER
IF <CONT.SECTOR.ISDARK>
IF <CONT.DISTANCE <CONT.HOME>> > 2
  IF <CONT.HOMEDIST> == 5
   CONT.HOMEDIST 2
  ENDIF
  CONT.GOTO <CONT.HOME>
  TIMER 10
  RETURN 1
ENDIF
ELSE
IF <CONT.HOMEDIST> == 2
  CONT.HOMEDIST 5
ENDIF
ENDIF
TIMER 10
RETURN 1

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
08-11-2012 06:34 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)