Jump to content
Sign in to follow this  

Recommended Posts

In <<this thread>> we were tracing ways of adding in install choices for players. in the meantime, the bigg has come up with some new WeiDU possibilities that allow some interesting ways of "swinging" code into separate branches based on setting/reading variables and matching against their values. Basically, the same kind of thinking that PATCH_IF statements use, but on a larger scale. Never one to do something and let it just sit, let's recast the player choices on install using this new method. He has a bunch of these new commands that might be interesting to heavy coders, but for gadabouts like me, ACTION_MATCH is the simplest to understand and shows basically what he is allowing in various forms by supporting this kind of code behavior.

 

note: Doing this is fun for me, but in this particular case it is hitting a fly with an ICBM. I suspect other code which relies on massive internal checking and patching based on a whole series of variables could be cleaned up using this kind of construction, done better - the code below is very clunky and linear, and does not take advantage of the heaviest potential gains, where separate 'building blocks" could be swapped in based on multiple matches or "guarding conditions" or whatever the big Boyz and Girlz use for terminology. Basically, stuff like

 

IF (A) AND (NOT B) AND © AND (D) AND (NOT E)

IF (NOT A) AND (NOT B) AND © AND (D) AND (NOT E)

IF (NOT A) AND (B) AND © AND (NOT D) AND (NOT E)

 

etc. etc. can be set up with a series of individual matched blocks of code, and put into play that way rather than creating a whole series of individual 'cases'.

 

The end Result of This As Applied To Aran

 

CODE

BEGIN ~Aran Whitehand, "No Choices Wanted" (Fighter)~

FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~

REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~

 

OUTER_SET class_choice = 5

LAUNCH_ACTION_MACRO customized_cre_choice

ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre file

COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~

WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start

WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */

WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */

WRITE_ASCII 0x248 ~C-ARN25~ #8 /* override script */

END

 

BEGIN ~Aran Whitehand, Mage Dual-Class stats configuration (Tinker)~

FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~

REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~

 

OUTER_SET class_choice = 1

LAUNCH_ACTION_MACRO customized_cre_choice

ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre file

COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~

WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start

WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */

WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */

WRITE_ASCII 0x248 ~C-ARN25~ #8 /* override script */

END

 

BEGIN ~Aran Whitehand, Cleric Dual-Class stats configuration (Tailor)~

FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~

REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~

 

OUTER_SET class_choice = 2

LAUNCH_ACTION_MACRO customized_cre_choice

ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre file

COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~

WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start

WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */

WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */

WRITE_ASCII 0x248 ~C-ARN25~ #8 /* override script */

END

 

BEGIN ~Aran Whitehand, Fighter stats configuration (Soldier)~

FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~

REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~

 

OUTER_SET class_choice = 3

LAUNCH_ACTION_MACRO customized_cre_choice

ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre file

COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~

WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start

WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */

WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */

WRITE_ASCII 0x248 ~C-ARN25~ #8 /* override script */

END

 

BEGIN ~Aran Whitehand, Thief Dual-Class stats configuration (Spy)~

FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~

REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~

 

OUTER_SET class_choice = 4

LAUNCH_ACTION_MACRO customized_cre_choice

ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre file

COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~

WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start

WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */

WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */

WRITE_ASCII 0x248 ~C-ARN25~ #8 /* override script */

END

 

 

For an "allow me to choose" subcomponent,

post-844-1292689645_thumb.png

 

or we let players just skip all the crap:

 

post-844-1292691479_thumb.png

 

 

ACTION_READLN and Other Macros as Building Blocks

 

Instead of the code in the previous thread, first we pull everything we can out into discreet blocks and turn them into "get information from the user" macros and "work on the .cre" macros. That allows us to individualize the class choice ones, change the order, and most of all get everything set up, then copy the .cre once and apply all the changes in one swoop.

 

CODE

DEFINE_ACTION_MACRO aran_wealth_selection BEGIN

OUTER_FOR( aran_wealth = 0; ~%aran_wealth%~ STRING_COMPARE_REGEXP ~^[123]$~; )BEGIN

PRINT ~Please choose from the following choices to modify starting armor and weapons available to him:

[1] Aran is down-and-out poor and has sold off most of his good equipment.

[2] Aran has kept most of his good gear.

[3] Aran has kept the best gear available to a successful mercenary.

 

Please select 1, 2, or 3 and press enter.~

ACTION_READLN aran_wealth

END

END

 

DEFINE_ACTION_MACRO aran_armor_choice BEGIN

OUTER_FOR( aran_armor_choice = 0; ~%aran_armor_choice%~ STRING_COMPARE_REGEXP ~^[12345]$~; )BEGIN

PRINT ~Please choose from the following starting armor choices for Aran:

[1] Leather

[2] Studded Leather

[3] Chain

[4] Splint

[5] Plate

 

Please select 1, 2, 3, 4, or 5 and press enter.~

ACTION_READLN aran_armor_choice

END

END

 

DEFINE_ACTION_MACRO aran_mage_choice BEGIN

OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[123]$~; )BEGIN // one way of setting up for READLN

PRINT ~You are probably going to Dual-Class Aran to Mage. He currently has proficiencies as follows:

** Long Sword

** Quarterstaff

** Dagger

 

Please choose from the following starting weapon choices and press enter:

[1] Long Sword, Shield, Dagger

[2] Long Sword, Shield, Quarterstaff

[3] Long Sword, Shield, Potions of healing~

ACTION_READLN ~weapon_choices~

END

END

 

DEFINE_ACTION_MACRO aran_cleric_choice BEGIN

OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[1234]$~; )BEGIN // one way of setting up for READLN

PRINT ~You are probably going to Dual-Class Aran to Cleric. He currently has proficiencies as follows:

* Long Sword

* Hammer

* Mace

* Flail

** Sword and Shield Style

 

Please choose from the following starting weapon choices:

[1] Long Sword, Shield, Mace

[2] Long Sword, Shield, Quarterstaff

[3] Long Sword, Shield, Hammer

[4] Long Sword, Shield, Flail~

ACTION_READLN ~weapon_choices~

END

END

 

DEFINE_ACTION_MACRO aran_fighter_choice BEGIN

OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[123456]$~; )BEGIN // one way of setting up for READLN

PRINT ~You are probably going to leave Aran as a fighter. He currently has proficiencies as follows:

** Long Sword

** Bastard Sword

* Long Bow

* Sword and Shield

 

Please choose from the following starting weapon choices:

[1] Long Sword, Shield, Dagger

[2] Long Sword, Shield, Long Bow

[3] Long Sword, Shield, Potions of healing

[4] Bastard Sword, Shield, Dagger

[5] Bastard Sword, Shield, Long Bow

[6] Long Sword, Shield, Hammer~

ACTION_READLN ~weapon_choices~

END

END

 

DEFINE_ACTION_MACRO aran_thief_choice BEGIN

OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[12345]$~; )BEGIN // one way of setting up for READLN

PRINT ~You are probably going to Dual-Class Aran as a Thief. He currently has proficiencies as follows:

** Long Sword

** Short Sword

* Dagger

* Crossbow

 

Please choose from the following starting weapon choices:

[1] Long Sword, Shield, Dagger

[2] Long Sword, Shield, Crossbow

[3] Long Sword, Shield, Potions of healing

[4] Short Sword, Shield, Dagger

[5] Short Sword, Shield, Crossbow~

ACTION_READLN ~weapon_choices~

END

END

 

 

Now, we have user choices defined, and we can apply them in a new macro, customized_cre_choice. Here, we are looking to "swing" the code into different branches based on the class, chosen, because we are working with two unique building blocks. While wealth and armor are the same for each, we need to bring a different base .cre into play, and the proficiency set (and weapons choices) vary by the base .cre chosen. So we need to

 

a. look at what the player chose,

b. swing a block of code temporarily down an alternate track based on that

c. remind the player what they chose (and list it in the .DEBUG for troubleshooting)

d. then bring everything back to order.

 

So,

 

CODE

ACTION_MATCH ~var~

WITH

1

BEGIN

<<do case 1 >>

END

2

BEGIN

<<or else do case 2 >>

END

DEFAULT

<<or if neither 11 nor 2, then do case 3/default actions >>

END

 

 

In Aran's implementation (tested and works; horribly clumsy though), instead of talking I commented stuff:

CODE

 

/* Installing one of the 5 forced subcomponents does OUTER_SET class_choice = 1 or 2 or 3 or 4 or 5 (5 = no player choices wanted). */

DEFINE_ACTION_MACRO customized_cre_choice BEGIN // define the instruction set to be called in other places

ACTION_MATCH ~%class_choice%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

1 // the first check. If %class_choice% = 1, the next stuff will work, else check the next

BEGIN /* mage dual-class build */

LAUNCH_ACTION_MACRO aran_wealth_selection

LAUNCH_ACTION_MACRO aran_mage_choice

LAUNCH_ACTION_MACRO aran_armor_choice

ACTION_MATCH ~%aran_wealth%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

3

BEGIN

PRINT ~Aran is successful~

END

2

BEGIN

PRINT ~Aran is of average wealth~

END

DEFAULT

PRINT ~Aran is down-and-out poor~

END

ACTION_MATCH ~%aran_armor_choice%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

1

BEGIN

PRINT ~Leather Armor~

END

2

BEGIN

PRINT ~Studded Leather Armor~

END

3

BEGIN

PRINT ~Chain Mail~

END

4

BEGIN

PRINT ~Splint Mail~

END

DEFAULT

PRINT ~Plate Armor~

END

/* we are using READLN values to set a variable - the mod range of possible combos is 1 to 15 inclusive, so we can't just read it directly */

ACTION_MATCH ~%weapon_choices%~ // check this value

WITH // against the following 3 cases, so

1

BEGIN

OUTER_SET ~aran_weapon_set~ = 1 // Long Sword, Shield, Dagger

PRINT ~Long Sword, Shield, Dagger~

PRINT ~~

END

2

BEGIN

OUTER_SET ~aran_weapon_set~ = 2 // Long Sword, Shield, Quarterstaff

PRINT ~Long Sword, Shield, Quarterstaff~

PRINT ~~

END

3

BEGIN

OUTER_SET ~aran_weapon_set~ = 3 // Long Sword, Shield, Potions of healing

PRINT ~Long Sword, Shield, Potions of Healing~

PRINT ~~

END

DEFAULT // this should never run, but as an emergency fallback

OUTER_SET ~aran_weapon_set~ = 6 // Long Sword, Shield, Long Bow

PRINT ~Long Sword, Shield, Long Bow~

PRINT ~~

END

COPY ~aranw/cre/c-arnmge.cre~ ~override/c-aran7.cre~ // copy the base .cre into the game, and

LAUNCH_PATCH_MACRO ~aran_cre_setup~ // patch in player choices using this pre-defined code

END // of dual-to-mage swing

2 // the second check. If %class_choice% = 2, the next stuff will work, else check the next

BEGIN /* cleric dual-class build */

LAUNCH_ACTION_MACRO aran_wealth_selection

LAUNCH_ACTION_MACRO aran_cleric_choice

LAUNCH_ACTION_MACRO aran_armor_choice

ACTION_MATCH ~%aran_wealth%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

3

BEGIN

PRINT ~Aran is successful~

END

2

BEGIN

PRINT ~Aran is of average wealth~

END

DEFAULT

PRINT ~Aran is down-and-out poor~

END

ACTION_MATCH ~%aran_armor_choice%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

1

BEGIN

PRINT ~Leather Armor~

END

2

BEGIN

PRINT ~Studded Leather Armor~

END

3

BEGIN

PRINT ~Chain Mail~

END

4

BEGIN

PRINT ~Splint Mail~

END

DEFAULT

PRINT ~Plate Armor~

END

ACTION_MATCH ~%weapon_choices%~ // check this value

WITH // against the following 3 cases, with 4 or anything else defaulting to a '"standard choice"

1

BEGIN

OUTER_SET ~aran_weapon_set~ = 4 // Long Sword, Shield, Mace

PRINT ~Long Sword, Shield, Mace~

PRINT ~~

END

2

BEGIN

OUTER_SET ~aran_weapon_set~ = 2 // Long Sword, Shield, Quarterstaff

PRINT ~Long Sword, Shield, Mace~

PRINT ~~

END

3

BEGIN

OUTER_SET ~aran_weapon_set~ = 12 // Long Sword, Shield, Hammer

PRINT ~Long Sword, Shield, Mace~

PRINT ~~

END

DEFAULT // this will run on 4, or as an emergency fallback

OUTER_SET ~aran_weapon_set~ = 5 // Long Sword, Shield, Flail

PRINT ~Long Sword, Shield, Flail~

PRINT ~~

END

COPY ~aranw/media/c-arnclr.cre~ ~override/c-aran7.cre~ // the cleric stat L7 .cre

LAUNCH_PATCH_MACRO ~aran_cre_setup~ // patch in player choices using this pre-defined code

END // of dual-to-cleric swing

3 // the third check. If %class_choice% = 3, the next stuff will work, else check the next

BEGIN /* fighter single-class build */

LAUNCH_ACTION_MACRO aran_wealth_selection

LAUNCH_ACTION_MACRO aran_fighter_choice

LAUNCH_ACTION_MACRO aran_armor_choice

ACTION_MATCH ~%aran_wealth%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

3

BEGIN

PRINT ~Aran is successful~

END

2

BEGIN

PRINT ~Aran is of average wealth~

END

DEFAULT

PRINT ~Aran is down-and-out poor~

END

ACTION_MATCH ~%aran_armor_choice%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

1

BEGIN

PRINT ~Leather Armor~

END

2

BEGIN

PRINT ~Studded Leather Armor~

END

3

BEGIN

PRINT ~Chain Mail~

END

4

BEGIN

PRINT ~Splint Mail~

END

DEFAULT

PRINT ~Plate Armor~

END

ACTION_MATCH ~%weapon_choices%~ // check this value

WITH // against the following 3 cases, with 4 or anything else defaulting to a '"standard choice"

1

BEGIN

OUTER_SET ~aran_weapon_set~ = 1 // Long Sword, Shield, Dagger

PRINT ~Long Sword, Shield, Dagger~

PRINT ~~

END

2

BEGIN

OUTER_SET ~aran_weapon_set~ = 6 // Long Sword, Shield, Long Bow

PRINT ~Long Sword, Shield, Long Bow~

PRINT ~~

END

3

BEGIN

OUTER_SET ~aran_weapon_set~ = 3 // Long Sword, Shield, Potions of healing

PRINT ~Long Sword, Shield, Potions of healing~

PRINT ~~

END

4

BEGIN

OUTER_SET ~aran_weapon_set~ = 7 // Bastard Sword, Shield, Dagger

PRINT ~Bastard Sword, Shield, Dagger~

PRINT ~~

END

5

BEGIN

OUTER_SET ~aran_weapon_set~ = 8 // Bastard Sword, Shield, Long Bow

PRINT ~Bastard Sword, Shield, Long Bow~

PRINT ~~

END

DEFAULT // this will run on 6, or as an emergency fallback

OUTER_SET ~aran_weapon_set~ = 12 // Long Sword, Shield, Hammer

PRINT ~Long Sword, Shield, Hammer~

PRINT ~~

END

COPY ~aranw/cre/c-arnftr.cre~ ~override/c-aran7.cre~ // the fighter stat L7 .cre

LAUNCH_PATCH_MACRO ~aran_cre_setup~ // patch in player choices using this pre-defined code

END // of just-a-fighter swing

4 // the second check. If %class_choice% = 4, the next stuff will work, else check the next

BEGIN /* thief dual-class build */

LAUNCH_ACTION_MACRO aran_wealth_selection

LAUNCH_ACTION_MACRO aran_thief_choice

LAUNCH_ACTION_MACRO aran_armor_choice

ACTION_MATCH ~%aran_wealth%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

3

BEGIN

PRINT ~Aran is successful~

END

2

BEGIN

PRINT ~Aran is of average wealth~

END

DEFAULT

PRINT ~Aran is down-and-out poor~

END

ACTION_MATCH ~%aran_armor_choice%~ // the thing we are checking to allow the code to "swing" to variants, the "case"

WITH

1

BEGIN

PRINT ~Leather Armor~

END

2

BEGIN

PRINT ~Studded Leather Armor~

END

3

BEGIN

PRINT ~Chain Mail~

END

4

BEGIN

PRINT ~Splint Mail~

END

DEFAULT

PRINT ~Plate Armor~

END

ACTION_MATCH ~%weapon_choices%~ // check this value

WITH // against the following 3 cases, with 4 or anything else defaulting to a '"standard choice"

1

BEGIN

OUTER_SET ~aran_weapon_set~ = 1 // Long Sword, Shield, Dagger

PRINT ~Long Sword, Shield, Dagger~

PRINT ~~

END

2

BEGIN

OUTER_SET ~aran_weapon_set~ = 9 // Long Sword, Shield, Crossbow

PRINT ~Long Sword, Shield, Crossbow~

PRINT ~~

END

3

BEGIN

OUTER_SET ~aran_weapon_set~ = 3 // Long Sword, Shield, Potions of healing

PRINT ~Long Sword, Shield, Potions of healing~

PRINT ~~

END

4

BEGIN

OUTER_SET ~aran_weapon_set~ = 10 // Short Sword, Shield, Dagger

PRINT ~Short Sword, Shield, Dagger~

PRINT ~~

END

DEFAULT // this will run on 5, or as an emergency fallback

OUTER_SET ~aran_weapon_set~ = 11 // Short Sword, Shield, Crossbow

PRINT ~Short Sword, Shield, Crossbow~

PRINT ~~

END

COPY ~aranw/cre/c-arnthf.cre~ ~override/c-aran7.cre~ // the thief stat L7 .cre

LAUNCH_PATCH_MACRO ~aran_cre_setup~ // patch in player choices using this pre-defined code

END // of dual-to-thief swing

DEFAULT // the fall-through check. If %class_choice% was not 1, 2, 3, or 4, the default code will run

PRINT ~No class choice was chosen... installing Aran's Default (Fighter, moderate wealth, long sword and bow)~

/* Set up the variables for a default .cre so BWP folks don't have to deal with READLN */

OUTER_SET ~aran_wealth~ = 2 // experienced mercenary with some resources

OUTER_SET ~aran_weapon_set~ = 6 // Long Sword, Shield, Long Bow

OUTER_SET ~aran_armor_choice~ = 4 // splint

COPY ~aranw/cre/c-arnftr.cre~ ~override/c-aran7.cre~ // the fighter stat L7 .cre

LAUNCH_PATCH_MACRO ~aran_cre_setup~ // patch in player choices using this pre-defined code

END // of default swing

END // of define action macro

 

 

This usage is interesting to me in that it shows how you can nest both macros and ACTION_MATCH WITH . It is a criminal waste of space to use this for just PRINT materials the way I have; the better usage would be to fully convert the various PATCH_IF statements and that whole pyramid of materials found in aran_cre_setup into a better/tighter logic chain, so that i could do away with SUBCOMPONENT entirely. Using this idea, the whole thing could be built into one component, and we could ask

 

"Default, or choice?"

 

and then if a person chose choice, they could run everything through a single run of code that asked and adjusted for responses. To do this, instead of using

 

LAUNCH_PATCH_MACRO ~aran_cre_setup~

 

the currently unchanged contents of aran_cre_setup's PATCH_IF statements would be integrated into the above.

Edited by cmorgan

Share this post


Link to post

OK, another pass at this, cleaning stuff up.

 

First, a "report the status of vars" feedback for the .DEBUG:

 

DEFINE_ACTION_MACRO ~aran_report_status~ BEGIN
ACTION_MATCH ~%aran_wealth%~
WITH
1
BEGIN
  PRINT ~Aran is down-and-out poor,~ 
END
2
BEGIN
  PRINT ~Aran is of average wealth,~
END
3
BEGIN
  PRINT ~Aran is successful,~
END
DEFAULT
  PRINT ~Something has gone wrong~
END
ACTION_MATCH ~%aran_armor_choice%~
WITH
1
BEGIN
	PRINT ~has Leather Armor,~
END
2
BEGIN
	PRINT ~has Studded Leather Armor,~
END
3
BEGIN
	PRINT ~has Chain Mail,~
END
4
BEGIN
	PRINT ~has Splint Mail,~
END
5
BEGIN
	PRINT ~has Plate Armor,~
END
	DEFAULT
			PRINT ~Something has gone wrong~		
			PRINT ~~
	END
ACTION_MATCH  ~%aran_weapon_set%~ 
	WITH 
	1  
	BEGIN
			PRINT ~carrying Long Sword, Shield, Dagger~
			PRINT ~~
	END
	2
	BEGIN
			PRINT ~carrying Long Sword, Shield, Quarterstaff~
			PRINT ~~
	END
	3
	BEGIN
			PRINT ~carrying Long Sword, Shield, Potions of Healing~
			PRINT ~~
	END
	4
	BEGIN
			PRINT ~carrying Long Sword, Shield, Mace~
			PRINT ~~
	END
	5
	BEGIN
			PRINT ~carrying Long Sword, Shield, Flail~		
			PRINT ~~		
	END
	6
	BEGIN
			PRINT ~carrying Long Sword, Shield, Long Bow~	   
			PRINT ~~		
	END
	7
	BEGIN
			PRINT ~carrying Bastard Sword, Shield, Dagger~		
			PRINT ~~		
	END
	8
	BEGIN
			PRINT ~carrying Bastard Sword, Shield, Long Bow~
			PRINT ~~		
	END
	9
	BEGIN
			PRINT ~carrying Long Sword, Shield, Crossbow~		
			PRINT ~~		
	END
	10
	BEGIN
			PRINT ~carrying Short Sword, Shield, Dagger~		
			PRINT ~~		
	END
	11
	BEGIN
			PRINT ~carrying Short Sword, Shield, Crossbow~		
			PRINT ~~		
	END
	12
	BEGIN
			PRINT ~carrying Long Sword, Shield, Hammer~		
			PRINT ~~		
	END	  
	DEFAULT
			PRINT ~Something has gone wrong~		
			PRINT ~~
	END   

END // of macro definition

Share this post


Link to post

Second, a new all-in-one-pass ACTION_MATCH-using macro that will handle wealth, weapon, and armor, or set the defaults, then report the choices, then patch in the creature (with fail messages if something goes wrong):

 

/* Installing one of the 5 forced subcomponents does OUTER_SET class_choice = 1 or 2 or 3 or 4 or 5 (5 = no player choices wanted). */
DEFINE_ACTION_MACRO customized_cre_choice BEGIN  // define the instruction set to be called in other places
 ACTION_MATCH ~%class_choice%~  // the thing we are checking to allow the code to "swing" to variants, the "case"
 WITH
 1   // the first check. If %class_choice% = 1, the next stuff will work, else check the next
 BEGIN /* mage dual-class build */
OUTER_FOR( aran_wealth = 0; ~%aran_wealth%~ STRING_COMPARE_REGEXP ~^[123]$~; )BEGIN
	PRINT ~Please choose from the following choices to modify starting armor and weapons available to him:
 [1] Aran is down-and-out poor and has sold off most of his good equipment.
 [2] Aran has kept most of his good gear.
 [3] Aran has kept the best gear available to a successful mercenary.
Please type 1, 2, or 3 and press enter.~
	  ACTION_READLN aran_wealth
  END
OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[123]$~; )BEGIN // one way of setting up for READLN
		PRINT ~You are probably going to Dual-Class Aran to Mage. He currently has proficiencies as follows:
 ** Long Sword
 ** Quarterstaff
 ** Dagger
Please choose from the following starting weapon choices:
 [1] Long Sword, Shield, Dagger
 [2] Long Sword, Shield, Quarterstaff
 [3] Long Sword, Shield, Potions of healing
Please type 1, 2, or 3, and press enter~
	  ACTION_READLN weapon_choices
END
/* we are using READLN values to set a variable - the mod range of possible combos is 1 to 15 inclusive, so we can't just read it directly */
ACTION_MATCH  ~%weapon_choices%~   // check this value
WITH  // against the following 3 cases, so
1
BEGIN
	OUTER_SET ~aran_weapon_set~ = 1  //  Long Sword, Shield, Dagger
END
2
BEGIN
  OUTER_SET ~aran_weapon_set~ = 2 // Long Sword, Shield, Quarterstaff
END
3
BEGIN
	OUTER_SET ~aran_weapon_set~ = 3 // Long Sword, Shield, Potions of healing
END
DEFAULT  // this should never run, but as an emergency fallback
  OUTER_SET ~aran_weapon_set~ = 6 // Long Sword, Shield, Long Bow
END // of default
OUTER_FOR( aran_armor_choice = 0; ~%aran_armor_choice%~ STRING_COMPARE_REGEXP ~^[12345]$~; )BEGIN
		PRINT ~Please choose from the following starting armor choices for Aran:
 [1] Leather
 [2] Studded Leather
 [3] Chain
 [4] Splint
 [5] Plate
Please type 1, 2, 3, 4, or 5 and press enter.~
	  ACTION_READLN aran_armor_choice
  END // of O_F
  LAUNCH_ACTION_MACRO ~aran_report_status~
  COPY ~aranw/cre/c-arnmge.cre~ ~override/c-aran7.cre~ // copy the base .cre into the game, and
  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN // if the .cre is valid, then
	  LAUNCH_PATCH_MACRO ~aran_cre_setup~  // patch in player choices using this pre-defined code
  END ELSE
   FAIL ~For some reason, %dest_res% is not valid. Please check your install.~
  END
  END // of dual-to-mage swing


  2 // the second check. If %class_choice% = 2, the next stuff will work, else check the next
  BEGIN /* cleric dual-class build */
  	OUTER_FOR( aran_wealth = 0; ~%aran_wealth%~ STRING_COMPARE_REGEXP ~^[123]$~; )BEGIN
  	 	 PRINT ~Please choose from the following choices to modify starting armor and weapons available to him:
 [1] Aran is down-and-out poor and has sold off most of his good equipment.
 [2] Aran has kept most of his good gear.
 [3] Aran has kept the best gear available to a successful mercenary.
Please type 1, 2, or 3 and press enter.~
		  ACTION_READLN aran_wealth
  END
OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[1234]$~; )BEGIN // one way of setting up for READLN
  	 		PRINT ~You are probably going to Dual-Class Aran to Cleric. He currently has proficiencies as follows:
 * Long Sword
 * Hammer
 * Mace
 * Flail
 ** Sword and Shield Style
Please choose from the following starting weapon choices:
 [1] Long Sword, Shield, Mace
 [2] Long Sword, Shield, Quarterstaff
 [3] Long Sword, Shield, Hammer
 [4] Long Sword, Shield, Flail
Please type 1, 2, or 3 and press enter.~
	  ACTION_READLN ~weapon_choices~
  END
  ACTION_MATCH  ~%weapon_choices%~   // check this value
  WITH  // against the following 3 cases, with 4 or anything else defaulting to a '"standard choice"
  1
  BEGIN
	  OUTER_SET ~aran_weapon_set~ = 4 // Long Sword, Shield, Mace
  END
  2
  BEGIN
	  OUTER_SET ~aran_weapon_set~ = 2 // Long Sword, Shield, Quarterstaff
  END
  3
  BEGIN
	  OUTER_SET ~aran_weapon_set~ = 12 // Long Sword, Shield, Hammer
  END
  DEFAULT  // this will  run on 4, or as an emergency fallback
	  OUTER_SET ~aran_weapon_set~ = 5 // Long Sword, Shield, Flail
  END
  OUTER_FOR( aran_armor_choice = 0; ~%aran_armor_choice%~ STRING_COMPARE_REGEXP ~^[12345]$~; )BEGIN
	  PRINT ~Please choose from the following starting armor choices for Aran:
 [1] Leather
 [2] Studded Leather
 [3] Chain
 [4] Splint
 [5] Plate
Please type 1, 2, 3, 4, or 5 and press enter.~
		  ACTION_READLN aran_armor_choice
	  END // of O_F
  LAUNCH_ACTION_MACRO ~aran_report_status~
	  COPY ~aranw/cre/c-arnmge.cre~ ~override/c-aran7.cre~ // copy the base .cre into the game, and
	  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN // if the .cre is valid, then
		  LAUNCH_PATCH_MACRO ~aran_cre_setup~  // patch in player choices using this pre-defined code
	  END ELSE
		  FAIL ~For some reason, %dest_res% is not valid. Please check your install.~
	  END
END // of dual-to-cleric swing

3 // the third check. If %class_choice% = 3, the next stuff will work, else check the next
BEGIN /* fighter single-class build */
	OUTER_FOR( aran_wealth = 0; ~%aran_wealth%~ STRING_COMPARE_REGEXP ~^[123]$~; )BEGIN
		PRINT ~Please choose from the following choices to modify starting armor and weapons available to him:
 [1] Aran is down-and-out poor and has sold off most of his good equipment.
 [2] Aran has kept most of his good gear.
 [3] Aran has kept the best gear available to a successful mercenary.
Please select 1, 2, or 3 and press enter.~
		  ACTION_READLN aran_wealth
	  END
	OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[123456]$~; )BEGIN	
		PRINT ~You are probably going to leave Aran as a fighter. He currently has proficiencies as follows:
 ** Long Sword
 ** Bastard Sword
 * Long Bow
 * Sword and Shield
Please choose from the following starting weapon choices:
[1] Long Sword, Shield, Dagger
[2] Long Sword, Shield, Long Bow
[3] Long Sword, Shield, Potions of healing
[4] Bastard Sword, Shield, Dagger
[5] Bastard Sword, Shield, Long Bow
[6] Long Sword, Shield, Hammer
Please type 1, 2, 3, 4, 5, or 6 and press enter.~
	  ACTION_READLN ~weapon_choices~
	END
	ACTION_MATCH  ~%weapon_choices%~   // check this value
	WITH  // against the following 3 cases, with 4 or anything else defaulting to a '"standard choice"
	1
	BEGIN
		OUTER_SET ~aran_weapon_set~ = 1 // Long Sword, Shield, Dagger
	END
	2
	BEGIN
		OUTER_SET ~aran_weapon_set~ = 6 // Long Sword, Shield, Long Bow
	END
	3
	BEGIN
		OUTER_SET ~aran_weapon_set~ = 3 // Long Sword, Shield, Potions of healing
	END
	4
	BEGIN
		OUTER_SET ~aran_weapon_set~ = 7 // Bastard Sword, Shield, Dagger
	END
	5
	BEGIN
		OUTER_SET ~aran_weapon_set~ = 8 // Bastard Sword, Shield, Long Bow
	END
	DEFAULT  // this will  run on 6, or as an emergency fallback
	  OUTER_SET ~aran_weapon_set~ = 12 // Long Sword, Shield, Hammer
  END // of default
	OUTER_FOR( aran_armor_choice = 0; ~%aran_armor_choice%~ STRING_COMPARE_REGEXP ~^[12345]$~; )BEGIN
		PRINT ~Please choose from the following starting armor choices for Aran:
 [1] Leather
 [2] Studded Leather
 [3] Chain
 [4] Splint
 [5] Plate
Please select 1, 2, 3, 4, or 5 and press enter.~
		  ACTION_READLN aran_armor_choice
	  END // of O_F
	  LAUNCH_ACTION_MACRO ~aran_report_status~
	  COPY ~aranw/cre/c-arnftr.cre~ ~override/c-aran7.cre~ // copy the base .cre into the game, and
	  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN // if the .cre is valid, then
		  LAUNCH_PATCH_MACRO ~aran_cre_setup~  // patch in player choices using this pre-defined code
	  END ELSE
		  FAIL ~For some reason, %dest_res% is not valid. Please check your install.~
	  END	  
END // of just-a-fighter swing

4 // the second check. If %class_choice% = 4, the next stuff will work, else check the next
BEGIN /* thief dual-class build */
	OUTER_FOR( aran_wealth = 0; ~%aran_wealth%~ STRING_COMPARE_REGEXP ~^[123]$~; )BEGIN
		PRINT ~Please choose from the following choices to modify starting armor and weapons available to him:
 [1] Aran is down-and-out poor and has sold off most of his good equipment.
 [2] Aran has kept most of his good gear.
 [3] Aran has kept the best gear available to a successful mercenary.
Please type 1, 2, or 3 and press enter.~
		  ACTION_READLN aran_wealth
	  END
	OUTER_FOR( weapon_choices = 0; ~%weapon_choices%~ STRING_COMPARE_REGEXP ~^[12345]$~; )BEGIN	
		PRINT ~You are probably going to Dual-Class Aran as a Thief. He currently has proficiencies as follows:
 ** Long Sword
 ** Short Sword
 * Dagger
 * Crossbow
Please choose from the following starting weapon choices:
 [1] Long Sword, Shield, Dagger
 [2] Long Sword, Shield, Crossbow
 [3] Long Sword, Shield, Potions of healing
 [4] Short Sword, Shield, Dagger
 [5] Short Sword, Shield, Crossbow
Please select 1, 2, 3, 4, or 5 and press enter.~
	  ACTION_READLN ~weapon_choices~
  END
  ACTION_MATCH  ~%weapon_choices%~   // check this value
  WITH  // against the following 3 cases, with 4 or anything else defaulting to a '"standard choice"
  1
  BEGIN
	  OUTER_SET ~aran_weapon_set~ = 1 // Long Sword, Shield, Dagger
  END
  2
  BEGIN
	  OUTER_SET ~aran_weapon_set~ = 9 // Long Sword, Shield, Crossbow
  END
  3
  BEGIN
	  OUTER_SET ~aran_weapon_set~ = 3 // Long Sword, Shield, Potions of healing
  END
  4
  BEGIN
	  OUTER_SET ~aran_weapon_set~ = 10 // Short Sword, Shield, Dagger
  END
  DEFAULT  // this will  run on 5, or as an emergency fallback
	  OUTER_SET ~aran_weapon_set~ = 11 // Short Sword, Shield, Crossbow
  END // of default
	OUTER_FOR( aran_armor_choice = 0; ~%aran_armor_choice%~ STRING_COMPARE_REGEXP ~^[12345]$~; )BEGIN
		PRINT ~Please choose from the following starting armor choices for Aran:
 [1] Leather
 [2] Studded Leather
 [3] Chain
 [4] Splint
 [5] Plate
Please select 1, 2, 3, 4, or 5 and press enter.~
		  ACTION_READLN aran_armor_choice
	  END // of O_F
	  LAUNCH_ACTION_MACRO ~aran_report_status~
	  COPY ~aranw/cre/c-arnthf.cre~ ~override/c-aran7.cre~ // copy the base .cre into the game, and
	  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN // if the .cre is valid, then
		  LAUNCH_PATCH_MACRO ~aran_cre_setup~  // patch in player choices using this pre-defined code
	  END ELSE
		  FAIL ~For some reason, %dest_res% is not valid. Please check your install.~
	  END   
END // of dual-to-thief swing

DEFAULT  // the fall-through check. If %class_choice% was not 1, 2, 3, or 4, the default code will run
PRINT ~Installing Aran's default settings (Soldier).~
/* Set up the variables for a default .cre so BWP folks don't have to deal with READLN */
OUTER_SET ~aran_wealth~ = 2 // experienced mercenary  with some resources
OUTER_SET ~aran_weapon_set~ = 6 // Long Sword, Shield, Long Bow
OUTER_SET ~aran_armor_choice~ = 4 // splint
  LAUNCH_ACTION_MACRO ~aran_report_status~
COPY ~aranw/cre/c-arnftr.cre~ ~override/c-aran7.cre~ // copy the base .cre into the game, and
  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN // if the .cre is valid, then
	  LAUNCH_PATCH_MACRO ~aran_cre_setup~  // patch in player choices using this pre-defined code
  END ELSE
	  FAIL ~For some reason, %dest_res% is not valid. Please check your install.~
  END 
END // of default swing

END // of define action macro

Share this post


Link to post

... which leaves us with the following .tp2 entries to handle the install of creatures:

 

BEGIN  ~Aran Whitehand, default configuration (Soldier)~
 FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~
 REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~
 /* register choice */
 OUTER_SET class_choice = 5
 /* Ask for choices and patch the .cre */
 LAUNCH_ACTION_MACRO ~customized_cre_choice~
 /* create the ToB version if ToB is installed */
 ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre  file
COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~
  WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start
  WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */
  WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */
  WRITE_ASCII 0x248 ~C-ARN25~ #8 /*  override script */
 END ELSE
  PRINT ~You do not appear to have ToB installed - skipping c-aran13.cre creation~
 END

BEGIN  ~Aran Whitehand, Mage Dual-Class stats configuration (Tinker)~
 FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~
 REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~
 /* register choice */
 OUTER_SET class_choice = 1
 /* Ask for choices and patch the .cre */
 LAUNCH_ACTION_MACRO ~customized_cre_choice~
 /* create the ToB version if ToB is installed */
 ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre  file
COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~
  WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start
  WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */
  WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */
  WRITE_ASCII 0x248 ~C-ARN25~ #8 /*  override script */
 END ELSE
  PRINT ~You do not appear to have ToB installed - skipping c-aran13.cre creation~
 END

BEGIN  ~Aran Whitehand, Cleric Dual-Class stats configuration (Tailor)~
 FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~
 REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~
 /* register choice */
 OUTER_SET class_choice = 2
 /* Ask for choices and patch the .cre */
 LAUNCH_ACTION_MACRO ~customized_cre_choice~
 /* create the ToB version if ToB is installed */
 ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre  file
COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~
  WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start
  WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */
  WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */
  WRITE_ASCII 0x248 ~C-ARN25~ #8 /*  override script */
 END ELSE
  PRINT ~You do not appear to have ToB installed - skipping c-aran13.cre creation~
 END

BEGIN  ~Aran Whitehand, Fighter stats configuration (Soldier)~
 FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~
 REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~
 /* register choice */
 OUTER_SET class_choice = 3
 /* Ask for choices and patch the .cre */
 LAUNCH_ACTION_MACRO ~customized_cre_choice~
 /* create the ToB version if ToB is installed */
 ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre  file
COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~
  WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start
  WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */
  WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */
  WRITE_ASCII 0x248 ~C-ARN25~ #8 /*  override script */
 END ELSE
  PRINT ~You do not appear to have ToB installed - skipping c-aran13.cre creation~
 END

BEGIN  ~Aran Whitehand, Thief Dual-Class stats configuration (Spy)~
 FORCED_SUBCOMPONENT ~Choose Which Aran Configuration to install...~
 REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~
 /* register choice */
 OUTER_SET class_choice = 4
 /* Ask for choices and patch the .cre */
 LAUNCH_ACTION_MACRO ~customized_cre_choice~
 /* create the ToB version if ToB is installed */
 ACTION_IF FILE_EXISTS_IN_GAME ~ar6111.are~ THEN BEGIN // ToB .cre  file
COPY_EXISTING ~c-aran7.cre~ ~override/c-aran13.cre~
  WRITE_LONG 0x18 2500000 // current XP 2500000, ToB start
  WRITE_ASCII 0x2cc ~C-ARN25A~ #8 /* dialogue */
  WRITE_ASCII 0x280 ~C-ARAN~ #32 /* DV */
  WRITE_ASCII 0x248 ~C-ARN25~ #8 /*  override script */
 END ELSE
  PRINT ~You do not appear to have ToB installed - skipping c-aran13.cre creation~
 END

Share this post


Link to post

Man, i need to figure out why jedit stuff sometimes posts within code tags with nice, viewable indentations, and other times seems to think the indentation space is way, way bigger - damn that copy/paste from different temporary working files!

Share this post


Link to post
Man, i need to figure out why jedit stuff sometimes posts within code tags with nice, viewable indentations, and other times seems to think the indentation space is way, way bigger - damn that copy/paste from different temporary working files!

The common spaces-vs-tabs?

Share this post


Link to post

I bet you are right. I need to remember to reset the buffer options to tabs=spaces, and spaces=2.

Share this post


Link to post
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...