Page 1 sur 1

INT_VAR, STR_VAR, je n'y comprend rien

Posté : jeu. 04 déc. 2025, 21:45
par deratiseur
j'ai écris ce code fonctionnant à l'aide d'une fonction fournie par subtledoctor :

Code : Tout sélectionner

LAF RES_NUM_OF_SPELL_NAME
STR_VAR spell_name = ~WIZARD_PX_PURGE_OF_MAGIC~
RET spell_res
END
COPY_EXISTING	~%spell_res%.spl~ 					~Derats_Magasin_2/TempDir/pxl2cd34.spl~	WRITE_SHORT 0x1c 2 WRITE_LONG 0x1e BIT30
ADD_SPELL ~Derats_Magasin_2/TempDir/pxl2cd34.spl~ 1 7 DRUIDIC_PX_PURGE_OF_MAGIC
LAF action_add_hla STR_VAR kit_name = ~CLERIC~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~FIGHTER_CLERIC~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~CLERIC_MAGE~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~CLERIC_THIEF~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~FIGHTER_MAGE_CLERIC~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~CLERIC_RANGER~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~GODTALOS~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~GODHELM~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~GODLATHANDER~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~OHTYR~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
LAF action_add_hla STR_VAR kit_name = ~OHTEMPUS~ ability = ~GA_pxl2cd34~ num_allowed = ~1~ END
Je dois la répéter 8 fois et je la trouve longue, ça va faire un paquet de lignes. je voudrais donc ne les écrire qu'une fois dans un "DEFINE_PATCH_FUNCTION" puis l'appeler en indiquant à chaque fois le nouveau sort.

J'ai écris ça :

Code : Tout sélectionner

DEFINE_PATCH_FUNCTION Cleric_hla
  STR_VAR
  Spell = ~~
 BEGIN
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~CLERIC~  num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~FIGHTER_CLERIC~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~CLERIC_MAGE~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~CLERIC_THIEF~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~FIGHTER_MAGE_CLERIC~  num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~CLERIC_RANGER~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~GODTALOS~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~GODHELM~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~GODLATHANDER~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~OHTYR~ num_allowed = ~1~ END
LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~OHTEMPUS~ num_allowed = ~1~ END
END

LAF RES_NUM_OF_SPELL_NAME
STR_VAR spell_name = ~WIZARD_PX_MASS_RAGE~
RET spell_res
END
COPY_EXISTING	~%spell_res%.spl~ 					~Derats_Magasin_2/TempDir/pxl2cd35.spl~	WRITE_SHORT 0x1c 2 WRITE_LONG 0x1e BIT31
ADD_SPELL ~Derats_Magasin_2/TempDir/pxl2cd34.spl~ 1 7 CLERIC_PX_MASS_RAGE
LPF Cleric_hla STR_VAR spell = ~pxl2cd34~ END
Sauf que c'est totalement foireux, weidu bloque sur la première ligne "LAF action_add_hla INT_VAR ability = ~%spell%~ STR_VAR kit_name = ~CLERIC~ num_allowed = ~1~ END"

Comme je m'en doutais un peu parce que même en copiant dans les autres mods je suis toujours autant une quiche, est ce que quelq'un pourrait m'aider svp ?

Note : et encore, ce code limite l'ajout du nouveau hla à tous les kits de pretre vanilla. Je cherche depuis deux jours à faire qu'il soit ajouté à TOUS les kits de pretre (y compris de mods), mais ça aussi je n'y arrive pas. Mais c'est un autre sujet.

Re: INT_VAR, STR_VAR, je n'y comprend rien

Posté : jeu. 04 déc. 2025, 23:02
par Selphira
Quelque chose comme ceci ?

Code : Tout sélectionner

DEFINE_PATCH_FUNCTION Cleric_hla
   STR_VAR Spell = ~~
BEGIN
   LAF action_add_hla STR_VAR kit_name = ~CLERIC~ ability = ~%spell%~  num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~FIGHTER_CLERIC~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~CLERIC_MAGE~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~CLERIC_THIEF~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~FIGHTER_MAGE_CLERIC~ ability = ~%spell%~  num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~CLERIC_RANGER~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~GODTALOS~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~GODHELM~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~GODLATHANDER~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~OHTYR~ ability = ~%spell%~ num_allowed = ~1~ END
   LAF action_add_hla STR_VAR kit_name = ~OHTEMPUS~ ability = ~%spell%~ num_allowed = ~1~ END
END

Re: INT_VAR, STR_VAR, je n'y comprend rien

Posté : ven. 05 déc. 2025, 17:04
par deratiseur
Merci de ta réponse

Ca c'est que j'ai essayé en premier, sachant que le code "non eval" est :

Code : Tout sélectionner

LAF action_add_hla STR_VAR kit_name = ~CLERIC~ ability = ~GA_pxl2cd32~ num_allowed = ~1~ END
j'ai simplement remplacé GA_pxl2cd32 par %spell% comme dans ton exemple. Mais ça refuse de s’installer, ça plante à la première ligne du bloc :

Code : Tout sélectionner

LAF action_add_hla STR_VAR kit_name = ~CLERIC~ ability = ~%spell%~  num_allowed = ~1~ END
avec ça :

Code : Tout sélectionner

[Derats_Magasin_2/Scripts/Cleric_EEex.tph]  ERROR at line 108 column 1-6
Near Text: LAF
	Parsing.Parse_error
ERROR: parsing [Derats_Magasin_2/Scripts/Cleric_EEex.tph]: Parsing.Parse_error

Re: INT_VAR, STR_VAR, je n'y comprend rien

Posté : ven. 05 déc. 2025, 18:02
par Selphira
Si l'argument n'est pas évalué, c'est que tu n'as pas le AUTO_EVAL_STRINGS dans ton tp2.

Dans ce cas, il faut ajouter manuellement le EVAL avant la variable, comme ceci

Code : Tout sélectionner

LAF action_add_hla STR_VAR kit_name = ~CLERIC~ ability = EVAL ~%spell%~ num_allowed = ~1~ END
Par contre, je ne comprends pourquoi tu as une parse_error, pourrais-tu fournir le fichier complet ?

Re: INT_VAR, STR_VAR, je n'y comprend rien

Posté : ven. 05 déc. 2025, 18:55
par deratiseur
Cleric.tph
(12.57 Kio) Téléchargé 20 fois
Toujours pas. Voilà le fichier

Re: INT_VAR, STR_VAR, je n'y comprend rien

Posté : ven. 05 déc. 2025, 20:18
par Selphira
Ah ! Mais tu es dans le contexte d'une ACTION, pas d'un PATCH

Remplace

Code : Tout sélectionner

DEFINE_PATCH_FUNCTION Cleric_hla
par

Code : Tout sélectionner

DEFINE_ACTION_FUNCTION Cleric_hla
Je pense que ça devrait régler le problème

Re: INT_VAR, STR_VAR, je n'y comprend rien

Posté : ven. 05 déc. 2025, 21:18
par deratiseur
OK, merci, ça marche :)