Bienvenue sur JeuxOnLine - MMO, MMORPG et MOBA !
Les sites de JeuxOnLine...
 

Panneau de contrôle

Recherche | Retour aux forums

JOL Archives

Animation : "Ronde"

Par Le Hamster le 24/8/2002 à 9:56:30 (#2017539)

Bonjour, un long post pour une petite question.

J'ai trouvé quelque part, euh, je sais plus où, pardon pardon cher auteur de cette jolie chose, un petit module pour animer une ville.

Il y a là un capitaine avec 4 gardes. La seule chose un tout petit peu génante est que le capitaine ne peut s'empècher d'énoncer le prochain waypoint. Peut-être peut-on améliorer cela, en clair le but est que le capitaine ne dise que "Marche" et pas "Marche WP_garde1_0x".

Voici le script.

Encore une fois, pardon de n'avoir pas retrouvé l'auteur, s'il est parmi vous.

Le script :


void MoveTagsToFormationPoint(object where, float xOffset, float yOffset, string sTag, int index)
{
vector mypos = GetPosition(where);
float fFacing = GetFacingFromLocation(GetLocation(OBJECT_SELF));
float xp = pow(xOffset, 2.0);
float yp = pow(yOffset, 2.0);
float angleOffset = 90.0f + acos(xOffset / (sqrt(xp + yp)));
float distance = sqrt(xp + yp);
object leGarde = GetObjectByTag(sTag, index);
float dx = distance * cos(fFacing - angleOffset);
float dy = distance * sin(fFacing - angleOffset);
vector gVector = Vector(mypos.x + dx, mypos.y + dy, 0.0f);
location dest = Location(GetArea(OBJECT_SELF), gVector, fFacing);
AssignCommand(leGarde, ActionMoveToLocation(dest));
DelayCommand(1.0, AssignCommand(leGarde, ActionMoveToLocation(dest)));
DelayCommand(1.0, AssignCommand(leGarde, ActionMoveToLocation(dest)));
DelayCommand(1.0, AssignCommand(leGarde, ActionMoveToLocation(dest)));
DelayCommand(1.0, AssignCommand(leGarde, ActionMoveToLocation(dest)));
DelayCommand(5.0, AssignCommand(leGarde, ActionDoCommand(SetFacing(fFacing))));
}

void main()
{
int nUser = GetUserDefinedEventNumber();
if(nUser == 1001) //HEARTBEAT
{
if (GetCurrentAction() == ACTION_MOVETOPOINT) { // busy, let 'em walk
return;
}
int nState = GetLocalInt(OBJECT_SELF, "grouped");
SetLocalInt(OBJECT_SELF, "grouped", nState + 1);
switch (nState)
{
case 0 : { // regroup
SpeakString("Alignez-vous ! ");
int nth = GetLocalInt(OBJECT_SELF, "wp_x"); // Next waypoint
object next_wp = GetObjectByTag("wp_garde1_" + IntToString(nth));
if (!GetIsObjectValid(next_wp)) {
SetLocalInt(OBJECT_SELF, "wp_x", 1);
next_wp = GetObjectByTag("wp_garde1_0");
SendMessageToPC(GetFirstPC(), "WP not found "+GetTag(next_wp));
} else {
SetLocalInt(OBJECT_SELF, "wp_x", nth + 1);
SendMessageToPC(GetFirstPC(), "Found WP "+GetTag(next_wp));
}
SetLocalObject(OBJECT_SELF, "current_wp", next_wp);
SetFacingPoint(GetPosition(next_wp));
MoveTagsToFormationPoint(OBJECT_SELF, -1.5f, -2.0f, "garde1", 0);
MoveTagsToFormationPoint(OBJECT_SELF, 1.5f, -2.0f, "garde1", 1);
MoveTagsToFormationPoint(OBJECT_SELF, -2.5f, -4.5f, "garde1", 2);
MoveTagsToFormationPoint(OBJECT_SELF, 2.5f, -4.5f, "garde1", 3);
break ;
}
case 1 : {
break;
}
case 2 : { // move
object next_wp = GetLocalObject(OBJECT_SELF, "current_wp");
SpeakString("Marche ! " +GetTag(next_wp));
ActionMoveToObject(next_wp);
MoveTagsToFormationPoint(next_wp, -1.5f, -2.0f, "garde1", 0);
MoveTagsToFormationPoint(next_wp, 1.5f, -2.0f, "garde1", 1);
MoveTagsToFormationPoint(next_wp, -2.5f, -4.5f, "garde1", 2);
MoveTagsToFormationPoint(next_wp, 2.5f, -4.5f, "garde1", 3);
break;
}
case 3 : {
SetLocalInt(OBJECT_SELF, "grouped", 0);
break;
}
}
}
}


Bises à toutes et à tous

simple

Par Jedaï le 24/8/2002 à 10:37:40 (#2017630)

Tu as, environ 15 lignes avant la fin une commande :

SpeakString("Marche !"+GetTag(next_wp));

Tu n'as qu'a effacer <> (juste ça, pas un signe de plus ou de moins)

JOL Archives 1.0.1
@ JOL / JeuxOnLine