encounters at night

Moderator: Event DM

Post Reply
User avatar
Schaek
Team Member; Retired with Honors
Posts: 481
Joined: Sun Feb 08, 2004 11:54 am
Location: Nijmegen (GMT +1)

encounters at night

Post by Schaek » Fri Oct 27, 2006 10:57 am

hi guys, hopefully one of you can help me with this. I wish to have certain encounters only spawn between dusk and dawn (18:00-06:00 in game). I'm fairly new to the toolset and scripting and have no idea to make this work.

Thanks :D
liephus wrote:The Avlis Team, we put the "F U" in fun.
User avatar
Jonezie
Team Member; Retired with Honors
Posts: 3905
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

Post by Jonezie » Fri Oct 27, 2006 11:27 am

Time of day limitations isn't something that you can setup with a standard encounter trigger. There's a couple of options for getting it to work, though.

A) Use a trigger/waypoint combination with a custom OnEnter script instead
B) Add an OnEnter or OnHeatbeat script to the area that runs through and sets the encounter to active/inactive depending on the time of day.

The first one is probably the better option. The script would look something like:

Code: Select all

void main()
{
    if (!GetIsPC(GetEnteringObject()))
        return;    

    if (GetLocalInt(OBJECT_SELF, "TTimeout"))
        return;

    if (!GetIsNight())
        return;

    string sTag = GetTag(OBJECT_SELF);
    
    //Insert Values here
    string sResRef1 = "xxxx"
    string sResRef2 = "yyyy"
    string sResRef3 = "zzzz"

    int iNo1 = #;
    int iNo2 = #;
    int iNo3 = #;
    
    int i;

    object oWP = GetNearestObjectByTag("WP_" + sTag);
    object oNew;

    location lWP = GetLocation(oWP);

    if (sResRef1 != "")
    {
        while (i < iNo1 && i < 10)
        {
            oNew = CreateObject(OBJECT_TYPE_CREATURE, sResRef1, lWP, TRUE);
            SetLocalInt(oNew, "despawn", TRUE);
            i++;
        }
    }

    i = 0;

    if (sResRef2 != "")
    {
        while (i < iNo2 && i < 10)
        {
            oNew = CreateObject(OBJECT_TYPE_CREATURE, sResRef2, lWP, TRUE);
            SetLocalInt(oNew, "despawn", TRUE);
            i++;
        }
    }

    i = 0;

    if (sResRef3 != "")
    {
        while (i < iNo3 && i < 10)
        {
            oNew = CreateObject(OBJECT_TYPE_CREATURE, sResRef3, lWP, TRUE);
            SetLocalInt(oNew, "despawn", TRUE);
            i++;
        }
    }

    SetLocalInt(OBJECT_SELF, "TTimeout", TRUE);
    DelayCommand(1800.0, DeleteLocalInt(OBJECT_SELF, "TTimeout"));
}
WARNING: Untested code

Basically, you need a trigger with a unique tag. You also have a waypoint with tag 'WP_<trigger tag>'. Fill out the blanks for creature resrefs and numbers in the script there, and put it in the OnEnter event of the trigger. Then, it'll function like an encounter, firing when it's stepped on and creating creatures at the waypoint, but only when it's night time. It's set to a respawn timer of 30 RL minutes, is capped at 10 of each creature, and can have 3 different creature types. Creatures will despawn with the avlis despawner. You can get much more complicated than this if you want, but it should do basically what you need.
User avatar
Schaek
Team Member; Retired with Honors
Posts: 481
Joined: Sun Feb 08, 2004 11:54 am
Location: Nijmegen (GMT +1)

Post by Schaek » Fri Oct 27, 2006 1:20 pm

Ok thanks a lot Jonezie!

As I said I'm a noob with scripting so I'll see if anyone can make this work for me instead of fucking it up myself. Anyone interested in building this encouter please send me a pm :P

thanks again
liephus wrote:The Avlis Team, we put the "F U" in fun.
Czarcasm
Team Member; Retired with Honors
Posts: 1724
Joined: Tue Nov 09, 2004 2:55 pm
Timezone: GMT-6
Location: St. Louis, MO

Post by Czarcasm » Fri Oct 27, 2006 1:41 pm

There's a script hanging around the Avlis modules for the OnEnter script of the encounter, called "encset_atnight." Here's the script:

Code: Select all

// Name     : encset_atnight.nss
// Purpose  :
// Author   : n.a.
// Modified : March 7, 2004 by Mistcaller
// ** Sets the encounter active only during night times **


void ResetEncounter(float fTimeToWait, int nValue, object encounter)
{
DelayCommand(fTimeToWait, SetEncounterActive(nValue, encounter));
DelayCommand(fTimeToWait, DeleteLocalInt(encounter, "Disabled"));
}
void main()
{
    object oPlayer = GetEnteringObject();
    if (!GetIsPC(oPlayer)) return;
    int nHour = GetTimeHour();
    if((nHour < 6 || nHour > 18) && GetLocalInt(OBJECT_SELF, "Disabled") == 0)
        {
        SetEncounterActive(TRUE,OBJECT_SELF);
        //1500 is 25 minutes
        ResetEncounter(1500.0, TRUE, OBJECT_SELF);
        SetLocalInt(OBJECT_SELF, "Disabled", 1);
        }
    ResetEncounter(3.0, FALSE, OBJECT_SELF);
}
User avatar
Kooshy
Newbie
Posts: 9
Joined: Sun Oct 22, 2006 8:43 pm
Location: Right here! ^^
Contact:

Post by Kooshy » Mon Oct 30, 2006 8:21 am

One neat approach is to make an NPC with a null body model, give them cutscene invisibility, all that concealment stuff to keep them from being seen.

And then in their OnPercieve event, you can do whatever tests and such you need to, and then spawn whatever, based on time of day, level of person/party percieved, a dice roll, intimidate skill ranks that people have.. Some combination.. Whatever you want, really.

It's quite a handy trick, and one of the few ideas used in the Gigaschatten engine that I really liked.

I just thought I'd mention it 'n stuff. :)
Post Reply