I’m trying to make a (OC) world map wondering monster script. The player has a 1 in 6 chance of encountering a wondering monster every time they travel to a new mod.
How it suppose to work.
There’s a 1 in 6 chance of a character or player of running into a wandering monster while in route to a destination. If the script fires a 1 then the player will be diverted to another small mod made up of small encounter areas. There’s 4 areas’ in the encounter mod that are d4 randomly picked.
My problem well I can’t get it to work. The script compiles fine and will take me to my picked destination but I suspect the ‘int d6’ is not working but not sure. No matter how I set the variables it won’t send me to the encounter mod. I posted a copy of the script below in hopes that somebody might be able to give me a clue on what I’m doing wrong. Thank you.
[nwscript]
//Put this script on Action Script.
#include "ginc_transition"
void main(string sModule0, string sModule, string sTarget)
{
object oPC = GetIsObjectValid(GetPCSpeaker()) ? GetPCSpeaker() : OBJECT_SELF;
object oTarget = GetObjectByTag(sTarget);
int nInt;
nInt = d6();
if (nInt==1)
{
int nInt;
nInt = d4();
if (nInt==1)
{
object oTarget = GetWaypointByTag("x_playerspawn_01");
// check if the target exists in the current module
if(GetIsObjectValid(oTarget))
{
// exists in module: jump the party to the target
SinglePartyTransition(oPC, oTarget);
}
else
{
// does not exist in module: load the appropriate module and jump the party to the target
LoadNewModule(sModule0);
}
}
if (nInt==2)
{
object oTarget = GetWaypointByTag("x_playerspawn_02");
// check if the target exists in the current module
if(GetIsObjectValid(oTarget))
{
// exists in module: jump the party to the target
SinglePartyTransition(oPC, oTarget);
}
else
{
// does not exist in module: load the appropriate module and jump the party to the target
LoadNewModule(sModule0);
}
}
if (nInt==3)
{
object oTarget = GetWaypointByTag("x_playerspawn_03");
// check if the target exists in the current module
if(GetIsObjectValid(oTarget))
{
// exists in module: jump the party to the target
SinglePartyTransition(oPC, oTarget);
}
else
{
// does not exist in module: load the appropriate module and jump the party to the target
LoadNewModule(sModule0);
}
}
if (nInt==4)
{
object oTarget = GetWaypointByTag("x_playerspawn_04");
// check if the target exists in the current module
if(GetIsObjectValid(oTarget))
{
// exists in module: jump the party to the target
SinglePartyTransition(oPC, oTarget);
}
else
{
// does not exist in module: load the appropriate module and jump the party to the target
LoadNewModule(sModule0);
}
}
{
object oPC = GetIsObjectValid(GetPCSpeaker()) ? GetPCSpeaker() : OBJECT_SELF;
object oTarget = GetObjectByTag(sTarget);
// check if the target exists in the current module
if(GetIsObjectValid(oTarget))
{
// exists in module: jump the party to the target
SinglePartyTransition(oPC, oTarget);
}
else
{
// does not exist in module: load the appropriate module and jump the party to the target
LoadNewModule(sModule, sTarget);
}
}
}
}[/nwscript]
OC) World Map Wondering Monsters
Débuté par
Alupinu
, juil. 15 2010 01:12
#1
Posté 15 juillet 2010 - 01:12
#2
Posté 15 juillet 2010 - 02:57
I'm not sure if this will work. It compiles but I dont have a way to test it. It also may not be what your looking for. I hope it helps.
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) LoadNewModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) LoadNewModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) LoadNewModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) LoadNewModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
LoadNewModule(sModule, sWaypoint);
}
}
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) LoadNewModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) LoadNewModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) LoadNewModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) LoadNewModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
LoadNewModule(sModule, sWaypoint);
}
}
#3
Posté 15 juillet 2010 - 09:22
Hey Hilltop2012, good to hear from you.
Yea thanks for the really good looking script, very professional looking.
I did have to make a few small changes to get it to work but nothing major. I do have one problem that I hope you can consider. When the pc spawns into the encounter area he has trouble continuing to his original destination. In other words the program thinks that the pc is in the map-pin mod and not in the floating mod. LOL, does that make any sense? The map-pin is red even know the pc is not in that mod so he cannot go there because the program thinks he is already there. I think the script needs something like ‘GetCurrentModule’ or something like that.
Anyway I’m posting the script below so you may see my changes and give me your opinion.
P.S Have you figured out how to post a script yet? lol
//Created by: Hilltop2012
//Date:July 15, 2010
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) LoadNewModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) LoadNewModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) LoadNewModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) LoadNewModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
LoadNewModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
Yea thanks for the really good looking script, very professional looking.
I did have to make a few small changes to get it to work but nothing major. I do have one problem that I hope you can consider. When the pc spawns into the encounter area he has trouble continuing to his original destination. In other words the program thinks that the pc is in the map-pin mod and not in the floating mod. LOL, does that make any sense? The map-pin is red even know the pc is not in that mod so he cannot go there because the program thinks he is already there. I think the script needs something like ‘GetCurrentModule’ or something like that.
Anyway I’m posting the script below so you may see my changes and give me your opinion.
P.S Have you figured out how to post a script yet? lol
//Created by: Hilltop2012
//Date:July 15, 2010
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) LoadNewModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) LoadNewModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) LoadNewModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) LoadNewModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
LoadNewModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
#4
Posté 16 juillet 2010 - 01:11
Hi Alupinu.
In another thread, Shaugn78 suggested using 'SaveRosterLoadModule(string module name, string start waypoint);' You would have to use the #include: "ginc_companion".
As for your other problem. If I understood you correctly. You could set a local variable on the PC for the destination Module when the random encounter module is loaded. Then retrieve it when the player leaves the encounter area. I hope that makes sense. I might need more coffee. :happy:
/ If you roll a 1 then load encounter module.if ( nRandomNumber == 1){
//roll 1d4 to pick a waypointobject oPC = GetPCSpeaker();int nPickWayPoint = d4();
//Store original intended destination on PC so when they kill the baddies they can continue.
SetLocalString(oPC, Variable Name, sModule);SetLocalString(oPC, Variable Name, sWayPoint);
//if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_01); if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_02); if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_03); if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_04); }
In another thread, Shaugn78 suggested using 'SaveRosterLoadModule(string module name, string start waypoint);' You would have to use the #include: "ginc_companion".
As for your other problem. If I understood you correctly. You could set a local variable on the PC for the destination Module when the random encounter module is loaded. Then retrieve it when the player leaves the encounter area. I hope that makes sense. I might need more coffee. :happy:
/ If you roll a 1 then load encounter module.if ( nRandomNumber == 1){
//roll 1d4 to pick a waypointobject oPC = GetPCSpeaker();int nPickWayPoint = d4();
//Store original intended destination on PC so when they kill the baddies they can continue.
SetLocalString(oPC, Variable Name, sModule);SetLocalString(oPC, Variable Name, sWayPoint);
//if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_01); if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_02); if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_03); if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_04); }
#5
Posté 16 juillet 2010 - 07:43
Hey Hilltop, did as you suggested and I think I got most of it right. Lol I am having a problem getting it to compile. On the 38th line, [SetLocalString (oPC, "Party0", sModule);SetLocalString(oPC, "Party0", sWayPoint);]I keep getting a message saying, “ERROR: VARIABLE DEFINED WITHOUT TYPE”. No idea what that means. For the life of me I can’t see anything wrong with it. The variable defined is "LocalString", right? I don't know...LOL! Anyway at your convenience I was hoping you take a look and see if you could spot the errors of my ways. Thanks. 
Script below.
//Created by: Hilltop2012
//Date:July 15, 2010.
#include "ginc_companion"
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
//Store original intended destination on PC so when they kill the baddies they can continue.
SetLocalString (oPC, "Party0", sModule);SetLocalString(oPC, "Party0", sWayPoint);
if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
SaveRosterLoadModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
Script below.
//Created by: Hilltop2012
//Date:July 15, 2010.
#include "ginc_companion"
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
//Store original intended destination on PC so when they kill the baddies they can continue.
SetLocalString (oPC, "Party0", sModule);SetLocalString(oPC, "Party0", sWayPoint);
if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
SaveRosterLoadModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
#6
Posté 16 juillet 2010 - 09:13
This compiles.
sWaypoint had an uppercase 'P' in it. I'm willing to bet that it was my fault, oops LOL
//Created by: Hilltop2012
//Date:July 15, 2010.
#include "ginc_companion"
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Store original intended destination on PC so when they kill the baddies they can continue.
SetLocalString (oPC, "Party0", sModule);
SetLocalString (oPC, "Party1", sWaypoint);
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
SaveRosterLoadModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
sWaypoint had an uppercase 'P' in it. I'm willing to bet that it was my fault, oops LOL
//Created by: Hilltop2012
//Date:July 15, 2010.
#include "ginc_companion"
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Store original intended destination on PC so when they kill the baddies they can continue.
SetLocalString (oPC, "Party0", sModule);
SetLocalString (oPC, "Party1", sWaypoint);
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_01);
if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_02);
if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_03);
if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, x_playerspawn_04);
}
else
{
//go to other destination with no encounter
SaveRosterLoadModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
#7
Posté 16 juillet 2010 - 09:18
Also, make sure that the variable names are different. Otherwise you will overwrite the value. I changed one of them from "party0" to "party1"
Now I'm curious if it will actually work, hehe.
When you set up your transition in your encounter module you can use:
GetLocalString(oPC, "party0");
to retrieve the info. If you need help with that part, let me know.
Now I'm curious if it will actually work, hehe.
When you set up your transition in your encounter module you can use:
GetLocalString(oPC, "party0");
to retrieve the info. If you need help with that part, let me know.
#8
Posté 17 juillet 2010 - 01:09
Hey Hilltop, LOL! Well I solved our problem with getting the right module. Turns out we didn’t need the oPC string after all. It was a big “Ooops!” on my part. On the transition trigger I forgot to fill in a field (string variable), ‘sOrigins’, that tells the script where the party is at the moment. My goof!
I did discover a new bug. Though the script is getting the encounter module at random (like it should) it’s not finding the tags of the waypoints. The script keeps loading up the same area spawning the character at the start point. Any ideas?
I did discover a new bug. Though the script is getting the encounter module at random (like it should) it’s not finding the tags of the waypoints. The script keeps loading up the same area spawning the character at the start point. Any ideas?
#9
Posté 17 juillet 2010 - 01:28
Check the tags of the waypoints in the areas and make sure they match the tags in the script.Thats the only thing that I can think of.
#10
Posté 17 juillet 2010 - 02:13
Yes I checked the tags and there all good. That was the first thing I thought of too. I'll keep playing with it, let you know if I figure anything out.
#11
Posté 17 juillet 2010 - 06:16
I think the waypoint's name needs to be in quotes (its a string variable). Here's a slightly altered version of hilltop's most recent script posted.
//Created by: Hilltop2012
//Date:July 15, 2010.
#include "ginc_companion"
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Store original intended destination on PC so when they kill the baddies they can continue.
SetLocalString (oPC, "Party0", sModule);
SetLocalString (oPC, "Party1", sWaypoint);
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if (nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
int nPickWayPoint = d4();
SaveRosterLoadModule(sModuleEncounter, "x_playerspawn_0" + IntToString(nPickWayPoint));
}
else
{
//go to other destination with no encounter
SaveRosterLoadModule(sModule, sWaypoint);
}
}
#12
Posté 17 juillet 2010 - 08:20
@Hey Hilltop2012,
Not to toot my own horn (Toot! Toot!)… But I figured out the problem. The ‘GetRosterLoadModule’ line was incomplete I posted the script below so you could see what I’m talking about. Quick question, do I still need those string variables’ for the wp’s in the first part?
Also I’m having trouble getting a message to appear in the chat box, does that function line look right?
@Hey _Knightmare_,
Haven’t chatted with you for a while good to hear from you. Thanks for the revised script but I think I have it all under control (Famous last words). As I stated above I think I found the problem and now Hilltop2012 script seems to be working like a champ well except my latest edition a message function. LOL
//Created by: Hilltop2012
//Date:July 15, 2010.
#include "ginc_companion"
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_01");
if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_02");
if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_03");
if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_04");
SendMessageToPC(oPC, "You encounter a wandering monster.");
}
else
{
//go to other destination with no encounter
SaveRosterLoadModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
Not to toot my own horn (Toot! Toot!)… But I figured out the problem. The ‘GetRosterLoadModule’ line was incomplete I posted the script below so you could see what I’m talking about. Quick question, do I still need those string variables’ for the wp’s in the first part?
Also I’m having trouble getting a message to appear in the chat box, does that function line look right?
@Hey _Knightmare_,
Haven’t chatted with you for a while good to hear from you. Thanks for the revised script but I think I have it all under control (Famous last words). As I stated above I think I found the problem and now Hilltop2012 script seems to be working like a champ well except my latest edition a message function. LOL
//Created by: Hilltop2012
//Date:July 15, 2010.
#include "ginc_companion"
void main(string sModuleEncounter, string sModule, string sWaypoint)
{
object oPC = GetPCSpeaker();
//Waypoint tag names
string x_playerspawn_01;
string x_playerspawn_02;
string x_playerspawn_03;
string x_playerspawn_04;
//Roll 1d6
int nRandomNumber = d6();
// If you roll a 1 then load encounter module.
if ( nRandomNumber == 1)
{
//roll 1d4 to pick a waypoint
object oPC = GetPCSpeaker();
int nPickWayPoint = d4();
if ( nPickWayPoint == 1 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_01");
if ( nPickWayPoint == 2 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_02");
if ( nPickWayPoint == 3 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_03");
if ( nPickWayPoint == 4 ) SaveRosterLoadModule(sModuleEncounter, sWaypoint="x_playerspawn_04");
SendMessageToPC(oPC, "You encounter a wandering monster.");
}
else
{
//go to other destination with no encounter
SaveRosterLoadModule(sModule, sWaypoint);
object oPC = GetPCSpeaker();
}
}
Modifié par Alupinu, 17 juillet 2010 - 08:22 .
#13
Posté 20 juillet 2010 - 04:25
Well for anybody that cares I just thought I let you know that all problems solved, script works great even the message thing. Lol Thanks again Hilltop 2012 and you to _knightmare_.





Retour en haut







