
Aide et informations diverses sur Neverwinter Nights ainsi que D&D3.







La date/heure actuelle est 16/04/2025 14:09:24
La Bibliothèque de Neverwinter Nights Index du Forum »
La Bibliothèque Binaire du NWScript - Neverwinter Nights
Voir le sujet précédent ¤ Voir le sujet suivant | |
---|---|
Auteur | Message |
Baldurien L'homme qui chutait sur le macadam ![]() Messages: 14070 Localisation: Quadran Alpha |
Code :
#include "inc_teleport" void main() { string sTag = GetTag( OBJECT_SELF ); /*object oObjectPersu = GetLastPerceived(); if ( CheckObjectForClass( oObjectPersu, CLASS_TYPE_DRUID ) == FALSE || CheckObjectForClass( oObjectPersu, CLASS_TYPE_RANGER ) == FALSE ) { ClearAllActions(); AssignCommand( OBJECT_SELF, ActionMoveAwayFromObject( oObjectPersu, TRUE ) ); }*/ object oOtherDeer = GetNearestObjectByTag( "NW_DEER", OBJECT_SELF ); object oOtherDeerF = GetNearestObjectByTag( "NW_DEER_F", OBJECT_SELF ); if ( oOtherDeer == OBJECT_SELF ) oOtherDeer = GetNearestObjectByTag( "NW_DEER", OBJECT_SELF, 2 ); if ( oOtherDeerF == OBJECT_SELF ) oOtherDeer = GetNearestObjectByTag( "NW_DEER_F", OBJECT_SELF, 2 ); if ( sTag == "NW_DEER" ) { FloatingTextStringOnCreature( "(je suis un male))", OBJECT_SELF ); // Si on voit un autre cerf, on l'empeche d'approcher du 'harem' if ( GetInt( OBJECT_SELF, "DeerHasFemale" ) == TRUE ) { FloatingTextStringOnCreature( "(je suis un male avec un harem)", OBJECT_SELF ); if ( GetIsObjectValid( oOtherDeer ) == TRUE && GetIsObjectValid( oOtherDeerF ) == TRUE && GetDistanceBetween( OBJECT_SELF, oOtherDeer ) <= 10.0f ) { ClearAllActions(); AssignCommand( OBJECT_SELF, ActionAttack( oOtherDeer, TRUE ) ); DelayCommand( 5.0f, ActionRandomWalk() ); FloatingTextStringOnCreature( "(Ce male n'a rien a faire ici... il veut mon harem)", OBJECT_SELF ); } } // on s'eloigne d'un male et de son harem else { FloatingTextStringOnCreature( "(je suis un male sans harem)", OBJECT_SELF ); if ( GetIsObjectValid( oOtherDeer ) == TRUE && GetIsObjectValid( oOtherDeerF ) == TRUE && GetDistanceBetween( OBJECT_SELF, oOtherDeer ) <= 10.0f ) { ClearAllActions(); AssignCommand( OBJECT_SELF, ActionMoveAwayFromObject( oOtherDeer, TRUE ) ); DelayCommand( 5.0f, ActionRandomWalk() ); FloatingTextStringOnCreature( "(il va penser que je veux son harem)", OBJECT_SELF ); } } } // La femelle n'a pas de male else if ( sTag == "NW_DEER_F" && GetIsObjectValid( oOtherDeer ) == TRUE && GetInt( OBJECT_SELF, "DeerFemaleHasMale" ) == FALSE ) { ClearAllActions(); AssignCommand( OBJECT_SELF, ActionForceFollowObject( oOtherDeer, 3.0f ) ); SetInt( oOtherDeer, "DeerHasFemale", TRUE ); SetInt( OBJECT_SELF, "DeerFemaleHasMale", TRUE ); } // Le petit n'a pas de femelle (mere!) else if ( sTag == "NW_DEER_C" && GetIsObjectValid( oOtherDeerF ) == TRUE && GetInt( OBJECT_SELF, "DeerChildHasMother" ) == FALSE ) { ClearAllActions(); AssignCommand( OBJECT_SELF, ActionForceFollowObject( oOtherDeerF, 3.0f ) ); SetInt( OBJECT_SELF, "DeerChildHasMother", TRUE ); } } J'explique le but du script : la partie commentée permet de faire fuire le cerc/biche/faon si un humain non rodeur/druide s'approche de près, mais ça on s'en fiche : ça fonctionne. J'essaye de foutre des comportements naturels dans mes scripts, et je sais pas si c'est parce que ce script est dans les événements OnPerception et OnHeartbeat, mais en tout cas le if ( sTag == "NW_DEER" ) n'est jamais utilisé ce qui fait que bien en gros y a que les parties réservées aux biches et aux faons qui sont utilisées. Where is the problem donc ? _________________ #nwnights-fr @ irc.darkmyst.org TitanQuest-FR |
Revenir en haut | ![]() ![]() ![]() ![]() |
Konrad Grand Maître Chanteur du Conseil ![]() Messages: 1258 Localisation: Empire d'Halöven |
hé bien en survolant vite fait ça me semble plutot juste.
On dirait que tes tags sont toujours égaux à NW_DEER Tu es sur que tu as bien mis NW_DEER_C et NW_DEER_F pour le bébé et les femelles ? ![]() Si oui c'est que ton bout de programme pour chopper les animaux voisin en variables ne marche pas ![]() _________________ Le site du Module Dragon Noir Le groupe du Module L5A - L'ombre et la Lumière Crimson Skies |
Revenir en haut | ![]() ![]() ![]() ![]() |
Baldurien L'homme qui chutait sur le macadam ![]() Messages: 14070 Localisation: Quadran Alpha |
ben
en théorie, ça devrait fonctionner vu que le cerf c bien NW_DEER il devrait au pire m'afficher le message comme quoi il est un mâle _________________ #nwnights-fr @ irc.darkmyst.org TitanQuest-FR |
Revenir en haut | ![]() ![]() ![]() ![]() |
Konrad Grand Maître Chanteur du Conseil ![]() Messages: 1258 Localisation: Empire d'Halöven |
En effet...
![]() Faut que j'essai ton script chez moi (ce week end si j'ai le temps) pour voir le comportement des bébettes. Tu as peut être un mini mod pour vérifier ça ? Moi pour des fonctions causto comme ça je fais un mini mod "Debug" _________________ Le site du Module Dragon Noir Le groupe du Module L5A - L'ombre et la Lumière Crimson Skies |
Revenir en haut | ![]() ![]() ![]() ![]() |
Baldurien L'homme qui chutait sur le macadam ![]() Messages: 14070 Localisation: Quadran Alpha |
boarf
je fais ça "inModule" une zone de départ avec les bestiaux _________________ #nwnights-fr @ irc.darkmyst.org TitanQuest-FR |
Revenir en haut | ![]() ![]() ![]() ![]() |
Baldurien L'homme qui chutait sur le macadam ![]() Messages: 14070 Localisation: Quadran Alpha |
bon
j'ai modifié pour un truc plus fonctionnel -> OnHeartbeat = Code : #include "inc_teleport" #include "inc_constantes" void main() { string sTag = GetTag( OBJECT_SELF ); float fDistance, fDistanceCerf = 0.0; object oOtherDeer = GetNearestObjectByTag( CERF_CERF_TAG, OBJECT_SELF ); object oOtherDeerF = GetNearestObjectByTag( CERF_BICHE_TAG, OBJECT_SELF ); // Partie reservee au faon if ( sTag == CERF_FAON_TAG && GetInt( OBJECT_SELF, "DeerChildHasMother" ) ) { /* On recupere la distance entre la biche et un male (sachant que la biche s'en fiche un brin de savoir quel est son male) */ fDistance = GetDistanceBetween( OBJECT_SELF, oOtherDeerF ); ActionSpeakString( "Maman? Ne suis-je pas loin de toi?" ); if ( fDistance > CERF_FAON_MAX_DISTANCE ) { ClearAllActions(); ActionSpeakString( "Maman, j'arrive" ); AssignCommand( OBJECT_SELF, ActionForceFollowObject( oOtherDeerF, CERF_FAON_MIN_DISTANCE ) ); DelayCommand( CERF_FAON_RANDOM_WALK, ActionRandomWalk() ); DelayCommand( CERF_FAON_RANDOM_WALK, ActionSpeakString( "MAMMMMMMAN" ) ); } } // Partie reservee a la biche if ( sTag == CERF_BICHE_TAG ) { /* On recupere la distance entre la biche et un male (sachant que la biche s'en fiche un brin de savoir quel est son male) */ fDistance = GetDistanceBetween( OBJECT_SELF, oOtherDeer ); if ( fDistance > CERF_BICHE_MAX_DISTANCE ) { ClearAllActions(); AssignCommand( OBJECT_SELF, ActionForceFollowObject( oOtherDeer, CERF_BICHE_MIN_DISTANCE ) ); DelayCommand( CERF_BICHE_RANDOM_WALK, ActionRandomWalk() ); DelayCommand( CERF_BICHE_RANDOM_WALK, ActionSpeakString( "MON CHERI !!!" ) ); } } // Partie reserve au cerf if ( sTag == CERF_CERF_TAG && GetInt( GetArea( OBJECT_SELF ), "DeerHasFemale" ) == TRUE ) { ActionSpeakString( "Je suis un cerf, et fier de l'etre. Pas touche a mes biches." ); /* Il y a deux choses a verifier : 1. Il y a un cerf a moins de CERF_BICHE_MAX_DISTANCE de moi 2. Il y a une biche a moins de CERF_BICHE_MAX_DISTANCE de moi */ fDistance = GetDistanceBetween( OBJECT_SELF, oOtherDeerF ); fDistanceCerf = GetDistanceBetween( OBJECT_SELF, oOtherDeer ); if ( fDistance <= CERF_CERF_MIN_DISTANCE && fDistanceCerf <= CERF_CERF_MIN_DISTANCE && fDistance != 0.0f && fDistanceCerf != 0.0f ) { if ( GetInt( OBJECT_SELF, "DeerHasFemale" ) == TRUE ) { // Le cerf fait un d20 > 18, il n'est plus male dominant if ( d20() > 18 ) { SetInt( OBJECT_SELF, "DeerHasFemale", FALSE ); SetInt( oOtherDeer, "DeerHasFemale", TRUE ); ClearAllActions(); ActionMoveAwayFromObject( oOtherDeer, TRUE, ( 3 * CERF_CERF_MIN_DISTANCE ) ); ActionSpeakString( "J'ai ete battu... " ); } else { ClearAllActions(); ActionAttack( oOtherDeer, TRUE ); ActionSpeakString( "Un autre male est dans mon harem ! Cela ne va pas!" ); } } else { ClearAllActions(); AssignCommand( oOtherDeer, ActionMoveAwayFromObject( OBJECT_SELF, TRUE, ( 3 * CERF_CERF_MIN_DISTANCE ) ) ); ActionSpeakString( "Je rentre dans le harem d'un autre... je ferais mieux de courrir!" ); } DelayCommand( CERF_CERF_ATTACK_FOR - 0.1, ClearAllActions() ); DelayCommand( CERF_CERF_ATTACK_FOR, ActionRandomWalk() ); DelayCommand( CERF_CERF_ATTACK_FOR, ActionSpeakString( "Action a faire" ) ); } } } => OnSpawn Code : #include "inc_teleport" #include "inc_constantes" void main() { if ( GetTag( OBJECT_SELF ) == CERF_CERF_TAG ) AssignCommand( OBJECT_SELF, ActionRandomWalk() ); else { object oFollow = GetNearestObjectByTag( CERF_CERF_TAG ); object oFollowF = GetNearestObjectByTag( CERF_BICHE_TAG ); if ( GetIsObjectValid( oFollow ) == TRUE && GetTag( OBJECT_SELF ) == CERF_BICHE_TAG ) { AssignCommand( OBJECT_SELF, ActionRandomWalk() ); // On definie une variable sur la zone: ca veut dire qu'il y a des biches. SetInt( GetArea( OBJECT_SELF ), "DeerHasFemale", TRUE ); // Celle la veut dire que le male a des biches par defaut SetInt( oFollow, "DeerHasFemale", TRUE ); } else if ( GetTag( OBJECT_SELF ) == CERF_FAON_TAG && GetIsObjectValid( oFollowF ) == TRUE) { AssignCommand( OBJECT_SELF, ActionForceFollowObject( oFollowF, CERF_FAON_MIN_DISTANCE ) ); SetInt( OBJECT_SELF, "DeerChildHasMother", TRUE ); } else { AssignCommand( OBJECT_SELF, ActionRandomWalk() ); } } } #inc_constantes: Code : // Constantes (ou var globales) // Nature : cerf float CERF_BICHE_MIN_DISTANCE = 5.0; // Distance minimale lorsque la biche est loin d'un male float CERF_BICHE_MAX_DISTANCE = 20.0; float CERF_BICHE_RANDOM_WALK = 15.0; // Au bout de 'x' secondes, la biche recommence sa marche aleatoire float CERF_CERF_MIN_DISTANCE = 7.5; // Si un male est a moins de <value> metre, on attaque ou on fuit float CERF_CERF_ATTACK_FOR = 5.0f; // Le cerf attaque l'autre cerf pendant 5 minutes float CERF_FAON_MIN_DISTANCE = 3.0; float CERF_FAON_MAX_DISTANCE = 12.0; float CERF_FAON_RANDOM_WALK = 9.0; // Au bout de 'x' secondes, la biche recommence sa marche aleatoire string CERF_BICHE_TAG = "NW_DEER_F"; string CERF_CERF_TAG = "NW_DEER"; string CERF_FAON_TAG = "NW_DEER_C"; #inc_teleport Code : // Raccourci pour SetLocalInt( , "bal_*", ); void SetInt( object oObject, string sVarname, int iValue ); // Raccourci pour GetLocalInt( , "bal_*", ); int GetInt( object oObject, string sVarname ); // Raccourci pour SetLocalInt( , "bal_*", ); void SetInt( object oObject, string sVarname, int iValue ) { SetLocalInt( oObject, "bal_" + sVarname, iValue ); //FloatingTextStringOnCreature( "SetInt() : bal_" + sVarname + " set to : " + IntToString( iValue ), GetFirstPC(), FALSE ); } // Raccourci pour GetLocalInt( , "bal_*" ); int GetInt( object oObject, string sVarname ) { int iValue = GetLocalInt( oObject, "bal_" + sVarname ); // FloatingTextStringOnCreature( "GetInt() : bal_" + sVarname + " is equal to : " + IntToString( iValue ), GetFirstPC(), FALSE ); return iValue; } Tu peux tester ? (en foutant je sais pas des kobolds à la place des faons et des biches) _________________ #nwnights-fr @ irc.darkmyst.org TitanQuest-FR |
Revenir en haut | ![]() ![]() ![]() ![]() |


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