NWScript:
void main()
{
object oSlotLight1;
object oSlotLight2;
object oSlotLight3;
object oPc = GetLastUsedBy();
location lLever = GetLocation(OBJECT_SELF);
location lSlotLight1;
location lSlotLight2;
location lSlotLight3;
int j = 1;
int randomNumber1 = Random(3);
int randomNumber2 = Random(3);
int randomNumber3 = Random(3);
int randomDeath = Random(3);
int validPlayer;
int percentToTake = 10;
int amountToGive = 20000;
int gameCost = 25;
if(GetIsObjectValid(oPc) == TRUE)
{
if(GetIsDead(oPc) == FALSE)
{
validPlayer = TRUE;
}
}
if((GetGold(oPc) >= gameCost) && (validPlayer == TRUE))
{
TakeGoldFromCreature(gameCost, oPc, TRUE);
object oObject = GetFirstObjectInShape(SHAPE_SPHERE, 30.0, lLever, FALSE, OBJECT_TYPE_PLACEABLE);
while(oObject != OBJECT_INVALID)
{
if(GetTag(oObject) == "plc_solwhite" ||
GetTag(oObject) == "Shaft of Light - Red" ||
GetTag(oObject) == "Shaft of Light - Yellow" ||
GetTag(oObject) == "Shaft of Light - Green")
{
switch(j)
{
case 1:
{
oSlotLight1 = oObject;
lSlotLight1 = GetLocation(oSlotLight1);
break;
}
case 2:
{
oSlotLight2 = oObject;
lSlotLight2 = GetLocation(oSlotLight2);
break;
}
case 3:
{
oSlotLight3 = oObject;
lSlotLight3 = GetLocation(oSlotLight3);
break;
}
}
j++;
}
oObject = GetNextObjectInShape(SHAPE_SPHERE, 30.0, lLever, FALSE, OBJECT_TYPE_PLACEABLE);
}
switch(randomNumber1)
{
case 0:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight1, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solred", lSlotLight1, FALSE);
break;
}
case 1:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight1, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solyellow", lSlotLight1, FALSE);
break;
}
case 2:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight1, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solgreen", lSlotLight1, FALSE);
break;
}
}
switch(randomNumber2)
{
case 0:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight2, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solred", lSlotLight2, FALSE);
break;
}
case 1:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight2, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solyellow", lSlotLight2, FALSE);
break;
}
case 2:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight2, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solgreen", lSlotLight2, FALSE);
break;
}
}
switch(randomNumber3)
{
case 0:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight3, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solred", lSlotLight3, FALSE);
break;
}
case 1:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight3, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solyellow", lSlotLight3, FALSE);
break;
}
case 2:
{
PlaySound("as_cv_bell1");
DestroyObject(oSlotLight3, 0.0);
CreateObject(OBJECT_TYPE_PLACEABLE, "plc_solgreen", lSlotLight3, FALSE);
break;
}
}
if(validPlayer == TRUE)
{
if(((randomNumber1 == 0) && (randomNumber2 == 0) && (randomNumber3 == 0)))
{
if(Random(2) == 1)
{
int deathOutcome;
AssignCommand(OBJECT_SELF, ActionSpeakString("Fool! Never look a gifthorse in the mouth!", 5));
switch(randomDeath)
{
case 0:
{
deathOutcome = VFX_IMP_SPIKE_TRAP;
break;
}
case 1:
{
deathOutcome = VFX_IMP_SONIC;
break;
}
case 2:
{
deathOutcome = VFX_IMP_SUNSTRIKE;
break;
}
}
effect death = EffectVisualEffect(deathOutcome);
ApplyEffectToObject(2, death, oPc, 2.0);
ApplyEffectToObject(5, EffectDeath(TRUE, TRUE), oPc);
}
else
{
AssignCommand(OBJECT_SELF, ActionSpeakString("Sorry, you have lost GP", 5));
int pcGold = GetGold(oPc);
int amountToTake = ((pcGold / 100) * percentToTake);
TakeGoldFromCreature(amountToTake, oPc, TRUE);
}
}
else if(((randomNumber1 == 1) && (randomNumber2 == 1) && (randomNumber3 == 1)))
{
AssignCommand(OBJECT_SELF, ActionSpeakString("Congratulations! You have won some GP!", 5));
GiveGoldToCreature(oPc, amountToGive);
}
else if(((randomNumber1 == 2) && (randomNumber2 == 2) && (randomNumber3 == 2)))
{
int randomVar = d6();
if(randomVar == 6)
{
AssignCommand(OBJECT_SELF, ActionSpeakString("Congratulations! You have earnt a level up!", 5));
int playerXP = GetXP(oPc);
if(playerXP < 100) GiveXPToCreature(oPc, (100 - playerXP));
else if(playerXP < 900) GiveXPToCreature(oPc, (900 - playerXP));
else if(playerXP < 2700) GiveXPToCreature(oPc, (2700 - playerXP));
else if(playerXP < 5400) GiveXPToCreature(oPc, (5400 - playerXP));
else if(playerXP < 9000) GiveXPToCreature(oPc, (9000 - playerXP));
else if(playerXP < 13000) GiveXPToCreature(oPc, (13000 - playerXP));
else if(playerXP < 19000) GiveXPToCreature(oPc, (19000 - playerXP));
else if(playerXP < 27000) GiveXPToCreature(oPc, (27000 - playerXP));
else if(playerXP < 36000) GiveXPToCreature(oPc, (36000 - playerXP));
else if(playerXP < 49000) GiveXPToCreature(oPc, (49000 - playerXP));
else if(playerXP < 66000) GiveXPToCreature(oPc, (66000 - playerXP));
else if(playerXP < 99000) GiveXPToCreature(oPc, (99000 - playerXP));
else if(playerXP < 150000) GiveXPToCreature(oPc, (150000 - playerXP));
else if(playerXP < 200000) GiveXPToCreature(oPc, (200000 - playerXP));
else if(playerXP < 260000) GiveXPToCreature(oPc, (260000 - playerXP));
else if(playerXP < 340000) GiveXPToCreature(oPc, (340000 - playerXP));
else if(playerXP < 440000) GiveXPToCreature(oPc, (440000 - playerXP));
else if(playerXP < 580000) GiveXPToCreature(oPc, (580000 - playerXP));
else if(playerXP < 760000) GiveXPToCreature(oPc, (760000 - playerXP));
GiveGoldToCreature(oPc, 500000);
}
else if(randomVar < 6 && randomVar > 3)
{
AssignCommand(OBJECT_SELF, ActionSpeakString("Congratulations! You have earnt 3000 XP Points!", 5));
GiveXPToCreature(oPc, 1000);
GiveGoldToCreature(oPc, 50000);
}
else if(randomVar < 4 && randomVar > 0)
{
AssignCommand(OBJECT_SELF, ActionSpeakString("Congratulations! You have earnt 500 XP Points!", 5));
GiveXPToCreature(oPc, 500);
}
}
}
}
}