Alupinu wrote...
Knightmare! Stealing that script! Thanks. '>
LOL, no problem - enjoy!
Personally, when I do something along these lines, I don't want the creature to ALWAYS say a line EVERY round. So, I just add in a further random check which alters part of my code above:
void main()
{
object oSelf = OBJECT_SELF;
// If creature is not currently in combat, just do the normal Heartbeat Script and that's it
if(!GetIsInCombat(oSelf))
{
ExecuteScript("nw_c2_default1", oSelf);
return;
}
// If creature is in combat, do the rest of this script
string sSpeak;
int nChance = Random(100 +1); // Roll a random percentage between 1 and 100
if(nChance <= 25) // If random chance roll is less than or equal to 25%
{
int nRand = d3(); // Roll a single 3 sided die and note the result
switch (nRand)
{
case 1 : sSpeak = "Brainssssss"; break; // If die roll result was a 1
case 2 : sSpeak = "Uuuuuhhhhhnn"; break; // If die roll result was a 2
case 3 : sSpeak = "Brains!"; break; // If die roll result was a 3
}
// Speak the line randomly chosen above
AssignCommand(oSelf, SpeakString(sSpeak));
}
// Execute the default Heartbeat script so the creature does the other stuff it should
ExecuteScript("nw_c2_default1", oSelf);
}
That way each creature has a 25% chance per round of combat (ie. every 6 seconds) of speaking a random line. That percentage chance can be changed easy by just editing the "25" value in the line if(nChance <= 25) to whatever percentage you want. If the Random roll is greater than 25, they will just do the normal Heartbeat stuff and not say anything that specific round.
Modifié par _Knightmare_, 12 décembre 2010 - 06:25 .