Hi fellas. I'm trying to get an NPC to spawn in an area when the PC enters that area and some predefined integer variable reaches a certain value. I placed this script in the area's Properties --> Events --> OnEnter window:
Hi fellas. I'm trying to get an NPC to spawn in an area when the PC enters that area and some predefined integer variable reaches a certain value. I placed this script in the area's Properties --> Events --> OnEnter window:
The GetLocation(OBJECT_SELF) that you used actually tries to get the location of the area, and not the WP.
If the WP tag you want to use is "angelaappearshere" then you need:
location angelaappearshere = GetLocation(GetObjectByTag("angelaappearshere"));
This is the on enter event so GetEnteringObject() instead of GetPCSpeker(). Also you might want to check that it is a PC
object oPC = GetEnteringObject();
if (GetIsPC(oPC)) {
<your spawning conditional here>
}
if((GetLocalInt(GetModule(), "violet99") == 3))Edit to add: make sure you do the same when you set the value to 4 later on.
That's what I call teamwork ![]()
Tried out the advice offered by all of you. This time it worked beautifully!
Thanks so much for the help, fellas. You all ROCK! ![]()
Though I use similar scripted encounters, more so from the OnEnter of a trigger than from the area itself, I find it helps to use GetNearest functions when the spawn is within the area where the script is triggered.
Instead of:
location angelaappearshere = GetLocation(GetObjectByTag("angelaappearshere"));
I'd suggest:
location angelaappearshere = GetLocation(GetNearestObjectByTag("angelaappearshere"));
While it doesn't really affect the outcome of the script you are using here, alternate versions that might be used across multiple areas will definately benefit.
Examples would be the random encounter system I use on my own PW or some of the "challenge enhancer" scripts I use. By "challenge enhancer" I mean trigger based scripts that spawn extra foes for large parties or higher level PCs exploring someplace normally not a challenge to them or even closing an area off to exploration, i.e., I have a low level dungeon that if a PC that is way over the challenge of the area enters, a placeable wall will appear blocking their progression. When they depart, my area cleaners will eat any spawns as well as remove the wall to reset the dungeon for those in the proper level ranges. Anyhow, using "GetNearest" helps streamline later things you might create and allow you to use them in multiple areas and not end up with a list of thousand of unique tags to keep track of.
Not sure about the GetNearest function, but for all you know it might come in handy for something else I might like to attempt in future. Thanks for sharing this! ![]()