Aller au contenu

Photo

Script needs 'advance time' inserted into it please


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

#1
dickel

dickel
  • Members
  • 72 messages
After trying several different scripts I found around the net, I have finally settled on one which works nicely for the what I require. i.e- a small rest zone that pc's can rest inside and only do so while inside that zone.

The below script does this very nicely for anyone else looking for something similar.

One of the other rest scripts I had trialed (which i have deleted now), allowed for time to advance by 8 hours while resting. I'd forgotten to check if this new script had this but have since realized it doesn't.
Would anyone please be able to insert into the script (wherever appropriate) the lines required to advance time forward by 8 hours.... please please pretty please :blush:



HERE IS THE SCRIPT




//A slightly modified version of the same script, with some minor adjustments to allow it to work anywhere.
//Place an ipoint (or waypoint) with a tag of "rest_ipoint".
//If you want to change the distance from 10 meters, create a float variable on it called "distance",
// and set it to the max distance away from the point the PC can be and still rest successfully.
//If you don't set it, it will use default to 10.0.
//If the ipoint doesn't exist in the current area, resting will work normally.

void main()
{
    object oPC = GetLastPCRested();
    if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
    {
        object oRestIpoint = GetNearestObjectByTag("rest_ipoint", oPC);
        if (GetIsObjectValid(oRestIpoint))
        {
            // Check for a specific proximity tot he waypoint that the PC needs.
            // If it doesn't exist, we'll assume 10 meters.
            float fMax = GetLocalFloat(oRestIpoint, "distance");
            if (fMax == 0.0)
                fMax = 10.0;
            float fDistance = GetDistanceBetween(oPC, oRestIpoint);
            if (fDistance <= fMax && fDistance >= 0.0)
            {
                SendMessageToPC(oPC, "[You rest safely.]");
                FloatingTextStringOnCreature("Time to rest.", oPC);
            }
            else
            {
                SendMessageToPC(oPC, "[You can rest in this area, just not here.]");
                FloatingTextStringOnCreature("We need to find a safer place to rest.", oPC);
                AssignCommand(oPC, ClearAllActions());
            }
        }
    }
}



I eagerly await a reply. Peace.



ps- Oh my campaign is still coming along nicely. After lord knows how many hours spent on it. I'm currently polishing the intro and the first few quests that are available.

[CAMPAIGN DESCRIPTION]
TITLE: Annexation at Aramakl
SETTING: Faerun on the western coast of the Western Heartlands. (above Baldur's gate, below Waterdeep)
STORY: You and your party (of 4) have spent the past few months earning minimum wages aboard a merchants cargo ship, the Fleeing Fleece. Circumstances cause your Captain to dock at the nearest port town for repairs, which turns out to be Incavale. (I made this place up)
It isn't long before you realize that sinister forces are at work to bring about the downfall of Incavale, for a purpose which threatens to change the outcome of life itself.

Modifié par dickel, 18 avril 2011 - 10:08 .


#2
Morbane

Morbane
  • Members
  • 1 883 messages
That script does not actually "rest" anyone - it simply sends messages - that's it. So if the resting takes place - does it actually heal the pc etc? If so then this script simply checks distance from the waypoint - have you placed one?

Edit: Ok I looked at the script again - if the pc is too far away then the script prevents resting by using ClearAllActions()

// Get current hour, minute, second and millisecond.

int nHour = GetTimeHour();

int nMinute = GetTimeMinute();

int nSecond = GetTimeSecond();

int nMillisecond = GetTimeMillisecond();


// Advance the hour by 8.

nHour += 8;



// Set the new time

SetTime(nHour, nMinute, nSecond, nMillisecond);

Put this in the part where it says "Time to rest"

Modifié par Morbane, 18 avril 2011 - 10:34 .


#3
Morbane

Morbane
  • Members
  • 1 883 messages
void main()
{
object oPC = GetLastPCRested();
if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
object oRestIpoint = GetNearestObjectByTag("rest_ipoint", oPC);
if (GetIsObjectValid(oRestIpoint))
{
// Check for a specific proximity tot he waypoint that the PC needs.
// If it doesn't exist, we'll assume 10 meters.
float fMax = GetLocalFloat(oRestIpoint, "distance");
if (fMax == 0.0)
fMax = 10.0;
float fDistance = GetDistanceBetween(oPC, oRestIpoint);
if (fDistance <= fMax && fDistance >= 0.0)
{
SendMessageToPC(oPC, "[You rest safely.]");
FloatingTextStringOnCreature("Time to rest.", oPC);

// Get current hour, minute, second and millisecond.
int nHour = GetTimeHour();
int nMinute = GetTimeMinute();
int nSecond = GetTimeSecond();
int nMillisecond = GetTimeMillisecond();
// Advance the hour by 8.
nHour += 8;
// Set the new time
SetTime(nHour, nMinute, nSecond, nMillisecond);
}
else
{
SendMessageToPC(oPC, "[You can rest in this area, just not here.]");
FloatingTextStringOnCreature("We need to find a safer place to rest.", oPC);
AssignCommand(oPC, ClearAllActions());
}
}
}
}

#4
dickel

dickel
  • Members
  • 72 messages
oh wow man I didnt expect a response so quickly. Legend once again Morbane :)
Yeah the other thing to note with the script is that in the area properties for whatever area you are placing the iPoint's... you need to make sure the box is not ticked that disables resting in the area. Ticking this box overrides resting in the area altogether.
Thanks Morbane.

#5
Morbane

Morbane
  • Members
  • 1 883 messages
So - did you get it working? I tested for it to compile but not a working test.

#6
dickel

dickel
  • Members
  • 72 messages
Just tested it. Works like a charm. :D