I wrote the script below to play a random animation on heartbeat for an npc.
It sort of works but the randomness does not. It only plays case 2 "tired" can anyone see what I have done wrong.
Cheers,
PJ
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;
int iRand = Random (3);
{switch (iRand)
{
case 0:
PlayCustomAnimation (OBJECT_SELF, "getlow",1,6.0);
break;
case 1:
PlayCustomAnimation (OBJECT_SELF, "standidle",1,6.0);
break;
case 2:
PlayCustomAnimation (OBJECT_SELF, "tired",1,6.0);
break;
}
}
}
Random selection in script question.
Débuté par
PJ156
, nov. 16 2012 06:32
#1
Posté 16 novembre 2012 - 06:32
#2
Posté 16 novembre 2012 - 11:31
I think you have to knock him out of the loop
before moving onto the next one,
ref: How Do You Stop A Looping Animation?
PlayCustomAnimation(OBJECT_SELF, "%", 0);
before moving onto the next one,
ref: How Do You Stop A Looping Animation?
#3
Posté 18 novembre 2012 - 12:24
That curly brace before your "switch" statement is making me uncomfortable. I don't like it, I don't like it one bit! Get rid of it, throw it in the garbage, and let us never speak of it again! And its matching one at the end, too!
But seriously, you're not bracketing anything there. Keep the one after the switch and the matching one below. I don't know if this would make any difference, but it's good practice to get rid of anything unnecessary when you're debugging.
But seriously, you're not bracketing anything there. Keep the one after the switch and the matching one below. I don't know if this would make any difference, but it's good practice to get rid of anything unnecessary when you're debugging.
#4
Posté 18 novembre 2012 - 07:41
yeah i can't see anything that would specificly break the code, but the curly braces before and at the end of the switch() block are unnecessary. So is the object oPC def'n -- lose it unless it's needed ;|
MC, ya got me playing around:
I was getting a reasonably bored guard, so bored he kept sticking himself in the neck on the "bored" animation ... with these timings
( note: fSpeed doesn't seem to work in this implementation )
link to Pastebin
btw PJ, i think you misunderstood the meaning of the last two parameters of PlayCustomAnimation() - not sure tho; also the animation labels were incorrect, it seems.
MC, ya got me playing around:
I was getting a reasonably bored guard, so bored he kept sticking himself in the neck on the "bored" animation ... with these timings
( note: fSpeed doesn't seem to work in this implementation )
link to Pastebin
btw PJ, i think you misunderstood the meaning of the last two parameters of PlayCustomAnimation() - not sure tho; also the animation labels were incorrect, it seems.
#5
Posté 18 novembre 2012 - 11:02
Thanks KevL that does the trick. I can see where I was going wrong too.
I did have an animation label incorrect, I looked up the animation 2da and got the right ones after I posted.
I need to look at playCustomAnimation again
PJ
I did have an animation label incorrect, I looked up the animation 2da and got the right ones after I posted.
I need to look at playCustomAnimation again
PJ





Retour en haut






