Pocket Plane Group Logo Callum logo
Welcome, Guest. Please login or register.
September 02, 2010, 03:56:41 PM

Login with username, password and session length
Search:     Advanced search
All Pocket Plane Group mods install using WeiDU.
132813 Posts in 13492 Topics by 3972 Members
Latest Member: nikjensen
* Home Help Search Login Register RSS feed
+  Pocket Plane Group
|-+  Friends and Neighbors
| |-+  Weimer Republic (WeiDU.org)
| | |-+  WeiDU (Moderators: weimer, the bigg)
| | | |-+  Functions and variables/strings that are set by other stuff
« previous next »
Pages: 1 2 [3] 4 5 Go Down Reply Print
Author Topic: Functions and variables/strings that are set by other stuff  (Read 5691 times)
cmorgan
Planewalker
*****
Offline Offline

Gender: Male
Posts: 1296

Searcher of Bugs


« Reply #50 on: January 10, 2010, 11:36:15 AM »
Reply with quote

NOT REQUESTING ACTION OR CHANGE - JUST INFORMATION -

this is for straight WRITE_ASCII usage, non-evaluated. But could I somehow force-multiplier this into a replacement for

Code:
  COPY ~BG1NPC/Phase2/cre/x#xqmer6.cre~ ~override~
    SAY NAME1 @640
    SAY NAME2 @640
    SAY DAMAGE @562
    SAY DYING @563
    WRITE_LONG INITIAL_MEETING (BNOT 0x0) // BLANKING SOUNDS
    WRITE_LONG DIALOGUE_HOSTILE (BNOT 0x0)
    WRITE_LONG MORALE (BNOT 0x0)
    WRITE_LONG HAPPY (BNOT 0x0)
    WRITE_LONG UNHAPPY_ANNOYED (BNOT 0x0)
    WRITE_LONG UNHAPPY_SERIOUS (BNOT 0x0)
    WRITE_LONG UNHAPPY_BREAKING (BNOT 0x0)
    WRITE_LONG LEADER (BNOT 0x0)
    WRITE_LONG TIRED (BNOT 0x0)
    WRITE_LONG BORED (BNOT 0x0)
    WRITE_LONG BATTLE_CRY1 (BNOT 0x0)
    WRITE_LONG BATTLE_CRY2 (BNOT 0x0)
    WRITE_LONG BATTLE_CRY3 (BNOT 0x0)
    WRITE_LONG BATTLE_CRY4 (BNOT 0x0)
    WRITE_LONG BATTLE_CRY5 (BNOT 0x0)
    WRITE_LONG HURT (BNOT 0x0)
    WRITE_LONG AREA_FOREST (BNOT 0x0)
    WRITE_LONG AREA_CITY (BNOT 0x0)
    WRITE_LONG AREA_DUNGEON (BNOT 0x0)
    WRITE_LONG AREA_DAY (BNOT 0x0)
    WRITE_LONG AREA_NIGHT (BNOT 0x0)
    WRITE_LONG SELECT_COMMON1 (BNOT 0x0)
    WRITE_LONG SELECT_COMMON2 (BNOT 0x0)
    WRITE_LONG SELECT_COMMON3 (BNOT 0x0)
    WRITE_LONG SELECT_COMMON4 (BNOT 0x0)
    WRITE_LONG SELECT_COMMON5 (BNOT 0x0)
    WRITE_LONG SELECT_COMMON6 (BNOT 0x0)
    WRITE_LONG SELECT_ACTION1 (BNOT 0x0)
    WRITE_LONG SELECT_ACTION2 (BNOT 0x0)
    WRITE_LONG SELECT_ACTION3 (BNOT 0x0)
    WRITE_LONG SELECT_ACTION4 (BNOT 0x0)
    WRITE_LONG SELECT_ACTION5 (BNOT 0x0)
    WRITE_LONG SELECT_ACTION6 (BNOT 0x0)
    WRITE_LONG SELECT_ACTION7 (BNOT 0x0)
    WRITE_LONG SELECT_RARE1 (BNOT 0x0)
    WRITE_LONG SELECT_RARE2 (BNOT 0x0)
    WRITE_LONG CRITICAL_HIT (BNOT 0x0)
    WRITE_LONG CRITICAL_MISS (BNOT 0x0)
    WRITE_LONG TARGET_IMMUNE (BNOT 0x0)
    WRITE_LONG INVENTORY_FULL (BNOT 0x0)
    WRITE_LONG PICKED_POCKET (BNOT 0x0)
    WRITE_LONG HIDDEN_IN_SHADOWS (BNOT 0x0)
    WRITE_LONG SPELL_DISRUPTED (BNOT 0x0)
    WRITE_LONG SET_A_TRAP (BNOT 0x0)
    WRITE_LONG BIO (BNOT 0x0)
    WRITE_EVALUATED_ASCII 0x280 ~%SOURCE_RES%~ #32 //  death variable
or even a list-driven .cre changer for materials like aVENGER (RR)'s modifications:

Code:
// Arledrian's Silverblaze Quest
COPY_EXISTING ~ARLED.CRE~ ~override~ // Arledrian
  WRITE_ASCII 0x34 ~RR#ARLDS~ #8 // Sets Arledrian's small portrait
  REMOVE_CRE_ITEM ~rndtre04~ // removes the random treasure 04 item
  REMOVE_CRE_ITEM ~bow05~ // removes the Short Bow (which messes up his DW)
  REMOVE_CRE_ITEM ~sw1h08~ // removes the Short Sword +1
  REMOVE_CRE_ITEM ~arow02~ // removes the Arrows +1
  REPLACE_CRE_ITEM ~CHAN02~ #0 #0 #0 ~UNSTEALABLE~ ~ARMOR~  // replaces Arledrian's armor with Chain Mail +1
  ADD_CRE_ITEM ~DAGG02~ #0 #0 #0 ~UNSTEALABLE~ ~WEAPON1~ EQUIP      // Replaces Arledrian Short Sword +1 with a Dagger +1
  ADD_CRE_ITEM ~DAGG15~ #0 #0 #0 ~UNSTEALABLE~ ~SHIELD~ // Gives Arledrian Dagger +2
  ADD_CRE_ITEM ~RR#SILV~ #0 #3 #0 ~NONE~ ~INV1~  // Gives Arledrian the Silverblaze dagger
  ADD_CRE_ITEM ~POTN10~ #1 #0 #0 ~UNSTEALABLE~ ~QITEM1~  // Gives Arledrian 1x Potion of Invisibility
  ADD_CRE_ITEM ~POTN52~ #1 #0 #0 ~NONE~ ~QITEM2~ // Gives Arledrian 1x Potion of Extra Healing
  WRITE_LONG 0x14 3000 // XP value (when killed)
  WRITE_LONG 0x18 161000  // current XP
  WRITE_SHORT 0x24 67 // current hit points
  WRITE_SHORT 0x26 67  // maximum hit points
  WRITE_SHORT 0x28 24833 // Sets avatar to FIGHTER_MALE_ELF
  WRITE_BYTE 0x2C 35 // metal color
  WRITE_BYTE 0x2D 32 // minor color
  WRITE_BYTE 0x2E 32 // major color
  WRITE_BYTE 0x2F 108  // skin color
  WRITE_BYTE 0x30 60 // leather color
  WRITE_BYTE 0x31 60 // armor color
  WRITE_BYTE 0x32 2  // hair color
  WRITE_BYTE 0x45 5 // Hide in Shadows skill
  WRITE_BYTE 0x52 14 // THAC0
  WRITE_BYTE 0x54 10 // save vs. death
  WRITE_BYTE 0x55 12 // save vs. wands
  WRITE_BYTE 0x56 11 // save vs. polymorph
  WRITE_BYTE 0x57 12 // save vs. breath
  WRITE_BYTE 0x58 13 // save vs. spells
  WRITE_BYTE 0x64 0  // Detect Illusions skill
  WRITE_BYTE 0x65 50 // Set Traps skill
  WRITE_BYTE 0x66 24  // Lore
  WRITE_BYTE 0x67 55 // Open Locks skill
  WRITE_BYTE 0x68 0  // Move Silently skill
  WRITE_BYTE 0x69 55  // Find Traps skill
  WRITE_BYTE 0x6a 50 // Pick Pockets skill
  WRITE_LONG 0xa4   // initial meeting string
  WRITE_LONG 0xec 12586  // damage string
  WRITE_LONG 0xf0 12587  // death string
  WRITE_LONG 0x10c 4942  // select common 1
  WRITE_LONG 0x110 4941 // select common 2
  WRITE_BYTE 0x234 7 // level (first class)
  WRITE_BYTE 0x235 8 // level (second class)
  WRITE_BYTE 0x236 0 // level (third class)
  WRITE_BYTE 0x238 12     // Strength
  WRITE_BYTE 0x23a 16    // Inteligence
  WRITE_BYTE 0x23b 11    // Wisdom
  WRITE_BYTE 0x23c 19    // Dexterity
  WRITE_BYTE 0x23d 10    // Constitution
  WRITE_BYTE 0x23e 13   // Charisma
  WRITE_BYTE 0x23f 18    // morale
  WRITE_BYTE 0x240 5 // morale break
  WRITE_BYTE 0x242 30     // morale recovery
  WRITE_BYTE 0x272 2  // race
  WRITE_BYTE 0x273 9 // class
  WRITE_BYTE 0x27b 34      // alignment
  WRITE_ASCII 0x248 ~RR#ARLED~ #8  // assign override AI script
  WRITE_ASCII 0x250 ~None~ #8   // disable class AI script (STEALAMN.BCS)
  WRITE_ASCII 0x258 ~None~ #8     // disable race AI script (GPUSE.BCS)
  WRITE_ASCII 0x260 ~None~ #8   // disable general AI script (NONE)
  WRITE_ASCII 0x268 ~None~ #8      // disable default AI script (WTARSGT.BCS)
  SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 2 // Give Arledrian 2 stars in the BG2 Dagger proficiency
  SET_BG2_PROFICIENCY ~PROFICIENCY2WEAPON~ 3 // Give Arledrian 3 stars in the BG2 Two Weapon Style proficiency
BUT_ONLY_IF_IT_CHANGES

If it really got going, it would need EVALUATED, though, as folks would need a list evaluated, like   WRITE_ASCII 0x248 ~%tutu_var%ARLED~ #8  // assign override AI script

NOT A FUNCTIONAL REQUEST AND I WON'T USE IT ENOUGH TO MAKE IT WORTH YOUR TIME, just an informationa follow-up - even if it could be done, I somehow think you folks will be sending me the macro route rather than making things a PITA on the weidu front.
Logged
aVENGER
Sneaksie!
Planewalker
*****
Offline Offline

Gender: Male
Posts: 137


« Reply #51 on: January 10, 2010, 12:05:07 PM »
Reply with quote

or even a list-driven .cre changer for materials like aVENGER (RR)'s modifications

Actually, that's kinda outdated. Smiley

You might want to check the RR#MDCRE.TPH and RR#MDCSC.TPH functions that I'm using in aTweaks nowadays. They aren't in the public version yet, but you can get a closed beta in the RR Workroom, which you should have access to. Sample usage:

Code:
// Bone Fiend

ACTION_FOR_EACH ~file~ IN                                                          // for each of the following files
              ~DBONEF01~                                                           // Bone Fiend
               ~GORBAT5~                                                           // Bone Fiend
              ~MELSUM02~                                                           // Bone Fiend
BEGIN                                                                              // execute the following
ACTION_IF FILE_EXISTS_IN_GAME ~%file%.cre~ BEGIN                                   // if the file exists
COPY_EXISTING ~%file%.cre~ ~override~
PATCH_INCLUDE ~aTweaks/lib/fj_cre_validity.tpp~                                    // Nythrun's CRE validity macro (detects corrupt and invalid CREs)
PATCH_IF valid BEGIN
  PATCH_INCLUDE ~aTweaks/lib/fj_cre_reindex.tpp~                                   // Nythrun's CRE reindex macro (this also calls the EFF macro if needed)
// =============================================================================== // the actual work starts from here
REMOVE_CRE_ITEM ~DW#SUMFI~                                                         // removes DW#SUMFI.ITM (SCSII's fiend immunities, prevents conflict)
REPLACE_CRE_ITEM ~RR#DBFND~ #0 #0 #0 ~UNDROPPABLE~ ~WEAPON1~ EQUIP                 // replace default weapon with a less powerful weapon (closer to PnP damage output)
REPLACE_CRE_ITEM ~RINGDEMN~ #0 #0 #0 ~UNDROPPABLE~ ~RRING~                         // replace undead immunities with fiend immunities
REMOVE_CRE_ITEM ~IMMUNE2~                                                          // removes IMMUNE2.ITM (no immunity to +1 weapons in PnP)
REMOVE_CRE_ITEM ~REGHP2R~                                                          // removes REGHP2R.ITM (no regeneration in PnP)
LAUNCH_PATCH_FUNCTION ~RR#MDCRE~                                                   // Starts FUNCTION call (aTweaks' Creature Modification function)
INT_VAR                                                                            // Initialize variables
"newxpv"   = "7000"                                                                // new XP value
"newhp"    = "40"                                                                  // new hit point value
"newac"    = "3"                                                                   // new Armor Class value
"newth"    = "15"                                                                  // new THAC0 value
"newapr"   = "4"                                                                   // new number of attacks per round
"newsvd"   = "11"                                                                  // new Save vs. Death
"newsvw"   = "13"                                                                  // new Save vs. Wand
"newsvp"   = "12"                                                                  // new Save vs. Polymorph
"newsvb"   = "13"                                                                  // new Save vs. Breath
"newsvs"   = "14"                                                                  // new Save vs. Spell
"newmr"    = "30"                                                                  // new Magic Resistance value
"newfr"    = "100"                                                                 // new Resist Fire value
"newcr"    = "50"                                                                  // new Resist Cold value
"newer"    = "0"                                                                   // new Resist Electricity value
"newlvl1"  = "5"                                                                   // new level (first class)
"newstr"   = "16"                                                                  // new Strength value
"newstrx"  = "0"                                                                   // new Exceptional Strength value
"newint"   = "12"                                                                  // new Intelligence value
"newwis"   = "12"                                                                  // new Wisdom value
"newdex"   = "14"                                                                  // new Dexterity value
"newcon"   = "15"                                                                  // new Constitution value
"newchr"   = "10"                                                                  // new Charisma value
"newmor"   = "12"                                                                  // new morale value
"newmorb"  = "4"                                                                   // new morale break value
"newmorr"  = "15"                                                                  // new morale recovery value
"newclass" = "179"                                                                 // new class (Imp)
"newalign" = "19"                                                                  // new alignment (Lawful Evil)
STR_VAR                                                                            // initialize strings
"enfc01"   = "DBONEF01"                                                            // enforced creature 1 (uses strict PnP values)
"enfc02"   = "GORBAT5"                                                             // enforced creature 2 (uses strict PnP values)
END                                                                                // ends FUNCTION call
LAUNCH_PATCH_FUNCTION ~RR#MDCSC~                                                   // Starts FUNCTION call (aTweaks' Creature Script Modification function)
STR_VAR                                                                            // Initialize strings
"newscript"  = "RR#HBFND"                                                          // new AI script
"script01"   = ""                                                                  // first AI script name
"script02"   = "None"                                                              // second AI script name
"script03"   = "WTASIGHT"                                                          // third AI script name
"script04"   = "BPDEMON"                                                           // Big Picture Demon AI
"script05"   = "DEMBAL01"                                                          // Big Picture script (misassigned?)
END                                                                                // ends FUNCTION call
LAUNCH_PATCH_FUNCTION ~DELETE_CRE_EFFECT~                                          // delete the EFF with the designated opcode
INT_VAR opcode_to_delete = "193" END                                               // mark opcode #193 (Invisible Detection by Script) for deletion
LAUNCH_PATCH_FUNCTION ~DELETE_CRE_EFFECT~                                          // delete the EFF with the designated opcode
INT_VAR opcode_to_delete = "292" END                                               // mark opcode #292 (Protection from Backstab) for deletion
LAUNCH_PATCH_FUNCTION ~DELETE_CRE_EFFECT~                                          // delete the EFF with the designated opcode
INT_VAR opcode_to_delete = "16" END                                                // mark opcode #16 (Haste) for deletion
LAUNCH_PATCH_FUNCTION ~ADD_CRE_EFFECT~                                             // Starts FUNCTION call (add new creature effect built-in function)
INT_VAR
opcode = "300"                                                                     // effect: #300 (NPC Bump)
target = "1"                                                                       // target: 1 (self)
timing = "9"                                                                       // timing mode: 9 (permanent after death)
"duration" = "0"                                                                   // duration: 0
"sectype" = "0"                                                                    // secondary type: none
parameter2 = "1"                                                                   // param2: 1 (constant value)
probability1 = "100"                                                               // probability1: 100%
STR_VAR
"effsource" = ""                                                                   // effsource: none
END
// =============================================================================== // the actual work ends here
END                                                                                // ends file validity check
BUT_ONLY_IF_IT_CHANGES
END                                                                                // ends ACTION_IF FILE_EXISTS_IN_GAME block
END                                                                                // ends ACTION_FOR_EACH block
Logged

Retired modder

Rogue Rebalancing - Author
aTweaks - Author
BG2 Fixpack - Contributor
Nythrun
Planewalker
*****
Offline Offline

Gender: Female
Posts: 89


« Reply #52 on: January 10, 2010, 12:19:18 PM »
Reply with quote

Code:
FOR (i = INITIAL_MEETING; i < BIO + 4; i += 4) BEGIN
  WRITE_LONG i ` 0
END

(i = INITIAL_MEETING; i < BIO + 4; i++++++++) coming in 214
/edit

More seriously, though, you'll want a function with all the variables initialized to dummy values (I'm using 0xdeadbeef, as is traditional, even for strings/bytes/etc). Once sane behavior goes in, call it with only the variables you need to change locally set to the new values (skip the rest). The bulk of the function should be PATCH_IF !IS_AN_INT var || var != dummy_value BEGIN WRITE_* END.
« Last Edit: January 10, 2010, 12:29:00 PM by Nythrun » Logged
GeN1e
Planewalker
*****
Offline Offline

Gender: Male
Posts: 167


« Reply #53 on: January 10, 2010, 10:38:37 PM »
Reply with quote

SPRINT IQ int>15? smart : int<=14&int>8? okay : int<=8? moron : rellewd_lwb pamela123

Hm? Just curious, though, not really a request.

PS
Or rather the question should be - can we get rid of PATCH_IF BEGIN END ELSE BEGIN END moronic sequence in favor of something more human-typable?

: cond? [action/patch_list] : cond2? [list2] : [list3]
« Last Edit: January 10, 2010, 10:49:05 PM by GeN1e » Logged
devSin
Planewalker
*****
Offline Offline

Gender: Male
Posts: 1550


« Reply #54 on: January 10, 2010, 11:21:51 PM »
Reply with quote

pamela123
For real. That stupid scab doesn't even have a brain!

: cond? [action/patch_list] : cond2? [list2] : [list3]
No, there will be no mixing of value and action like this.

You could conceivably convince bigg to alias BEGIN to { and END to }, but it's going to look retarded (I already debated and dismissed suggesting that one years ago).
Logged
the bigg
The Avatar of Fighter / Thieves
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3370


« Reply #55 on: January 11, 2010, 02:36:42 AM »
Reply with quote

Picking up the stuff that seems to be related to me and not just circle jerking.

i++++ and extending the ?: syntax isn't going to happen, since tp2 is *barely* held together by a ton of duct tape and keeping actions,patches and values syntactically different (if only wes used ; to end statements and BEGIN/END to hold patches within a COPY, tp2 would be much more readable this day).

BEGIN/END -> {} aliasing takes all of ten minutes.
Logged

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - Some mods that I won't mention in public
Soundset and portrait packs: Alyx Vance (from Half-Life 2) - Jane "The Soldier" Doe (from Team Fortress 2)
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Contributions: See the PPG Modlist  Smiley
pamela1234
Guest
« Reply #56 on: January 11, 2010, 03:24:35 AM »
Reply with quote

Speaking of circle jerking...how about
Code:
    | TP_PE_ASCII_At(where,size,null_terminated) ->
        let where = Int32.to_int (eval_pe buff game where) in
        let size = Int32.to_int (eval_pe buff game size) in
        let value = bounds_check where size
            (fun () -> if null_terminated then get_string_of_size buff where size)
            (fun v ->  Var.get_string v) in
        value
(* except actually functional *)
so that the three people who care about variable scope needn't STR_VAR var = garbage...READ_ASCII where var? It's like LOCAL_READ_* risen from its request grave!

Y'all need to quit harshing on my girl pam. None of them knew they were robots.
Logged
the bigg
The Avatar of Fighter / Thieves
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3370


« Reply #57 on: January 11, 2010, 07:36:56 AM »
Reply with quote

No.
Logged

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - Some mods that I won't mention in public
Soundset and portrait packs: Alyx Vance (from Half-Life 2) - Jane "The Soldier" Doe (from Team Fortress 2)
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Contributions: See the PPG Modlist  Smiley
devSin
Planewalker
*****
Offline Offline

Gender: Male
Posts: 1550


« Reply #58 on: January 11, 2010, 06:24:50 PM »
Reply with quote

quit harshing on my girl pam.
Eww, I'm not into that stuff at all. Use a toilet.

Figures she's all nasty like that.
Logged
GeN1e
Planewalker
*****
Offline Offline

Gender: Male
Posts: 167


« Reply #59 on: January 13, 2010, 01:35:49 AM »
Reply with quote

While we here, the ADD_CRE_EFFECT function has a typo, it sprints 'effresource' to ~~, while instead it shoud be 'effsource'.
Logged
the bigg
The Avatar of Fighter / Thieves
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3370


« Reply #60 on: January 13, 2010, 06:19:30 AM »
Reply with quote

Sigh.
Logged

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - Some mods that I won't mention in public
Soundset and portrait packs: Alyx Vance (from Half-Life 2) - Jane "The Soldier" Doe (from Team Fortress 2)
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Contributions: See the PPG Modlist  Smiley
devSin
Planewalker
*****
Offline Offline

Gender: Male
Posts: 1550


« Reply #61 on: January 18, 2010, 05:15:54 PM »
Reply with quote

BEGIN/END -> {} aliasing takes all of ten minutes.
If you haven't already, please don't. Since GeN1e never came back and said "Yeah, that's a great time saver, I think you should add it!" and I definitely don't want it to ever be supported.

The first time I saw code that used this, my head would explode.
Logged
GeN1e
Planewalker
*****
Offline Offline

Gender: Male
Posts: 167


« Reply #62 on: January 18, 2010, 07:09:59 PM »
Reply with quote

It's not exactly what I was asking for, but nonetheless that's a great time saver, I think you should add it.

Well, dev has a certain point regarding head explosion, especially when we talk about PATCH_IF SOURCE_SIZE IS_LEGAL BEGIN PATCH_LIST END, but shorter bits of code would definitely benefit from it.

DEFINE_ARRAY => DA, ADA, DAA, ADAA? Looks a bit weird, though, not sure if they're shortable in human fashion.
CLEAR_ARRAY, GET_OFFSET_ARRAY_(2) as well?

Here's what {} has turned the first piece of code I have found into (dev, don't look, or you'll dirt us with your brain Wink )

Code:
DEFINE_PATCH_FUNCTION items_to_order {

PATCH_IF SOURCE_SIZE>0x9b { PATCH_SILENT
  FOR (i=0;i<47;i+=1) { SET $counter("%i%")=0 }
  delete=0
  CLEAR_ARRAY sales GET_OFFSET_ARRAY sales 0x34 4 0x38 4 0 0 0x1c
  PHP_EACH sales AS ind => res {
    READ_ASCII res item_entry (0x1c)
    READ_ASCII res item_name (8) NULL
    PATCH_IF FILE_EXISTS_IN_GAME ~%item_name%.itm~ { INNER_ACTION {
     COPY_EXISTING - ~%item_name%.itm~ ~override~ PATCH_IF SOURCE_SIZE>0x71 { // seems i can't check the size if i do INNER_PATCH_FILE
      READ_SHORT 0x1c type
      READ_SHORT 0x22 anim
      READ_BYTE  0x31 prof
      order =                // here starts the identification process that determines whichever group an item belongs to
          type=0x10                                      ? 0  // dagger
        : type=0x13&prof=0x5b                            ? 1  // short sword
        : type=0x14&prof=0x5a                            ? 2  // long sword
        : type=0x14&prof=0x59                            ? 3  // bastard sword
        : type=0x14&prof=0x5d                            ? 4  // 2handed sword
        : type=0x19                                      ? 5  // axe
        : type=0x15                                      ? 6  // hammer
        : type=0x11&prof=0x73                            ? 7  // club
        : type=0x11&prof=0x65                            ? 8  // mace
        : type=0x16                                      ? 9  // morning star
        : type=0x17                                      ? 10 // flail
        : type=0x1a                                      ? 11 // staff
        : type=0x1e                                      ? 12 // halberd
        : type=0x1d                                      ? 13 // spear
        : type=0x14&prof=0x5f&anim=0x4353                ? 14 // scimitar  --\ these checks would have identified Usuno's Blade as a scimitar
        : type=0x14&(prof=0x5b|prof=0x5f)&anim=0x3153    ? 15 // ninja-to  --/ item, but to my knowledge it's not available in stores anyway
        : type=0x13&(prof=0x5e|prof=0x5f)                ? 16 // wakizashi
        : type=0x14&prof=0x5e                            ? 17 // katana
        : type=0x18                                      ? 18 // dart
        : type=0xf&prof=0x69                             ? 19 // short bow
        : type=0xf&prof=0x68                             ? 20 // long bow
        : type=0x5                                       ? 21 // arrow
        : type=0x1b                                      ? 22 // crossbow
        : type=0x1f                                      ? 23 // bolt
        : type=0x12                                      ? 24 // sling
        : type=0xe                                       ? 25 // bullet
        : type=0x2&anim=0x4132                           ? 26 // leather armor
        : type=0x2&anim=0x4133                           ? 27 // chainmail armor
        : type=0x2&anim=0x4134                           ? 28 // plate armor
        : type=0xc&anim=0x3144                           ? 29 // buckler in modded game
        : type=0xc&anim=0x3244                           ? 30 // small shield and vanilla buckler
        : type=0xc&anim=0x3344                           ? 31 // medium shield
        : type=0xc&anim=0x3444                           ? 32 // tower shield
        : type=0x7                                       ? 33 // headgear
        : type=0x6                                       ? 34 // bracer/gauntlets
        : type=0x4                                       ? 35 // boots
        : type=0x3                                       ? 36 // belt
        : type=0x20                                      ? 37 // cloak
        : type=0x2&(anim=0x5732|anim=0x5733|anim=0x5734) ? 38 // robe
        : type=0x9                                       ? 39 // potion
        : type=0xb                                       ? 40 // scroll
        : type=0x1                                       ? 41 // amulet
        : type=0xa                                       ? 42 // ring
        : type=0x22                                      ? 43 // gem
        : type=0x23                                      ? 44 // wand
        : type=0x24                                      ? 45 // bag
        :                                                  46 // book, wooden stake, figurine or other crap

// ok, i'll be honest - i've tried to recode it to use names instead of integers, but goddamn
//
// SPRINT IQ int>15? smart : int<=14&int>8? okay : int<=8? moron : [s]rellewd_lwb[/s] pamela123
//
// refused to work. so screw it. it's not like each and every n00b is gonna try and tweak the
// code, making more even mess than The Darkest Day can possibly do to your BG2 installation
//
// numbers after the ? character are closely tied to $fixed("") arrays, so change the numbers order in both only

      SPRINT $name("%order%"$counter("%order%")) ~%item_name%~   // ITM filename
      SPRINT $entry("%order%"$counter("%order%")) ~%item_entry%~ // item entry's ASCII copypaste
      SET $sorted("%order%"$counter("%order%")) = 0              // whether the entry was already rearranged - not yet
      SET $counter("%order%")+=1
    } ELSE { delete+=1 } } } ELSE { delete+=1 } // SOURCE_SIZE INNER_PATCH_FILE FILE_EXISTS_IN_GAME
  } // PHP_EACH

  z=40
  // scrolls are damn bitchy things, thanks to Demi they need inner sorting :)
  // 0-8 are arcane
  // 9-15 are divine
  // 16 is what remains; green scrolls belong here, but the array of fixed positions will drag them to the top
  FOR (i=0;i<17;i+=1) { SET $scroll_counter("%i%")=0 }
  bad_scroll=0
  FOR (i=0;i<EVAL $counter("%z%");i+=1) {
    bastard=0 // yep, bastard, as i forgot to put it here and for a full hour couldn't figure out what was wrong
    SPRINT name $name("%z%""%i%")
    INNER_PATCH_FILE ~%name%.itm~ { // file is valid, else it wouldn't have been enlisted, no need to check twice
      CLEAR_ARRAY itm_head GET_OFFSET_ARRAY itm_head ITM_V10_HEADERS
      PHP_EACH itm_head AS ind => res {
        CLEAR_ARRAY effects GET_OFFSET_ARRAY2 effects res ITM_V10_HEAD_EFFECTS
        PHP_EACH effects AS ind2 => res2 {
          READ_SHORT res2 opcode
          PATCH_IF (opcode=146|opcode=148)&bastard=0 { // if can cast spell
            READ_ASCII res2+0x14 resource (8) NULL
            PATCH_IF FILE_EXISTS_IN_GAME ~%resource%.spl~ { INNER_ACTION {
             COPY_EXISTING - ~%resource%.spl~ ~override~ PATCH_IF SOURCE_SIZE>0x72 { // same again, can't do INNER_PATCH_FILE
              READ_SHORT 0x1c type
              READ_LONG  0x34 level
              PATCH_IF type=1 {                // if arcane
                FOR (j=1;j<10;j+=1) {
                  PATCH_IF level=j {
                    x=j - 1
                    SPRINT $scroll_name("%x%"$scroll_counter("%x%")) $name("%z%""%i%")
                    SPRINT $scroll_entry("%x%"$scroll_counter("%x%")) $entry("%z%""%i%")
                    SET $scroll_counter("%x%")+=1
                    bastard=1
                  }
                }
              }
              PATCH_IF type=2 {                // if divine
                FOR (j=1;j<8;j+=1) {
                  PATCH_IF level=j {
                    x=j+8
                    SPRINT $scroll_name("%x%"$scroll_counter("%x%")) $name("%z%""%i%")
                    SPRINT $scroll_entry("%x%"$scroll_counter("%x%")) $entry("%z%""%i%")
                    SET $scroll_counter("%x%")+=1
                    bastard=1
                  }
                }
              }
              PATCH_IF !(type=1|type=2) {      // if neither = crap
                x=16
                SPRINT $scroll_name("%x%"$scroll_counter("%x%")) $name("%z%""%i%")
                SPRINT $scroll_entry("%x%"$scroll_counter("%x%")) $entry("%z%""%i%")
                SET $scroll_counter("%x%")+=1
                bastard=1
              }
            } ELSE { bad_scroll+=1 } } } ELSE { bad_scroll+=1 } // SOURCE_SIZE INNER_PATCH_FILE FILE_EXISTS_IN_GAME
          } // if can cast spell
          PATCH_IF !(opcode=146|opcode=148)&bastard=0 { // if can't cast spell = crap
            SPRINT $scroll_name("16"$scroll_counter("16")) EVAL $name("%z%""%i%")
            SPRINT $scroll_entry("16"$scroll_counter("16")) EVAL $entry("%z%""%i%")
            SET $scroll_counter("16")+=1
            bastard=1
          }
        } // PHP_EACH
      } // PHP_EACH
    } // INNER_PATCH_FILE
  } // FOR
  scroll_counter=0
  FOR (i=0;i<17;i+=1) {
    FOR (j=0;j<$scroll_counter("%i%");j+=1) {
      SPRINT $name("%z%""%scroll_counter%") $scroll_name("%i%""%j%")
      SPRINT $entry("%z%""%scroll_counter%") $scroll_entry("%i%""%j%")
      scroll_counter+=1
    }
  }
  SET $counter("%z%") -= bad_scroll
  delete+=bad_scroll
  // } of scrolls

  READ_LONG 0x34 offset
  READ_LONG 0x38 count
  DELETE_BYTES offset delete*0x1c   // if we ran across invalid items or scrolls with invalid spells
  WRITE_LONG 0x38 count - delete
  PATCH_FOR_EACH off IN 0x2c 0x4c 0x70 {
    READ_LONG off another
    PATCH_IF another>=offset {
      WRITE_LONG off another - delete*0x1c
    }
  }
  FOR (i=0;i<47;i+=1) {                      // global item type loop
    PATCH_IF $counter("%i%")>0 {             // if there's at least one of this type - no need to waste electric power
      PHP_EACH $fixed("%i%") AS ind => res { // load the hardcoded array
        FOR (j=0;j<$counter("%i%");j+=1) {   // check every item in this type group
          SPRINT name $name("%i%""%j%")
          PATCH_IF (~%name%~ STRING_EQUAL_CASE ~%res%~) {
            SET $sorted("%i%""%j%") = 1
            WRITE_ASCIIE offset $entry("%i%""%j%") (0x1c)
            offset+=0x1c
          }
        }
      }
      FOR (j=0;j<$counter("%i%");j+=1) {     // now we simply put in what remains, if...
        PATCH_IF $sorted("%i%""%j%")=0 {     // ...the previous block didn't sort it out
          WRITE_ASCIIE offset $entry("%i%""%j%")
          offset+=0x1c
        }
      }
    } // PATCH_IF
  } // FOR

PATCH_VERBOSE }

}
« Last Edit: January 18, 2010, 07:23:32 PM by GeN1e » Logged
the bigg
The Avatar of Fighter / Thieves
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3370


« Reply #63 on: January 18, 2010, 07:51:05 PM »
Reply with quote

DEFINE_ARRAY => DA, ADA, DAA, ADAA? Looks a bit weird, though, not sure if they're shortable in human fashion.
CLEAR_ARRAY, GET_OFFSET_ARRAY_(2) as well?
might as well do \([A-Z]\)[A-Z]*_ -> \1 as a generic rule by this point.

Quote
Here's what {} has turned the first piece of code I have found into (dev, don't look, or you'll dirt us with your brain Wink )
The problem is that WeiDU uses a very ugly synthax, and adding curly braces to it isn't much different to dressing a 300 pounds man in a bikini.
Logged

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - Some mods that I won't mention in public
Soundset and portrait packs: Alyx Vance (from Half-Life 2) - Jane "The Soldier" Doe (from Team Fortress 2)
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Contributions: See the PPG Modlist  Smiley
GeN1e
Planewalker
*****
Offline Offline

Gender: Male
Posts: 167


« Reply #64 on: January 18, 2010, 08:58:38 PM »
Reply with quote

I take it as no.

Code:
ADA array {a b c d e f}
C_E_R GLOB ~.*\.spl~ override P_IF S_SIZE>0x71 {
  do=1 PHP_E array AS ind => res {P_IF ~%S_RES%~ STR_EQC ~%res%~ {do=0} }
  P_IF do=1{CA header GOA header 0x64 4 0x68 4 0 0 0x28 PHP_E header AS ind => res {R2 res type P_IF type=1 {W2 res+0x26 1}  }  }
} B_O
Sweet dreams...
« Last Edit: January 18, 2010, 09:05:38 PM by GeN1e » Logged
GeN1e
Planewalker
*****
Offline Offline

Gender: Male
Posts: 167


« Reply #65 on: January 18, 2010, 09:42:59 PM »
Reply with quote

So, yeah. Just in very thin case you'll be looking for a present for my 25th birthday:

PATCH_ -> P_
ACTION_ -> A_
SOURCE_ -> S_
READ_BYTE -> R1
READ_SHORT -> R2
READ_LONG -> R4
WRITE_BYTE -> W1
WRITE_SHORT -> W2
WRITE_LONG -> W4
STRING_EQUAL_CASE -> STR_EQC
DEFINE_ARRAY -> D_A
BEGIN -> {
END -> }
INT_VAR -> INT
STR_VAR -> STR

And also

OUTER_ -> O_
CLEAR_ARRAY -> C_A
GET_OFFSET_ARRAY -> GOA
GET_OFFSET_ARRAY2 -> GOA2
DEFINE_ACTION/PATCH_FUNCTION/MACRO -> D_A_F, ...,  D_P_M
COPY_EXISTING -> C_E
READ_ASCII -> RASCII
WRITE_ASCII -> WASCII
WRITE_ASCIIE -> WASCIIE
VARIABLE_IS_SET -> VAR_SET
BYTE_AT -> 1AT
SHORT_AT -> 2AT
LONG_AT -> 4AT
« Last Edit: January 18, 2010, 09:48:26 PM by GeN1e » Logged
cmorgan
Planewalker
*****
Offline Offline

Gender: Male
Posts: 1296

Searcher of Bugs


« Reply #66 on: January 18, 2010, 10:10:59 PM »
Reply with quote

Quote
// SPRINT IQ int>15? smart : int<=14&int>8? okay : int<=8? moron : rellewd_lwb pamela123
//
// refused to work. so screw it. it's not like each and every n00b is gonna try and tweak the
// code, making more even mess than The Darkest Day can possibly do to your BG2 installation

don't bet on it! This here n00b, me, the idiot posting,  is a prime example of a dude trying to figure things out the hard way, by reading the code. And messing up stuff happily like a baby playing mudpies with your Monet painting and your Chateau Yquem :


Logged
the bigg
The Avatar of Fighter / Thieves
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3370


« Reply #67 on: January 19, 2010, 03:11:30 AM »
Reply with quote

The file's src/aliases.in. Send git commits/diffs at pleasure.

Or wait for me to do a general \([A-Z]\)[A-Z]*_ -> \1 aliasing.
Logged

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - Some mods that I won't mention in public
Soundset and portrait packs: Alyx Vance (from Half-Life 2) - Jane "The Soldier" Doe (from Team Fortress 2)
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Contributions: See the PPG Modlist  Smiley
Miloch
Barbarian
Planewalker
*****
Offline Offline

Gender: Male
Posts: 667



« Reply #68 on: January 23, 2010, 07:05:34 AM »
Reply with quote

Is the point, GeN1e, to obfuscate your code and make it as unreadable as possible? And you give me a hard time for that sort of thing Tongue.
Logged

the bigg
The Avatar of Fighter / Thieves
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3370


« Reply #69 on: January 23, 2010, 07:22:32 AM »
Reply with quote

That's my opinion as well, but the problem with you guys is that you continue asking me for that sort of stupid stuff until I cave in.
Logged

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - Some mods that I won't mention in public
Soundset and portrait packs: Alyx Vance (from Half-Life 2) - Jane "The Soldier" Doe (from Team Fortress 2)
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Contributions: See the PPG Modlist  Smiley
GeN1e
Planewalker
*****
Offline Offline

Gender: Male
Posts: 167


« Reply #70 on: January 23, 2010, 10:32:01 AM »
Reply with quote

New shortcuts
Just to be sure - you aren't joking about the green light?
Btw, do you think it's safe to use W2/R4? Intelligent people don't use upper case for their variables, but who knows.
Is the point, GeN1e, to obfuscate your code and make it as unreadable as possible? And you give me a hard time for that sort of thing Tongue.
Not neccesarily obfuscate, compare these for example
D_A array {a b c d e f}
DEFINE_ARRAY array BEGIN a b c d e f END

Or those lengthy 'PATCH_IF blah BEGIN blah2 END ELSE BEGIN blah3 END' that you have to perform for something extremely short by itself.
Or long arrays of WRITE/READs (I wish I could 'length=2 R("%lenght%") varname', but needs to be done far too seldom to ever bother asking for it).

Speaking of which, whatever code I've sent your way before, imo it wasn't 'as unreadable as possible'. Or do you need me to produce more stuff in the near future? If so, your fault for not telling it earlier Tongue

That's my opinion as well, but the problem with you guys is that you continue asking me for that sort of stupid stuff until I cave in.
There're others? I thought it was just me outta my mind.


Sane behavior
Well-well, the consilium of active modders has a victim already - seems like we've shot SConrad down with that decision. Day before yesterday I've been checking the Worldmap patching lib (for reason I can remember no longer) and it was assuming the insane behavior. Will PM him soon.

Besides SC, I know Wisp, plainab and DavidW to be smart enough to use functions and who haven't shown up in this thread. Any other folks to be notified?


RET
I've already brought this up before, and while I personally don't have any immediate reason to worry about it, if FUNCs were executing normally without all RETs (either LAUNCH ones or DEFINE) set, that'd be a bit more convenient. You've been against it, so I'm not insisting, but with the sanity in, I can't foresee any consequences.
« Last Edit: January 23, 2010, 10:41:12 AM by GeN1e » Logged
the bigg
The Avatar of Fighter / Thieves
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3370


« Reply #71 on: January 23, 2010, 12:06:29 PM »
Reply with quote

It looks like 214 is set to break mods (sane Functions and Worldmap, SET_2DA_ENTRY and CtB, ...), so I might as well take the occasion to fix other insanity.

I have more or less to assume that people don't use unquoted uppercase variable names, or I wouldn't be able to add anything.

Can you link to that RET discussion?
Logged

Author or Co-Author: WeiDU - Widescreen - Generalized Biffing - Refinements - TB#Tweaks - IWD2Tweaks - Some mods that I won't mention in public
Soundset and portrait packs: Alyx Vance (from Half-Life 2) - Jane "The Soldier" Doe (from Team Fortress 2)
Maintainer: Semi-Multi Clerics - Nalia Mod - Nvidia Fix
Contributions: See the PPG Modlist  Smiley
cmorgan
Planewalker
*****
Offline Offline

Gender: Male
Posts: 1296

Searcher of Bugs


« Reply #72 on: January 23, 2010, 12:16:22 PM »
Reply with quote

igi, Mike1072, devSin, Nythrun, Wisp, Taimon, Miloch, Ardanis, GeN1e, Yovannoeth, CamDawg, SConrad, teh ggib|the bigg...

who else is there who uses heavy stuff? I have this nagging sensation I am missing some of the folks who use this.

possibly Sam. at SHS -

(I would assume that it is *not* safe to assume that people are going to use lowercase. Remember, I joke about it, but this is playtime for folks like me, and we really do not have a clue about baby stuff. Like I started by writing variables all ridiculously long, because I wanted them to be simple for pikers like me to understand, so

OUTER_SPRINT "AJANTIS_JOINED" "_AJANTJ"

OUTER_SPRINT "Candlekeep_Catacombs_L1Antechamber" "FW2613"

Then again, not many folks find it fun to dive into the stuff you guys are doing and jus piss around randomly. So I am offering commentary from the peanut gallery, so to speak.

EDIT:/ damn. crosspost. I was talking to G, not TB. Plus, there is always the point that when some idiot uses W4 as an unquoted var, the thing will fail spectacularly, and then they will come poking, and someone will say, "don't do that you idiot - use lowercase".
« Last Edit: January 23, 2010, 12:19:02 PM by cmorgan » Logged
GeN1e
Planewalker
*****
Offline Offline

Gender: Male
Posts: 167


« Reply #73 on: January 23, 2010, 12:47:52 PM »
Reply with quote

RET
Although not that much of a discussion.

Quote
Ardanis, GeN1e,
Same person Smiley
Logged
aVENGER
Sneaksie!
Planewalker
*****
Offline Offline

Gender: Male
Posts: 137


« Reply #74 on: January 23, 2010, 12:54:31 PM »
Reply with quote

Btw, do you think it's safe to use W2/R4? Intelligent people don't use upper case for their variables, but who knows.

I generally use uppercase for everything (blame my MS-DOS roots) including variables, but I always prefix them and tend to enclose them in quotes.

However, if I understand correctly, unless someone makes RR# a shorthand for something, I should be fine right?
Logged

Retired modder

Rogue Rebalancing - Author
aTweaks - Author
BG2 Fixpack - Contributor
Pages: 1 2 [3] 4 5 Go Up Reply Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Valid XHTML 1.0! Valid CSS!