Aller au contenu

Photo

saferest trigger


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

#1
andysks

andysks
  • Members
  • 1 651 messages
There is this trigger in the toolset, and the instructions on the comment seem pretty straight forward. However, I cannot make it work. Instructions state, that you paint this trigger to enclose a small room, it has to have a door and the door to be closed. Then to an area that uses NWN X1, it will be a safe room to rest. So I did all this, I set an area to be in iminent danger of wandering monsters and went in the room, closed the door and I still get ambushed while resting. I also tried to set the whole area as no resting allowed, but this didn't work either. The safe room is also no rest allowed like that. Has anyone used this trigger, and if so how?

#2
Shaughn78

Shaughn78
  • Members
  • 637 messages
The saferest triggers are left over from NWN1. The current rest script for the game does not check for them in resting.

For my campaign I created my own triggers and modified the rest script to make it check for the triggers and cancel rest if it was unsafe.

If you would like I can post the scripts. I know other builders have also created other systems as well.

#3
andysks

andysks
  • Members
  • 1 651 messages
Oh I didn't know that, I thought they worked in NWN2. All I want is a safe room in a very unsafe area. The area has 80% possibility of wandering monsters, made with the MotB rest system. So I want a safe spot where you can rest. Is that possible?

#4
Shaughn78

Shaughn78
  • Members
  • 637 messages
Here are the scripts I used for Risen Hero.
Module on rest script:

void main()
{
    object oPC         =     GetLastPCRested();
    object oArea     =     GetArea(oPC);
    object oTrigger    =    GetNearestObjectByTag("tgr_rest",oPC);
    int iRest         =     GetLocalInt(oPC, "safe_rest");
   
   
   
    if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
    {
       //Checks area for specific events

        if (GetTag(oArea) == "waste_dead_end")//Area specific spawns huge earth elemental x1
        {
            object oOnce    = GetObjectByTag("wt_dead_end_rest");
            int iOnce         = GetLocalInt(oOnce,"wt_rest_times");
            object oEl_Spawn = GetWaypointByTag("gnollexit_wp_door");
            location lEl_Spawn = GetLocation(oEl_Spawn);
           
            if (iOnce == 0)//Hasn't happened
            {
            SetLocalInt(oOnce,"wt_rest_times", 1);
            FadeToBlack(oPC,0.5,0.5);
            AssignCommand(oPC,ActionSpeakString("Your rest is interupted."));
            PlayVoiceChat(VOICE_CHAT_ENEMIES,oPC);
            CreateObject(OBJECT_TYPE_CREATURE,"c_elmearthhuge",lEl_Spawn);
            }
            else //Has happened
            {
            //rest
            PlayCustomAnimation(oPC,"yawn",0,1.0);
            PlayVoiceChat(VOICE_CHAT_REST,oPC);
            DelayCommand(1.5, ExecuteScript("k_mod_player_rest", oPC));
            }
        }
       
        else if (GetTag(oArea) == "sunset_mountain_peak")//Area specific too cold to sleep
        {
            PlayVoiceChat(VOICE_CHAT_BADIDEA,oPC);
            PlayCustomAnimation(oPC, "nodno",0,1.0);
            AssignCommand(oPC,ActionSpeakString("It is too cold here with out shelter."));
            //SendMessageToPC(oPC, "It is not safe to rest here.");
            AssignCommand(oPC,ClearAllActions(FALSE));
        }
       
        //checks for safe rest trigger. If one is in the area checks if player is in the trigger
        // if trigger is in in accessible area entire area will not allow resting

        else if (GetIsObjectValid(oTrigger)) //Checks if dangerous area with limited rest
        {
            if (iRest == FALSE) //Not in a safe place
            {
            PlayVoiceChat(VOICE_CHAT_BADIDEA,oPC);
            PlayCustomAnimation(oPC, "nodno",0,1.0);
            AssignCommand(oPC,ActionSpeakString("It is not safe to rest here."));
            //SendMessageToPC(oPC, "It is not safe to rest here.");
            AssignCommand(oPC,ClearAllActions(FALSE));
            }
            else //In a safe place of dangerous area
            {
            //rest
            PlayCustomAnimation(oPC,"yawn",0,1.0);
            PlayVoiceChat(VOICE_CHAT_REST,oPC);
            DelayCommand(1.5, ExecuteScript("k_mod_player_rest", oPC));
           
            }
        }
       
        //No saferest trigger, entire area is safe to rest in.
        else
        {
        //rest
        PlayCustomAnimation(oPC,"yawn",0,1.0);
        PlayVoiceChat(VOICE_CHAT_REST,oPC);
        DelayCommand(1.5, ExecuteScript("k_mod_player_rest", oPC));
       
        }
    }
   
}

Trigger on enter script:

//Sets safe rest variable and notifies player that area is safe
void main()
{
    object oPC = GetEnteringObject();
   
    if (GetIsPC(oPC) == TRUE)
    {
        SetLocalInt(oPC,"safe_rest", TRUE);
        SetNoticeText(oPC,"You can rest here");
        AssignCommand(oPC,ActionSpeakString("This looks like it may be safe enough to sleep here."));
    }
}

On exit trigger:
//Removes safe rest variable
void main()
{
    object oPC = GetExitingObject();
   
    if (GetIsPC(oPC) == TRUE)
    {
        SetLocalInt(oPC,"safe_rest", FALSE);
    }
}



These scripts are written for a single player game, so if you're working on a multiplayer they may need to be tweeked. I have left some of the area specific events for my campaign so you can see how I set them up.
   
   
   

Modifié par Shaughn78, 26 août 2013 - 01:51 .


#5
andysks

andysks
  • Members
  • 1 651 messages
Hmm thanks a lot for the reply but it doesn't seem to work. the wandering monster system will ambush the PC no matter the On enter script. Did you use the MotB rest system in Risen Hero?

#6
Shaughn78

Shaughn78
  • Members
  • 637 messages
I had to open some old areas to see how I handled it all. I did use wandering monsters and left a small chance for them to discover the party.

You can turn the wandering monster on and off via script though. And I think I am going to update my enter and exit code so it can be disabled. Give me a little bit and I will update thew new code.

#7
Shaughn78

Shaughn78
  • Members
  • 637 messages
WM_DISABLE is the variable on the areas that will turn off wandering monsters. I have added a local variable (no_wandering_monster) to the rest trigger that the script will look for. If that variable is set to true (1) then it will disble the wandering monsters. If it is set to false (0) or left blank it will leave the wandering monsters active.

on enter:
void main()
{
object oPC = GetEnteringObject();
object oArea = GetArea(oPC);

int nDisable = GetLocalInt(OBJECT_SELF,"no_wandering_monster");

if (GetIsPC(oPC) == TRUE)
{
SetLocalInt(oPC,"safe_rest", TRUE);
SetNoticeText(oPC,"You can rest here");
AssignCommand(oPC,ActionSpeakString("This looks like it may be safe enough to sleep here."));

if(nDisable == 1)
{
SetLocalInt(oArea,"WM_DISABLED",1);
}
}
}

On exit:

void main()
{
object oPC = GetExitingObject();
object oArea = GetArea(oPC);

int nDisable = GetLocalInt(OBJECT_SELF,"no_wandering_monster");

if (GetIsPC(oPC) == TRUE)
{
SetLocalInt(oPC,"safe_rest", FALSE);
if(nDisable == 1)
{
SetLocalInt(oArea,"WM_DISABLED",0);
}
}
}

#8
andysks

andysks
  • Members
  • 1 651 messages
Hey Shaughn, the scripts compiles now but there is still an ambush. It is strange because I see no reason for this to happen since the updated script seems fine. We are talking about a generic trigger now yes? Not a safe_rest anymore...

#9
Shaughn78

Shaughn78
  • Members
  • 637 messages
It isd a generic trigger but I forgot to mention for the script to work that trigger will need this tag "tgr_rest"

Its been a while since I've been in the toolset, I've got a bit of relearning to do.

#10
andysks

andysks
  • Members
  • 1 651 messages
So, it didn't work for some reason, but a much more simplified version worked, I don't know why.

void main()
{
object oPC = GetEnteringObject();
object oArea = GetArea(oPC);

AssignCommand(oPC,ActionSpeakString("This looks like it may be safe enough to sleep here."));
SetLocalInt(oArea,"WM_DISABLED",1);
}

Thanks a lot for the help, it really was helpful.

#11
ColorsFade

ColorsFade
  • Members
  • 1 270 messages
This thread is incredibly helpful to me.

One of my first dungeons, I went to use the Wandering Monster system that I wrote the guide for, and I have been wondering how to make certain rooms safe... This is a great thread. Thanks!

#12
andysks

andysks
  • Members
  • 1 651 messages
Heh, I also was in the same situation as you... that's why I created this thread. It felt so good once I got it working... it was quite a victory :D.