Aller au contenu

Photo

Activating Encounters by Night


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

#1
Corvittin

Corvittin
  • Members
  • 23 messages
Hi guys i like to activate encounters only night but my encoutners isnt working. this scripts are onhb of encounters
and  this encs playeronly,active from properties window and have auto_reset for 600 seconds
here is code;
void main()
{

object oEncounter=OBJECT_SELF;
if (GetIsDay()|| GetIsDawn() == TRUE)
{
SetEncounterActive(FALSE, oEncounter);
}
else
{
SetEncounterActive(TRUE, oEncounter);
}

}
thx :innocent:

Modifié par Corvittin, 15 décembre 2013 - 10:20 .


#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
GetIsDay is inexplicably bugged, use GetTimeHour instead and do the math.

#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
I've found that encounters won't trigger if there is no player in the same area as the object that triggers the encounter. Players don't need to be in the same area as the encounter trigger though.

In Isle of Shrines I have ipoints that create or destroy encounters at certain times of day. Initially the script tried to spawn the encounters even when there were no players in the area, but when you entered the area the encounter creatures never showed up.

I changed the ipoint HB script so that it aborts if there is no player in the same area as the ipoint itself. That means that encounters spawn within six seconds of when a player enters the area instead, if the time of day is right. I've since refined the HB script for my next module, where forest encounters use different creatures depending on whether it's day or night.

Modifié par DannJ, 15 décembre 2013 - 10:08 .


#4
Dann-J

Dann-J
  • Members
  • 3 161 messages
Here's the script I'm currently using. The tag of the encounter trigger is almost the same as the tag of the ipoint, although with an 'e' in front of it ("day_encounter" verses "eday_encounter" for instance). You set a string variable on the ipoint called 'Time' to either 'day' or 'night'. That could easily be modified to include specific hours of the day if necessary.

include "ginc_group"

void SpawnEncounter(object oEncounter, string sTime)
{
SetLocalInt(OBJECT_SELF,"Active",1);
SetEncounterActive(TRUE,oEncounter);
TriggerEncounter(oEncounter,GetFirstPC(),ENCOUNTER_CALC_FROM_FACTION, -1.0);
ResetGroup("e"+sTime);
EncounterToGroup("e"+sTime,1);
DelayCommand(0.1, SetEncounterActive(FALSE,oEncounter));
}

void KillEncounter(string sTime)
{
SetLocalInt(OBJECT_SELF,"Active",0);
DestroyObjectsInGroup("e"+sTime,0.0);
ResetGroup("e"+sTime);
}

void main()
{
int iActive = GetLocalInt(OBJECT_SELF,"Active");
string sTime = GetLocalString(OBJECT_SELF,"Time");

if (GetArea(GetFirstPC()) != GetArea(OBJECT_SELF))
{
if (iActive == 0) return;
KillEncounter(sTime);
return;
}

string sTag = GetTag(OBJECT_SELF);

object oEncounter = GetObjectByTag("e"+sTag);

if (iActive == 0 && sTime == "day" && GetIsDay())
{
SpawnEncounter(oEncounter, sTime);
}
if (iActive == 0 && sTime == "night" && GetIsNight())
{
SpawnEncounter(oEncounter, sTime);
}
if (iActive == 1 && sTime == "day" && !GetIsDay())
{
KillEncounter(sTime);
}
if (iActive == 1 && sTime == "night" && !GetIsNight())
{
KillEncounter(sTime);
}
}

#5
Corvittin

Corvittin
  • Members
  • 23 messages
GetTimeHour is simply fixes my problems. Thank you.
@DannJ Thank you for your attention my friend but im very very noob at the moment
i can barely understand your script. my goal is very very easy i just trying to spawn zombies when nights.

#6
Corvittin

Corvittin
  • Members
  • 23 messages
Heres my Code
void main()
{
object oEncounter = OBJECT_SELF;
int nAbsoluteTime = GetTimeHour();
int nNightTime = 18;
int nDayTime = 6;
if ((nAbsoluteTime >= nNightTime) || (nAbsoluteTime <= nDayTime))
{
SetEncounterActive(TRUE, oEncounter);
}
else
{
SetEncounterActive(FALSE, oEncounter);
}

}

#7
MarshallV

MarshallV
  • Members
  • 43 messages
http://www.nwn2legen...ds-spawn-plugin

Take a look, it might be useful.

Cheers