226 lines
8.3 KiB
Plaintext
226 lines
8.3 KiB
Plaintext
// makes the audience shout something
|
|
void Audience(int nFinish=FALSE)
|
|
{
|
|
// store the message here
|
|
string sMessage;
|
|
|
|
// if it is the end of the race
|
|
if (nFinish)
|
|
{
|
|
// get a random end phrase
|
|
switch (d6())
|
|
{
|
|
case 1: sMessage = "Ah git mah gold un that wun!"; break;
|
|
case 2: sMessage = "Ah donnae know why ah play this rubbush!"; break;
|
|
case 3: sMessage = "Hells! Ah lost agun!"; break;
|
|
case 4: sMessage = "Aye, tha' be tha wun!"; break;
|
|
case 5: sMessage = "Ah gonna be winnun' a furtune!"; break;
|
|
case 6: sMessage = "Ye be a loser no', ha ha!"; break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// get a random in-race phrase
|
|
switch (d12())
|
|
{
|
|
case 1: sMessage = "Go un Jasper, ye can win!"; break;
|
|
case 2: sMessage = "Go un ye stupud rat!"; break;
|
|
case 3: sMessage = "Aye! Aye! This gunna be a winnur!"; break;
|
|
case 4: sMessage = "Ye silly rat, 'urry up!"; break;
|
|
case 5: sMessage = "Ah donnae know aboot this 'ere rat!"; break;
|
|
case 6: sMessage = "Tha rat is tha fastust evur!"; break;
|
|
case 7: sMessage = "Oi! Tha rat is a slow wun!"; break;
|
|
case 8: sMessage = "'Urry up ratty, ye can win mah sum gold!"; break;
|
|
case 9: sMessage = "Oi! Ah wunt a drink!"; break;
|
|
case 10: sMessage = "Ah, tha Misty gunna win fer sure!"; break;
|
|
case 11: sMessage = "Go un rat!"; break;
|
|
case 12: sMessage = "Ah put all mah gold un tha' wun!"; break;
|
|
}
|
|
}
|
|
// shout the phrase
|
|
object oGambler = GetObjectByTag("npc_gambler_" + IntToString(d2()));
|
|
|
|
// check if the gambler exists
|
|
// if people import the scripts and stuff, they might not want the gamblers
|
|
if (GetIsObjectValid(oGambler))
|
|
{
|
|
// this variable holds animations for the gambler
|
|
int nAnim;
|
|
|
|
// random action
|
|
switch (d3())
|
|
{
|
|
case 1: nAnim = ANIMATION_LOOPING_TALK_LAUGHING; break;
|
|
case 2: nAnim = ANIMATION_LOOPING_TALK_FORCEFUL; break;
|
|
case 3: nAnim = ANIMATION_LOOPING_TALK_PLEADING; break;
|
|
}
|
|
// make the queue
|
|
AssignCommand(oGambler, ClearAllActions());
|
|
// make them face in the direction of the race
|
|
AssignCommand(oGambler, SetFacing(0.0));
|
|
// say a random message
|
|
AssignCommand(oGambler, SpeakString(sMessage));
|
|
// play a random animation
|
|
AssignCommand(oGambler, ActionPlayAnimation(nAnim, 1.2, 3.0));
|
|
}
|
|
}
|
|
|
|
// makes the rat squeak if someone bet on it
|
|
void Squeak(object oRat)
|
|
{
|
|
// rat number
|
|
string sRat = GetStringRight(GetTag(oRat), 1);
|
|
// check if the player is valid
|
|
if (GetIsObjectValid(GetLocalObject(GetModule(), "IC_RAT_PLAYER_" + sRat)))
|
|
// squeak!
|
|
AssignCommand(oRat, SpeakString("*squeak*"));
|
|
}
|
|
|
|
// when a rat has won, clear everything up
|
|
void Winner(object oWinnerRat)
|
|
{
|
|
// used in the loop for destroying rats
|
|
int n;
|
|
// for storing rats to be deleted
|
|
object oRat;
|
|
// handle to drurri
|
|
object oDrurri = GetObjectByTag("npc_gambler_drurri");
|
|
// name of the winner
|
|
string sWinner = GetName(oWinnerRat);
|
|
// this gets the number of the winner
|
|
string sWinnerRat = GetStringRight(GetTag(oWinnerRat), 1);
|
|
// handle to module
|
|
object oMod = GetModule();
|
|
// the person (if any) that won
|
|
object oPlayerWinner = GetLocalObject(oMod, "IC_RAT_PLAYER_" + sWinnerRat);
|
|
|
|
// make the rat squeak
|
|
SpeakString("*squeak* *squeak*");
|
|
// make the audience shout a random end message
|
|
Audience(TRUE);
|
|
|
|
// reset the music
|
|
MusicBackgroundChangeDay(GetArea(oWinnerRat), TRACK_SEWER);
|
|
MusicBackgroundChangeNight(GetArea(oWinnerRat), TRACK_SEWER);
|
|
|
|
// make drurri announce the winner and give out the bets
|
|
AssignCommand(oDrurri, SpeakString("Race is ovur, " + sWinner + " is tha winnur!"));
|
|
// remove that variable that shows a race is in progress
|
|
DeleteLocalInt(oDrurri, "IC_RACE_RUNNING");
|
|
|
|
|
|
// see if someone bet on the winning rat
|
|
if (GetIsObjectValid(oPlayerWinner))
|
|
{
|
|
// see how much they bet
|
|
int nBet = GetLocalInt(oMod, "IC_RAT_GAMBLE_" + sWinnerRat);
|
|
// give them three times the bet
|
|
GiveGoldToCreature(oPlayerWinner, nBet * 3);
|
|
// play coin sound
|
|
AssignCommand(oPlayerWinner, ActionDoCommand(PlaySound("it_coins")));
|
|
// send a message
|
|
SendMessageToPC(oPlayerWinner, "Your rat was the winner!");
|
|
}
|
|
|
|
// destroy all the rats
|
|
for (n = 1; n <= 4; n++)
|
|
{
|
|
// handle to the rat
|
|
oRat = GetObjectByTag("npc_rat_" + IntToString(n));
|
|
// make it destroyable
|
|
SetPlotFlag(oRat, FALSE);
|
|
// make the rat disappear
|
|
DestroyObject(oRat);
|
|
// delete the person who bet on this rat
|
|
DeleteLocalObject(oMod, "IC_RAT_PLAYER_" + IntToString(n));
|
|
// delete the amounts bet on the rats
|
|
DeleteLocalInt(oMod, "IC_RAT_GAMBLE_" + IntToString(n));
|
|
}
|
|
|
|
}
|
|
|
|
void main()
|
|
{
|
|
// WAY_RAT_FLAG_(1-5)
|
|
// WAY_RAT_START_(1-4)
|
|
// npc_rat_1
|
|
// rat00(3-6)
|
|
int n;
|
|
object oRat;
|
|
int nWay1, nWay2, nWay3, nWay4;
|
|
object oRat1, oRat2, oRat3, oRat4;
|
|
object oWay1 = GetWaypointByTag("WAY_RAT_FLAG_1");
|
|
object oWay2 = GetWaypointByTag("WAY_RAT_FLAG_2");
|
|
object oWay3 = GetWaypointByTag("WAY_RAT_FLAG_3");
|
|
object oWay4 = GetWaypointByTag("WAY_RAT_FLAG_4");
|
|
object oWay5 = GetWaypointByTag("WAY_RAT_FLAG_5");
|
|
object oDrurri = GetObjectByTag("npc_gambler_drurri");
|
|
float fDelay;
|
|
|
|
// save that a race is in progress
|
|
SetLocalInt(oDrurri, "IC_RACE_RUNNING", TRUE);
|
|
|
|
// destroy any existing rats
|
|
// shouldn't be any though
|
|
for (n = 1; n <= 4; n++)
|
|
{
|
|
oRat = GetObjectByTag("npc_rat_" + IntToString(n));
|
|
SetPlotFlag(oRat, FALSE);
|
|
DestroyObject(oRat);
|
|
}
|
|
|
|
// pick random start places for all rats
|
|
switch (d4())
|
|
{
|
|
case 1: nWay1=1; nWay2=2; nWay3=3; nWay4=4; break;
|
|
case 2: nWay1=4; nWay2=3; nWay3=2; nWay4=1; break;
|
|
case 3: nWay1=3; nWay2=1; nWay3=4; nWay4=2; break;
|
|
case 4: nWay1=2; nWay2=4; nWay3=1; nWay4=3; break;
|
|
}
|
|
|
|
// create each rat
|
|
oRat1 = CreateObject(OBJECT_TYPE_CREATURE, "jasper", GetLocation(GetWaypointByTag("WAY_RAT_START_" + IntToString(nWay1))), TRUE);
|
|
oRat2 = CreateObject(OBJECT_TYPE_CREATURE, "misty", GetLocation(GetWaypointByTag("WAY_RAT_START_" + IntToString(nWay2))), TRUE);
|
|
oRat3 = CreateObject(OBJECT_TYPE_CREATURE, "julian", GetLocation(GetWaypointByTag("WAY_RAT_START_" + IntToString(nWay3))), TRUE);
|
|
oRat4 = CreateObject(OBJECT_TYPE_CREATURE, "george", GetLocation(GetWaypointByTag("WAY_RAT_START_" + IntToString(nWay4))), TRUE);
|
|
|
|
// put some battle music on
|
|
MusicBackgroundChangeDay(GetArea(oRat1), TRACK_BATTLE_CITYBOSS);
|
|
MusicBackgroundChangeNight(GetArea(oRat1), TRACK_BATTLE_CITYBOSS);
|
|
|
|
// loop through each rat
|
|
for (n = 1; n <= 4; n++)
|
|
{
|
|
// handle to the rat
|
|
oRat = GetObjectByTag("npc_rat_" + IntToString(n));
|
|
|
|
// random start delay
|
|
// 4.7 + (0.1 > 0.4)
|
|
// 4.8 / 4.9 / 5.0 / 5.1
|
|
fDelay = 4.7 + IntToFloat(d4() / 10);
|
|
// random rat speed increase
|
|
// 1 > 20
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectMovementSpeedIncrease(d20()), oRat);
|
|
|
|
// now make up the queue
|
|
// pause to begin with, around 5 seconds
|
|
AssignCommand(oRat, ActionWait(fDelay));
|
|
// rats with people betting on them should squeak
|
|
AssignCommand(oRat, ActionDoCommand(Squeak(oRat)));
|
|
// make them move to the first point
|
|
AssignCommand(oRat, ActionMoveToObject(oWay1, TRUE));
|
|
// make the gamblers say something
|
|
if (n==1) AssignCommand(oRat, ActionDoCommand(Audience()));
|
|
AssignCommand(oRat, ActionMoveToObject(oWay2, TRUE));
|
|
if (n==1) AssignCommand(oRat, ActionDoCommand(Audience()));
|
|
AssignCommand(oRat, ActionMoveToObject(oWay3, TRUE));
|
|
if (n==1) AssignCommand(oRat, ActionDoCommand(Audience()));
|
|
AssignCommand(oRat, ActionMoveToObject(oWay4, TRUE));
|
|
if (n==1) AssignCommand(oRat, ActionDoCommand(Audience()));
|
|
AssignCommand(oRat, ActionMoveToObject(oWay5, TRUE));
|
|
// run the function for the winner
|
|
AssignCommand(oRat, ActionDoCommand(Winner(oRat)));
|
|
}
|
|
|
|
}
|