Jump to content

Using FOR/WHILE loops 'outside' of patch commands


Recommended Posts

For a private, for-fun Nymph kit (that will not have a public release), I designed an innate ability called "Kiss of Death". The ability creates a magical weapon that causes 4 damage per level of the Nymph with a save vs. breath for half. I didn't want to create 40 items manually or by 40 seperate patch commands (call me lazy... or efficient ). I wanted to use a FOR loop to create the items for me. But... WeiDU will not allow a FOR or WHILE loop outside of a patch-type command. So... I created this workaround (which saves time and decreases tp2 size):

 

COPY ~Nymph/WLKISSD.ITM~ ~override/WLKISSD.ITM~

FOR ( index = 1 ; index < 41 ; index = index + 1 ) BEGIN

  INNER_ACTION BEGIN

  COPY ~Nymph/WLKISSD.ITM~ ~override/WLKISS%index%.ITM~

    SAY NAME2 @3

    WRITE_LONG 0xAE ("%index%" * 2)

    WRITE_LONG 0xDE ("%index%" * 2)

  END // INNER_ACTION

END // FOR

 

The first copy command is meaningless: it simply copies the item template into the override directory.

 

Skilled modders can figure out the rest without a lengthy explanation from me.

 

Do I get bonus points from Japeth for finding a way to use INNER_ACTION BEGIN in my mod?

 

a Wounded Lion

Link to comment
For a private, for-fun Nymph kit (that will not have a public release), I designed an innate ability called "Kiss of Death".  The ability creates a magical weapon that causes 4 damage per level of the Nymph with a save vs. breath for half.  I didn't want to create 40 items manually or by 40 seperate patch commands (call me lazy... or efficient  ).  I wanted to use a FOR loop to create the items for me.  But... WeiDU will not allow a FOR or WHILE loop outside of a patch-type command.  So... I created this workaround (which saves time and decreases tp2 size):

 

COPY ~Nymph/WLKISSD.ITM~ ~override/WLKISSD.ITM~

FOR ( index = 1 ; index < 41 ; index = index + 1 ) BEGIN

  INNER_ACTION BEGIN

  COPY ~Nymph/WLKISSD.ITM~ ~override/WLKISS%index%.ITM~

    SAY NAME2 @3

    WRITE_LONG 0xAE ("%index%" * 2)

    WRITE_LONG 0xDE ("%index%" * 2)

  END // INNER_ACTION

END // FOR

 

The first copy command is meaningless: it simply copies the item template into the override directory.

 

Skilled modders can figure out the rest without a lengthy explanation from me.

 

Do I get bonus points from Japeth for finding a way to use INNER_ACTION BEGIN in my mod?

 

a Wounded Lion

The bonus points have been taken by Ghreyfain (he was the first to release a mod with INNER_*, while to truth I have been the first to have used INNER_* in development-time.

 

Anyway, I could try to code some kind of OUTER_FOR command, but you'd have to be careful to use only SET, SPRINT, INNER_*, FOR and variants... But you could just use your COPY workaround.

Note on style: to avoid serious problems, you'd better use

COPY_EXISTING ~sw1h01.itm~ ~override~
 DO_YOUR_STUFF
BUT_ONLY_IF_IT_CHANGES

as your dummy copy.

Link to comment
Because when doing this you should always copy a file that is in no way related to ones you're dealing with (accidental changes in one part of the code might have bad effects on subsequent parts, and so on.

 

Interesting. I suppose you might be right. Though no actual changes are made to the template... Anyway, thank you for the advice.

 

In truth, my technique is useful in only a relatively small number of situations (usually kit components). I thought I'd share just in case someone else needed just such a technique.

 

a W.L.

Link to comment

Archived

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

×
×
  • Create New...