Page 1 of 1
SYSEVENT_ENTERED_AREA on item control script
Posted: Sat Sep 17, 2016 7:28 pm
by DevGIB
Hi All,
Been searching the forums and only found 1 reference to it with no answer given.
I'm trying to apply a SYSEVENT_ENTERED_AREA on an item control script so that when players walk within range of a camp fire it triggers something.
At the moment from what i can see its doing the while loop and waiting for an even but at the end of the wait there is no event received even though a player has walked within the range defined.
Is there a specific reason why SYSEVENT_ENTERED_AREA doesn't appear to work on items or am i doing something wrong?
Code: Select all
program townflamecontrol( item )
EnableEvents( SYSEVENT_ENTEREDAREA, 4 );
var ev;
while( item )
ev := os::wait_for_event( 10 );
if( ev )
if( ev.type == SYSEVENT_ENTEREDAREA )
SendQuestArrowEx( ev.source, -1, -1 );
endif
endif
endwhile
return 1;
endprogram
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Sun Sep 18, 2016 12:03 am
by Nando
If I recall correctly, the ENTEREDAREA event was only sent to NPCs for performance reasons, because there may be too many items in an area. I'm afraid that's an old limitation of POL.
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Sun Sep 18, 2016 2:22 am
by DevGIB
I guess there could be just as many NPC's in an area, but i understand that there might be limitations.
I just wanted to make sure that i wasn't missing something basic. I'm sure i can work out a different way of handling things just the entered area would be worked well for what i wanted.
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Sun Sep 18, 2016 6:35 pm
by CWO
What's the range that you want to search, how many of these items would exist, and how instant does the reaction need to be? You can probably pull it off using ListMobilesNearLocation with about a second or two of sleep between checks.
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Mon Sep 19, 2016 2:17 am
by DevGIB
Item count: approx 10.
Range: approx 3-4.
Response time: fairly quick.
Effectively what you've suggested is what I ended up doing. It works fine for now
If i wanted to be crazy technical i could have it spawn an invisible NPC which carried out the function but that just seems overkill.
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Mon Sep 19, 2016 11:54 am
by Nando
It's an old design decision, I assume it would require some big code changes at the moment. Probably at the time the cost of updating the events each time an item was added/removed from the world was considered too high. Or just no one thought about it...

Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Mon Sep 19, 2016 9:28 pm
by Yukiko
Given today's processor speeds I imagine the overhead of adding that event to items shouldn't be a problem. The Devs would know better about this but it seems to me that having a script scan for mobiles in a range would take about as much time.
We're talking about players entering the area here. Is there a way to specify some sort of flag to differentiate between mobile types, ie. NPCs and players? That might reduce overhead since the entered area event would be looking for only characters that are players. I've thought it odd that this was only limited to NPCs but I'm sure Nando is right that it was either a design oversight or the original though was to reduce overhead.
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Tue Jan 03, 2017 2:50 pm
by OWHorus
Hello,
I would like a special POL object with a control script which acts like a NPC and supports EnteredArea-Events. It is not necessary that every item supports this.
I am using a NPC for exactly this function: I have a miracle-spell which does things to an area, for example it does not allow fighting. This is temporary and limited to a radius around the cast location. I am actually using an invisible NPC with a special NPC-script for this - it works like a charm, but is a bit complicated.
What I did: I created a NPC (human form), and set it invisible, the player will never see it. The NPC-script does not support moving or fighting, it is very simple and does only setup the Area-Events for itself. Then it stands around and applies the effect to every mobile entering its area, and removes it when it leaves the area. It also stores all modified mobiles, and when the effect ends, it removes it from all remaining mobiles and deletes itself.
This could be a solution to your problem, but not a very elegant one I admit...
OWHorus
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Thu Jan 05, 2017 5:09 am
by guialtran
sorry about my English.
How are you starting the script on this item?
NpcTemplate AlfredNobel
{
//Name (string paperdoll name)
//ObjType (integer body model type)
//Script (string AI script) <<<<<<<< THISS
This is a special script that only has in the NPC.
Item 0x7778
{
//Name (string unique object name)
//Graphic (int tile number)
//[Color (int color {default 0})]
//[Facing (int facing {default 0})]
//[Desc (string description {default empty})]
//[Tooltip (string tooltip {default empty})]
//[WalkOnScript (string scriptname)]
//[Script (string scriptname)] <<< This script is only called when you click on the item.
So you have to look for a script that runs at the beginning of the server, to always be in it
Item (objtype)
{
Name (string unique object name)
[Name...]
Graphic (int tile number)
[Color (int color {default 0})]
[Facing (int facing {default 0})]
[Desc (string description {default empty})]
[Tooltip (string tooltip {default empty})]
[WalkOnScript (string scriptname)]
[Script (string scriptname)]
[EquipScript (string scriptname)]
[UnequipScript (string scriptname)]
[ControlScript (string scriptname)] <<<<<<<this
Re: SYSEVENT_ENTERED_AREA on item control script
Posted: Thu Jan 05, 2017 5:27 am
by guialtran