I am working on a module that has a big if statement at the moment. And by the time I am done,
it will probably be bigger. I was wondering what's a good way to try to streamline it.
This is the current script with it:
void main()
{
int seconddoor; //This is the number rolled.
int set = 0; //This is to determine if the conversation should get this far.
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 < 3)
{
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 > 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
{
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) && (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
{
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
{
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
{
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);
}
}
At three different cities in the module, this randomly sets the bank door for that city to one of the
premade bank interiors. It does not set two to the same one(which is how I want it). This way
you don't know which bank will be for which city until you go in.
But I will probably be adding cities/towns and was wondering about streamlining this.
------------------------
"Knowledge knows no bounds!" But hindsight might wish there had been some!