Jump to content

i don't understand the "macros" so i need you


deratiseur

Recommended Posts

Hello again

I'm sorry to disturb you again and again on this time :-/

 

A have partially rewrited my setup.tp2, and use many "COPY_EXISTING and WRITExxx" instead of "COPY" from my directory. So i have many less files in the archive of my mod. This is done (i think)

 

Now, i know that i can win more place by replace another parts of my code, and this is request a bit of macro. but i really don't understand thems. I have look a bit of setups (Druidsor, bg2tweaks....), but that' leave really oscure for me :-/

 

So, this is what i try to replace :

COPY ~Derats_kits/Warlord/Spells/Pxw1exal.spl~ ~override~ SAY NAME1 @713 SAY UNIDENTIFIED_DESC @714

SAY 0x236 @713

SAY 0x326 @713

SAY 0x416 @713

SAY 0x506 @713

SAY 0x5f6 @713

SAY 0x6e6 @713

SAY 0x7d6 @713

SAY 0x8c6 @713

SAY 0x9b6 @713

SAY 0xaa6 @713

This is a specification of what must be at the [#139: display string]on each effect (level) of the spell

 

COPY ~Derats_kits/Flammes/Spells/pxf7boux.spl~ ~override~ SAY NAME1 @271 SAY UNIDENTIFIED_DESC @2721

WRITE_SHORT 0x98 ~%pxf7boul%~

WRITE_SHORT 0xc0 ~%pxf7boul%~

WRITE_SHORT 0xe8 ~%pxf7boul%~

WRITE_SHORT 0x110 ~%pxf7boul%~

WRITE_SHORT 0x138 ~%pxf7boul%~

WRITE_SHORT 0x160 ~%pxf7boul%~

WRITE_SHORT 0x188 ~%pxf7boul%~

 

This is the projectile specified on each effect (level) of the spell

 

And the last one, i have remade many spells for give them negative bonus at each 5 levels after the level 20, from -1 at lvl 25 to -6 at lvl 50. I've remenber that BG2tweak suggest a similar component, so can someone give me a easy way to made this in the setup and so have lighter spells in the archive of my mods ?

Link to comment
COPY ~Derats_kits/Flammes/Spells/pxf7boux.spl~ ~override~ SAY NAME1 @271 SAY UNIDENTIFIED_DESC @2721

WRITE_SHORT 0x98 ~%pxf7boul%~

WRITE_SHORT 0xc0 ~%pxf7boul%~

WRITE_SHORT 0xe8 ~%pxf7boul%~

WRITE_SHORT 0x110 ~%pxf7boul%~

WRITE_SHORT 0x138 ~%pxf7boul%~

WRITE_SHORT 0x160 ~%pxf7boul%~

WRITE_SHORT 0x188 ~%pxf7boul%~

 

This is the projectile specified on each effect (level) of the spell

You can simplify this by setting the projectile as you loop through all of the item's abilities.

 

READ_LONG 0x64 abilities_off
READ_SHORT 0x68 num_abilities
FOR (i = 0; i < num_abilities; i += 1) BEGIN // for each ability
 WRITE_SHORT (abilities_off + 0x28*i + 0x26) pxf7boul
END

 

Also, the unidentified description looks like it might have a typo - @2721 should be @272?

 

COPY ~Derats_kits/Warlord/Spells/Pxw1exal.spl~ ~override~ SAY NAME1 @713 SAY UNIDENTIFIED_DESC @714

SAY 0x236 @713

SAY 0x326 @713

SAY 0x416 @713

SAY 0x506 @713

SAY 0x5f6 @713

SAY 0x6e6 @713

SAY 0x7d6 @713

SAY 0x8c6 @713

SAY 0x9b6 @713

SAY 0xaa6 @713

This is a specification of what must be at the [#139: display string]on each effect (level) of the spell

You can loop through all of the effects in the file and patch the ones that use opcode 139 like this:

 

READ_LONG 0x64 abilities_off
READ_SHORT 0x68 num_abilities
READ_LONG 0x6a effects_off
FOR (i = 0; i < num_abilities; i += 1) BEGIN // for each ability
 READ_SHORT (abilities_off + 0x28*i + 0x1e) num_effects
 READ_SHORT (abilities_off + 0x28*i + 0x20) effects_ind
 FOR (j = 0; j < num_effects; j += 1) BEGIN // for each of the ability's effects
READ_SHORT (effects_off + 0x30*(effects_ind + j)) opcode
PATCH_IF (opcode == 139) BEGIN // if the effect uses opcode 139 (display string)
  SAY (effects_off + 0x30*(effects_ind + j) + 0x04) @713
END
 END
END

Link to comment
READ_LONG 0x64 abilities_off
READ_SHORT 0x68 num_abilities
READ_LONG 0x6a effects_off
FOR (i = 0; i < num_abilities; i += 1) BEGIN // for each ability
 READ_SHORT (abilities_off + 0x28*i + 0x1e) num_effects
 READ_SHORT (abilities_off + 0x28*i + 0x20) effects_ind
 FOR (j = 0; j < num_effects; j += 1) BEGIN // for each of the ability's effects
READ_SHORT (effects_off + 0x30*(effects_ind + j)) opcode
PATCH_IF (opcode == 139) BEGIN // if the effect uses opcode 139 (display string)
  SAY (effects_off + 0x30*(effects_ind + j) + 0x04) @713
END
 END
END

 

Hu.... The solution seems to be more long than the original text ^^

 

 

Also, the unidentified description looks like it might have a typo - @2721 should be @272?

 

Thanks for your answer, and thanks for your advice :mad:

 

No, there's no typo error.

The normal spell have @271 et @272. It can be replaced by another one, more powerful, by taking an hla, and the alternate one have the same name, but no the same description, so it have @272 and @2721.

 

Have a good day :beer:

Link to comment

I don't really understand this, you assemble a spell manually? (i mean using weidu).

 

Why don't just edit the spell itself?

As far as i see it is your own creation.

 

If you have two spells, prepare both.

Reduce weidu hackery to strings, that is probably faster and more reliable than creating long scripts with lots of offsets.

Link to comment
I don't really understand this, you assemble a spell manually? (i mean using weidu).

 

Why don't just edit the spell itself?

As far as i see it is your own creation.

He can't know what value will be assigned to the new projectile he's adding before install-time... the same goes with the reference to his (presumably new) string.

 

Reduce weidu hackery to strings, that is probably faster and more reliable than creating long scripts with lots of offsets.

I don't follow... are you suggesting to stick with the original method of writing to hardcoded offsets or something else entirely?

Link to comment

Ahh, i see, that is a projectile number that may change.

 

 

>I don't follow... are you suggesting to stick with the original method of writing to hardcoded offsets or something else entirely?

 

No, loops that calculate offsets are better than separate lines of hardcoded offsets.

I just didn't know why all this hackery was needed.

I guess weidu updates projectl.ids now.

 

The best would be however a built in function in weidu that sets all projectiles :mad:

Anyway, that is totally out of the scope of my original question.

I just didn't notice he writes a dynamic short value.

Link to comment
I don't follow...
Nor do I... but anyway...

When ever I hear the word "Macro" mentioned in the WeiDU .tp2 coding, I associate it with the DEFINE_PATCH_MACRO command, in where we first make a function that patches a file, like this:

DEFINE_PATCH_MACRO ~error_finding~ BEGIN //inner action that really doesn't matter what it does
 PATCH_IF ("%SOURCE_SIZE%" > "0x71") BEGIN
SET x = 0 - 1
DECOMPILE_BCS_TO_BAF
	REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN
					x += 1
			END "\1
	ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~))"
COMPILE_BAF_TO_BCS
 END
END

And then we execute it to a list of files like this:

COPY_EXISTING ~IJ#dog.bcs~ ~override~ 
 LAUNCH_PATCH_MACRO ~error_finding~
COPY_EXISTING ~ar0602.bcs~ ~override~ 
 LAUNCH_PATCH_MACRO ~error_finding~
COPY_EXISTING ~ar1513.bcs~ ~override~ 
 LAUNCH_PATCH_MACRO ~error_finding~
COPY_EXISTING ~ar2900.bcs~ ~override~ 
 LAUNCH_PATCH_MACRO ~error_finding~
COPY_EXISTING ~Baldur.bcs~ ~override~ 
 LAUNCH_PATCH_MACRO ~error_finding~

Yes, of course that could have been done with less lines too, but this was copied from an existing function/solution... and I have no idea even if or not it even works, but anyway.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...