Système de casse ( venant du vault )

Répondre
Partager Rechercher
Voilà j'ai choppé ce système de casse qui me semble bien :

http://nwvault.ign.com/Files/scripts...28128000.shtml

Rapido comment il fonctionne :

Les armes et autres items ont des pts de vies, ces pts sont fonctions du type de l'item et de ses propriétés magiques ( paramétrable dans la biblio )

Quand une arme frappe, elle perd un pt de vie
A chaque fin de round de combat ( théoriquement car voir plus bas ) un slot équipé autre qu'une arme est tiré au hasard et perd un pt de vie.

Il y a un jet de dé ( 3 chances sur 100 ) pour voir si un dégat extraordinaire à lieu ( 1 ou 2 d20 je sais plus )

Voilà, quand l'arme arrive à 0 ou moins de pts de vie, elle se brise.

Ca me semble pas mal comme système, on peut imaginer des forgerons pouvant réparer des armes avec ce système.

Petit problème, les pts de vies sont stockés sur l'arme via une variable locale donc une déco reco remet l'arme à neuf.
Mais j'pense ( je m'y connais pas trop en BDD mébon ) que les fonctions de campagne peuvent pallier à ça.

Côté technique :
-------------------
Une biblio de fonctions.

3 scripts à modifier dans les scripts de base :
nw_c2_default6
nw_c2_default3
nw_c2_default7

défault 6 et 7 gèrent les casses des armes et les flèches qui peuvent éventuellement se retrouver sur les corps des NPC tués en combat.

le défault 3 gère les armures et les items dans les slots.
C'est là que le bas blesse, ça ne marche pas pour le défault3...

je vous donne la fonction à mettre dans ce script :

Code PHP:

#include "aa_itembreak_inc"

    // Recommended to add just before the following line
    // if (GetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT))

    // Do Armor/Item Breakage
    
DoArmorItemBreakage(OBJECT_SELFoTarget); 
oTarget n'est pas déclaré, et je ne sais vraiment pas comment le déclarer.....

J'ai essayé pas mal de trucs, GetLastDamager, GetLastHostileActor... rien ne fonctionne en test....

Pourtant ce script me semble bien...


Voilà, moralité, la casse des armes fonctionne à merveille mais pas le reste, et c'est bien dommage.

Si quelqu'un a une idée... Moi j'en ai plus là, je recommencerai à chercher demain

A+
Bon voilà j'y suis enfin arrivé

Je vais pas rentrer dans les détails je laisse juste l'include qui contient tout ce qu'il faut si ça interresse quelqu'un.

Pour une persistance des degats sur le matos faudra que quelqu'un s'y colle moi j'en ai pas besoin. [ EDIT : avec la 1.62 la persistance des dégats est assurée sans BDD ]

Petit détail qui peut avoir son importance, si un joueur s'amuse à courir en évitant les monstres, si ya bcp de monstres et si le joueur court longtemps ( entendez par là une minute ) Ca lag sévère et j'ai testé en solo et pas sur le net donc voilà quoi...
[EDIT : Après tests, c'est kifkif avec ou sans ces scripts, c'est le fait que plusieurs créatures courent derrière le joueur qui fait le plus lagger que les scripts d'usure, enfin a priori... ]

Code PHP:

//::///////////////////////////////////////////////
//:: BASE INCLUDE FILE FOR WEAPON/ARMOR/ITEM BREAKAGE
//:: aa_itembreak_inc
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    This is a base include file to be used to add in
    some basic item breakage.  This is not been heavily
    tested, but from the testing done this works fine.

    SET UP:
    ==========================================
    Modify the following scripts and make sure the variables
    are all defined (all functions have base definitions to make
    it simpler to integrate:

    ------------------------------------------------------
    nw_c2_default6:
    ------------------------------------------------------

    #include "aa_itembreak_inc"

    object oTarget = GetAttackTarget();
    object oDamager = GetLastDamager();
    object oWeapon = GetLastWeaponUsed(oDamager);

    // Recommended to add just before the following line
    // if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))

    // Begin Weapon Breakage / Ammo Return
    if(GetIsObjectValid(oWeapon) == TRUE)
    {
        DoWeaponBreakage(oDamager, oTarget, oWeapon);
    }

    ------------------------------------------------------
    nw_c2_default3:
    ------------------------------------------------------

    #include "aa_itembreak_inc"

    // Recommended to add just before the following line
    // if (GetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT))

    // Do Armor/Item Breakage
    object oAttacker = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
    DoArmorItemBreakage(oAttacker,OBJECT_SELF);


    ------------------------------------------------------
    nw_c2_default7:
    ------------------------------------------------------

    #include "aa_itembreak_inc"

    object oKiller = GetLastKiller();
    object oWeapon = GetLastWeaponUsed(oKiller);

    // Recommended to add towards the top of this script.

    // Begin Weapon Breakage / Ammo Return
    if(GetIsObjectValid(oWeapon) == TRUE)
    {
        DoWeaponBreakage(oKiller, OBJECT_SELF, oWeapon);
    }


*/
//:://////////////////////////////////////////////
//:: Created By: Raasta
//:: Created On: 4/3/04
//:: Modifie par Ketil Dimzad, avril 2004
//:://////////////////////////////////////////////

// DEBUG MODE - TRUE is ON / FALSE if OFF
// Set this to FALSE to not see the debug info
// Set this to TRUE to see all debug info
// (Default = TRUE)
int DEBUGME FALSE;

// void DoCheckMissleReturn(object oAttacker, object oTarget, object oWeapon);
// ================================================================
// This funtion Checks to see if the weapon (oWeapon) being used by (oAttacker)
// is a valid ranged weapon on (oTarget).  If so then it rolls a base chance and
// creates a duplicate of the missle on the target.  So on death there is a chance
// of recovering your missle weapons.
void DoCheckMissleReturn(object oAttackerobject oTargetobject oWeapon);

// int GetIsWeaponAmmoReturnable(object oWeapon);
// ================================================================
// This function returns TRUE if the weapon is ranged
// and returns FALSE if it is not.
int GetIsWeaponAmmoReturnable(object oWeapon);

// int DoGetMagicItemBonus(object oWeapon);
// ================================================================
// This function is used with the DoSetItemMax function to determine
// the ItemMax HitPoints.  This is set through a loop that will determine
// all the magic properties and add them up to get a total.  The iMax +
// values can be changed to suit your taste.
int DoGetMagicItemBonus(object oWeapon);

// int DoGetBaseItemBonus(object oWeapon);
// ================================================================
// This function is used with the DoSetItemMax function to determine
// the ItemMax HitPoints.  This is will determine the base item type
// and set the base hit points for that item.  The iMax + values can
// be changed to suit your taste.
int DoGetBaseItemBonus(object oWeapon);

// void DoSetItemMax(object oWeapon, object oPC);
// ================================================================
// This function will get the base item type (base hit points) and
// then check to see if there are magic item properties on it if so
// it will add all these up to get the ItemMax Hit Points.  This is
// a variable stored on the item itsself.
void DoSetItemMax(object oWeaponobject oPC);


// void DoWeaponBreakageAdvance(object oAttacker, object oWeapon, int iCurrent);
// ================================================================
// This function will advance the damage on an item (subtract hit points)
// from the MaxHit Points of an item damaged.  Note, there is a 3% chance
// that damage done to an item can be 'exceptional'.  Exceptional damage
// will do 2d20 points of damage.
void DoWeaponBreakageAdvance(object oAttackerobject oWeaponint iCurrent);

// void DoArmorBreakageAdvance(object oAttacker, object oWeapon, int iCurrent);
// ================================================================
// Cette fonction fonctionne de la meme maniere que celle pour les armes.
// Ca permet juste d'avoir un parametrage different pour les armures et items
// equipes comme ils sont touches moins souvent avec ce systeme que les armes.
// N'ayant pas tout compris a la fonction c'est le mieux que je puisse faire :)
void DoArmorBreakageAdvance(object oAttackerobject oWeaponint iCurrent);


// void DoWeaponBreakage(object oAttacker, object oTarget, object oWeapon);
// ================================================================
// This is the base function that will check if an item is valid and if it
// has a set MaxHit Points.  If not then it will create a new MaxHit point
// value and do calculations against the weapon.
void DoWeaponBreakage(object oAttackerobject oTargetobject oWeapon);


// void DoArmorItemBreakage(object oAttacker, object oTarget);
// ================================================================
// This is the base function that will check if an item is valid and if it
// has a set MaxHit Points.  If not then it will create a new MaxHit point
// value and do calculations against the armor or worn item (this includes
// all worn item slots).
void DoArmorItemBreakage(object oAttackerobject oTarget);

////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////////////////

void DoCheckMissleReturn(object oAttackerobject oTargetobject oWeapon)
{
    
int iWeapon GetBaseItemType(oWeapon);
    
int iRandRoll d20();
    
int iRandBreak d100();

    switch(
iWeapon)
    {
        case 
BASE_ITEM_DART:
            if(
iRandBreak >= 5)
            {
                
string sAmmoResRef GetResRef(oWeapon);
                
CreateItemOnObject(sAmmoResRefoTarget1);
            }
            break;
        case 
BASE_ITEM_HEAVYCROSSBOW:
            if(
iRandBreak <= 12)
            {
                
object oAmmo GetItemInSlot(INVENTORY_SLOT_BOLTSoAttacker);
                if(
GetIsObjectValid(oAmmo) == TRUE)
                {
                    
string sAmmoResRef GetResRef(oAmmo);
                    
CreateItemOnObject(sAmmoResRefoTarget1);
                }
            }
            break;
        case 
BASE_ITEM_LIGHTCROSSBOW:
            if(
iRandBreak <= 12)
            {
                
object oAmmo GetItemInSlot(INVENTORY_SLOT_BOLTSoAttacker);
                if(
GetIsObjectValid(oAmmo) == TRUE)
                {
                    
string sAmmoResRef GetResRef(oAmmo);
                    
CreateItemOnObject(sAmmoResRefoTarget1);
                }
            }
            break;
        case 
BASE_ITEM_LONGBOW:
            if(
iRandBreak <= 12)
            {
                
object oAmmo GetItemInSlot(INVENTORY_SLOT_ARROWSoAttacker);
                if(
GetIsObjectValid(oAmmo) == TRUE)
                {
                    
string sAmmoResRef GetResRef(oAmmo);
                    
CreateItemOnObject(sAmmoResRefoTarget1);
                }
            }
            break;
        case 
BASE_ITEM_SHORTBOW:
            if(
iRandBreak <= 12)
            {
                
object oAmmo GetItemInSlot(INVENTORY_SLOT_ARROWSoAttacker);
                if(
GetIsObjectValid(oAmmo) == TRUE)
                {
                    
string sAmmoResRef GetResRef(oAmmo);
                    
CreateItemOnObject(sAmmoResRefoTarget1);
                }
            }
            break;
        case 
BASE_ITEM_SHURIKEN:
            if(
iRandBreak >= 5)
            {
                
string sAmmoResRef GetResRef(oWeapon);
                
CreateItemOnObject(sAmmoResRefoTarget1);
            }
            break;
        case 
BASE_ITEM_SLING:
            if(
iRandBreak <= 12)
            {
                
object oAmmo GetItemInSlot(INVENTORY_SLOT_BULLETSoAttacker);
                if(
GetIsObjectValid(oAmmo) == TRUE)
                {
                    
string sAmmoResRef GetResRef(oAmmo);
                    
CreateItemOnObject(sAmmoResRefoTarget1);
                }
            }
            break;
        case 
BASE_ITEM_THROWINGAXE:
            if(
iRandBreak >= 5)
            {
                
string sAmmoResRef GetResRef(oWeapon);
                
CreateItemOnObject(sAmmoResRefoTarget1);
            }
            break;
        default:
            break;
    }
}


int GetIsWeaponAmmoReturnable(object oWeapon)
{
    
int iReturn;
    
int iWeapon GetBaseItemType(oWeapon);

    if( 
iWeapon == BASE_ITEM_DART ||
        
iWeapon == BASE_ITEM_HEAVYCROSSBOW ||
        
iWeapon == BASE_ITEM_LIGHTCROSSBOW ||
        
iWeapon == BASE_ITEM_LONGBOW ||
        
iWeapon == BASE_ITEM_SHORTBOW ||
        
iWeapon == BASE_ITEM_SHURIKEN ||
        
iWeapon == BASE_ITEM_SLING ||
        
iWeapon == BASE_ITEM_THROWINGAXE)    iReturn TRUE;
    else 
iReturn FALSE;

    return 
iReturn;
}

int DoGetMagicItemBonus(object oWeapon)
{
    
int iMax 1;
    
itemproperty ipLoop GetFirstItemProperty(oWeapon);


//Bon alors dans cette boucle on défini la valeur en hp qu'apporte les propriétés des items.
//Donc un item magique est plus résistant qu'un item non magique.
    
while (GetIsItemPropertyValid(ipLoop))
    {
        
int iType GetItemPropertyType(ipLoop);

        if(
iType == ITEM_PROPERTY_ABILITY_BONUS)                                    iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_AC_BONUS)                                    iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_AC_BONUS_VS_ALIGNMENT_GROUP)                 iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_AC_BONUS_VS_DAMAGE_TYPE)                     iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_AC_BONUS_VS_RACIAL_GROUP)                    iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_AC_BONUS_VS_SPECIFIC_ALIGNMENT)              iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_ARCANE_SPELL_FAILURE)                        iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_ATTACK_BONUS)                                iMax iMax 750;
        else if(
iType == ITEM_PROPERTY_ATTACK_BONUS_VS_ALIGNMENT_GROUP)             iMax iMax 450;
        else if(
iType == ITEM_PROPERTY_ATTACK_BONUS_VS_RACIAL_GROUP)                iMax iMax 250;
        else if(
iType == ITEM_PROPERTY_ATTACK_BONUS_VS_SPECIFIC_ALIGNMENT)          iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_BASE_ITEM_WEIGHT_REDUCTION)                  iMax iMax 100;
        else if(
iType == ITEM_PROPERTY_BONUS_FEAT)                                  iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_BONUS_SPELL_SLOT_OF_LEVEL_N)                 iMax iMax 400;
        else if(
iType == ITEM_PROPERTY_CAST_SPELL)                                  iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_DAMAGE_BONUS)                                iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP)             iMax iMax 700;
        else if(
iType == ITEM_PROPERTY_DAMAGE_BONUS_VS_RACIAL_GROUP)                iMax iMax 700;
        else if(
iType == ITEM_PROPERTY_DAMAGE_BONUS_VS_SPECIFIC_ALIGNMENT)          iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_DAMAGE_REDUCTION)                            iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_DAMAGE_RESISTANCE)                           iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_DAMAGE_VULNERABILITY)                        iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DARKVISION)                                  iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_DECREASED_ABILITY_SCORE)                     iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DECREASED_AC)                                iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DECREASED_ATTACK_MODIFIER)                   iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DECREASED_DAMAGE)                            iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DECREASED_ENHANCEMENT_MODIFIER)              iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DECREASED_SAVING_THROWS)                     iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DECREASED_SAVING_THROWS_SPECIFIC)            iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_DECREASED_SKILL_MODIFIER)                    iMax iMax 1;
        else if(
iType == ITEM_PROPERTY_ENHANCED_CONTAINER_REDUCED_WEIGHT)           iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_ENHANCEMENT_BONUS)                           iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_ALIGNMENT_GROUP)        iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_RACIAL_GROUP)           iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_SPECIFIC_ALIGNEMENT)    iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_EXTRA_MELEE_DAMAGE_TYPE)                     iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_EXTRA_RANGED_DAMAGE_TYPE)                    iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_FREEDOM_OF_MOVEMENT)                         iMax iMax 900;
        else if(
iType == ITEM_PROPERTY_HASTE)                                       iMax iMax 900;
        else if(
iType == ITEM_PROPERTY_HOLY_AVENGER)                                iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_IMMUNITY_DAMAGE_TYPE)                        iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_IMMUNITY_MISCELLANEOUS)                      iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_IMMUNITY_SPECIFIC_SPELL)                     iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_IMMUNITY_SPELL_SCHOOL)                       iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_IMMUNITY_SPELLS_BY_LEVEL)                    iMax iMax 900;
        else if(
iType == ITEM_PROPERTY_IMPROVED_EVASION)                            iMax iMax 1200;
        else if(
iType == ITEM_PROPERTY_KEEN)                                        iMax iMax 1200;
        else if(
iType == ITEM_PROPERTY_LIGHT)                                       iMax iMax 100;
        else if(
iType == ITEM_PROPERTY_MASSIVE_CRITICALS)                           iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_MIGHTY)                                      iMax iMax 600;
        else if(
iType == ITEM_PROPERTY_MIND_BLANK)                                  iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_ON_HIT_PROPERTIES)                           iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_ON_MONSTER_HIT)                              iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_ONHITCASTSPELL)                              iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_POISON)                                      iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_REGENERATION)                                iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_REGENERATION_VAMPIRIC)                       iMax iMax 900;
        else if(
iType == ITEM_PROPERTY_SAVING_THROW_BONUS)                          iMax iMax 600;
        else if(
iType == ITEM_PROPERTY_SAVING_THROW_BONUS_SPECIFIC)                 iMax iMax 600;
        else if(
iType == ITEM_PROPERTY_SKILL_BONUS)                                 iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_SPELL_RESISTANCE)                            iMax iMax 1000;
        else if(
iType == ITEM_PROPERTY_TRUE_SEEING)                                 iMax iMax 500;
        else if(
iType == ITEM_PROPERTY_TURN_RESISTANCE)                             iMax iMax 600;
        else if(
iType == ITEM_PROPERTY_UNLIMITED_AMMUNITION)                        iMax iMax 800;
        else if(
iType == ITEM_PROPERTY_USE_LIMITATION_ALIGNMENT_GROUP)              iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_USE_LIMITATION_CLASS)                        iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_USE_LIMITATION_RACIAL_TYPE)                  iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_USE_LIMITATION_SPECIFIC_ALIGNMENT)           iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_USE_LIMITATION_TILESET)                      iMax iMax 300;
        else if(
iType == ITEM_PROPERTY_VISUALEFFECT)                                iMax iMax 100;
        else if(
iType == ITEM_PROPERTY_WEIGHT_INCREASE)                             iMax iMax 10;

        
ipLoop GetNextItemProperty(oWeapon);
    }

    return 
iMax;
}

//Ici on modifie la valeur en hp de l'item de base

int DoGetBaseItemBonus(object oWeapon)
{
    
int iMax 1;
    
int iWeapon GetBaseItemType(oWeapon);

    if(
iWeapon == BASE_ITEM_AMULET)             iMax iMax 500;
    else if(
iWeapon == BASE_ITEM_ARMOR)         iMax iMax 500 + (GetItemACValue(oWeapon)*50);
    else if(
iWeapon == BASE_ITEM_ARROW)         iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_BASTARDSWORD)  iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_BATTLEAXE)     iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_BELT)          iMax iMax 500;
    else if(
iWeapon == BASE_ITEM_BOLT)          iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_BOOTS)         iMax iMax 500;
    else if(
iWeapon == BASE_ITEM_BRACER)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_BULLET)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_CLOAK)         iMax iMax 500;
    else if(
iWeapon == BASE_ITEM_CLUB)          iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_DAGGER)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_DART)          iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_DIREMACE)      iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_DOUBLEAXE)     iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_DWARVENWARAXEiMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_GLOVES)        iMax iMax 500;
    else if(
iWeapon == BASE_ITEM_GOLD)          iMax iMax 99999;
    else if(
iWeapon == BASE_ITEM_GREATAXE)      iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_GREATSWORD)    iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_HALBERD)       iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_HANDAXE)       iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_HEAVYCROSSBOWiMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_HEAVYFLAIL)    iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_HELMET)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_KAMA)          iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_KATANA)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_KUKRI)         iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_LARGESHIELD)   iMax iMax 650;
    else if(
iWeapon == BASE_ITEM_LIGHTCROSSBOWiMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_LIGHTFLAIL)    iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_LIGHTHAMMER)   iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_LIGHTMACE)     iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_LONGBOW)       iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_LONGSWORD)     iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_MORNINGSTAR)   iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_QUARTERSTAFF)  iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_RAPIER)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_RING)          iMax iMax 250;
    else if(
iWeapon == BASE_ITEM_SCIMITAR)      iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_SCYTHE)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_SHORTBOW)      iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_SHORTSPEAR)    iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_SHORTSWORD)    iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_SHURIKEN)      iMax iMax 500;
    else if(
iWeapon == BASE_ITEM_SICKLE)        iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_SLING)         iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_SMALLSHIELD)   iMax iMax 450;
    else if(
iWeapon == BASE_ITEM_THROWINGAXE)   iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_TOWERSHIELD)   iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_TWOBLADEDSWORD)iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_WARHAMMER)     iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_WHIP)          iMax iMax 1000;
    else if(
iWeapon == BASE_ITEM_INVALID)       iMax 100000;
    else 
iMax 500;

    return 
iMax;
}


void DoSetItemMax(object oWeaponobject oPC)
{
    
int iMax 1;
    
int iISPlotItem GetPlotFlag(oWeapon);
    
int iTypeBonus DoGetBaseItemBonus(oWeapon);
    
int iMagicBonus DoGetMagicItemBonus(oWeapon);

    if(
iISPlotItem == TRUE)    iMax iMax 2000000;

    
int iTotal iMax iMagicBonus iTypeBonus;

    if(
DEBUGME == TRUE)
    {
        
SendMessageToPC(oPC"SETTING NEW ITEM HP ");
        
SendMessageToPC(oPC"=======================");
        
SendMessageToPC(oPC"BASE BONUS  = " IntToString(iTypeBonus));
        
SendMessageToPC(oPC"MAGIC BONUS = " IntToString(iMagicBonus));
        
SendMessageToPC(oPC"TOTAL BONUS = " IntToString(iTotal));
        
SendMessageToPC(oPC"=======================");
    }

    
SetLocalInt(oWeapon"MAX_HP"iTotal);
    
SetLocalInt(oWeapon"CUR_HP"iTotal);
    
SetLocalInt(oWeapon"ITEM_SET"TRUE);
}

void DoWeaponBreakageAdvance(object oAttackerobject oWeaponint iCurrent)
{
    
int iExceptional d100();

    if(
iCurrent <= 0)
    {
        
SendMessageToPC(oAttacker"*************************");
        
SendMessageToPC(oAttacker"*** Objet detruit : " GetName(oWeapon) + " ***");
        
SendMessageToPC(oAttacker"*************************");
        
//PlayVoiceChat(VOICE_CHAT_BORED,oAttacker);
   /*la ligne PlayVOiceChat a été commenté parce que très chiante à force mais on peut apprécier...  */  
        
FloatingTextStringOnCreature("*** Objet detruit : " GetName(oWeapon) + " ***",oAttacker);
        
DestroyObject(oWeapon);
    }
    else
    {
        if(
iExceptional <= 5)    //Changer ici le % de chance d'avoir des degats exceptionnels
        
{
            
SendMessageToPC(oAttacker"** PERTE D'INTEGRITE IMPORTANTE : " GetName(oWeapon) + "**");
            
int iDamRoll d10(3); //Changer ici les degats subit en cas de perte importante
            
int iNewTotal iCurrent iDamRoll;
            
SendMessageToPC(oAttacker"Perte importante de " IntToString(iDamRoll) + " pts d'integrite.");
            
//PlayVoiceChat(VOICE_CHAT_BORED,oAttacker);
            
FloatingTextStringOnCreature("Votre " GetName(oWeapon) + " est endommagé par le combat.",oAttacker);
            
SetLocalInt(oWeapon"CUR_HP"iNewTotal);
        }
        else
        {
            
int iNewTotal iCurrent 5;  //Changer ici le nb de pts de degats classiques
            
SetLocalInt(oWeapon"CUR_HP"iNewTotal);
        }

        if(
DEBUGME == TRUE)
        {
            
int iCURitemHP GetLocalInt(oWeapon"CUR_HP");
            
SendMessageToPC(oAttacker"SETTING NEW HP ");
            
SendMessageToPC(oAttacker"=======================");
            
SendMessageToPC(oAttacker"NEW TOTAL = " IntToString(iCURitemHP));
            
SendMessageToPC(oAttacker"=======================");
        }
    }
}
//DoArmorBreakageAdvance    RAJOUTEE PAR MOI MEME, pour parametrer differement des armes
//Fonctionne désormais beaucoup mieux et marche sur tous les items équipés.
void DoArmorBreakageAdvance(object oAttackerobject oWeaponint iCurrent)
{
    
int iExceptional d100();

    if(
iCurrent <= 0)
    {
        
SendMessageToPC(oAttacker"*************************");
        
SendMessageToPC(oAttacker"*** Objet detruit : " GetName(oWeapon) + " ***");
        
SendMessageToPC(oAttacker"*************************");
        
//PlayVoiceChat(VOICE_CHAT_BORED,oAttacker);
        
FloatingTextStringOnCreature("*** Objet detruit : " GetName(oWeapon) + " ***",oAttacker);
        
DestroyObject(oWeapon);
    }
    else
    {
        if(
iExceptional <= 5)        //Changer ici le % de chance d'avoir des degats exceptionnels
        
{
            
SendMessageToPC(oAttacker"** PERTE D'INTEGRITE IMPORTANTE : " GetName(oWeapon) + "**");
            
int iDamRoll d10(3); //Changer ici les degats subit en cas de perte importante
            
int iNewTotal iCurrent iDamRoll;
            
SendMessageToPC(oAttacker"Perte importante de " IntToString(iDamRoll) + " pts d'integrite.");
            
//PlayVoiceChat(VOICE_CHAT_BORED,oAttacker);
            
FloatingTextStringOnCreature("Votre " GetName(oWeapon) + " est endommagé par le combat.",oAttacker);
            
SetLocalInt(oWeapon"CUR_HP"iNewTotal);
        }
        else
        {
            
int iNewTotal iCurrent 5//Changer ici le nb de pts de degats classique
            
SetLocalInt(oWeapon"CUR_HP"iNewTotal);
        }

        if(
DEBUGME == TRUE)
        {
            
int iCURitemHP GetLocalInt(oWeapon"CUR_HP");
            
SendMessageToPC(oAttacker"SETTING NEW HP ");
            
SendMessageToPC(oAttacker"=======================");
            
SendMessageToPC(oAttacker"NEW TOTAL = " IntToString(iCURitemHP));
            
SendMessageToPC(oAttacker"=======================");
        }
    }
}
//------------------------FONCTION AJOUTEE



void DoWeaponBreakage(object oAttackerobject oTargetobject oWeapon)
{
    
int iIsValid GetIsWeaponAmmoReturnable(oWeapon);
    
int iMAXitemHP GetLocalInt(oWeapon"MAX_HP");
    
int iISitemSET GetLocalInt(oWeapon"ITEM_SET");

    if(
DEBUGME == TRUE)
    {
        
SendMessageToPC(oAttacker"HP SETTINGS");
        
SendMessageToPC(oAttacker"=======================");
        
SendMessageToPC(oAttacker"MAX TOTAL  = " IntToString(iMAXitemHP));
        
SendMessageToPC(oAttacker"ITEM SETUP = " IntToString(iISitemSET));
        
SendMessageToPC(oAttacker"=======================");
    }

    if(
iIsValid == TRUE)
    {
        if(
iISitemSET == FALSE)
        {
            
DoSetItemMax(oWeaponoAttacker);

            if(
DEBUGME == TRUE)
            {
                
int iCURitemHP GetLocalInt(oWeapon"CUR_HP");
                
SendMessageToPC(oAttacker"=======================");
                
SendMessageToPC(oAttacker"MAX TOTAL = " IntToString(iMAXitemHP));
                
SendMessageToPC(oAttacker"CUR TOTAL = " IntToString(iCURitemHP));
                
SendMessageToPC(oAttacker"=======================");
            }
        }
        else
        {
            
int iCURitemHP GetLocalInt(oWeapon"CUR_HP");
            
DoCheckMissleReturn(oAttackeroTargetoWeapon);
            
DoWeaponBreakageAdvance(oAttackeroWeaponiCURitemHP);
        }
    }
    else
    {
        if(
iISitemSET == FALSE)
        {
            
DoSetItemMax(oWeaponoAttacker);
        }
        else
        {
            
int iCURitemHP GetLocalInt(oWeapon"CUR_HP");
            
DoWeaponBreakageAdvance(oAttackeroWeaponiCURitemHP);

            if(
DEBUGME == TRUE)
            {
                
int iCURitemHP GetLocalInt(oWeapon"CUR_HP");
                
SendMessageToPC(oAttacker"ITEM = " GetName(oWeapon));
                
SendMessageToPC(oAttacker"=======================");
                
SendMessageToPC(oAttacker"CUR TOTAL = " IntToString(iCURitemHP));
                
SendMessageToPC(oAttacker"=======================");
            }
        }
    }
}

void DoArmorItemBreakage(object oAttackerobject oTarget)
{
    
int iBeenDamaged GetLocalInt(oAttacker"LAST_HP");
    
int iCurrent GetCurrentHitPoints(oAttacker);


//En commentant les lignes ci-dessous, la fonction marche bien mieux.
    //if(iCurrent < iBeenDamaged)   //Je capte pas trop ce que ca veut dire, souvent le script
    //{                             //S'arrete la, ce qui diminue les degats sur les armures/items
        
int nSlot Random(17);

        
object oItem=GetItemInSlot(nSlotoAttacker);
//Si nSlot n'est pas equipe, le script s'arrete, donc c'est au builder de voir :
//Ca parait logique de pouvoir taper sur un endroit ou il n'y a pas d'objets et ainsi
//ne pas faire de degats aux objets equipes.
//MAIS en comparaison des degats recus par les armes c'est de la gnognotte.
//D'ou la creation de la fonction DoArmorBreakageAdvance qui permet de parametrer
//differemment les degats recu par les objets puisqu'ils sont bcp moins souvent
//touches autant leur faire mal quand ils le sont.
        
if (GetIsObjectValid(oItem))
        {

            
int iMAXitemHP GetLocalInt(oItem"MAX_HP");
            
int iISitemSET GetLocalInt(oItem"ITEM_SET");

            if(
iISitemSET == FALSE)
            {
                
DoSetItemMax(oItemoAttacker);

                if(
DEBUGME == TRUE)
                {
                    
int iCURitemHP GetLocalInt(oItem"CUR_HP");
                    
SendMessageToPC(oAttacker"ITEM = " GetName(oItem));
                    
SendMessageToPC(oAttacker"=======================");
                    
SendMessageToPC(oAttacker"CUR TOTAL = " IntToString(iCURitemHP));
                    
SendMessageToPC(oAttacker"=======================");
                }
            }
            else
            {
                
int iCURitemHP GetLocalInt(oItem"CUR_HP");
                
DoArmorBreakageAdvance(oAttackeroItemiCURitemHP);

                if(
DEBUGME == TRUE)
                {
                    
int iCURitemHP GetLocalInt(oItem"CUR_HP");
                    
SendMessageToPC(oAttacker"ITEM = " GetName(oItem));
                    
SendMessageToPC(oAttacker"=======================");
                    
SendMessageToPC(oAttacker"MAX TOTAL = " IntToString(iMAXitemHP));
                    
SendMessageToPC(oAttacker"CUR TOTAL = " IntToString(iCURitemHP));
                    
SendMessageToPC(oAttacker"=======================");
                }


                }

    
// }
    
}

    
// SET PC's HitPoints to CurrentLevel to check at next EOR
    
SetLocalInt(oAttacker"LAST_HP"iCurrent);


Voilà, c'est testé ça fonctionne avec NWN+SoU+HotU v1.61 et au delà à priori, ça peut être pas mal de le rajouter aux persistants

EDIT pour petite maj et rajout de commentaires.
NOTE: Les variables locales des objets d'inventaire sont sauvegardées avec l'objet et le personnage. Donc l'arme reste théoriquement dans l'état même après une déconnexion ou un reboot du serveur.
J'aime pas trop faire ma pub d'habitude, mais le système du scripts valprofond utilise déjà une usure des armes/armures (et autres objets d'équipement), ainsi que leur possibilité de réparation (en utilisant les dons HotU)

Un module de démo du système se trouve à cette adresse (ainsi que les différents Hak, override et TLK nécessaires à son fonctionnement):

Système Valprofond

Je n'ai pas encore écrit d'aide (mis à part les quelques infos dans les scripts), mais si vous voulez tester l'usure et la réparation des objets, faites comme suit:

- En entrant sur le module, ouvrez le coffre et prenez le marteau de forgeron
- Allez sur la droite entre les murs de pierre (il y a un spawn de créatures), et combattez les (pour abimer un peu vos objets).
- Lorsqu'un de vos objet est abimé (pour le savoir il suffit de le ramasser ou l'équiper), allez à la forge.
- Déposez l'objet à réparer dedans.
- Equipez le marteau de forgeron et frappez l'enclume.

Si vous voulez plus d'infos, n'hésitez pas à venir nous rendre visite sur notre site:
http://www.nightsofneverwinter.com/fr/
Répondre

Connectés sur ce fil

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