Author Topic: Array of components.  (Read 1977 times)

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Array of components.
« on: March 22, 2005, 06:44:03 AM »
In rewriting Mazzy the Paladin, I'm thinking about offering different dialogue styles (4th wall breaking and non 4th wall breaking). Also, I'd like to offer also the choice of paladin kit at install time (should mazzy become a Cavalier, Inquisitor, etc.).

Using regular SUBCOMPONENTS, i'd need to use something like this group of subcomponents:

Code: [Select]
BEGIN ~4th wall breaking dialogues: Trueclass~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/stupid_dial/truecl~
  {other 200 lines of install}

BEGIN ~4th wall breaking dialogues: Cavalier~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/stupid_dial/cavalier~
  {other 200 lines of install}

BEGIN ~roleplaying dialogues: Trueclass~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/rp_dial/truecl~
  {other 200 lines of install}

BEGIN ~roleplaying dialogues: Cavalier~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/rp_dial/cavalier~
  {other 200 lines of install}
Etc.

Of course, this means I'll have to repeat the 200 lines of install over and over. This increases exponentially if I were to add multiple portraits or other stuff.

What I'd like to have is a subcomponent n-array:

Code: [Select]
BEGIN_ARRAY #2 ~Mazzy the Paladin~
[optional: PROCESS_LAST]
 //flags0
 //actions0
  BEGIN_ARRAY_LEVEL #1 ~Choose the style of your dialogues~
  BEGIN_ARRAY_LEVEL #2 ~Choose Mazzy's kit~
    BEGIN_ARRAY_ELEMENT #1 ~Old Style dialogues~
      //flags1
      //actions1
    END_ARRAY_ELEMENT
    BEGIN_ARRAY_ELEMENT #1 ~New Style Dialogues~
      //flags2
      //actions2
    END_ARRAY_ELEMENT
    BEGIN_ARRAY_ELEMENT #2 ~Trueclass~
      // flags3
      //actions3
    END_ARRAY_ELEMENT
    BEGIN_ARRAY_ELEMENT #2 ~Cavalier~
      // flags4
      //actions4
    END_ARRAY_ELEMENT
END_ARRAY

BEGIN_ARRAY #a would be the new component, which contains a a-dimensional array of subcomponents. Any instructions following this are common to all elements of the array.
The optional PROCESS_LAST means that the common instructions are to be processed last, instead than first.
BEGIN_ARRAY_LEVEL #b defines the name of the b-th dimension.
BEGIN_ARRAY_ELEMENT #c defines a possible choice for the c-th dimension and the relative instructions.

The components would then be equivalent to:
Code: [Select]
BEGIN ~Mazzy the Paladin: Old Style Dialogues: Trueclass~
flag0
flag1
flag3
action0
action1
action3

BEGIN ~Mazzy the Paladin: Old Style Dialogues: Cavalier~
flag0
flag1
flag4
action0
action1
action4

BEGIN ~Mazzy the Paladin: New Style Dialogues: Trueclass~
flag0
flag2
flag3
action0
action2
action3

BEGIN ~Mazzy the Paladin: New Style Dialogues: Cavalier~
flag0
flag2
flag4
action0
action2
action4

This is how it should be presented: The user is presented with

Code: [Select]
Install component: Mazzy the Paladin
[Y]es, [N]o, [Q]uit

If user chooses yes, then he will be presented with

Code: [Select]
Choose the Style of dialogues:
1] Old Style Dialogues
2] New Style Dialogues

Then there will be the choice

Code: [Select]
Choose Mazzy's kit:
1] Trueclass
2] Cavalier

After last array's dimension is chosen, the relative component is installed.

Example of use of PROCESS_LAST: a mod to reduce creature's XP by a percent, to the choice of installer (SimDing0's mod, EG)
Code: [Select]
BEGIN_ARRAY #1 ~Experience Fixer~
 PROCESS_LAST
 XP = XP * reduction_rate / 100

 BEGIN_ARRAY_LEVEL #1 ~Choose reduction level:~
    BEGIN_ARRAY_ELEMENT #1 ~50%~
      SET reduction_rate = 50
    END_ARRAY_ELEMENT
    BEGIN_ARRAY_ELEMENT #1 ~10%~
      SET reduction_rate = 10
    END_ARRAY_ELEMENT
END_ARRAY
the actions in the array element chosen sets reduction_rate, which is then processed by the main component to reduce the XP.

As far as component count goes, this would be a single component, which is then detailed as EG #0.2.1, where 0 is the component number and 2.1 are the coordinates I chose, starting from 1 instead from 0. This way, I can use
REQUIRE_COMPONENT ~Setup-MazzyThePaladin.tp2~ #0.0.1, where the 2nd 0 is a cutoff, to see if, in component 0, dimension 2 = 1 and dimension 1 is ininfluent.

Weidu.log would contain

~Setup-MazzyThePaladin.tp2~ #0 #0.0.1 // ~Mazzy the Paladin: New Style Dialogues: Trueclass~

I hope this wasn't extremely confusing, and that it's possible to code without a complete rewrite  :-\
Anyway, thanks in advance  :)
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Rastor

  • Planewalker
  • *****
  • Posts: 271
  • Author of the book, "Being a Jerk for Dummies"
    • RPG Dungeon
Re: Array of components.
« Reply #1 on: March 22, 2005, 10:29:40 AM »
Instead of:
Code: [Select]
BEGIN ~4th wall breaking dialogues: Trueclass~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/stupid_dial/truecl~
  {other 200 lines of install}

BEGIN ~4th wall breaking dialogues: Cavalier~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/stupid_dial/cavalier~
  {other 200 lines of install}

BEGIN ~roleplaying dialogues: Trueclass~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/rp_dial/truecl~
  {other 200 lines of install}

BEGIN ~roleplaying dialogues: Cavalier~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/rp_dial/cavalier~
  {other 200 lines of install}

Why can't you do:
Code: [Select]
BEGIN ~Mazzy the Paladin:  4th Wall Dialogues~
SUBCOMPONENT ~Trueclass~
  COMPILE ~mtp/stupid_dial/truecl~
SUBCOMPONENT ~Cavalier~
  COMPILE ~mtp/stupid_dial/cavalier~

BEGIN ~Mazzy the Paladin:  Roleplaying Dialogues~
SUBCOMPONENT ~Trueclass~
  COMPILE ~mtp/rp_dial/truecl~
SUBCOMPONENT ~Cavalier~
  COMPILE ~mtp/rp_dial/cavalier~

Since Mazzy can't be both a cavalier and a trueclass paladin, there's really no reason for you to be using the components and subcomponents the way you are.

This way will also save you several hundred lines of code because you don't have to put in all the code for each subcomponent (as you do for each component).  You can also make generous use of the ALWAYS action if necessary.

Am I missing something here?

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Array of components.
« Reply #2 on: March 22, 2005, 10:41:08 AM »
Instead of:
Code: [Select]
BEGIN ~4th wall breaking dialogues: Trueclass~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/stupid_dial/truecl~
  {other 200 lines of install}

BEGIN ~4th wall breaking dialogues: Cavalier~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/stupid_dial/cavalier~
  {other 200 lines of install}

BEGIN ~roleplaying dialogues: Trueclass~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/rp_dial/truecl~
  {other 200 lines of install}

BEGIN ~roleplaying dialogues: Cavalier~
SUBCOMPONENT ~Mazzy the Paladin~
  COMPILE ~mtp/rp_dial/cavalier~
  {other 200 lines of install}

Why can't you do:
Code: [Select]
BEGIN ~Mazzy the Paladin:  4th Wall Dialogues~
SUBCOMPONENT ~Trueclass~
  COMPILE ~mtp/stupid_dial/truecl~
SUBCOMPONENT ~Cavalier~
  COMPILE ~mtp/stupid_dial/cavalier~

BEGIN ~Mazzy the Paladin:  Roleplaying Dialogues~
SUBCOMPONENT ~Trueclass~
  COMPILE ~mtp/rp_dial/truecl~
SUBCOMPONENT ~Cavalier~
  COMPILE ~mtp/rp_dial/cavalier~

Since Mazzy can't be both a cavalier and a trueclass paladin, there's really no reason for you to be using the components and subcomponents the way you are.

This way will also save you several hundred lines of code because you don't have to put in all the code for each subcomponent (as you do for each component).  You can also make generous use of the ALWAYS action if necessary.

Am I missing something here?
Ok, that's right, but I'd like / need to present the player all choices before installing, otherwise some stupid n00b could install 1st part, then [Q]uit, and "WTH DOESNT IT WORK???"; also, I'd be using this also in other components: EG in the imprisonment Fix + Drop Weapons in Panic tweaks I'd have to write and run the scanning code once instead of twice, with great advantage in terms of execution time and easiness of debug.
In my current setup (components), I'm having a component for Imprisonment and one for DWIP, which equals 2 rewrites and 2 executions.
In a SUBCOMPONENT setup, I'd have 3 rewrites (I, DWIP, I + DWIP) and 1 execution. If I were to include another effect tweak (EG petrification) I'd have to do 7 rewrites (I, DWIP, I + DWIP, P, P + I, P + DWIP,P + I + DWIP).
In an ARRAY setup, I'd have 1 rewrite and 1 execution. If I were to tweak 10 effects, that would sum up to 1 rewrite, instead of 1023.
About ALWAYS, I cannot use it if I'm installing a multi-component mod (like a tweak pack).
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline igi

  • IESDP Guardian
  • Planewalker
  • *****
  • Posts: 124
  • IESDP Guardian
Re: Array of components.
« Reply #3 on: March 22, 2005, 02:41:39 PM »
Quote
otherwise some stupid n00b could install 1st part, then [Q]uit, and "WTH DOESNT IT WORK???"
You are never going to solve that problem, especially as the trend seems to be towards making players require less and less intelligence.

I don't see the point in this feature TBH, but, since it will only bulk out weidu by a few kb and not affect anything else I have no major objection.
NPC: Arg || Galoomp || Thash
Mods: Dark Heart of the Xvart || GbG
Tweak Pack: iiTweak

mcwrench.com
mcwrench.com forums

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: