Initial Commit
Initial Commit
This commit is contained in:
55
_module/nss/explo_bacvillage.nss
Normal file
55
_module/nss/explo_bacvillage.nss
Normal file
@@ -0,0 +1,55 @@
|
||||
#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);
|
||||
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);
|
||||
|
||||
//Randomly select a village area
|
||||
int nElementIndex = Random(3)+22; //22, 23 or 24
|
||||
string sRandomAreaString = sRegionString+"_"+IntToString(nElementIndex);
|
||||
|
||||
//Teleport the PC (and their party) to the southern entrance waypoint of the chosen area
|
||||
object oWaypoint = GetWaypointByTag("exit_wp_"+sRandomAreaString+"_s");
|
||||
//We should teleport the party leader first to make him trigger the OnEnter event
|
||||
object oParty = GetFactionLeader(oPC);
|
||||
SetLocalInt(oParty, "CanDiscover", GetLocalInt(oParty, "CanDiscover")+1);
|
||||
AssignCommand(oParty, ClearAllActions());
|
||||
SetLocalInt(oParty, "Miles", GetLocalInt(oParty, "Miles")+1);
|
||||
AssignCommand(oParty, JumpToObject(oWaypoint));
|
||||
//Now for the rest of the party
|
||||
oParty = GetFirstFactionMember(oPC, FALSE);
|
||||
while ( oParty != OBJECT_INVALID )
|
||||
{
|
||||
if (oParty != GetFactionLeader(oParty))
|
||||
{
|
||||
SetLocalInt(oParty, "Miles", GetLocalInt(GetFactionLeader(oPC), "Miles")); //Set everyone's distance travelled to that of the party leader
|
||||
SetLocalInt(oParty, "CanDiscover", GetLocalInt(oParty, "CanDiscover")+1);
|
||||
AssignCommand(oParty, ClearAllActions());
|
||||
|
||||
SetLocalInt(oParty, "Miles", GetLocalInt(oParty, "Miles")+1);
|
||||
if (GetLocalString(GetModule(), "MODE") == "LOCAL" && GetIsPC(oParty)) SetCampaignInt(CharacterDB(oParty), "MILES", GetLocalInt(oParty, "Miles")); //store miles travelled in LOCAL mode
|
||||
AssignCommand(oParty, JumpToObject(oWaypoint));
|
||||
}
|
||||
|
||||
oParty = GetNextFactionMember(oPC, FALSE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user