J'exhume ce fil pour confirmer que tout fonctionne parfaitement bien. J'ai même réussi à autoriser ma chevaucheuse à utiliser les arcs SAUF les arcs composites et à porter des cottes de mailles elfiques MAIS PAS de cottes de mailles classiques.
Mais plus fort et plus facile : pour tous ceux qui voudraient moder avec les versions EE, c'est beaucoup plus simple et on n'est plus obligé de bidouiller les codes d'interdiction. Il suffit de patcher les objets concernés avec le nouvel effet #319 en utilisant la valeur du kit pour le paramètre 1 et 9 pour le paramètre 2.
#319 (0x13F) Usability: Item Usability
Parameter #1: IDS Entry
Parameter #2: IDS File
Special: Description note
Description:
This effect restricts the item to creature(s) matching the object identifiers. The string to display when an invalid creature attempts to use the item is held in 0x2c.
Known values for 'IDS File' are:
2 EA.ids
3 General.ids
4 Race.ids
5 Class.ids
6 Specific.ids
7 Gender.ids
8 Align.ids
9 Kit.ids
10 Actor's name
11 Actor's scripting name (8 maximum in resource field)
If 'IDS File' is set to 10, the item is restricted to characters with the name specified by the strref held in parameter1.
If 'IDS File' is set to 11, the item is restricted to characters with the death variable specified by the resource field.
The message defined in 'Description note' will be displayed whenever this effect is triggered.
Ce qui donne pour les armures légères :
Code : Tout sélectionner
COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
READ_BYTE 0x18 flags1
PATCH_IF ((flags1 & BIT3) = BIT3) BEGIN // Movable, otherwise useless.
READ_BYTE 0x29 kit_usability1
READ_BYTE 0x2b kit_usability2
READ_ASCII 0x22 animation (2)
READ_BYTE 0x31 item_prof // Weapon Proficiency
// Armure de cuir, Besantine et Cuirasse (Leather, Studded, Hide) : Chevalier de Diamant can't wear them.
// ------------------------------------------------------------------------------------------------------
[color="#FFFF00"]PATCH_IF ("%animation%" STRING_EQUAL_CASE "2A") BEGIN // 2A = Animations des armures de cuir[/color]
PATCH_IF GW_EE BEGIN // GW_EE = variable définie auparavant indiquant que le jeu est EE
LPF ~GW_ITEM_RESTRICT_USABILITY_BGEE~ STR_VAR GW_restrict = "GW_DIAMOND_KNIGHT" GW_kind = "KIT" GW_mess319 = 7700002 END // @7700002 = ~Chevalier de Diamant~
END ELSE BEGIN // Sinon, ce n'est pas une version EE
PATCH_IF ((kit_usability1 & BIT4) = 0) BEGIN // CD : if usable by shapeshifters
WRITE_BYTE 0x29 THIS | BIT4 // remove shapeshifters flag
END
END
END
...
avec la fonction GW_ITEM_RESTRICT_USABILITY_BGEE définie avant de lancer la procédure pour éviter d'aller chercher la valeur du kit.
Code : Tout sélectionner
/* =============================================================================================================== *
* FONCTION GW_ITEM_RESTRICT_USABILITY_BGEE : INTERDIT l'UTILISATION d'UN OBJET à un type de créature dans BG2EE. *
* --------------------------------------------------------------------------------------------------------------- *
* #319 Usability: Item Usability : This effect restricts the item to creature(s) matching the object identifiers. *
* The string to display in the description note is held in 0x2c. *
* =============================================================================================================== */
DEFINE_PATCH_FUNCTION ~GW_ITEM_RESTRICT_USABILITY_BGEE~
STR_VAR GW_restrict = "" // HUMAN, MALE, CAVALIER... Or string defining Actor's name, or scripting name (8 maximum length).
GW_kind = "" // IDS file : EA, General, Race, class, Specific, Gender, Align, Kit. OR Name (Actor's name), script_name (Actor's scripting name).
GW_mess319 = 0 // Description note (special field)
BEGIN
PATCH_IF (ENGINE_IS ~bgee bg2ee eet~) OR GAME_INCLUDES ~sod~ BEGIN
SET GW_param2 = 0
SET GW_special319 = 0
SPRINT GW_resource319 ""
PATCH_IF ("%GW_restrict%" STR_CMP ~~) AND ("%GW_kind%" STR_CMP ~~) BEGIN
// IDS files case : EA, General, Race, class, Specific, Gender, Align, Kit.
// --------------
PATCH_IF ("%GW_kind%" STRING_COMPARE_CASE ~NAME~) AND ("%GW_kind%" STRING_COMPARE_CASE ~SCRIPT_NAME~) BEGIN
PATCH_IF FILE_EXISTS_IN_GAME ~%GW_kind%.ids~ BEGIN
SET GW_param1 = IDS_OF_SYMBOL (~%GW_kind%~ ~%GW_restrict%~)
PATCH_IF (GW_param1 != "-1") BEGIN // IDS_OF_SYMBOL returns -1 if GW_restrict is not associated in GW_kind.ids.
PATCH_MATCH ~%GW_kind%~ WITH
EA BEGIN SET GW_param2 = 2 END
GENERAL BEGIN SET GW_param2 = 3 END
RACE BEGIN SET GW_param2 = 4 END
CLASS BEGIN SET GW_param2 = 5 END
SPECIFIC BEGIN SET GW_param2 = 6 END
GENDER BEGIN SET GW_param2 = 7 END
ALIGN BEGIN SET GW_param2 = 8 END
KIT BEGIN SET GW_param2 = 9 END
DEFAULT
END // of PATCH_MATCH ~%GW_kind%~ WITH
END // of PATCH_IF (GW_param1 != "-1")
END // of PATCH_IF FILE_EXISTS_IN_GAME ~%GW_kind%.ids~
END // of PATCH_IF ("%GW_kind%" STRING_COMPARE_CASE ~NAME~) AND ("%GW_kind%" STRING_COMPARE_CASE ~SCRIPT_NAME~)
// Actor's name case : If 'IDS File' is set to 10, the item is restricted to characters with the name specified by the strref held in parameter1.
// -----------------
PATCH_IF ("%GW_kind%" STRING_COMPARE_CASE ~NAME~ = 0) BEGIN
SET GW_param2 = 10
PATCH_IF (STRING_LENGTH "%GW_restrict%" > 6) BEGIN // La première donnée du fichier tra est @8000001
SET GW_param1 = RESOLVE_STR_REF ((AT %GW_restrict%))
END ELSE BEGIN // Sinon, on va chercher la référence dans le fichier dialog.tlk
SET GW_param1 = EVAL "%GW_restrict%"
END
END // of PATCH_IF ("%GW_kind%" STRING_COMPARE_CASE ~NAME~ = 0)
// Actor's scripting name case : If 'IDS File' is set to 11, the item is restricted to characters with the death variable specified by the resource field.
// ---------------------------
PATCH_IF ("%GW_kind%" STRING_COMPARE_CASE ~SCRIPT_NAME~ = 0) BEGIN
SET GW_param1 = 0
PATCH_IF (STRING_LENGTH "%GW_restrict%" < 9) BEGIN // 8 caracters maximum in resource field
SPRINT GW_resource319 EVAL "%GW_restrict%"
SET GW_param2 = 11
END
END // of PATCH_IF ("%GW_kind%" STRING_COMPARE_CASE ~SCRIPT_NAME~ = 0)
// Description note.
// -----------------
PATCH_IF (STRING_LENGTH "%GW_mess319%" > 6) BEGIN // La première donnée du fichier tra est @8000001
SET GW_special319 = RESOLVE_STR_REF ((AT %GW_mess319%))
END ELSE BEGIN // Sinon, on va chercher la référence dans le fichier dialog.tlk
SET GW_special319 = EVAL "%GW_mess319%"
END
// Adds Effect #319 Usability: Item Usability if needed.
// -----------------------------------------------------
PATCH_IF (GW_param2 > 0) BEGIN
LPF ~ADD_ITEM_EQEFFECT~ INT_VAR opcode = 319 target = 1 timing = 2 parameter1 = EVAL "%GW_param1%" parameter2 = EVAL "%GW_param2%" special = EVAL "%GW_special319%" STR_VAR resource = EVAL "%GW_resource319%" END
END // of PATCH_IF (GW_param2 > 0)
END // of PATCH_IF ("%GW_restrict%" STR_CMP ~~) AND ("%GW_kind%" STR_CMP ~~)
END // of PATCH_IF (ENGINE_IS ~bgee bg2ee eet~) OR GAME_INCLUDES ~sod~
END // of DEFINE_PATCH_FUNCTION
Sans cette fonction, il suffit de remplacer dans le premier code
Code : Tout sélectionner
LPF ~GW_ITEM_RESTRICT_USABILITY_BGEE~ STR_VAR GW_restrict = "GW_DIAMOND_KNIGHT" GW_kind = "KIT" GW_mess319 = 7700002 END
par
Code : Tout sélectionner
LPF ~ADD_ITEM_EQEFFECT~ INT_VAR opcode = 319 target = 1 timing = 2 parameter1 = IDS_OF_SYMBOL (~kit~ ~GW_DIAMOND_KNIGHT~) parameter2 = 9 special = RESOLVE_STR_REF (@7700002) STR_VAR resource = EVAL "%DEST_RES%" END
Je l'ai définie car je l'utilise pour d'autres manips.