Bugfix pass.
Fixed onRespawn & onDying scripts. Fixed XP awards. Added temple hospital & library.
This commit is contained in:
104
_module/nss/temple_moaning.nss
Normal file
104
_module/nss/temple_moaning.nss
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Make the patients moan. This is a heartbeat script, placed not on
|
||||
any of the individual patients, but rather, on some innocuous
|
||||
placeable object (rug, scorchmark, blood puddle, etc...)
|
||||
No need to make millions of heartbeat scripts =)
|
||||
|
||||
WWWWolf 2003-11-09
|
||||
*/
|
||||
|
||||
// Patient tag.
|
||||
const string PATIENT = "Patient";
|
||||
|
||||
// NOTE: BROKEN (below code uses a brute-force approach.)
|
||||
// Causes "TOO MANY INSTRUCTIONS" error.
|
||||
int HowManyWithTag(string sTag) {
|
||||
object obj;
|
||||
int n = 0;
|
||||
|
||||
do {
|
||||
obj = GetObjectByTag(sTag,n);
|
||||
} while (obj != OBJECT_INVALID);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
object RandomPatient() {
|
||||
object x;
|
||||
|
||||
/* // Optimal solution
|
||||
x = GetObjectByTag(PATIENT, Random(n));
|
||||
if(x == OBJECT_INVALID)
|
||||
continue;
|
||||
*/
|
||||
/* // Brute force but safe solution
|
||||
int z;
|
||||
for(z = 0; z < 10; z++) { // 10 tries
|
||||
x = GetObjectByTag(PATIENT,Random(40));
|
||||
if(x != OBJECT_INVALID)
|
||||
break;
|
||||
}
|
||||
if(x == OBJECT_INVALID)
|
||||
continue;
|
||||
*/
|
||||
// Lightweight brute force solution
|
||||
x = GetObjectByTag(PATIENT,Random(40));
|
||||
/* if(x == OBJECT_INVALID)
|
||||
continue; */
|
||||
return x;
|
||||
}
|
||||
|
||||
string RandomMoaning() {
|
||||
// Pick a random moaning
|
||||
switch(d6(1)) {
|
||||
default:
|
||||
case 1:
|
||||
return "Aaaaargh!";
|
||||
break;
|
||||
case 2:
|
||||
return "Oooooh my head!";
|
||||
break;
|
||||
case 3:
|
||||
return "Aaaaargh my legs!";
|
||||
break;
|
||||
case 4:
|
||||
return "Uuuuaaaargh! Ooh!";
|
||||
break;
|
||||
case 5:
|
||||
return "Ooooaaaargh!";
|
||||
break;
|
||||
case 6:
|
||||
return "Make this pain stop, please!";
|
||||
break;
|
||||
}
|
||||
// This is an impossible case. Just here to keep the compiler happy.
|
||||
return "This moan script sucks and WWWWolf is an idiot! AAAAaaaaAargh!";
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
object x;
|
||||
int n;
|
||||
int a;
|
||||
string moan;
|
||||
|
||||
// Count the patients.
|
||||
// n = HowManyWithTag(PATIENT);
|
||||
|
||||
// Let's do 1d4 moaning patients
|
||||
int nmoans = d4(1);
|
||||
for(a = 0; a < nmoans; a++) {
|
||||
|
||||
// Get a random patient
|
||||
x = RandomPatient();
|
||||
if(x == OBJECT_INVALID)
|
||||
continue;
|
||||
|
||||
// Pick a random moaning
|
||||
moan = RandomMoaning();
|
||||
|
||||
// Make the patient moan.
|
||||
// AssignCommand(x, ActionSpeakString(moan));
|
||||
AssignCommand(x, SpeakString(moan));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user