Compagnons

Répondre
Partager Rechercher
Bonjour à tous, je suis nouveau dans le modding et j'essai de faire un mod BG1 pour NWN2 (je sais qu'il y en a déja un en cours sur les forums officiels mais c'est pour mon plaisir ).

Mon souci vient du fait que lorsque je cré un compagnon (pas un henchman) il n'attaque pas les créatures hostiles et même pire les considère comme amicales !!!

J'utilise les ga_roster_add_object, ga_roster_selectable et ga_roster_party_add pour l'ajouter en jeu (et j'ai importé ses propriétés bien sur).

Après 3 jours de recherches intensive, je dois bien admettre que je commence à craquer !!!

Merci pour votre aide !
Non, hélas, ils sont bien "defender" au départ. Il faudrait que je mette mes zones en JcJ pour que les joueurs puissent les "forcer" à attaquer des créatures hostiles !

Edit:

Après avoir testé sur une toute nouvelle zone (avec mêmes commandes et scripts), tout fonctionne correctement. Si je cré une nouvelle zone dans le même module qu'au début ça ne fonctionne plus. Les deux modules de ma campagne sont dans ce cas, se peut il que le problème provienne du passage en "campagne" ??
Pour une campagne, dans les propriétés de la campagne, fixer UsePersonalReputations à False.

Sinon les compagnons ne feront rien tant que le PJ n'aura pas acquis suffisamment de réputation.
Merci pour vos réponses, je viens finalement (au bout de 7 jours c'est pas mal !) de trouver la racine du mal ! Il s'agit en fait d'un fichier "campaign.cam" dans mon repertoire de campagne qui faisait bugger les compagnons. Depuis que je l'ai enlevé tout est rentré dans l'ordre.

Encore merci pour votre aide !

Edit: je me suis trompé, c'est effectivement le "use personnal reputation" qui était à incriminer.
J'exhume ce topic, ça m'évite d'en créer un pour une question sur les compagnons.

Deux petites questions:

- les compagnons que l'on "flag" campaign npc ne sont ils pas limités en nombre dans l'équipe ? (je me retrouve avec 6 compagnons et je ne sais pas comment limiter à 5).

- lorsque je fais quitter l'équipe à un compagnon (campaign npc) j'utilise le despawn, mon problème c'est qu'il disparait. Je voudrais qu'il puisse rester à l'endroit ou il quitte le groupe, est-ce possible ? Si non, comment le faire apparaitre à un point précis pour être de nouveau disponible quelque soit le module ?
Pour définir le nombre maximum de compagnon d'armes dans un groupe, tu peux utiliser la fonction "SetRosterNPCPartyLimit(...)" dans l'événement "OnLoad" du module.

Pour faire réapparaître ton compagnon, tu peux utiliser la série de fonctions suivante :
Code PHP:

location lLocation GetLocation(oTonCompagnon);

// TRUE permet de "despawn" immédiatement le compagnon, mais ne le sauvegarde pas.
RemoveRosterMemberFromParty(sRosterName,oPC,FALSE);

// Pour pouvoir le sauvegarder.
DespawnRosterMember(sRosterName);

// Pour le faire apparaître à l'endroit de ton choix. Par exemple,
// j'ai choisi plus tôt la localisation à laquelle il s'est fait despawnifier.
// Il ne sera pas logiquement rajouté à ton groupe, auquel cas
// il aurait fallu utiliser en plus "AddRosterMemberToParty(...)".
SpawnRosterMember(sRosterName,lLocation); 
Ce script permet de laisser un compagnon qui quitte le groupe à l'endroit où il est :

utilisation sd_dismiss("rostername")

Code PHP:

// sd_dismiss companion leaves the party then stays in place
void main(string sName)
{
    
object oPC GetFirstPC();
    
object oC GetObjectByTag(sName);
    
location lPosition GetLocation(oC);
    
RemoveRosterMemberFromParty(sNameoPCTRUE); // remove, despawn
    
SpawnRosterMember(sNamelPosition); // respawn where he/she was    

Par ailleurs, je fais toujours tag_compagnon = rostername, tout en minuscules.

En fait Deyonara avait déjà répondu .
Citation :
Publié par Deyonara
Pour définir le nombre maximum de compagnon d'armes dans un groupe, tu peux utiliser la fonction "SetRosterNPCPartyLimit(...)" dans l'événement "OnLoad" du module....
J'ai essayé de faire un script comme indiqué dans le lien mais ça me renvoie une erreur "unknown state in compiler" en face de la dernière ")". Faut il que je rajoute quelque chose ?
De plus ça ne semble limiter que la fenêtre de choix de l'équipe. Je voudrais que ce soit limité aussi en conv et que le pj ne puisse pas recruter un pnj si il a atteint le "quota" (message, ou possibilité d'enlever un des membres).
Le SetRosterNPCPartyLimit s'utilise comme suit :

Pour un groupe comprenant le PJ + 4 compagnons :
SetRosterNPCPartyLimit( 4 );

Tu peux d'inspirer du script suivant, toujours tiré d'une célèbre campagne , pour vérifier les possibilités de changement :
Le script prend un paramètre 0 (sortie d'un compagnon) ou 1 (entrée d'un compagnon) et retourne Vrai ( 1 ) si les conditions sont vérifiées ou Faux ( 0 ) sinon.

Un changement n'est possible que si :
- Le PJ est dans une zone du module où les changements sont possibles (ici la zone "rhodes").
- Les conditions spécifiques au module sont réunies, ici bataille terminée.
- En cas d'ajout, le nombre maximum n'est pas encore atteint.

Le script sd_party listé ci-dessous s'utilise dans la zone condition d'une ligne de conversation :

Ajout
PJ : J'ai besoin de vous..................................................................sd_party( 1 )
PNJ : Je le savais.......................................ga_roster_party_add(sRosterName)

Sortie
PJ : Vous êtes fatigué. Reposez vous ici............................................sd_party ( 0 )
PNJ Vous vous sortirez sans moi...........sd_dismiss(sRosterName)

(Si le script renvoie faux, les lignes n'apparaîtront
pas au joueur pendant la conversation).

Bien sûr on peut rajouter autant de conditions spécifiques au module que nécessaire, par exemple présence obligatoire d'un des compagnons pour le module, soit dans le script, soit dans la conversation. De préférence dans le script quand elles sont valables pour les compagnons.


Code PHP:

// Checks the conditions to accept a change of the party - module dependant
// parm 0 = dismiss, 1 = add

int StartingConditional(int iAdd)
{
    
object oPC GetFirstPC();
    
    
string sArea GetTag(GetArea(GetFirstPC()));
    
int iCheck = ((sArea=="rhodes")&&GetLocalInt(GetModule(), "BattleDone")); // area condition
    
    
if (iCheck==0) return(iCheck) ; // not in a right area
    
    
if (iAdd==1)            // if adding check the party limit
    
{
        
object oName GetObjectByTag(GetFirstRosterMember());
        
int iNum 0;
        while(
GetIsRosterMember(oName))
        {
            if (
GetFactionEqual(oPCoName)) iNum++;
            
oName GetObjectByTag(GetNextRosterMember());
        }
        
iCheck = (iNum GetRosterNPCPartyLimit());
    }
    return(
iCheck);

Salut, désolé de te répondre si tardivement mais je fais tellement de choses en même temps que j'arrive à en oublier la moitié

J'ai essayé de modifier un peu le script que tu m'as montré en "supprimant" la vérification des zones mais il me renvoie une erreur "variable defined without type" lorsque je compile sur la ligne 22. Voici le script comme je l'ai modifié (si on peut appeler ça modifié):

Code PHP:

// Checks the conditions to accept a change of the party - module dependant
// parm 0 = dismiss, 1 = add
int StartingConditional(int iAdd)
{
    
object oPC GetFirstPC();
 
//    string sArea = GetTag(GetArea(GetFirstPC()));
//   int iCheck = ((sArea=="rhodes")&&GetLocalInt(GetModule(), "BattleDone")); // area condition
 
//    if (iCheck==0) return(iCheck) ; // not in a right area
 
    
if (iAdd==1)            // if adding check the party limit
    
{
        
object oName GetObjectByTag(GetFirstRosterMember());
        
int iNum 0;
        while(
GetIsRosterMember(oName))
        {
            if (
GetFactionEqual(oPCoName)) iNum++;
            
oName GetObjectByTag(GetNextRosterMember());
        }
        
iCheck = (iNum GetRosterNPCPartyLimit());
    }
    return(
iCheck);

Me revoila, après de multiples tests je n'arrive toujours pas à compiler mon ...
Code PHP:

SetRosterNPCPartyLimit); 

voilà mon script:

Code PHP:

//::///////////////////////////////////////////////
//:: Example XP2 OnLoad Script
//:: x2_mod_def_load
//:: (c) 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Put into: OnModuleLoad Event
    This example script demonstrates how to tweak the
    behavior of several subsystems in your module.
    For more information, please check x2_inc_switches
    which holds definitions for several variables that
    can be set on modules, creatures, doors or waypoints
    to change the default behavior of Bioware scripts.
    Warning:
    Using some of these switches may change your games
    balancing and may introduce bugs or instabilities. We
    recommend that you only use these switches if you
    know what you are doing. Consider these features
    unsupported!
    Please do NOT report any bugs you experience while
    these switches have been changed from their default
    positions.
    Make sure you visit the forums at nwn.bioware.com
    to find out more about these scripts.
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////
// ChazM 9/10/06 Item scripts defaulted to seperate item scripts that start w/ "i_".  This is needed for crafting to work.
//       Also added new flags (commented out).
// 9/18/06 ChazM - added switch MODULE_SWITCH_ENABLE_MULTI_HENCH_AOE_DAMAGE + other comments
// BMA-OEI 11/14/06 -- CAMPAIGN_SWITCH_USE_PERSONAL_REPUTATION: Defaulted TRUE to enable spell targetting neutral PC associates (nw_i0_spells)
#include "x2_inc_switches"
#include "x2_inc_restsys"
void main()
{
 {
  
SetRosterNPCPartyLimit);
   if (
GetGameDifficulty() ==  GAME_DIFFICULTY_CORE_RULES || GetGameDifficulty() ==  GAME_DIFFICULTY_DIFFICULT)
   {
        
// * Setting the switch below will enable a seperate Use Magic Device Skillcheck for
        // * rogues when playing on Hardcore+ difficulty. This only applies to scrolls
        
SetModuleSwitch (MODULE_SWITCH_ENABLE_UMD_SCROLLSTRUE);
  
// ChazM: this doesn't appear to be used anywhere...
       // * Activating the switch below will make AOE spells hurt neutral NPCS by default
       // SetModuleSwitch (MODULE_SWITCH_AOE_HURT_NEUTRAL_NPCS, TRUE);
 
    // ChazM: controls whether NPC can hurt each other with AOE's.
       //SetModuleSwitch (MODULE_SWITCH_ENABLE_NPC_AOE_HURT_ALLIES, TRUE);
 
    // ChazM: controls whether a PC party can hurt each other with AOE's.
       
SetModuleSwitch (MODULE_SWITCH_ENABLE_MULTI_HENCH_AOE_DAMAGETRUE);
   }
   
// * AI: Activating the switch below will make the creaures using the WalkWaypoint function
   // * able to walk across areas
   // SetModuleSwitch (MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTS, TRUE);
   // * Spells: Activating the switch below will make the Glyph of Warding spell behave differently:
   // * The visual glyph will disappear after 6 seconds, making them impossible to spot
   // SetModuleSwitch (MODULE_SWITCH_ENABLE_INVISIBLE_GLYPH_OF_WARDING, TRUE);
   // * Craft Feats: Want 50 charges on a newly created wand? We found this unbalancing,
   // * but since it is described this way in the book, here is the switch to get it back...
   // SetModuleSwitch (MODULE_SWITCH_ENABLE_CRAFT_WAND_50_CHARGES, TRUE);
   // * Craft Feats: Use this to disable Item Creation Feats if you do not want
   // * them in your module
   // SetModuleSwitch (MODULE_SWITCH_DISABLE_ITEM_CREATION_FEATS, TRUE);
   // * Palemaster: Deathless master touch in PnP only affects creatures up to a certain size.
   // * We do not support this check for balancing reasons, but you can still activate it...
   // SetModuleSwitch (MODULE_SWITCH_SPELL_CORERULES_DMASTERTOUCH, TRUE);
   // * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
   // * did not fit into NWNs spell system and was confusing, so we took it out...
   // SetModuleSwitch (MODULE_SWITCH_EPIC_SPELLS_HURT_CASTER, TRUE);
   // * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
   // * did not fit into NWNs spell system and was confusing, so we took it out...
   // SetModuleSwitch (MODULE_SWITCH_RESTRICT_USE_POISON_TO_FEAT, TRUE);
    // * Spellcasting: Some people don't like caster's abusing combat expertise to raise their AC
    // * Uncommenting this line will drop expertise mode whenever a spell is cast by a player
    // SetModuleSwitch (MODULE_VAR_AI_STOP_EXPERTISE_ABUSE, TRUE);
 
    // * Item Event Scripts: The game's default event scripts allow routing of all item related events
    // * into a single file, based on the tag of that item. If an item's tag is "test", it will fire a
    // * script called "test" when an item based event (equip, unequip, acquire, unacquire, activate,...)
    // * is triggered. Check "x2_it_example.nss" for an example.
    // * This feature is disabled by default.
   
SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTSTRUE);
 
// Enabling this causes tagbased scripting to use 7 different scripts for item events instead of 
 // having them packaged all in one.  
 // The scripts are postfixed with "_aq", "_ua", "_eq", "_ue", "_ac", "_ci", and "hc"
   
SetModuleSwitch (MODULE_SWITCH_ENABLE_SEPERATE_ITEM_SCRIPTSTRUE);
   if (
GetModuleSwitchValue (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
   {
        
// * If Tagbased scripts are enabled, and you are running a Local Vault Server
        // * you should use the line below to add a layer of security to your server, preventing
        // * people to execute script you don't want them to. If you use the feature below,
        // * all called item scrips will be the prefix + the Tag of the item you want to execute, up to a
        // * maximum of 16 chars, instead of the pure tag of the object.
        // * i.e. without the line below a user activating an item with the tag "test",
        // * will result in the execution of a script called "test". If you uncomment the line below
        // * the script called will be "1_test.nss"
        
SetUserDefinedItemEventPrefix("i_");
   }
 
   
// * This initializes Bioware's wandering monster system as used in Hordes of the Underdark
   // * You can deactivate it, making your module load faster if you do not use it.
   // * If you want to use it, make sure you set "x2_mod_def_rest" as your module's OnRest Script
   // SetModuleSwitch (MODULE_SWITCH_USE_XP2_RESTSYSTEM, TRUE);
   
if (GetModuleSwitchValue(MODULE_SWITCH_USE_XP2_RESTSYSTEM) == TRUE)
   {
       
// * This allows you to specify a different 2da for the wandering monster system.
       // SetWanderingMonster2DAFile("des_restsystem");
       //* Do not change this line.
       
WMBuild2DACache();
   }
 
 
// Only setup once for entire campaign
 
if ( GetGlobalInt("CAMPAIGN_SETUP_FLAG") == FALSE )
 {
  
SetGlobalInt"CAMPAIGN_SETUP_FLAG"TRUE );
 
  
//This variable makes all transitions a "gather your party" transition.
  // SetGlobalInt( VAR_GLOBAL_GATHER_PARTY, 1 );
 
  // Force kills dominated group members if no valid members remain - checked on HeartBeat ( nw_g0_dominate )
  //SetGlobalInt( CAMPAIGN_SWITCH_FORCE_KILL_DOMINATED_GROUP, TRUE );
 
  // Removes effect and prevents transition if object is dominated - checked in ginc_transition / nw_g0_transition
  //SetGlobalInt( CAMPAIGN_SWITCH_REMOVE_DOMINATED_ON_TRANSITION, TRUE );  
 
  // A flag that reflects the engine setting for whether or not we use personal reputation; this is a consideration in spell targeting
  // BMA-OEI 11/14/2006: Defaulted TRUE to enable spell targetting neutral PC associates (nw_i0_spells)
  
SetGlobalIntCAMPAIGN_SWITCH_USE_PERSONAL_REPUTATIONTRUE );
 } 
Lorsque je compile, il m'indique "unexpected end compound statement" sur la dernière ligne, je ne vois vraiment pas pourquoi
Après quelques tests, tout fonctionne à merveille ! Toutefois, je n'arrive pas à modifier ce script pour qu'il vérifie la limite de personnage lorsque je veux en ajouter 2 d'un coup dans le groupe.

Code PHP:

// Checks the conditions to accept a change of the party - module dependant
// parm 0 = dismiss, 1 = add
int StartingConditional(int iAdd)
{
    
object oPC GetFirstPC();
 
int iCheck 0;
 
//    string sArea = GetTag(GetArea(GetFirstPC()));
//   int iCheck = ((sArea=="rhodes")&&GetLocalInt(GetModule(), "BattleDone")); // area condition
 
//    if (iCheck==0) return(iCheck) ; // not in a right area
 
    
if (iAdd==1)            // if adding check the party limit
    
{
        
object oName GetObjectByTag(GetFirstRosterMember());
        
int iNum 0;
        while(
GetIsRosterMember(oName))
        {
            if (
GetFactionEqual(oPCoName)) iNum++;
            
oName GetObjectByTag(GetNextRosterMember());
        }
        
iCheck = (iNum GetRosterNPCPartyLimit());
    }
    return(
iCheck);

Si je le laisse comme ceci, il me prend mes deux personnages et donc je peux me retrouver avec un compagnon de plus que ce que la limite permet. Y-a-t il un moyen de faire en sorte qu'il vérifie pour 2 compagnons ?
C'est effectivement prévu pour un compagnon à la fois.

Soit tu découpes la conversation correspondante de façon à avoir une ligne par compagnons. Et dans ce cas le premier pourra entrer dans le groupe s'il y a la place.

Soit tu autorises la valeur 2 (ou plus) pour le paramètre iAdd, ce qui revient à donner le nombre de compagnons à intégrer.

et tu modifies :
if (iAdd > 0) // if adding check the party limit

et int iNum = iAdd - 1;

Dans ce cas ça testera s'il y a deux places... Mais refusera les 2 même s'il y a une place. Tout ern continuant à marcher pour tester l'entrée d'un seul compagnon.
Ca fonctionne à merveille, merci !

Dernière question toutefois, y aurait-il moyen que ça renvoie un dialogue permettant d'évacuer certains membres pour intégrer les nouveaux ?
Oui, en faisant une ligne de conversation conditionnée par NON sd_party ( 2 )
(Cocher la case NON).

Dans cette ligne ligne tu pourras faire sortir les membres que tu souhaites et intégrer les nouveaux.
Répondre

Connectés sur ce fil

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