Apparition de monstre

Répondre
Partager Rechercher
Comment pui je faire pour que ce script ne se réalise qu'une seul fois ?

Code PHP:

//::///////////////////////////////////////////////
//:: NW_O2_SKELETON.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Turns the placeable into a skeleton
   if a player comes near enough.
*/
//:://////////////////////////////////////////////
//:: Created By:   Brent
//:: Created On:   January 17, 2002
//:://////////////////////////////////////////////
void ActionCreate(string sCreaturelocation lLoc)
{
    
CreateObject(OBJECT_TYPE_CREATUREsCreaturelLoc);
}
void main()
{
   
object oCreature GetNearestCreature(CREATURE_TYPE_PLAYER_CHARPLAYER_CHAR_IS_PC);
   if (
GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
   {
    
effect eMind EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
    
string sCreature "Grifferampante";
    
location lLoc GetLocation(OBJECT_SELF);
    
DelayCommand(0.3ActionCreate(sCreaturelLoc));
    
ApplyEffectAtLocation(DURATION_TYPE_INSTANTeMindGetLocation(OBJECT_SELF));
    
SetPlotFlag(OBJECT_SELFFALSE);

   }

c'est plutôt simple... tu le met dans le heartbeat du placeable et tu ajoute un destroyobjet du placeable comme ça le script de fera plus effet...

J'espère que ça répond à ta question.
__________________
Florynth ... bientôt un monde sera miens...
Vi je suppose que c'est la meilleur solution

Code PHP:

void ActionCreate(string sCreaturelocation lLoc)
{
    
CreateObject(OBJECT_TYPE_CREATUREsCreaturelLoc);
}
void main()
{
   
object oCreature GetNearestCreature(CREATURE_TYPE_PLAYER_CHARPLAYER_CHAR_IS_PC);
   if (
GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
   {
    
effect eMind EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
    
string sCreature "Grifferampante";
    
location lLoc GetLocation(OBJECT_SELF);
    
DelayCommand(0.3ActionCreate(sCreaturelLoc));
    
ApplyEffectAtLocation(DURATION_TYPE_INSTANTeMindGetLocation(OBJECT_SELF));
    
SetPlotFlag(OBJECT_SELFFALSE);
    
   
DestroyObject(OBJECT_SELF);
   }

C'est peut être un peu bourrin un DestroyObject sur lui même, mais ca devrait marcher
Je dirais même que c'est bien pensé
Par contre Bioware ne semble pô du même avis, ils ont mis un EffectDamage puis commenté le DestroyObject. Je voie vraiment pô pourkoi ils ont fait ça, le Destroy me parait bien

Code PHP:

//::///////////////////////////////////////////////
//:: NW_O2_GARGOYLE.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Turns the placeable into a gargoyle
   if a player comes near enough.
*/
//:://////////////////////////////////////////////
//:: Created By:   Brent
//:: Created On:   January 17, 2002
//:://////////////////////////////////////////////

void CreateGargoyle(object oPC)
{
    
object oGargoyle CreateObject(OBJECT_TYPE_CREATURE"NW_GARGOYLE"GetLocation(OBJECT_SELF));
    
DelayCommand(0.1AssignCommand(oGargoyleActionAttack(oPC)));
}

void main()
{
   
object oCreature GetNearestCreature(CREATURE_TYPE_PLAYER_CHARPLAYER_CHAR_IS_PC);
   if (
GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 7.0)
   {
    
//effect eMind = EffectVisualEffect(VFX_IMP_HOLY_AID);
    
DelayCommand(0.1CreateGargoyle(oCreature));
    
//ApplyEffectToObject(DURATION_TYPE_INSTANT, eMind, oGargoyle);
    
effect eDam EffectDamage(500);
    
SetPlotFlag(OBJECT_SELFFALSE);
    
ApplyEffectToObject(DURATION_TYPE_INSTANTeDamOBJECT_SELF);
   
//DestroyObject(OBJECT_SELF, 0.5);
   
}

si tu fais ça:
Code:
    DelayCommand(0.3, ActionCreate(sCreature, lLoc));

    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eMind, GetLocation(OBJECT_SELF));

    SetPlotFlag(OBJECT_SELF, FALSE);

    

   DestroyObject(OBJECT_SELF);
Il faut faire un AssignCommand, par ce que là tu détruis OBJECT_SELF avant qu'il n'aie l'occasion d'exécuter ActionCreate.

Quelque chose du genre:
Code:
AssignCommand(GetModule(),  DelayCommand(0.3, ActionCreate(sCreature, lLoc)));
PS quand on fait ce genre de AssignCommand/DelayCommand il est fortement conseillé de chercher à limiter le nombre de variables dans la portée desquelles l'appel ce fait.
lol ^^

bon, alors une petite variable locale suffira

Code PHP:

//::///////////////////////////////////////////////
//:: NW_O2_SKELETON.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Turns the placeable into a skeleton
   if a player comes near enough.
*/
//:://////////////////////////////////////////////
//:: Created By:   Brent
//:: Created On:   January 17, 2002
//:://////////////////////////////////////////////
void ActionCreate(string sCreaturelocation lLoc)
{
    
CreateObject(OBJECT_TYPE_CREATUREsCreaturelLoc);
}
void main()
{
    if(!
GetLocalInt(OBJECT_SELF"Created"))
    {
        
object oCreature GetNearestCreature(CREATURE_TYPE_PLAYER_CHARPLAYER_CHAR_IS_PC);
       if (
GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
       {
        
effect eMind EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
         
string sCreature "Grifferampante";
        
location lLoc GetLocation(OBJECT_SELF);
        
DelayCommand(0.3ActionCreate(sCreaturelLoc));
        
ApplyEffectAtLocation(DURATION_TYPE_INSTANTeMindGetLocation(OBJECT_SELF));
        
SetPlotFlag(OBJECT_SELFFALSE);
        
SetLocalInt(OBJECT_SELF"Created"TRUE);
       }
   }

bon ben la ça change tout... c'est pas ben ben plus compliqué
Code PHP:

//::///////////////////////////////////////////////
//:: NW_O2_SKELETON.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Turns the placeable into a skeleton
   if a player comes near enough.
*/
//:://////////////////////////////////////////////
//:: Created By:   Brent
//:: Created On:   January 17, 2002
//:://////////////////////////////////////////////
void ActionCreate(string sCreaturelocation lLoc)
{
    
CreateObject(OBJECT_TYPE_CREATUREsCreaturelLoc);
}
void main()
{
   
//Voici la premiere ligne a ajouté...
   
int dejaExecGetLocalInt(OBJECT_SELF,"dejaExec");
   
//Ou en accès BD (je te mets le code en commentaire)
  //int dejaExec = GetCampaignInt("NOM_CAMPAGNE","dejaExecObjetTransform");
/*la faut dire qu'avec le campaignInt (dans ce code si) tu peux pas utilisé ça pour plusieurs placeable qui utilise ce script car il vont tout accédé à la même variable*/
if(dejaExec == 0){
object oCreature GetNearestCreature(CREATURE_TYPE_PLAYER_CHARPLAYER_CHAR_IS_PC);
   if (
GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
   {
    
effect eMind EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
    
string sCreature "Grifferampante";
    
location lLoc GetLocation(OBJECT_SELF);
    
DelayCommand(0.3ActionCreate(sCreaturelLoc));
    
ApplyEffectAtLocation(DURATION_TYPE_INSTANTeMindGetLocation(OBJECT_SELF));
    
SetPlotFlag(OBJECT_SELFFALSE);
//Voici la deuxième ligne à ajouter
SetLocalInt(OBJECT_SELF,"dejaExec",1);
   
//Ou en accès BD 
  //SetCampaignInt("NOM_CAMPAGNE","dejaExecObjetTransform",1);

   
}
}

Une autre chose que tu pourrais faire mais la il y a juste toi pour savoir si ça pourrait marché c'est de faire le test avec ceci
Code PHP:

if(GetPlotFlag() == 1)
{
  
// ton code

comme tu fait SetPlotFlag(OBJECT_SELF, FALSE) je présume que avant il était a TRUE...

Ou encore... (ben oui il y plein de possibilité) je pense que c'est des meilleurs idée car ça utilise le destroyobject() (ça permet de libérer le processeur car je présume que tu met ton code dans le onHeartBeat()...) tu créé deux objet un qui est la par parrure (que tu veux pas détruire) et l'autre qui est invisible qui exécute ton code lui tu pourras faire un destroyobject dessu(de la façon la plus efficace cité plus haut)

Bon c'est sur qu'il reste probablement 1258 autres façon de faire met pourquoi pensé à de mauvaise façon de faire
__________________
Florynth ... bientôt un monde sera miens...
C'est toujours le fun d'écrire un message pendant que l'autre répond exactement de la même façon (ou presque)

en passant sert toi du script de Azrael je n'était pas sur si tu pouvait faire un if direct avec le GetLocalInt(...) car il n'y a pas de variable booléen mais ça dégorge un peu le code comme ça...
__________________
Florynth ... bientôt un monde sera miens...
Citation :
je n'était pas sur si tu pouvait faire un if direct avec le GetLocalInt(...) car il n'y a pas de variable booléen
Peux tu développer un peu, j'ai pas vraiment compris ton raisonnement ?
une condition marche toujours de facon booléene, ce n'est pas possible autrement.

Quand on fait une opération du style
int bRep = (sString == "bouh!");

bRep va prendre pour valeur 1 si sString est "bouh!", et 0 dans les autres cas.

au final dans une condition, on arrive inévitablement à une opération booléenne
Oui je sais, je sais pas si tu fais de la programmation autre que dans NWN (je présume que oui car tu donnes de bon script) mais dans certains langage le 1 n'est pas nécessairement considéré comme un true... il faut absolument faire un test. Je sais que le nwnscript est basé sur du C mais disons que ça fait longtemps que j'en ai pas fait (mise à part ici)

Je sais pas si c'est plus claire...
__________________
Florynth ... bientôt un monde sera miens...
Pas très compliqué tu met une boucle for...
Code PHP:

//::///////////////////////////////////////////////
//:: NW_O2_SKELETON.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Turns the placeable into a skeleton
   if a player comes near enough.
*/
//:://////////////////////////////////////////////
//:: Created By:   Brent
//:: Created On:   January 17, 2002
//:://////////////////////////////////////////////
void ActionCreate(string sCreaturelocation lLoc)
{
    
CreateObject(OBJECT_TYPE_CREATUREsCreaturelLoc);
}
void main()
{
    
int nbrMonstre 1;// Le nombre de monstre que tu veux...
    
int i;
    if(!
GetLocalInt(OBJECT_SELF"Created"))
    {
        
object oCreature GetNearestCreature(CREATURE_TYPE_PLAYER_CHARPLAYER_CHAR_IS_PC);
       if (
GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
       {
        
effect eMind EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
         
string sCreature "Grifferampante";
        
location lLoc GetLocation(OBJECT_SELF);
        for(
nbrMonstre i++)//La boucle for
{
        
DelayCommand(0.3ActionCreate(sCreaturelLoc));
        
ApplyEffectAtLocation(DURATION_TYPE_INSTANTeMindGetLocation(OBJECT_SELF));
}
        
SetPlotFlag(OBJECT_SELFFALSE);
        
SetLocalInt(OBJECT_SELF"Created"TRUE);
       }
   }

__________________
Florynth ... bientôt un monde sera miens...
Répondre

Connectés sur ce fil

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