Skip to content

NW Time in script

Trying to randomly fire a wandering monster script at different times. It is on the OnEnter handler for area properties.

This is what I have and I don't think I know what I'm doing... :)
void main()
{

object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;

int nRandom = 10;
int nTime = GetTimeHour();

    if (nTime>=12)
    {
        if (nRandom>=7)
        ExecuteScript("wm_table_05");
    }

    else return; FALSE;
}

I haven't tested this yet. I'm hoping you guys have something clever to add to this. Thx in advance.

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited March 2021
    First things first a void function, including main(), cannot return anything; that is what the void means. Next thing is that NwN does not support wandering monsters per se. There are various wandering monster systems on the vault that you would probably do well to look into. Looking at your script I see that you have used GetEnteringObject() to get the PC object. What causes the OnEnter event to fire? Is it a trigger or entering an area?

    Anyway, FWIW I have tidied your original script up a bit -
    void main()
    {
        object oPC = GetEnteringObject();
        int nRandom = d10();
        int nTime = GetTimeHour();
    
        if(GetIsPC(oPC))
            if(nTime>=12 && nRandom>=7)
                ExecuteScript("wm_table_05");
    }
    

    BTW, if you are struggling with scripting you might find the small series of tutorials I wrote just for beginners useful. First one is here and there are links to the other volumes on that page.

    TR
    ForSerious
  • ZephiriusZephirius Member Posts: 411
    It's OnEnter an area. Thanks for the help. I've been slowly taking Celowin's lessons on the Lexicon and I will check yours out too.
  • ZephiriusZephirius Member Posts: 411
    I started reading your Tutorial TarotRedHand,
    void main()
    {
    
    
    //data type - string
    //variable - sJohn
    //operator - =
    
    string sJohn = "John-Paul";
    }
    

    I know what data types and operators are now!
    TarotRedhandNeverwinterWightsForSerious
Sign In or Register to comment.