Aller au contenu

Photo

ScriptHidden Bug


  • Veuillez vous connecter pour répondre
12 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I have noticed that if you apply the command SetScriptHidden(oObject,TRUE) to an object that is already script hidden, you cannot unhide the object with SetScriptHidden(oObject,FALSE).  Has anyone figured out how to unhide it if you accidentally double-hide it?

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
I haven't experienced this bug, though I think I would have, with all the script-hiding I do. What I have noticed is that script-hidden creatures cannot be moved using the JumpToLocation commands. Could that be part of your problem?

#3
SkywingvL

SkywingvL
  • Members
  • 351 messages
This functon toggles a boolean value in the internal object structure for a game object, so I think that there's likely something else going on here.

#4
Dann-J

Dann-J
  • Members
  • 3 161 messages

M. Rieder wrote...

I have noticed that if you apply the command SetScriptHidden(oObject,TRUE) to an object that is already script hidden, you cannot unhide the object with SetScriptHidden(oObject,FALSE). 


Double-hiding a creature sends it to the astral plane. Any 1st-year wizard's apprentice could tell you that.

:)

#5
MasterChanger

MasterChanger
  • Members
  • 686 messages
Good programming practice would probably say that you should check whether something is already script-hidden before you set it to be script-hidden. Then you would only set it script-hidden if it isn't already set that way.

Still, interesting bug to hear about.

#6
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Suggest posting your scripts on pastebin or similar so we can see if there is something you are missing. Script hidden should be relatively safe, even though i heard there are some issues with the new limbo functions.

#7
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
You were all right, of course. I did a simple test and applied script hidden to an object twice and it unhid just fine. I have no idea whay my characters stay hidden.

Here is the ambience script I am using. There is a place where I apply an invisibility effect, but I tried removing all effects and it doesn't seem to help.


Here's the script so you can take a look at it:

/////////////////////////////////////////////////
//controls the cycle of NPCs going to bed and getting up in the barbarian camp
//placed in the area HB location.
//The NPCs will go to a waypoint with the tag "204_wpt_night_[tag of NPC]"


//I couldn't get the NPCs to animate, so I used corpses instead that
//appear at night and I just hide all the barbarians.
//If the NPC lives in a tent, the NPC will be scripted invisible for
//the duration of nighttime.
//if the NPC lives in a hut that is open, the NPC will be forced to
//lay down for the duration of the nighttime.
//this will be determined by the local integer:
//nScriptHiddenAtNight - 1 for yes, 0 for no.

//also sets nIsSleeping to 1 on the NPCs that are not scripted invisible
//so that they respond properly when the PC talks to them.


//If a creature has the variable
//nStayUpAtNight set to 1,
//then it will not run this script.


void GetUp();
void GoToBed();
void HideSleepingBarbarians();
void ShowSleepingBarbarians();




void main()
{




object oSelf = OBJECT_SELF;
int nStopHeartbeat = GetLocalInt(oSelf,"nStopHeartbeat");
if (nStopHeartbeat == 1)
{
return;
}
//nIsDay is a local int stored on the area to make sure the script only runs
//one time for each change of day/night cycle.

int nIsDay = GetLocalInt(oSelf,"nIsDay");

if ((GetIsDay())&&
(nIsDay == 0))
{
GetUp();
HideSleepingBarbarians();
SetLocalInt(oSelf,"nIsDay",1);
}


if ((GetIsNight())&&
(nIsDay == 1))
{
GoToBed();
ShowSleepingBarbarians();
SetLocalInt(oSelf,"nIsDay",0);
}
}
//************************************************************
void GetUp()
{
object oSelf = OBJECT_SELF;
object oTarget = GetFirstObjectInArea();
effect eEffect;
while (GetIsObjectValid(oTarget))
{
if ((GetObjectType(oTarget)==OBJECT_TYPE_CREATURE)&&
(GetLocalInt(oTarget,"nStayUpAtNight")!=1)&&//check for the local int to make the npc exempt from resting
(GetLocalInt(oTarget,"nIgnore204HBScript")!=1)&&//check to make sure the dark seeker forces aren't revealed
(!GetIsOwnedByPlayer(GetOwnedCharacter(GetFactionLeader(oTarget)))))
{
//unhide
SetScriptHidden(oTarget,FALSE);
//return ai level to normal to allow HB script to start working again
SetAILevel(oTarget,AI_LEVEL_DEFAULT);
//remove all effects-to remove the freeze animation vfx effect
eEffect=GetFirstEffect(oTarget);
while (GetIsEffectValid(eEffect))
{
if (GetEffectCreator(eEffect)==oSelf)
{
RemoveEffect(oTarget,eEffect);
eEffect=GetFirstEffect(oTarget);
}
else
{
eEffect=GetNextEffect(oTarget);
}
}
}

oTarget=GetNextObjectInArea();
}






}



void GoToBed()
{
string sHomeWPT = "204_wpt_night_";
object oHomeWPT;
int nScriptHiddenAtNight;
object oTarget = GetFirstObjectInArea();
effect eFreeze = EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION);
effect eInvisible = EffectNWN2SpecialEffectFile("total_invisibility");
while (GetIsObjectValid(oTarget))
{
if ((GetObjectType(oTarget)==OBJECT_TYPE_CREATURE)&&
(GetTag(oTarget)!= "ayale")&&//make ayale not subject to script so she doesn't become invisible when she joins the party
(GetTag(oTarget)!= "burlak_fellaxe")&&//make burlak not subject to script so he doesn't become invisible when she joins the party
(GetTag(oTarget)!= "sheala_wulvein")&&//make sheala not subject to script so she doesn't become invisible when she joins the party
(!GetScriptHidden(oTarget))&&//make sure it isn't already hidden
(!IsInConversation(oTarget))&&//make sure it doesn't interrupt a convo
(!GetIsPC(GetFactionLeader(oTarget)))&&//more checks to make sure it isn't in party
(GetLocalInt(oTarget,"nStayUpAtNight")!=1)&&//check for the local int to make the npc exempt from resting
(!GetIsOwnedByPlayer(GetFactionLeader(oTarget))))
{
//clear all actions on NPC...
AssignCommand(oTarget,ClearAllActions());
//determine if the NPC should be scripted invisible
//or made to play sleeping animation
nScriptHiddenAtNight = GetLocalInt(oTarget,"nScriptHiddenAtNight");
//define the waypoint the NPC will go to;
oHomeWPT = GetWaypointByTag(sHomeWPT+GetTag(oTarget));

//turn down AI to make the HB script not run to prevent ambient
//animations and walkwaypoint from happening
AssignCommand(oTarget,ActionForceMoveToObject(oHomeWPT,FALSE,0.0));
SetAILevel(oTarget,AI_LEVEL_VERY_LOW);
/*Originally there would be barbarians that would go an lay down in their
//tent, but I couldn't make the animation work, so I just used placeable
//corpses that would appear when the barbarians disappeared.
if (nScriptHiddenAtNight == 0)
{
//set local int "nIsSleeping" to make sure if the PC talks
//to the NPC, there is an appropriate response.
SetLocalInt(oTarget,"nIsSleeping",1);
//Make NPC face the direction of WPT to make sure it lays properly
SetFacing(GetFacing(oHomeWPT));
//apply prone effect to target, then freeze the NPC.
ActionPlayAnimation(ANIMATION_FIREFORGET_LAYDOWN,1.0,50000000.0);
//DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_PERMANENT,eFreeze,oTarget));
}
*/
// if (nScriptHiddenAtNight == 1)
// {
//set local int "nIsSleeping" to make sure if the PC talks
//to the NPC, there is an appropriate response.
SetLocalInt(oTarget,"nIsSleeping",1);
AssignCommand(oTarget,ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_PERMANENT,eInvisible,oTarget)));

}
oTarget=GetNextObjectInArea();
}
}


//********************************************

void ShowSleepingBarbarians()
{
int nCycle = 1;
string sTagOriginal = "204_sleeping_barbarian_";
string sCycle = IntToString(nCycle);
string sTag = sTagOriginal+sCycle;

object oSleeper = GetObjectByTag(sTag);

while (GetIsObjectValid(oSleeper))
{
SetScale(oSleeper,1.0,1.0,1.0);
nCycle++;
sCycle = IntToString(nCycle);
sTag = sTagOriginal + sCycle;
oSleeper = GetObjectByTag(sTag);
}
}

//****************************************************

void HideSleepingBarbarians()
{
int nCycle = 1;
string sTagOriginal = "204_sleeping_barbarian_";
string sCycle = IntToString(nCycle);
string sTag = sTagOriginal+sCycle;

object oSleeper = GetObjectByTag(sTag);

while (GetIsObjectValid(oSleeper))
{
SetScale(oSleeper,0.0001,0.0001,0.0001);
nCycle++;
sCycle = IntToString(nCycle);
sTag = sTagOriginal + sCycle;
oSleeper = GetObjectByTag(sTag);
}
}

#8
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
I don't think GetIsNight works properly, and PlayCustomAnimation usually works better then ActionPlayAnimation.

#9
Dann-J

Dann-J
  • Members
  • 3 161 messages
I haven't had any problems with GetIsNight (or GetIsDay for that matter). Isle of Shrines uses it to spawn day-only or night-only encounters.

Although I agree about PlayCustomAnimation being the better function. I would touch any of the PlayAnimation functions with a barge pole.

Modifié par DannJ, 18 janvier 2012 - 02:37 .


#10
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I don't use the part that has ActionPlayAnimation. I agree, that function is a curse. The script works properly, so I don't think there are any problems with the GetIsDay or GetInNight. The problem is that in the past I have had problems unhiding creatures that have been hidden by this script. I'm not sure if it is the effect or the scripthiddenness, but I can't get them to re-appear. I have included conditionals to make sure this does not happen and it appears to work, but I was just wondering if setscripthidden was somehow broken. I ran some tests and I don't think it is.

#11
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi Matt,

Just a quick thought ... Is it the scaling function? I believe rescaling an object to its original size after it has been scaled down may not work as you think ... and so it remains too small to see.

Consider EffectSetScale instead.

Cheers.

Lance

#12
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks for the suggestion, Lance. I did some more testing without posting it here. Turns out it was the invisibility SEF I made. I was applying it but trying to remove with with RemoveEffect() instead of RemoveSEFFromObject(). As soon as I used RemoveSEFFromObject() the creature was visible again.

#13
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

M. Rieder wrote...

Thanks for the suggestion, Lance. I did some more testing without posting it here. Turns out it was the invisibility SEF I made. I was applying it but trying to remove with with RemoveEffect() instead of RemoveSEFFromObject(). As soon as I used RemoveSEFFromObject() the creature was visible again.


Hi Matt,

I had that "removal" problem with an effect once. :)

Glad you have it sorted!

Lance.