Hello again.
I'll try to explain the problem shortly:
I'm working on "random" regions, that is - each region has 10 large areas with encounters + 3 safe areas ("towns).
At the end of each area is a trigger that randomly chooses the next area (or to be more accurate, the waypoint placed in that area) and stores it as a string variable on the current area and then another trigger teleports the player to this waypoint. There is supposed to be 5% chance of teleporting to a town and 95% chance of teleporting to another hostile area.
Edit: Looks like this script can't be properly displayed on the forum.
Here's a more clear version of it:
http://pastebin.com/ni9ZDczqHere's the script of trigger that chooses the waypoint:
//Put this script on a trigger's OnEnter tag.
void main(){//This line tells us who used the triggering object and in which areaobject oPC = GetEnteringObject();object oArea = GetArea(oPC);
if (!GetIsPC(oPC)) return;
SetLocalInt(oPC, "ready_to_tp", 1);
//This line randomly generates the point the PC will teleport to.int nWaypointNumber = Random(9);
switch (nWaypointNumber) { case 0: SetLocalString(oArea, "next_area", "random210"); break; case 1: SetLocalString(oArea, "next_area", "random21"); break; case 2: SetLocalString(oArea, "next_area", "random23"); break; case 3: SetLocalString(oArea, "next_area", "random24"); break; case 4: SetLocalString(oArea, "next_area", "random25"); break; case 5: SetLocalString(oArea, "next_area", "random26"); break; case 6: SetLocalString(oArea, "next_area", "random27"); break; case 7: SetLocalString(oArea, "next_area", "random28"); break; case 8: SetLocalString(oArea, "next_area", "random29"); break; }//A 5% chance of the next area being a village or an inn instead of wildernessif (d100()<=5) { int nTownNumber = Random(3); switch (nWaypointNumber) { case 0: SetLocalString(oArea, "next_area", "random2t1"); break; case 1: SetLocalString(oArea, "next_area", "random2t2"); break; case 2: SetLocalString(oArea, "next_area", "random2t3"); break; }
}
}
At first when I started testing the system, it seemed to work OK, but then I grew suspicious and to test it further, I modified a script so that it would always set the waypoint to one of three towns and not to any hostile area.
Or at least that's how it should be.
I just modified the line:
if (d100()<=5)
to
if (d100()<=100)
Then I proceeded to test it.
First try: OK, PC teleported to "random2t2"
Second try: Same story.
Third try: "random2t3".
Fourth try: tried to teleport me to "random2t1" but then the game crashed at the end of the loading, no error message or anything, the game just shut down. Ever since then, when I repeated my tests, I would get teleported to town 2 and town 3 properly, but I would never teleport to the first town, the one that caused the game to crash earlier. Instead, I teleported sometimes to one of the hostile areas, even though the modified script should always choose a town waypoint.
It looks as if the waypoint of the first town was suddenly considered an invalid location - that would explain why the script sent me to hostile areas at times. However, the waypoint does exist, the area loads without a problem in the toolset and what's more, I could teleport there before I decided to indulge in more testing.
I'm not sure what's causing this problem. I also don't know if I should post it in the "Scripting" forum, so sorry if it's not related to my script at all.
Any help is welcome.
Modifié par Grani, 30 septembre 2013 - 12:00 .