La Bibliothèque de Neverwinter Nights
Aide et informations diverses sur Neverwinter Nights ainsi que D&D3.
La date/heure actuelle est 30/04/2025 17:22:12


  Page 1 sur 1 ¤

Voir le sujet précédent ¤ Voir le sujet suivant 
Auteur Message
Noon
Héros
Inscrit le: 15 Jan 2005
Messages: 272
Localisation: Entre Vannes et les RO
Répondre en citant
Posté le : 16/02/2006 17:57:04 Sujet du message : [Question] Pourquoi ce script me fait planter

Bonjour, j'ai un script de contingence qui marche très bien à placer dans le onPerception des PNJ. J'ai essayer de le lancer par le OnUserDefined et là, dès que le PNJ me "perçoit", mon jeu plante et je dois faire un retour sauvage sous windows et fermer nwn. Je me contente donc du onPerception mais j'aimerais savoir si ça vient du script ou de mon PC qui est un peu faiblard (ou du script qui demande trop de ressources mais ça m'étonnerait).

Voilà ce que j'ai mis dans le OnUserDefined :

NWScript :
//:Confused///////////////////////// /////////////////////
//:: Name x2_def_userdef
//:: Copyright (c) 2001 Bioware Corp.
//:Confused///////////////////////// ////////////////////
/*
    Default On User Defined Event script
*/

//:Confused///////////////////////// ////////////////////
//:: Created By: Keith Warner
//:: Created On: June 11/03
//:Confused///////////////////////// ////////////////////

const int EVENT_USER_DEFINED_PRESPAWN = 1510;
const int EVENT_USER_DEFINED_POSTSPAWN = 1511;
void main()
{
    object oPC;
    oPC = GetLastPerceived();
    int nUser = GetUserDefinedEventNumber();

    if(nUser == EVENT_HEARTBEAT ) //HEARTBEAT
    {

    }
    else if(nUser == EVENT_PERCEIVE) // PERCEIVE
    {
    if (!GetIsPC(oPC)) return;
    ExecuteScript("contingence", OBJECT_SELF);
    }
    else if(nUser == EVENT_END_COMBAT_ROUND) // END OF COMBAT
    {

    }
    else if(nUser == EVENT_DIALOGUE) // ON DIALOGUE
    {

    }
    else if(nUser == EVENT_ATTACKED) // ATTACKED
    {

    }
    else if(nUser == EVENT_DAMAGED) // DAMAGED
    {

    }
    else if(nUser == 1007) // DEATH  - do not use for critical code, does not fire reliably all the time
    {

    }
    else if(nUser == EVENT_DISTURBED) // DISTURBED
    {

    }
    else if (nUser == EVENT_USER_DEFINED_PRESPAWN)
    {

    }
    else if (nUser == EVENT_USER_DEFINED_POSTSPAWN)
    {

    }


}
Note : le code affiché ci-dessus n'est pas rendu tel qu'il devrait l'être réellement, en particulier des sauts de lignes sont automatiquement insérés pour éviter de casser la mise en page. En le copiant/collant, vous résoudrez ce problème.



Et dans le onSpawn j'ai modifié le script par défaut ainsi :

NWScript :
These user-defined events are in the range 1001-1007.
    */

    // * Fire User Defined Event 1001 in the OnHeartbeat
    // *
    // SetSpawnInCondition(NW_FLAG_HE ARTBEAT_EVENT);

    // * Fire User Defined Event 1002
    // *
    SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT);

    // * Fire User Defined Event 1005
    // *
    // SetSpawnInCondition(NW_FLAG_AT TACK_EVENT);
Note : le code affiché ci-dessus n'est pas rendu tel qu'il devrait l'être réellement, en particulier des sauts de lignes sont automatiquement insérés pour éviter de casser la mise en page. En le copiant/collant, vous résoudrez ce problème.


(Bien sûr j'ai renommé différemment).

Voilà, je n'ai rien utilisé de compliquer et ça compile bien alors je pense que c'est mon PC mais on ne sait jamais.
_________________
Beshaba me protège, Tymora guide mes tirs.

The Cake is a lie !

Mes modules NwN2:De Vieilles Rencontres! et De Vieilles Rencontres2
Double Avenir sur le Nwvault
 
Revenir en haut Voir le profil de l'utilisateur Envoyer un message privé Ignorer l'utilisateur
 
Sith Vicious
Grand Sage du Conseil
Inscrit le: 19 Oct 2005
Messages: 693
Répondre en citant
Posté le : 16/02/2006 18:00:43 Sujet du message :

et ton script contigence c'est quoi ?
 
Revenir en haut Voir le profil de l'utilisateur Envoyer un message privé Ignorer l'utilisateur
 
Noon
Héros
Inscrit le: 15 Jan 2005
Messages: 272
Localisation: Entre Vannes et les RO
Répondre en citant
Posté le : 16/02/2006 19:26:08 Sujet du message :

Il est assez long, j'ai pas envie de le mettre. Je l'ai chopé sur le Vault. Mais il marche bien.
_________________
Beshaba me protège, Tymora guide mes tirs.

The Cake is a lie !

Mes modules NwN2:De Vieilles Rencontres! et De Vieilles Rencontres2
Double Avenir sur le Nwvault
 
Revenir en haut Voir le profil de l'utilisateur Envoyer un message privé Ignorer l'utilisateur
 
Sith Vicious
Grand Sage du Conseil
Inscrit le: 19 Oct 2005
Messages: 693
Répondre en citant
Posté le : 16/02/2006 21:30:36 Sujet du message :

Ben ouais mais du coup ça va être un peu dur de t'aider Very Happy

Vérifie quand même que dedans il ne signale pas un EVENT_PERCEIVE, on sait jamais...
 
Revenir en haut Voir le profil de l'utilisateur Envoyer un message privé Ignorer l'utilisateur
 
Noon
Héros
Inscrit le: 15 Jan 2005
Messages: 272
Localisation: Entre Vannes et les RO
Répondre en citant
Posté le : 17/02/2006 16:35:01 Sujet du message :

Bon bah je vais le mettre alors, parce que je crois qu'il contient un script onPerception par défaut.

NWScript :
//:Confused//////////////////////////////////////////////
//:: Pseudo Contingency Script!!!!
//:: Used to buff up those mages a bit before combat..
//:: 01/12/03, by BrianDahlquist/Plas
//:Confused/////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
/*
  Instructions: Put this Script in the SpellCasters :OnPerception: script. Give
  the caster a Tag in the format PCS_XX_YY_ZZ, where

    XX,YY,ZZ = All integers, between 00-31, to pick which spell is cast when
                the wizard sees a hostile player.

  Tag MUST be full 12 characters long. If you only want to cast one or two spells,
  put in '00' for the parameter.

  00 = Cast no Spell.
//Level One Spells
  01 = MageArmor
  02 = ProtectionFromLaw
//Level Two Spells
  03 = ResistElements
  04 = CatsGrace
  05 = Endurance
  06 = Ghostly Visage
  07 = See Invisibility
  32 = invisibility
//Level Three Spells
  08 = Haste
  09 = MagicCircleAgainst Good
  10 = ProtectionFromElements
//Level Four Spells
  11 = ImprovedInvis
  12 = MinorGlobeOfInvulnerability
  13 = PolyMorph Self
  14 = StoneSkin
//Level Five Spells
  15 = ElementalShield
  16 = EnergyBuffer
  17 = LesserSpellMantle
//Level SixSpells
  18 = EtherealVisage
  19 = GlobeOfInvulnerability
  20 = GreaterStoneSkin
  21 = MassHaste
  22 = TensersTransformation
  23 = TrueSeeing
//Level Seven Spells
  24 = ProtectionFromSpells
  25 = ShadowShield
  26 = SpellMantle
//Level EightSpells
  27 = MindBlank
  28 = Premonition
//Level NineSpells
  29 = GreaterSpellMantle
  30 = ShapeChange
  31 = TimeStop

*/
////////////////////////////////////////////////////////////////////////////////
#include "NW_O2_CONINCLUDE"
#include "NW_I0_GENERIC"

void CastContingencySpell(int SpellNumber)
{
    switch(SpellNumber)
    {
      case 00:
          break;

      //level 1 spells

      case 1:
              ActionCastSpellAtObject(SPELL_MAGE_ARMOR,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 2:
              ActionCastSpellAtObject(SPELL_PROTECTION_FROM_LAW,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      //level 2 spells
      case 3:
              ActionCastSpellAtObject(SPELL_RESIST_ELEMENTS,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 4:
              ActionCastSpellAtObject(SPELL_CATS_GRACE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 5:
              ActionCastSpellAtObject(SPELL_ENDURANCE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 6:
              ActionCastSpellAtObject(SPELL_GHOSTLY_VISAGE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 32:
              ActionCastSpellAtObject(SPELL_INVISIBILITY,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 7:
              ActionCastSpellAtObject(SPELL_SEE_INVISIBILITY,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);              ActionCastSpellAtObject(SPELL_PROTECTION_FROM_LAW,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
        //Level 3 SPells
      case 8:
              ActionCastSpellAtObject(SPELL_HASTE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 9:
              ActionCastSpellAtObject(SPELL_MAGIC_CIRCLE_AGAINST_GOOD,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 10:
              ActionCastSpellAtObject(SPELL_PROTECTION_FROM_ELEMENTS,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      //Level 4 Spells
      case 11:
              ActionCastSpellAtObject(SPELL_IMPROVED_INVISIBILITY,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 12:
              ActionCastSpellAtObject(SPELL_MINOR_GLOBE_OF_INVULNERABILITY,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 13:
              ActionCastSpellAtObject(SPELL_POLYMORPH_SELF,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 14:
              ActionCastSpellAtObject(SPELL_STONESKIN,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      //Level 5 Spells
      case 15:
              ActionCastSpellAtObject(SPELL_ELEMENTAL_SHIELD,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 16:
              ActionCastSpellAtObject(SPELL_ENERGY_BUFFER,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 17:
              ActionCastSpellAtObject(SPELL_LESSER_SPELL_MANTLE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      //Level 6 Spells
      case 18:
              ActionCastSpellAtObject(SPELL_ETHEREAL_VISAGE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 19:
              ActionCastSpellAtObject(SPELL_GLOBE_OF_INVULNERABILITY,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 20:
              ActionCastSpellAtObject(SPELL_GREATER_STONESKIN,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 21:
              ActionCastSpellAtObject(SPELL_MASS_HASTE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 22:
              ActionCastSpellAtObject(SPELL_TENSERS_TRANSFORMATION,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 23:
              ActionCastSpellAtObject(SPELL_TRUE_SEEING,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      //Level 7 Spells
      case 24:
              ActionCastSpellAtObject(SPELL_PROTECTION_FROM_SPELLS,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 25:
              ActionCastSpellAtObject(SPELL_SHADOW_SHIELD,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 26:
              ActionCastSpellAtObject(SPELL_SPELL_MANTLE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      //Level 8 SPells
      case 27:
              ActionCastSpellAtObject(SPELL_MIND_BLANK,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 28:
              ActionCastSpellAtObject(SPELL_PREMONITION,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      //Level 9 Spells
      case 29:
              ActionCastSpellAtObject(SPELL_GREATER_SPELL_MANTLE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 30:
              ActionCastSpellAtObject(SPELL_SHAPECHANGE,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
      case 31:
              ActionCastSpellAtObject(SPELL_TIME_STOP,OBJECT_SELF,METAMAGIC_ANY,TRUE,20,PROJECTILE_PATH_TYPE_DEFAULT,TRUE);
              break;
    }
}


void main()
{

//////////////////////////////////////////////////////////////////////////////////
//  This Section Has The Default Bioware OnPerception Script  -nw_c2_default2-. I
//  did NOT write this, and do NOT take credit for it. Only thier for proper AI
//  reactions.
//////////////////////////////////////////////////////////////////////////////////

    //If the last perception event was hearing based or if someone vanished then go to search mode
    if ((GetLastPerceptionVanished()) && GetIsEnemy(GetLastPerceived()))
    {
        object oGone = GetLastPerceived();
        if((GetAttemptedAttackTarget() == GetLastPerceived() ||
          GetAttemptedSpellTarget() == GetLastPerceived() ||
          GetAttackTarget() == GetLastPerceived()) && GetArea(GetLastPerceived()) != GetArea(OBJECT_SELF))
        {
          ClearAllActions();
          DetermineCombatRound();
        }
    }
    //Do not bother checking the last target seen if already fighting
    else if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
    {
        //Check if the last percieved creature was actually seen
        if(GetLastPerceptionSeen())
        {
            if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
            {
                DetermineSpecialBehavior();
            }
            else if(GetIsEnemy(GetLastPerceived()))
            {
                if(!GetHasEffect(EFFECT_TYPE_SLEEP))
                {
                    SetFacingPoint(GetPosition(GetLastPerceived()));
                    SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
                    DetermineCombatRound();
                }
            }
            //Linked up to the special conversation check to initiate a special one-off conversation
            //to get the PCs attention
            else if(GetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION) && GetIsPC(GetLastPerceived()))
            {
                ActionStartConversation(OBJECT_SELF);
            }
        }
    }
    if(GetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT) && GetLastPerceptionSeen())
    {
        SignalEvent(OBJECT_SELF, EventUserDefined(1002));
    }

////////////////////////////////////////////////////////////////////////////////
// End of Bioware Default Script.
// Now Goes through the SelectionProcess of filtering out the Other creatures
// And Finding out WHat Spells to Cast.
////////////////////////////////////////////////////////////////////////////////

    object oNoticed = GetLastPerceived();

    int DoOnce = GetLocalInt(OBJECT_SELF,"ContCheck");

//Will Cast it when Wizard Sees an Object of A different Faction.
if(  !GetFactionEqual(oNoticed,OBJECT_SELF)&&GetLastPerceptionSeen() )
        {
              SetLocalInt(OBJECT_SELF,"ContCheck",1);            //So we dont Cast the spells for EVERY hostile Player

              string CreatureTag = GetTag(OBJECT_SELF);          //Get the Tag of the Creature.
              int StringTagLength = GetStringLength(CreatureTag); //Get the TagLength.

              string CastCheck = GetSubString(CreatureTag, 0,3);  //Get first 3 figures in tag, to Verify it starts with SC

//only run the script if the first letters in the Tag are SCS,and the taglength is 12.Just to make sure
//that people actually REMEMBER to change the tag name, and put enough parameters in it.

          if((CastCheck == "PCS")&&(StringTagLength==12))
                {
                      ClearAllActions();
                    //disect each part of the Tag - each of the three spells, and the visual.
                      int Spell1 = StringToInt(GetSubString(CreatureTag,4,2));
                      int Spell2 = StringToInt(GetSubString(CreatureTag,7,2));
                      int Spell3 = StringToInt(GetSubString(CreatureTag,10,2));
                    //CastTheSpells Themselves.
                      CastContingencySpell(Spell1);
                      CastContingencySpell(Spell2);
                      CastContingencySpell(Spell3);
                    //GetBackTo Normal AI Decision Making
                      DelayCommand(2.0,DetermineCombatRound(oNoticed));
                }
        }
}
Le code a colorer syntaxiquement est trop long (plus de 10240 caractères) et risque de ne pas s'afficher du tout. Vous pouvez le voir en version colorée ici.



Voilà le dit script de contingence.
_________________
Beshaba me protège, Tymora guide mes tirs.

The Cake is a lie !

Mes modules NwN2:De Vieilles Rencontres! et De Vieilles Rencontres2
Double Avenir sur le Nwvault
 
Revenir en haut Voir le profil de l'utilisateur Envoyer un message privé Ignorer l'utilisateur
 
Sith Vicious
Grand Sage du Conseil
Inscrit le: 19 Oct 2005
Messages: 693
Répondre en citant
Posté le : 17/02/2006 17:32:46 Sujet du message :

vire ces 2 lignes là :
NWScript :Note : le code affiché ci-dessus n'est pas rendu tel qu'il devrait l'être réellement, en particulier des sauts de lignes sont automatiquement insérés pour éviter de casser la mise en page. En le copiant/collant, vous résoudrez ce problème.


en fait il s'appelle en boucle donc ça fait planter, c'est bien ce que je pensais.

edit : vire au moins ces instructions, mais si tu gardes le OnPerception par défaut vire le completement du script Contingence, sinon ça le fait faire 2 fois, c'est pas grave mais pas nécessaire.
Dernière édition par Sith Vicious le 17/02/2006 17:47:07; édité 1 fois
 
Revenir en haut Voir le profil de l'utilisateur Envoyer un message privé Ignorer l'utilisateur
 
Noon
Héros
Inscrit le: 15 Jan 2005
Messages: 272
Localisation: Entre Vannes et les RO
Répondre en citant
Posté le : 17/02/2006 17:46:05 Sujet du message :

mmmh, bien vu, merci.Very Happy
_________________
Beshaba me protège, Tymora guide mes tirs.

The Cake is a lie !

Mes modules NwN2:De Vieilles Rencontres! et De Vieilles Rencontres2
Double Avenir sur le Nwvault
 
Revenir en haut Voir le profil de l'utilisateur Envoyer un message privé Ignorer l'utilisateur
 
Montrer les messages depuis :
Page 1 sur 1 ¤


Vous ne pouvez pas poster de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas voter dans les sondages de ce forum


Sauter vers:
FAQ | Rechercher | Liste des Membres | Groupes d'utilisateurs | S'enregistrer | Profil | Se connecter pour vérifier ses messages privés | Connexion
Powered by phpBB 2.* [m] © 2001, 2002 phpBB Group
Theme rewritten in beautiful XHTML code by Baldurien.
Thème "La Bibliothèque de Neverwinter" crée par Kruger
Traduction par : phpBB-fr.com
Page generated in 49.414ms