I assume that almost every builder has noticed the OnEnter-problem introduced in 1.21. If not
here's Rob McGinnis quick update. When looking over all scripts in the module that are affected by this I found that assigning variables to a PC through a OnEnter-script (Area, Module, Trigger) as the first thing that happens when the player enters a new area is unreliable, not only after 1.21 but has been so since the first version. This was news to me. Important news. You see, I have some variables set on the PC when he/she enters a new area. Such as if the PC is in a Dark Area or a Theif-Free Area. Sometimes checks against those variables have failed and I have suspected myself to have missed setting the variables correctly. It seems that I've been setting them before the Area is completely loaded (or if it's that the PC isn't controllable) . So now when I've introduced a loop that checks that the PC has the variable everything works fine. The same thing works for conversations started from a trigger. You have probably worked this out already but heres how I did:
#include "ginc_item_script"
void StartConversation(object oPC);
void main(string sCommand = "")
{
object oPC = GetEnteringObject();
if (!GetIsObjectValid(GetControlledCharacter(oPC))) return; //*
if (!GetIsPC(oPC)) return;
string sTrigger = GetTag(OBJECT_SELF);
if (sTrigger == "TR_RIVER2A") // Entering the River Area from north
{
StartConversation(oPC);
}
else if (sTrigger == "TR_ARAGAIN") // Entering the aragaiN Falls
{
CreateBoat(GetLocation(GetObjectByTag("WP_ARAGAIN")));
StartConversation(oPC);
}
}
void StartConversation(object oPC)
{
//Fix the OnEnter problem in version 1.21
if (!GetLocalInt (OBJECT_SELF, "Trigged") && !IsInConversation(oPC))
{
DelayCommand(0.5, AssignCommand(oPC, ActionStartConversation(oPC, "river_travel", TRUE, FALSE)));
DelayCommand (1.0, StartConversation(oPC));
}
}
2 comments:
I used to use OnEnter myself (ever since NWN1 modding days) and I had problems with it back in 1.01. I have since been told (by Rob) that they use OnClientEnter. I looked into the OCs opening cutscene and sure enough, they use OnClientEnter. I have been using that method without any issues (I just moved all of my OnEnter scripts to OnClientEnter). OnClientEnter fires only after everything is loaded and all PCs/companions have entered the area. It supposively only fires once, whereas OnEnter fires every time something enters the area. I'm not the scripting guru, so this is my limited understanding and could be incorrect assumptions.
I can't find it, but I am almost sure that I saw a post on the bioboards about how OnEnter wasn't firing at the right time, ie before the PC was necessarily valid.
As a result, I've always been using OnClientEnter as well.
In other, unrelated news, this is intriguing: http://www.gamasutra.com/php-bin/news_index.php?story=21848
Post a Comment