|
Voulant contourner le problème passablement agaçant ci-dessus, j'ai donc tenter d'user d'objets pour gérer les transformations.
Pour se faire j'use de ces fonctions:
#include "nwnx_include" #include "nwnx_sql"
const string sRFBiteG = "nw_it_crewps010"; const string sRFClawG = "nw_it_crewpsp005";
const string sRFBite = "nw_it_crewps005"; const string sRFClaw = "nw_it_crewpsp026";
const string sRFCArmourInnate = "duk_carmor_innate"; const string sRFCArmour = "duk_carmor";
/* =============================================================================== */
// Add nModifier to nAbility of oCreature void adjustAbilityPos( object oCreature, int nAbility, int nModifier ) { SetBaseAbilityScore( oCreature, nAbility, GetAbilityScore( oCreature, nAbility, TRUE ) + nModifier ); }
// Sub nModifier to nAbility of oCreature void adjustAbilityNeg( object oCreature, int nAbility, int nModifier ) { SetBaseAbilityScore( oCreature, nAbility, GetAbilityScore( oCreature, nAbility, TRUE ) - nModifier ); }
// Rise the HitPoint of oCreature when morphing into hybrid or animal form void pseudoHealing( object oCreature, int nConMod ) { int nHD = GetHitDice( oCreature ); ApplyEffectToObject( DURATION_TYPE_INSTANT, EffectHeal( nHD * nConMod /2 ), oCreature ); }
// Lower the HitPoint of oCreature when morphing back to normal form void pseudoHurting( object oCreature, int nConMod ) { int nHD = GetHitDice( oCreature ); int nDamage = nConMod /2 * nHD; // SpeakString( "Damage: " + IntToString( nDamage ), TALKVOLUME_SHOUT ); // It will not kill oCreature this way if( GetCurrentHitPoints( oCreature ) < nDamage ) nDamage = GetCurrentHitPoints( oCreature ) -1; ApplyEffectToObject( DURATION_TYPE_INSTANT, EffectDamage( nDamage, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_NORMAL ), oCreature ); }
// Add nModifier to nSkill of oCreature void adjustSkillPos( object oCreature, int nSkill, int nModifier ) { SetBaseSkillRank( oCreature, nSkill, ( GetSkillRank( nSkill, oCreature, TRUE ) + nModifier ) ); }
// Sub nModifier to nSkill of oCreature void adjustSkillSub( object oCreature, int nSkill, int nModifier ) { SetBaseSkillRank( oCreature, nSkill, ( GetSkillRank( nSkill, oCreature, TRUE ) - nModifier ) ); }
// Set the Appearance, weapons, and ability to oCreature transformed in sAnimal void setPC( object oCreature, string sAnimal, int nAppearance, int nInnate ) { // SpeakString( "Set the PC form !", TALKVOLUME_SHOUT );
string sSQL = "SELECT size, bonusfor, bonusdex, bonuscon" + " FROM polymorph_animal" + " WHERE animal = '" + sAnimal + "'";
SQLExecDirect( sSQL ); // Do almost nothing if oCreature is already in Hybrid or Animal form if( SQLFetch() && !GetLocalInt( oCreature, "morphed" ) ) { // Add to oCreature its bonus in Strength, Dexterity, and Constitution adjustAbilityPos( oCreature, ABILITY_STRENGTH, StringToInt( SQLGetData( 2 ) ) ); adjustAbilityPos( oCreature, ABILITY_DEXTERITY, StringToInt( SQLGetData( 3 ) ) ); adjustAbilityPos( oCreature, ABILITY_CONSTITUTION, StringToInt( SQLGetData( 4 ) ) ); FeatAdd( oCreature, 289, TRUE ); // Creature Weapon Profiency // Create and equip Bite, Claws, and Creature Armour object oBite; object oClaw; if( StringToInt( SQLGetData( 1 ) ) == CREATURE_SIZE_LARGE ) { oBite = CreateItemOnObject( sRFBiteG, oCreature, 1, "", FALSE ); oClaw = CreateItemOnObject( sRFClawG, oCreature, 1, "", FALSE );; } else { oBite = CreateItemOnObject( sRFBite, oCreature, 1, "", FALSE ); oClaw = CreateItemOnObject( sRFClaw, oCreature, 1, "", FALSE ); } // SpeakString( "Equip Start !", TALKVOLUME_SHOUT ); ActionEquipItem( oBite, INVENTORY_SLOT_CWEAPON_B ); ActionEquipItem( oClaw, INVENTORY_SLOT_CWEAPON_R ); ActionEquipItem( oClaw, INVENTORY_SLOT_CWEAPON_L ); // SpeakString( "Equip End !", TALKVOLUME_SHOUT ); object oCArmour; if( nInnate ) oCArmour = CreateItemOnObject( sRFCArmourInnate, oCreature, 1, "", FALSE ); else oCArmour = CreateItemOnObject( sRFCArmour, oCreature, 1, "", FALSE ); ActionEquipItem( oCArmour, INVENTORY_SLOT_CARMOUR ); pseudoHealing( oCreature, StringToInt( SQLGetData( 4 ) ) ); // Add the bonus skill point from the hybrid and animal form sSQL = "SELECT skill, skillpoint" + " FROM polymorph_skill" + " WHERE animal = '" + sAnimal + "'"; SQLExecDirect( sSQL ); while( SQLFetch() ) adjustSkillPos( oCreature, StringToInt( SQLGetData( 1 ) ), StringToInt( SQLGetData( 2 ) ) ); // Add the bonus feat from the hybrid and animal form sSQL = "SELECT bonusfeat" + " FROM polymorph_feat " + " WHERE animal = '" + sAnimal + "'"; SQLExecDirect( sSQL ); while( SQLFetch() ) FeatAdd( oCreature, StringToInt( SQLGetData( 1 ) ), FALSE ); SetLocalInt( oCreature, "morphed", 1 ); } // Give the expected nAppearance to oCreature SetCreatureAppearanceType( oCreature, nAppearance ); }
// Change the caller in an hybrid form void changeToHybrid( object oTarget ) { if( GetLocalInt( oTarget, "DM_Morph" ) ) return;
// SpeakString( "Hybrid Form !", TALKVOLUME_SHOUT ); string sPC = GetBicFileName( oTarget ); string sSQL = "SELECT appearance_hybrid, innate, polymorph_player.animal" + " FROM polymorph_appearance, polymorph_player" + " WHERE playername = '" + sPC + "'" + " AND polymorph_player.animal = polymorph_appearance.animal"; SQLExecDirect( sSQL ); if( SQLFetch() ) { // SpeakString( SQLGetData( 1 ), TALKVOLUME_SHOUT ); setPC( oTarget, SQLGetData( 3 ), StringToInt( SQLGetData( 1 ) ), StringToInt( SQLGetData( 2 ) ) ); } }
// Change the caller in an animal form void changeToAnimal( object oTarget ) { if( GetLocalInt( oTarget, "DM_Morph" ) ) return;
// SpeakString( "Animal Form !", TALKVOLUME_SHOUT );
string sPC = GetBicFileName( oTarget ); string sSQL = "SELECT appearance_animal, innate, polymorph_player.animal" + " FROM polymorph_appearance, polymorph_player" + " WHERE playername = '" + sPC + "'" + " AND polymorph_player.animal = polymorph_appearance.animal"; SQLExecDirect( sSQL ); if( SQLFetch() ) { // SpeakString( SQLGetData( 1 ), TALKVOLUME_SHOUT ); setPC( oTarget, SQLGetData( 3 ), StringToInt( SQLGetData( 1 ) ), StringToInt( SQLGetData( 2 ) ) ); } int i = 0; for( i; i < 6; ++i ) ActionUnequipItem( GetItemInSlot( i, oTarget ) ); }
Les objets en question, quand ils sont utilisés (activés) font appel au fonction changeToAnimal() et changeToHybrid(), selon le cas.
Le problème rencontré est qu'en faisant ainsi, le personnage change bien d'apparence, gagne les dons, les points de compétences et de stats, mais refuse d'équiper l'une des griffes, la morsures, et la peau de créature, alors que cela fonctionne parfaitement quand j'utilise le don plutôt qu'un objet !
Ça en devient désespérant, alors auriez vous une idée pour m'aider ?
|