Bon bin j'ai trouvé la solution. Le scriptage est à améliorer car il ne fonctionne pour le moment que pour les effets visuels de base, les autres étant à rajouter au fur et à mesure (je vous explique tout ça plus bas
)
Donc le soucis se trouve sur un script en dur qui ne fonctionne pas (les effets visuels des torches qui foirent). Je pensais au départ mettre un script sur l'objet, mais il faut mettre les script sur le module en fait (OnEquip et OnDesequip, en français "
Script déclenché par l'objet équipé par le joueur" et "
Script enlevé par l'objet enlevé par la joueur")
Il faut
- modifier les scripts d'origine et rajouter quelques lignes de codes
- créer une bibliothèque (ce n'est pas indispensable mais c'est pour rajouter les effets)
- mettre sur les items des variables de type
string avec comme valeur le nom de l'effet visuel correspondant dans la bibliothèque
Allez on commence
Sur le OnEquip
#include ginc_effect
// à mettre avant le void main() et
// changer le nom si vous voulez modifier-rajouter-enlever des effets visuels
// (...)
string eEffectObjet = GetLocalString (OBJECT_SELF,"eEffetVisuel");
if (eEffectObjet != "")
{
ApplySEFToObject(eEffectObjet ,OBJECT_SELF,600.0);
// 600.0 c'est complètement arbitraire en fait.. C'est le nombre de secondes
//pendant lequel l'effet visuel fonctionnera
}
Sur le OnDesequip
// je sais pas si c'est vraiment utile mais je préfère enlever tous
// les effets au cas où ça prendrai trop de place mémoire
//à mettre après void main()
effect eEffect = GetFirstEffect( OBJECT_SELF );
//Enlève les effets visuels
while ( GetIsEffectValid(eEffect) == TRUE )
{
RemoveEffect( OBJECT_SELF, eEffect );
eEffect = GetNextEffect( OBJECT_SELF );
}
La bibliothèque s'appelle à l'origine
ginc_effect
Elle contient comme effets visuels
const string BLOODSPURT = "bloodspurt.sef";
const string FX_ALTARGEN = "fx_altargen.sef";
const string FX_BLACK_COULD = "fx_black_cloud.sef";
const string FX_CANDLE = "fx_candle.sef";
const string FX_DUST = "fx_dust.sef";
const string FX_FIREFLIES = "fx_fireflies.sef";
const string FX_FIREPLACE = "fx_fireplace.sef";
const string FX_FIRE_LG = "fx_fire_lg.sef";
const string FX_FIRE_LG_BLUR = "fx_fire_lg_blur.sef";
const string FX_FIRE_SMOKE = "fx_fire_smoke.sef";
const string FX_FOG_LG = "fx_fog_lg.sef";
const string FX_LAMPGLOW = "fx_lampglow.sef";
const string FX_LOOTBAG = "fx_lootbag.sef";
const string FX_SPLASH = "fx_splash.sef";
const string FX_SPLASH2 = "fx_splash2.sef";
const string FX_TORCH_BLUE = "fx_torch_blue.sef";
const string FX_TORCHGLOW = "fx_torchglow.sef";
const string FX_VOID = "fx_void.sef";
const string SP_ATK_MISSILE = "sp_atk_missile.sef";
const string SP_BLESS = "sp_bless.sef";
const string SP_CURE_CRITICAL = "sp_cure_critical.sef";
const string SP_CURE_LIGHT = "sp_cure_light.sef";
const string SP_FIREBALL = "sp_fireball.sef";
const string SP_MAGICMISSILE = "sp_magicmissile.sef";
const string SP_RAYFROST = "sp_rayfrost.sef";
pour rajouter des effets pris en compte, il suffit de rajouter une ligne dans le style
const string FX_TORCHHAND = "fx_torchhand.sef";
// rajoute l'effet TorchHand mais TorchGlow est tout aussi joli
donc voilà, les torches éclairent et brûlent maintenant.
Pour les flemmards, voici les scripts en entier
OnEquip_Module
#include "x2_inc_switches"
#include "x2_inc_intweapon"
#include "ktx_ginc_effect"
void main()
{
string eEffectObjet = GetLocalString (OBJECT_SELF,"eEffetVisuel");
object oItem = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
// -------------------------------------------------------------------------
// Intelligent Weapon System
// -------------------------------------------------------------------------
if (IPGetIsIntelligentWeapon(oItem))
{
IWSetIntelligentWeaponEquipped(oPC,oItem);
// prevent players from reequipping their weapon in
if (IWGetIsInIntelligentWeaponConversation(oPC))
{
object oConv = GetLocalObject(oPC,"X2_O_INTWEAPON_SPIRIT");
IWEndIntelligentWeaponConversation(oConv, oPC);
}
else
{
//------------------------------------------------------------------
// Trigger Drain Health Event
//------------------------------------------------------------------
if (GetLocalInt(oPC,"X2_L_ENSERRIC_ASKED_Q3")==1)
{
ExecuteScript ("x2_ens_dodrain",oPC);
}
else
{
IWPlayRandomEquipComment(oPC,oItem);
}
}
}
//-------------------------------------------------------------------
// Ajoute les effets à l'objet -----------------------------------------
//-------------------------------------------------------------------
if (eEffectObjet != "") // si pas d'effets sur l'item la variable est vide
{
ApplySEFToObject(eEffectObjet ,OBJECT_SELF,600.0);
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// -------------------------------------------------------------------------
// Generic Item Script Execution Code
// If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
// it will execute a script that has the same name as the item's tag
// inside this script you can manage scripts for all events by checking against
// GetUserDefinedItemEventNumber(). See x2_it_example.nss
// -------------------------------------------------------------------------
if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_EQUIP);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
}
OnDesequip_Module
#include "x2_inc_switches"
#include "x2_inc_intweapon"
void main()
{
effect eEffect = GetFirstEffect( OBJECT_SELF );
object oItem = GetPCItemLastUnequipped();
object oPC = GetPCItemLastUnequippedBy();
// -------------------------------------------------------------------------
// Intelligent Weapon System
// -------------------------------------------------------------------------
if (IPGetIsIntelligentWeapon(oItem))
{
IWSetIntelligentWeaponEquipped(oPC,OBJECT_INVALID);
IWPlayRandomUnequipComment(oPC,oItem);
}
// -------------------------------------------------------------------------
//Enlève les effets visuels
// -------------------------------------------------------------------------
while ( GetIsEffectValid(eEffect) == TRUE )
{
RemoveEffect( OBJECT_SELF, eEffect );
eEffect = GetNextEffect( OBJECT_SELF );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Generic Item Script Execution Code
// If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
// it will execute a script that has the same name as the item's tag
// inside this script you can manage scripts for all events by checking against
// GetUserDefinedItemEventNumber(). See x2_it_example.nss
// -------------------------------------------------------------------------
if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_UNEQUIP);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
}
Ginc_effect modifié (à enregistrer avec pour nom celui de la bibliothèqe que l'on appelle dans le
OnEquip
J'ai gardé toutes les remarques d'origine au cas où je voudrais le modifier
// ginc_effect_modif
// ChazM 10/03/05
// EPF 10/3/05
// ChazM 10/03/05 added CreateBeam(), VoidCreateBeam(), changed include file
// ChazM 10/04/05 added Note on SEF's and the nBodyPart param
// BMA-OEI 7/04/06 -- Added GetHasEffectType(), RemoveEffectByType()
#include "ginc_param_const"
//void main (){}
//For reference, here are the prototypes for the related functions in nwscript.nss:
//Durations below this number specified in the effect applying functions will be treated as 0,
//which we take to mean you want to apply an effect permanently
const float MY_EPSILON = 0.001;
const string BLOODSPURT = "bloodspurt.sef";
const string FX_ALTARGEN = "fx_altargen.sef";
const string FX_BLACK_COULD = "fx_black_cloud.sef";
const string FX_CANDLE = "fx_candle.sef";
const string FX_DUST = "fx_dust.sef";
const string FX_FIREFLIES = "fx_fireflies.sef";
const string FX_FIREPLACE = "fx_fireplace.sef";
const string FX_FIRE_LG = "fx_fire_lg.sef";
const string FX_FIRE_LG_BLUR = "fx_fire_lg_blur.sef";
const string FX_FIRE_SMOKE = "fx_fire_smoke.sef";
const string FX_FOG_LG = "fx_fog_lg.sef";
const string FX_LAMPGLOW = "fx_lampglow.sef";
const string FX_LOOTBAG = "fx_lootbag.sef";
const string FX_SPLASH = "fx_splash.sef";
const string FX_SPLASH2 = "fx_splash2.sef";
const string FX_TORCH_BLUE = "fx_torch_blue.sef";
const string FX_TORCHGLOW = "fx_torchglow.sef";
const string FX_TORCHHAND = "fx_torchhand.sef";
const string FX_VOID = "fx_void.sef";
const string SP_ATK_MISSILE = "sp_atk_missile.sef";
const string SP_BLESS = "sp_bless.sef";
const string SP_CURE_CRITICAL = "sp_cure_critical.sef";
const string SP_CURE_LIGHT = "sp_cure_light.sef";
const string SP_FIREBALL = "sp_fireball.sef";
const string SP_MAGICMISSILE = "sp_magicmissile.sef";
const string SP_RAYFROST = "sp_rayfrost.sef";
//** FUNCTION DECLARATIONS **
// SEF effect functions
//** For all below functions, Duration of 0 means effect is permanent. **
void ApplySEFToLocation(string sEffectFile, location lLoc, float fDuration = 0.f);
void ApplySEFToObject(string sEffectFile, object oTarget, float fDuration = 0.f);
void ApplySEFToObjectByTag(string sEffectFile, string sTag, float fDuration = 0.f);
void ApplySEFToWP(string sEffectFile, string sWPTag, float fDuration = 0.f);
//SEF goes to all WPs of tag sWPTag
void ApplySEFToWPs(string sEffectFile, string sWPTag, float fDuration = 0.f);
void RemoveSEFFromWP(string sEffectFile, string sWPTag );
//SEF removed from all WPs of tag sWPTag
void RemoveSEFFromWPs(string sEffectFile, string sWPTag );
// Other effect functions
effect CreateBeam(int iBeamVisualEffect, object oSource, object oTarget, int
nDurationType=DURATION_TYPE_PERMANENT,
float fDuration = 0.0f, int nBodyPart = BODY_NODE_CHEST, int bMissEffect = FALSE);
void VoidCreateBeam(int iBeamVisualEffect, object oSource, object oTarget, int
nDurationType=DURATION_TYPE_PERMANENT,
float fDuration = 0.0f, int nBodyPart = BODY_NODE_CHEST, int bMissEffect = FALSE);
// Return TRUE, if oObject is affected by effect type nEffectType
int GetHasEffectType( object oObject, int nEffectType );
// Removes all effects from oObject matching effect type nEffectType
// Returns number of matching effects removed
int RemoveEffectsByType( object oObject, int nEffectType );
void ApplySEFToLocation(string sEffectFile, location lLoc, float fDuration = 0.f)
{
if(fDuration < MY_EPSILON)
{
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile(sEffectFile),
lLoc);
}
else
{
ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectNWN2SpecialEffectFile(sEffectFile),
lLoc, fDuration);
}
}
void ApplySEFToObject(string sEffectFile, object oTarget, float fDuration = 0.f)
{
if(fDuration < MY_EPSILON)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile(sEffectFile),
oTarget);
}
else
{
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectNWN2SpecialEffectFile(sEffectFile),
oTarget, fDuration);
}
}
void ApplySEFToObjectByTag(string sEffectFile, string sTag, float fDuration = 0.f)
{
if(fDuration < MY_EPSILON)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile(sEffectFile),
GetTarget(sTag));
}
else
{
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectNWN2SpecialEffectFile(sEffectFile),
GetTarget(sTag), fDuration);
}
}
void ApplySEFToWP(string sEffectFile, string sWPTag, float fDuration = 0.f)
{
if(fDuration < MY_EPSILON)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile(sEffectFile),
GetTarget(sWPTag));
}
else
{
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectNWN2SpecialEffectFile(sEffectFile),
GetTarget(sWPTag), fDuration);
}
}
void ApplySEFToWPs(string sEffectFile, string sWPTag, float fDuration = 0.f)
{
object oWP = GetObjectByTag(sWPTag);
int i = 1;
while(GetIsObjectValid(oWP))
{
if(fDuration < MY_EPSILON)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectNWN2SpecialEffectFile(sEffectFile), GetTarget(sWPTag));
}
else
{
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,
EffectNWN2SpecialEffectFile(sEffectFile), GetTarget(sWPTag), fDuration);
}
oWP = GetObjectByTag(sWPTag,i);
i++;
}
}
void RemoveSEFFromWP(string sEffectFile, string sWPTag )
{
RemoveSEFFromObject( GetTarget(sWPTag), sEffectFile );
}
void RemoveSEFFromWPs(string sEffectFile, string sWPTag )
{
object oWP = GetObjectByTag(sWPTag);
int i = 1;
while(GetIsObjectValid(oWP))
{
RemoveSEFFromObject(oWP, sEffectFile);
oWP = GetObjectByTag(sWPTag,i);
i++;
}
}
// create a beam between two objects
effect CreateBeam(int iBeamVisualEffect, object oSource, object oTarget, int
nDurationType=DURATION_TYPE_PERMANENT,
float fDuration = 0.0f, int nBodyPart = BODY_NODE_CHEST, int bMissEffect = FALSE)
{
effect eBeam = EffectBeam(iBeamVisualEffect, oSource, nBodyPart);
ApplyEffectToObject(nDurationType, eBeam, oTarget, fDuration);
return (eBeam);
}
void VoidCreateBeam(int iBeamVisualEffect, object oSource, object oTarget, int
nDurationType=DURATION_TYPE_PERMANENT,
float fDuration = 0.0f, int nBodyPart = BODY_NODE_CHEST, int bMissEffect = FALSE)
{
CreateBeam(iBeamVisualEffect, oSource, oTarget, nDurationType,
fDuration, nBodyPart, bMissEffect);
}
// Return TRUE, if oObject is affected by effect type nEffectType
int GetHasEffectType( object oObject, int nEffectType )
{
effect eEffect = GetFirstEffect( oObject );
while ( GetIsEffectValid(eEffect) == TRUE )
{
if ( GetEffectType(eEffect) == nEffectType )
{
return ( TRUE );
}
eEffect = GetNextEffect( oObject );
}
return ( FALSE );
}
// Removes all effects from oObject matching effect type nEffectType
// Returns number of matching effects removed
int RemoveEffectsByType( object oObject, int nEffectType )
{
int nCount = 0;
effect eEffect = GetFirstEffect( oObject );
while ( GetIsEffectValid(eEffect) == TRUE )
{
if ( GetEffectType(eEffect) == nEffectType )
{
nCount = nCount + 1;
RemoveEffect( oObject, eEffect );
eEffect = GetFirstEffect( oObject );
}
else
{
eEffect = GetNextEffect( oObject );
}
}
return ( nCount );
}
voili voilou
[EDIT] (flûte vais être en retard pour le repas
) [/EDIT]