Question About Game Crash
Zephirius
Member Posts: 419
The game only started crashing after writing this heartbeat script. Two NPC's are attacking one another whilst spouting obscenities -
I don't know why the game crashes to the desktop when this or these scripts runs?
Second hearbeat script -
void main()
{
int nDie = d20();
if (nDie >= 10)
{
switch (d3())
{
case 1: AssignCommand(OBJECT_SELF, SpeakString("I'll bleed you dry Crevek!")); break;
case 2: AssignCommand(OBJECT_SELF, SpeakString("I'll feed your body to the shadows...!")); break;
case 3: AssignCommand(OBJECT_SELF, SpeakString("Feel the cold steel of my knife...!")); break;
}
}
}
I don't know why the game crashes to the desktop when this or these scripts runs?
Second hearbeat script -
int nDie = d20();
if (nDie >= 10)
{
switch (d3())
{
case 1: AssignCommand(OBJECT_SELF, SpeakString("Your life belongs to me now!")); break;
case 2: AssignCommand(OBJECT_SELF, SpeakString("I'll crush your skull to dust...!")); break;
case 3: AssignCommand(OBJECT_SELF, SpeakString("May the dead feast on your soul!")); break;
}
}
}
0
Comments
Looking at your code, nothing jumps out as being wrong or liable to cause a crash. Personally I would change 1 little part of it but that is just a personal thing. I would change -
int nDie = d20(); if (nDie >= 10)to -int nDie = d2() - 1; if (nDie)which if d2() (i.e. a 2 sided die) works as I think it should means that nDie will either equate to TRUE (1) or FALSE (0).
TR
I have instances of these working on my NPCs.
This may not apply to this situation but I use a GetIsInCombat() check and GetDistanceBetween(oNPC,oPlayer) < 10.0 or something so the NPCs don't spout off their lines when they shouldn't or when there isn't a player close enough to notice any of it.
I just tested this and unless I am missing something, d3() cases are 1, 2 or 3 and Random(3) cases are 0,1 or 2.
I use a lot of d(3) for my random property items so I wanted to make sure I didn't have to go back and change all of them.