Bonjour à tous !
Voila je suis en train de scripter un petit jeu de cache cache pour animer les enfants d'un village. Seul hic le "chasseur" ne voit pas sa "proie". Ma question est la suivante : est-ce que l'événement onperveive fonctionne entre NPC ?
Je ne peux pas vous mettre le code, je suis au boulot ... mais dés que j'ai cinq minutes j'éditerais ce post. Grosso modo :
//dans le onUserDefined
void main()
{
int nPlayerNumber = 5;
switch(GetUserDefinedEventNumber())
{
case 1001: // Appele par OnHeartbeat
{
object oSelf = OBJECT_SELF;
object oStake = GetObjectByTag("MH_STAKE");
object oHidingPlace;
int nHunter = GetLocalInt(oSelf, "MH_Hunter");
int nCatched = GetLocalInt(oSelf, "MH_Catched");
int nStep = GetLocalInt(oSelf, "MH_Step");
int i = GetLocalInt(oSelf, "MH_NbCachette");
oHidingPlace = GetObjectByTag("MH_HIDINGPLACE", i );
// Debug
AssignCommand (OBJECT_SELF,
SpeakString("DEBUG "+" Step: "+IntToString(nStep)+
" i: "+IntToString(i)+
" tag : "+GetTag(GetLastPerceived())+
" name : "+GetName(GetLastPerceived())+
" catched : "+ IntToString(nCatched)
,
TALKVOLUME_SHOUT));
// Fin debug
switch(nStep)
{
case 0: // Etape d'initialisation: tout le monde au piquet
{
if (GetDistanceToObject(oStake) > 1.0f && nHunter==1)
{
AssignCommand (OBJECT_SELF, ActionMoveToObject(oStake,TRUE,1.0));
}
if (GetDistanceToObject(oStake) < 2.0f && nHunter==1)
{
AssignCommand (OBJECT_SELF, ActionSpeakString("Un...", TALKVOLUME_SHOUT));
DelayCommand (0.5, ActionSpeakString("Deux...", TALKVOLUME_SHOUT));
DelayCommand (1.0, ActionSpeakString("Trois...", TALKVOLUME_SHOUT));
DelayCommand (1.5, ActionSpeakString("Quatre...", TALKVOLUME_SHOUT));
DelayCommand (2.0, ActionSpeakString("Cinq...", TALKVOLUME_SHOUT));
DelayCommand (2.5, ActionSpeakString("Six...", TALKVOLUME_SHOUT));
DelayCommand (3.0, ActionSpeakString("Sept...", TALKVOLUME_SHOUT));
DelayCommand (3.5, ActionSpeakString("Huit...", TALKVOLUME_SHOUT));
DelayCommand (4.0, ActionSpeakString("Neuf...", TALKVOLUME_SHOUT));
DelayCommand (4.5, ActionSpeakString("Et dix !", TALKVOLUME_SHOUT));
nStep = 1;
SetLocalInt (OBJECT_SELF, "MH_Step", nStep);
}
break;
}
case 1: // Etape 1 : l'un compte pendant que les autres se cachent
{
if ( GetLocalInt(OBJECT_SELF, "MH_EnCours")==FALSE)
{
AssignCommand (OBJECT_SELF, ActionMoveToObject (oHidingPlace, TRUE, 1.0f));
SetLocalInt(oSelf, "MH_EnCours", TRUE);
}
if ( GetLocalInt(OBJECT_SELF, "MH_EnCours")==TRUE && GetDistanceToObject(oHidingPlace) < 2.0f )
{
AssignCommand (OBJECT_SELF, ActionRandomWalk());
AssignCommand (OBJECT_SELF, ActionSpeakString("Mais ou sont ils ?", TALKVOLUME_SHOUT));
SetLocalInt(oSelf, "MH_EnCours", FALSE);
SetLocalInt(oSelf, "MH_NbCachette", ++i);
}
break;
}// fin case 1
} // fin switch
break;
}// fin du case 1001
case 1002: // Appel par OnPerception
{
object oStake = GetObjectByTag("MH_STAKE");
if ( (GetLocalInt(OBJECT_SELF,"MH_Step")==1) && (GetLocalInt(OBJECT_SELF,"MH_Hunter")==1) )
{
object oNoticed = GetLastPerceived();
if ( GetLastPerceptionSeen() && GetIsObjectValid(oNoticed) && GetTag(oNoticed)=="MH_PLAYER")
{
//ClearAllActions();
int nCatched = GetLocalInt(OBJECT_SELF, "MH_catched")+1;
SetLocalInt(oNoticed, "MH_Catched", nCatched);
SetLocalInt (OBJECT_SELF, "MH_Catched", nCatched);
string sNoticed = GetName (oNoticed);
AssignCommand(OBJECT_SELF, SpeakString("Vu ! Je t'ai trouve"+sNoticed+" !", TALKVOLUME_SHOUT));
AssignCommand(oNoticed, ActionMoveToObject(oStake,TRUE,1.0) );
if (nCatched == (nPlayerNumber-1))
SetLocalInt (OBJECT_SELF, "MH_Step", 0);
}
}
break;
J'édite pour faire remonter le message... Si vous avez besoin de plus d'infos n'hésitez pas