Initial Commit
Initial Commit
This commit is contained in:
71
_module/nss/explo_start.nss
Normal file
71
_module/nss/explo_start.nss
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "x4_inc_functions"
|
||||
#include "_sh_inc_list"
|
||||
void main()
|
||||
{
|
||||
object oPC = GetPCSpeaker();
|
||||
object oArea = GetArea(OBJECT_SELF);
|
||||
|
||||
//A conditional check
|
||||
float fDistance;
|
||||
object oMember = GetFirstFactionMember(oPC);
|
||||
//Halt if the PC is in a different area
|
||||
if (GetLocalString(oPC, "AreaString") != GetLocalString(oArea, "AreaString")) return;
|
||||
while (GetIsObjectValid(oMember))
|
||||
{
|
||||
fDistance = GetDistanceBetween(oMember, oPC); //Get the distance between the PC and a party member
|
||||
if (oPC != oMember && (fDistance == 0.0 || fDistance > 10.0)) //If they are in different areas or the distance is longer than 10 meters...
|
||||
{
|
||||
FloatingTextStringOnCreature("Your party wants to travel, but you are absent!", oMember, FALSE);
|
||||
return;
|
||||
}
|
||||
oMember = GetNextFactionMember(oPC);
|
||||
}
|
||||
|
||||
//Get area string
|
||||
string sAreaString = GetLocalString(oArea, "AreaString");
|
||||
string sRegionString = GetStringLeft(sAreaString, 1);
|
||||
int nReturn = FALSE;
|
||||
if (GetStringRight(sAreaString, 1) == "r") nReturn = TRUE; //We want to restore miles travelled if we are in the return area
|
||||
|
||||
//Get the list of free areas
|
||||
string sList = "sList"+sRegionString;
|
||||
object oList = GetLocalObject(GetModule(), sList);
|
||||
|
||||
//Get the number of free areas
|
||||
int nCount = ListGetElementCount(oList);
|
||||
|
||||
//Randomly select a free area
|
||||
int nElementIndex = Random(nCount)+1;
|
||||
string sRandomAreaString = ListGetString(oList, nElementIndex);
|
||||
|
||||
//Teleport the PC (and their party) to the southern entrance waypoint of the chosen area and start counting miles travelled
|
||||
object oWaypoint = GetWaypointByTag("exit_wp_"+sRandomAreaString+"_s");
|
||||
//Let's store the party leader on the area about to be entered
|
||||
SetLocalObject(GetArea(oWaypoint), "PartyLeader", GetFactionLeader(oPC));
|
||||
//Now we move the party
|
||||
object oParty = GetFirstFactionMember(oPC, FALSE);
|
||||
while ( oParty != OBJECT_INVALID )
|
||||
{
|
||||
SetLocalInt(oParty, "CanDiscover", 1); //We don't want to encounter any villages or dungeons (or chests?) at the exit of the first area, but want to be able to do this in the second area
|
||||
AssignCommand(oParty, ClearAllActions());
|
||||
AssignCommand(oParty, JumpToObject(oWaypoint));
|
||||
if (nReturn == FALSE)
|
||||
{
|
||||
SetLocalInt(oParty, "Miles", 1);
|
||||
if (GetLocalString(GetModule(), "MODE") == "LOCAL" && GetIsPC(oParty)) SetCampaignInt(CharacterDB(oParty), "MILES", 1); //store miles travelled in LOCAL mode
|
||||
if (sRegionString != GetCampaignString(CharacterDB(oParty), "REGION") && GetIsPC(oParty)) SetCampaignString(CharacterDB(oParty), "REGION", sRegionString); //store the region
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLocalInt(oParty, "Miles", GetCampaignInt(CharacterDB(oParty), "MILES"));
|
||||
}
|
||||
|
||||
oParty = GetNextFactionMember(oPC, FALSE);
|
||||
}
|
||||
|
||||
/*//Simulate the OnEnter event of the area - we do not use the normal OnEnter to avoid event/encounter reloading in case of a loaded save file
|
||||
object oRandomArea = GetArea(oWaypoint);
|
||||
SetLocalObject(GetModule(), "TravellingPC", oPC);
|
||||
ExecuteScript("execute_onenter", oRandomArea);
|
||||
DeleteLocalObject(GetModule(), "TravellingPC");*/
|
||||
}
|
Reference in New Issue
Block a user