Another quick question. And since it involves an addition to one of these scripts, I will post this here.
I started working on one of the modules I had planned for this and set up at three different spots the random area set script(roll a dice, and depending on the result, set the door's destination to there). I added to that where it will only use an area once. If say I have three towns with banks, and the PC activates the conversation right outside(clicks on the sign) it randomly sets that door to one of three premade bank interiors I have made.
Then if I click on the bank sign in another town, it will NOT have the first town's bank(as it is now set) as one of the options(I don't want to different towns that are meant to be far apart having bank doors leading to the same bank.)
Now I have this working with this script:
void main()
{
int seconddoor;
int set = 0;
string diceroll;
object oPC = GetPCSpeaker();
int BanksetTotal = GetLocalInt(oPC, "BanksetTotal");
int Bank01 = GetLocalInt(oPC, "Bank01");
int Bank02 = GetLocalInt(oPC, "Bank02");
int Bank03 = GetLocalInt(oPC, "Bank03");
// Get the Object for each door.
object oNPCsDoor = GetNearestObject(OBJECT_TYPE_DOOR);
object oDestDoor;
if (BanksetTotal == 0)
{
seconddoor = d6();
if ((seconddoor == 1) || (seconddoor == 2))
{
oDestDoor = GetObjectByTag("BankDoor1");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank01 = Bank01 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank01", Bank01);
}
else if ((seconddoor == 3) || (seconddoor == 4))
{
oDestDoor = GetObjectByTag("BankDoor3");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank02 = Bank02 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank02", Bank02);
}
else if ((seconddoor == 5) || (seconddoor == 6))
{
oDestDoor = GetObjectByTag("BankDoor5");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank03 = Bank03 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank03", Bank03);
}
else
return;
//Set oDestDoor as the destination for oNPC's door.
SetLocalObject(oNPCsDoor,"TRANS_TARGET",oDestDoor);
// Set oNPC's door as the Destination for oDestDoor
SetLocalObject(oDestDoor,"TRANS_TARGET",oNPCsDoor);
SetLocalInt(oNPCsDoor, "set", 1);
}
else if ((BanksetTotal == 1) && (Bank01 == 1))
{
seconddoor = d2();
if (seconddoor == 1)
{
oDestDoor = GetObjectByTag("BankDoor3");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank02 = Bank02 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank02", Bank02);
}
else if (seconddoor == 2)
{
oDestDoor = GetObjectByTag("BankDoor5");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank03 = Bank03 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank03", Bank03);
}
//Set oDestDoor as the destination for oNPC's door.
SetLocalObject(oNPCsDoor,"TRANS_TARGET",oDestDoor);
//Set oNPC's door as the Destination for oDestDoor
SetLocalObject(oDestDoor,"TRANS_TARGET",oNPCsDoor);
SetLocalInt(oNPCsDoor, "set", 1);
}
else if ((BanksetTotal == 1) && (Bank02 == 1))
{
seconddoor = d2();
if (seconddoor == 1)
{
oDestDoor = GetObjectByTag("BankDoor1");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank01 = Bank01 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank01", Bank01);
}
else if (seconddoor == 2)
{
oDestDoor = GetObjectByTag("BankDoor5");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank03 = Bank03 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank03", Bank03);
}
//Set oDestDoor as the destination for oNPC's door.
SetLocalObject(oNPCsDoor,"TRANS_TARGET",oDestDoor);
//Set oNPC's door as the Destination for oDestDoor
SetLocalObject(oDestDoor,"TRANS_TARGET",oNPCsDoor);
SetLocalInt(oNPCsDoor, "set", 1);
}
else if ((BanksetTotal == 1) && (Bank03 == 1))
{
seconddoor = d2();
if (seconddoor == 1)
{
oDestDoor = GetObjectByTag("BankDoor1");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank01 = Bank01 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank01", Bank01);
}
else if (seconddoor == 2)
{
oDestDoor = GetObjectByTag("BankDoor3");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank02 = Bank02 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank02", Bank02);
}
//Set oDestDoor as the destination for oNPC's door.
SetLocalObject(oNPCsDoor,"TRANS_TARGET",oDestDoor);
//Set oNPC's door as the Destination for oDestDoor
SetLocalObject(oDestDoor,"TRANS_TARGET",oNPCsDoor);
SetLocalInt(oNPCsDoor, "set", 1);
}
else if ((BanksetTotal == 2) && (Bank01 == 0))
{
// seconddoor = d2();
// if (seconddoor == 1)
// {
oDestDoor = GetObjectByTag("BankDoor1");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
// FloatingTextStringOnCreature("The dice roll is:", oPC);
// SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank01 = Bank01 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank01", Bank01);
// }
/* else if (seconddoor == 2)
{
oDestDoor = GetObjectByTag("BankDoor3");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank02 = Bank02 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank02", Bank02);
}*/
//Set oDestDoor as the destination for oNPC's door.
SetLocalObject(oNPCsDoor,"TRANS_TARGET",oDestDoor);
//Set oNPC's door as the Destination for oDestDoor
SetLocalObject(oDestDoor,"TRANS_TARGET",oNPCsDoor);
SetLocalInt(oNPCsDoor, "set", 1);
}
else if ((BanksetTotal == 2) && (Bank02 == 0))
{
// seconddoor = d2();
// if (seconddoor == 1)
// {
oDestDoor = GetObjectByTag("BankDoor3");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
// FloatingTextStringOnCreature("The dice roll is:", oPC);
// SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank01 = Bank01 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank02", Bank02);
// }
/* else if (seconddoor == 2)
{
oDestDoor = GetObjectByTag("BankDoor3");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank02 = Bank02 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank02", Bank02);
}*/
//Set oDestDoor as the destination for oNPC's door.
SetLocalObject(oNPCsDoor,"TRANS_TARGET",oDestDoor);
//Set oNPC's door as the Destination for oDestDoor
SetLocalObject(oDestDoor,"TRANS_TARGET",oNPCsDoor);
SetLocalInt(oNPCsDoor, "set", 1);
}
else if ((BanksetTotal == 2) && (Bank03 == 0))
{
// seconddoor = d2();
// if (seconddoor == 1)
// {
oDestDoor = GetObjectByTag("BankDoor5");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
// FloatingTextStringOnCreature("The dice roll is:", oPC);
// SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank01 = Bank01 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank03", Bank03);
// }
/* else if (seconddoor == 2)
{
oDestDoor = GetObjectByTag("BankDoor3");
//This is to let the PC know what the number rolled is.
diceroll = IntToString(seconddoor);
FloatingTextStringOnCreature("The dice roll is:", oPC);
SendMessageToPC(oPC, diceroll);
BanksetTotal = BanksetTotal + 1;
Bank02 = Bank02 + 1;
SetLocalInt(oPC, "BanksetTotal", BanksetTotal);
SetLocalInt(oPC, "Bank02", Bank02);
}*/
//Set oDestDoor as the destination for oNPC's door.
SetLocalObject(oNPCsDoor,"TRANS_TARGET",oDestDoor);
//Set oNPC's door as the Destination for oDestDoor
SetLocalObject(oDestDoor,"TRANS_TARGET",oNPCsDoor);
SetLocalInt(oNPCsDoor, "set", 1);
}
}
BanksetTotal, Bank01, Bank02, and Bank03 are set when the PC enters the module.
The int set that I have this script setting, is where the conversation determines if it should activate the line that runs this script. This way, it gets the int on the nearest door and if it is 1, it doesn't run the script again.
My question is, can this be streamlined anymore? It seems a little long to me, and if I add more banks/towns, it will make it even longer.
-------------------------
"Knowledge knows no bounds! But hindsight might have wished there was some!"