DMH-Online

Dungeon Masters Helper · Est. 2005

Resting Scripts

NWN Script: rest_002.htm

Author Sticky: Post Working Scripts Here
Balance Posted: Tuesday, 25 June 07:45AM
k I got a version of allowing resting at any interval you want. Included is Tribes 2 Message of the day type deal. Let me know if anyone knows how to pop up messages in a Windows type GUI.

K heres the deal. Edit Copy your creature armor for drow. Name the new item DMUse and sets its tag to something you can type later. (I used fx_drowskin) Then COPY the blueprint ref id.

Once you got that pop open module properties.

You want to replace OnClientEnter with

NWScript:
#include "nw_i0_tool"
//Send a message to all the players
//Equip players with a DMUse drowskin that can hold local variables for
//a single player.
void main()
    {
    object oPC;
    oPC = GetEnteringObject();
    SendMessageToPC(oPC,"Welcome to the World of Moubsin. Quick rules: Player vrs Player is allowed but you are encouraged to group and go through the quests. This Modules is designed for level 1 characters, you should be level 5 when you complete this module. Please dont kill the npcs unless you really have to, instead try talking to them and do a quest or two. Have fun.");
    //Tag in the next line
    if(!(HasItem(oPC, "fx_drowskin")))
        {
        // Remember that blueprint you copied? It goes in the next line
        object oItem = CreateItemOnObject("it_creitem056", oPC, 1);
        AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_CARMOUR));
        }
    else
        {
        //Well isnt that special?
        }
}



You want to replace OnPlayerRest with

NWScript:
#include "nw_i0_tool"
void main()
{
//Set this to the number of seconds that must pass between resting periods
float fx_rest_time = 900.0;
//The next part sends a message to the player at half time so they don't
//get too worried. (Their still annoyed but now they think this is cool)
float fx_rest_halftime = (fx_rest_time / 2.0);
    // yeah yeah, so If someone is attacked while resting
    // and are interupted then they cant rest again. Add all
    // that stuff if you like. I tell my players to make sure
    // you rest when its safe.
    if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
    {
    object oPC = GetLastPCRested();
    // Make sure the PC speaker has these items in their inventory
    // THIS is the TAG of your item. This function is in Bios Include
    // so dont forget it.
    if(HasItem(oPC, "fx_drowskin"))
        {
        //Tag on the next line
        if (GetLocalInt(GetItemPossessedBy(oPC, "fx_drowskin"), "CanRest") == 1)
            {
            //No Resting
            AssignCommand(oPC, ClearAllActions());
            //I try to give my players some direction
            SendMessageToPC(oPC, "You are too well rested to sleep now. Wait a while and try again.");
            }
        else
            {
            // Allow resting
            // I personally dont know of any performance issues when using delays.
            // Maybe someone from bioware can tell us.
            //Tag on the nextline
            SetLocalInt(GetItemPossessedBy(oPC, "fx_drowskin"), "CanRest", 1);
            DelayCommand(fx_rest_halftime, SendMessageToPC(oPC, "You are starting to feel tired."));
            DelayCommand(fx_rest_time, SendMessageToPC(oPC, "You are tired and should sleep soon."));
            DelayCommand(fx_rest_time, SetLocalInt(GetItemPossessedBy(oPC, "fx_drowskin"), "CanRest", 0));
            }
        }
    else
        {
        //No resting
        //They dont have DMUse? Better warn them.
        AssignCommand(oPC, ClearAllActions());
        SendMessageToPC(oPC, "You cannot rest ever. There is sometype of error with your character. Please log out and log in to remedy the problem");
        }
    }
}




If you come up with some other ways to do this please post em.
 

⌂ All Scripts ← PreviousNext → 👁 Category List

All Resting Scripts

📄 rest_001 📄 rest_002 📄 rest_003 📄 resting 📄 resting_004 📄 resting_005 📄 resting_006