[Beginner] Respawn aléatoire de créature

Répondre
Partager Rechercher
Bonjour,
Bon et bien mon probleme actuel est que j'aimerai faire un respawn aléatoire de differentes créatures dans une zone.
Je vous expose mon script (que je place dans le OnDeath d'une créa X de la zone):

Code PHP:

void main()
{
int nRandom Random(10);
string sRandom IntToString (nRandom+1);
object oWP GetNearestObjectByTag("respawn"+sRandom);
object oCrea = (OBJECT_SELF);
string sCrea GetResRef (oCrea);
location lWP GetLocation (oWP);
CreateObject (OBJECT_TYPE_CREATURE,sCrea,lWP);


Mais je ne comprend pas pourquoi la creature ne se crée pas...
Enfin si j'ai bien compris la fonction CreateObject il faut utiliser le resref d'une créa, non ?

Enfin je ne suis pas super fort en édition de script mais j'essaie de me débrouiller sans trop utiliser les forums, etc...
Elle ne se crée pas parce que sur le OnDeath d'une créature, tu ne peux rien créer. Sinon, le script est tout bon, tu peux récupérer son Resref, son tag, sa position, etc, mais pas créer. C'est simplement un mauvais choix d'évènement.
Tu peux créer ta propre fonction et l'assigner au module plutôt qu'à la créature morte, comme ceci:

Code PHP:

//Juste un exemple de structure
//
AssignCommand(GetModule(), DelayCommand(fDelayFonctionRespawnObject(Arguments)));
//
// 
Citation :
Publié par Nek
Tu peux créer ta propre fonction et l'assigner au module plutôt qu'à la créature morte, comme ceci:

Code PHP:

//Juste un exemple de structure
//
AssignCommand(GetModule(), DelayCommand(fDelayFonctionRespawnObject(Arguments)));
//
// 
Euh, je ne comprend pas vraiment à quoi cette fonction sert... Enfin si je comprend, avec cette fonction toute les créatures du module, lorsqu'elles vont mourir, vont appliquer ce script et respawn sur un des WP ?


J'édite et je pose une question en supplément toujours sur un spawn :

J'ai pris ce script sur le module de démonstration Kobold vs Goblin mais il ne fonctionne pas vraiment.

Code PHP:


void main
()
{
    
int iUD GetUserDefinedEventNumber();
    
int iRandom Random(6)+1;
    
int iRandom1 Random(6)+1;
    
string sRandom IntToString(iRandom);
    
string sRandom1 IntToString(iRandom1);
    
object oCreaSpawn1 GetNearestObjectByTag("cite1");
    
location lSpawn1 GetLocation(oCreaSpawn1);
    
object oCreaSpawn2 GetNearestObjectByTag("cite2");
    
location lSpawn2 GetLocation(oCreaSpawn2);

    if (
iUD == 1007)
    {
        
CreateObject(OBJECT_TYPE_CREATURE"kobold00"+sRandomlSpawn1);
        
CreateObject(OBJECT_TYPE_CREATURE"squelette00"+sRandom1lSpawn2);
    }

Mais bon on va dire que je ne comprend pas vraiment la fonction "GetUserDefinedEventNumber()" sinon le reste c'est pas trop compliqué.
Car en fait dans ma ville je simule une attaque, donc il y a plusieurs lieu de spawn (comme le script demandé plus haut) dont 2 qui "devraient" faire spawn des squelettes ou des kobolds... Mais lorsque je teste, rien ne se passe.Donc si jamais quelqu'un peut m'expliquer comment marche cette fonction et à quoi elle sert ici, en quelques lignes ^^
Merci

Mimi
Code PHP:

//La fonction
void FonctionRespawnObject(string sResRefint nTypelocation lLocfloat fFacingstring sNewTag)
{
 
object oRespawn CreateObject(nTypesResReflLoc);
 
object oNew CopyObject(oRespawnlLocOBJECT_INVALIDsNewTag);
 
DestroyObject(oRespawn);
 
AssignCommand(oNewActionDoCommand(SetFacing(fFacing)));
}

//La ligne de code à appeler dans le nw_c2_default7 (ondeath)
AssignCommand(GetModule(), DelayCommand(fDelayFonctionRespawnObject(sResRefnTypelLocfFacingsNewTag))); 
Fonction générique que tu peux mettre dans une boucle afin d'assigner comme valeur à lLoc les différentes locations de tes WP.


Mais... tu sais... les rencontres Bioware font exactement ce que tu as envie de faire
Pourquoi ne les utilises-tu pas ?

Citation :
GetUserDefinedEventNumber()
Le code que tu as recopié doit être placé dans l'event OnUserDefined et pas dans le OnDeath. Il y fait appel à l'event 1007, qui est le OnDeath.

Je t'invite à lire la tutorial fourni par Bioware à ce sujet http://nwn.bioware.com/builders/sctutorial6.html/
Sinon toujours un probléme de spawn... (Je ne comprend toujours pas pourquoi)
Pour simplifier la chose je me suis dis que plutot que d'utiliser une fonction qui fait que ca invoque une bestiole à chaque mort, je vais faire apparaitre des bestioles en continue ca fera moins effet de chaine mais c'est pas grave.
Dans le OnHeartBeat de la zone, j'ai placé ceci:


Code PHP:


void main
()
{

object oWP1GetWaypointByTag ("cite1");
object oWP2GetWaypointByTag ("cite2");
int nRandom1 Random(6)+1;
int nRandom2 Random (6)+1;

string sRandom1 IntToString (nRandom1);
string sRandom2 IntToString (nRandom2);

int nRandom4 Random(6)+1;
int nRandom5 Random (6)+1;

string sRandom4 IntToString (nRandom4);
string sRandom5 IntToString (nRandom5);


location lWP1 GetLocation (oWP1);
location lWP2 GetLocation (oWP2);
CreateObject OBJECT_TYPE_CREATURE"kobold00"+sRandom1,lWP1 );
CreateObject OBJECT_TYPE_CREATURE"squelette00"+sRandom2,lWP2 );

CreateObject OBJECT_TYPE_CREATURE"kobold00"+sRandom4,lWP2 );
CreateObject OBJECT_TYPE_CREATURE"squelette00"+sRandom5,lWP1 );





J'ai bien mes 7 kobolds differents avec les ResRef "Kobold001 / 002 / 003 / .... / 007 "
et mes squelette idem

Mais même en OnHeartBeat ca ne fonctionne pas...
Code PHP:

 void main()
 {
 
 
object oWP1GetWaypointByTag ("cite1");
 
object oWP2GetWaypointByTag ("cite2");
 
int nRandom1 Random(6)+1;
 
int nRandom2 Random (6)+1;
 
 
string sRandom1 IntToString (nRandom1);
 
string sRandom2 IntToString (nRandom2);
 
 
int nRandom4 Random(6)+1;
 
int nRandom5 Random (6)+1;
 
 
string sRandom4 IntToString (nRandom4);
 
string sRandom5 IntToString (nRandom5);
 
 
 
location lWP1 GetLocation (oWP1);
 
location lWP2 GetLocation (oWP2);
 
string sKob1 "kobold00" sRandom1;
 
string sSquel1"squelette00" sRandom2;
 
string sKob2 "kobold00" sRandom4;
 
string sSquel2"squelette00" sRandom5;
 
 
CreateObject OBJECT_TYPE_CREATUREsKob1,lWP1 );
 
CreateObject OBJECT_TYPE_CREATUREsSquel1,lWP2 );
 
 
CreateObject OBJECT_TYPE_CREATUREsKob2,lWP2 );
 
CreateObject OBJECT_TYPE_CREATUREsSquel2,lWP1 );
 } 
Et comme ça, ça marche ou pas ?
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés