BioWare Forums: View Post For Code Display


You are viewing a single post. Please do not take this post out of context.
Read the full topic: Post Working Scripts Here

Author Sticky: Post Working Scripts Here
Morfedel Posted: Saturday, 29 June 06:21PM
1. Go Sit Into Nearest Chair

2. Tells an NPC to look for the nearest unoccupied chair, and go sit in it.

3. You need to make one or more chairs and make them usuable/sittable. Make sure they all have the same tag. I put this script in an action triggered when a dialogue between PCs and NPCs ended.

4. The Script:

NWScript:
//Written By James A Beggs
//This script is intended to be placed in some event
//to make a creature go sit down at the nearest unoccupied
//chair.
//It was inserted at the end of a dialogue after
//a PC is done talking to them.
//note that a few changes need to be made, depending
//on your module, as noted below in comments.
void main()
{
    int nIAmSitting=0;
    int iCounter=1;
    int iMaxChairs=6; //put whatever the max # chairs you have
    string sChair="ChairTagName"; //put chair tag name here
    object oCurrentChairCheck;
    object SittingCritter;
    ActionWait(10.0)
    while (!nIAmSitting)
    {
        oCurrentChairCheck = GetNearestObjectByTag(sChair, OBJECT_SELF, iCounter);
        SittingCritter = GetSittingCreature(oCurrentChairCheck);
        if (SittingCritter!=OBJECT_INVALID )
        {
            iCounter++;
            if (iCounter > iMaxChairs)
            {
                iCounter=1;
            }
            ActionWait(10.0);
        }
        else
        {
            ActionSit(oCurrentChairCheck);
            nIAmSitting=1;
        }
    }
}

This post taken from the BioWare Forums
Powered by BioBoards Version 2.05.006
Please read our Copyright and Trademark Information