Jump to content

Using the new WeiDU CREATE STO ~mystore1~


cmorgan

Recommended Posts

So, cool "new to me" feature -

 


CREATE type [ VERSION version ] resref [ patch list ] Creates a new file of the specified type with the resource reference resref and a correct file extension for the file type. If there are any patches, they are applied to contents of the new file. Any existing file with the same name will be backed up, as normal. The file will be created structurally correct but will contain no non-zero data aside from the structural details. The file version will be native to the current game, or default to "V1.0", but can be overridden with the VERSION option, which takes a string specifying the desired version. CREATE supports the file types ARE, CRE, EFF, ITM, SPL and STO and all their known file versions (aside from EFF V1.0, which is never found as a file).

 

Love the idea. No subdirectory or extra COPY, fits whatever it is installed on, created on the fly, easily changed and edited on GitHub without uploading a new file... awesome.

 

And (of course) it works! I created a store file, used lines like

 

SAY NAME2 @153

 

and a list of

 

ADD_STORE_ITEM ~MISC16~ #0 #0 #0 ~IDENTIFIED~ #5 /* Fire Agate Gem */

 

and it popped into place without so much as even a "copy"!

 

Now comes the awkward part - making it actually useable. See... the blank structure works in game, but because I didn't set or declare any of the myriad of bits of information the tore actually needs, it fires up ingame - but is completely unuseable. Not declared a tavern, no flags set, nada.

 

I looked around, but I couldn't find corresponding things like SET_STO_FLAG or some such to quickly set the following:

 

0x0008 2 // Inn(2)

0x0010 // 4 (dword) Flags
// bit 0: User allowed to buy (want to set yes)
// bit 1: User allowed to sell (want to set yes)
// bit 2: User allowed to identify items (want to set yes)
// bit 3: User allowed to steal (want to set yes)
// bit 4: User allowed to donate money (want to set no, so leave alone)
// bit 5: User allowed to purchase cures (want to set no, so leave alone)
// bit 6: User allowed to purchase drinks (want to set yes)
// bit 7: Unknown
// bit 8: Unknown
// bit 9: Quality 1 (tvrnqul0-3)
// bit 10: Quality 2 (tvrnqul0-3) (want to set yes)
// bit 11: Unknown
// bit 12: Buy Fenced Goods

0x0014 135 // 4 (dword) Store "sell price markup" (percentage of base price store charges for items) (want to set 135)
0x0018 30 // 4 (dword) Store "buy price markup" (percentage of base price store is willing to pay) (want to set 30)
0x001c 5 // 4 (dword) Depreciation rate (want to set 5)
0x0020 85 // 2 (word) % chance of steal failure (want to set 85)

etc. etc. - basically the laundry list from http://gemrb.org/iesdp/file_formats/ie_formats/sto_v1.htm .

 

I even tried Avenger_RR's code for RR, but in the examples I could find he only used patching of existing stores.

 

Before I go wandering about wasting time poking through mods to find examples of patching these into a blank .sto file, are there any existing works that have examples of using CREATE in this fashion? Or is there a mod that declares all of the elements of a .sto file that can be used?

 

(Side note: BG2EE uses three additional flags: ee ignore reputation, ex toggle recharge, ee can sell critical. I don't need any of them; just noting them for other folks.)

Link to comment

I looked around, but I couldn't find corresponding things like SET_STO_FLAG or some such to quickly set the following:

0x0010 // 4 (dword) Flags

// bit 0: User allowed to buy (want to set yes)

// bit 1: User allowed to sell (want to set yes)

// bit 2: User allowed to identify items (want to set yes)

// bit 3: User allowed to steal (want to set yes)

// bit 4: User allowed to donate money (want to set no, so leave alone)

// bit 5: User allowed to purchase cures (want to set no, so leave alone)

// bit 6: User allowed to purchase drinks (want to set yes)

// bit 7: Unknown

// bit 8: Unknown

// bit 9: Quality 1 (tvrnqul0-3)

// bit 10: Quality 2 (tvrnqul0-3) (want to set yes)

// bit 11: Unknown

// bit 12: Buy Fenced Goods

This is easy, just edit the referred .sto file, and set the flags bit by bit. And to do that I would suggest that you use a binary, as in the number starts with 0b and has 16 or less numbers(zeroes are assumed, so you won't actually have to write them), ps remember the bit zero is the very last number, bit one is the next and so forth, and when writing bits, 0 is no, and 1 is yes.... aka:

COPY ~modfolder/xyz.sto~ ~override~
WRITE_LONG ~0x0010~ ~0b0100 0100 1111~

//The others can use a decimal or hex or whatever, so they end up:
WRITE_LONG ~0x0008~ ~0x2~
WRITE_LONG ~0x0014~ ~135~
WRITE_LONG ~0x0018~ ~30~
WRITE_LONG ~0x001c~ ~5~
WRITE_SHORT ~0x0020~ ~85~
Link to comment

Sure thing - if there isn't an existing mod that sets these up in an orderly fashion, I can do the WRITE_BYTE/WRITE_SHORT/WRITE_LONG SAY NAME2 et al.

 

I do peg out at updating/extending the offset (for example, patching in Drinks Sold, adding the space to the file, and defining the drinks, etc.) but I have several examples I can work from.

 

Opening an existing .sto file in NI or DLTCEP and copying values is a simple workaround, but if I were doing that, I'd just use COPY_EXISTING and tweak the .sto (already have an edited base .sto file in the project that does exactly what I want on BG2 and works without error in BG2:EE).

 

What I was hoping for was an already working function that could do things like

 

store_name = c-tavar01 // must be 8 charcters

store_type = 2 // inn

store_flags = 0 1 2 5 6 10

store_sell_markup = 110

store_buy_markup = 20

store_depreciation = 5

store_steal_failure = 85

store_capacity = // unset = unlimited

store_lore = 100

store_IDprice = 100

store_rumors = RUMCAR01

store_rooms = 0 1 2

store_peasant = 1

store_merchant = 5

store_noble = 10

store_royal = // unset as not present

store_items_purchased = 0 1 2 3 4 6 7 10 15 22

 

and something that would work along the lines of

ADD_STORE_DRINK

ADD_STORE_CURE

 

Since we have moved folks onto LPF and such, I was hoping someone had already done my work for me :)

Link to comment

I also used CREATE to create effects files on the fly. And it works!

ACTION_DEFINE_ASSOCIATIVE_ARRAY Effet_DragonSlayer2 BEGIN
// ids        type    bonus  =>    effet
//--0 ------ 1 -------- 2 ---------------
    4,    Dragon,       3    =>    GWCDDg
    4,    Dragon,       4    =>    GWDgn
    4,    Dragon,       1    =>    GWCDDg
    6,    Blanc,        2    =>    GWDgWh
    6,    Bleu,         2    =>    GWDgBl
    6,    Noir,         2    =>    GWDgNr
    6,    Rouge,        2    =>    GWDgRg
    6,    Vert,         2    =>    GWDgVt
    6,    Brun,         2    =>    GWDgBr
    6,    Jaune,        2    =>    GWDgJa
    6,    Ombre,        2    =>    GWDgOm
    6,    Pourpre,      2    =>    GWDgPu
    6,    Profondeurs,  2    =>    GWDgPf
    6,    Rattelyr,     2    =>    GWDgRa
    6,    Pyrocla,      2    =>    GWDgPy
    6,    Sorcellerie,  2    =>    GWDgSo
    6,    Decerveleur,  2    =>    GWDgDe
    6,    Chaos,        2    =>    GWDgCh
    6,    Hurleur,      2    =>    GWDgHu
    6,    Rouille,      2    =>    GWDgRo
    6,    Vampire,      2    =>    GWDgVp
    6,    Zombie,       2    =>    GWDgZo
    6,    Dracoliche,   2    =>    GWDgDL
END
ACTION_PHP_EACH Effet_DragonSlayer2 AS donnees => effet BEGIN
    CREATE eff "%effet%H%donnees_2%"
        PATCH_MATCH ~%donnees_1%~ WITH
            Dragon      BEGIN    SET par1 = EVAL "%GW_R_Dragon%"               END
            Blanc       BEGIN    SET par1 = EVAL "%GW_S_DragonBlanc%"          END
            Bleu        BEGIN    SET par1 = EVAL "%GW_S_DragonBleu%"           END
            Noir        BEGIN    SET par1 = EVAL "%GW_S_DragonNoir%"           END
            Rouge       BEGIN    SET par1 = EVAL "%GW_S_DragonRouge%"          END
            Vert        BEGIN    SET par1 = EVAL "%GW_S_DragonVert%"           END
            Brun        BEGIN    SET par1 = EVAL "%GW_S_DragonBrun%"           END
            Jaune       BEGIN    SET par1 = EVAL "%GW_S_DragonJaune%"          END
            Ombre       BEGIN    SET par1 = EVAL "%GW_S_DragonOmbre%"          END
            Pourpre     BEGIN    SET par1 = EVAL "%GW_S_DragonPourpre%"        END
            Profondeurs BEGIN    SET par1 = EVAL "%GW_S_DragonProfondeurs%"    END
            Rattelyr    BEGIN    SET par1 = EVAL "%GW_S_DragonRattelyr%"       END
            Pyrocla     BEGIN    SET par1 = EVAL "%GW_S_DragonPyroclastique%"  END
            Sorcellerie BEGIN    SET par1 = EVAL "%GW_S_DragonSorcellerie%"    END
            Decerveleur BEGIN    SET par1 = EVAL "%GW_S_DragonDecerveleur%"    END
            Chaos       BEGIN    SET par1 = EVAL "%GW_S_DragonChaos%"          END
            Hurleur     BEGIN    SET par1 = EVAL "%GW_S_DragonHurleur%"        END
            Rouille     BEGIN    SET par1 = EVAL "%GW_S_DragonRouille%"        END
            Vampire     BEGIN    SET par1 = EVAL "%GW_S_DragonVampire%"        END
            Zombie      BEGIN    SET par1 = EVAL "%GW_S_DragonZombie%"         END
            Dracoliche  BEGIN    SET par1 = EVAL "%GW_S_Dracoliche%"           END
            DEFAULT
        END
        WRITE_LONG    0x10 178            // opcode = Spell Effect: THAC0 vs. Creature Type Modifier [178]
//        WRITE_LONG  0x14 0              // cible ou 2
        WRITE_LONG    0x20 "%donnees_0%"  // Fichier ids
        WRITE_SHORT   0x24 2              // timing = 2-While equiped
        WRITE_LONG    0x1c EVAL "%par1%"  // paramètre 1
        WRITE_SHORT   0x2c 100            // Probability 1
        WRITE_LONG    0x60 "%donnees_2%"  // Bonus-Malus (parameter3)
END

// THAC0 et Dégâts du Dragon ennemi principal et de la capacité innée Châtiment des dragons
ACTION_FOR_EACH dragon IN Wh Bl Nr Rg Vt Br Ja Om Pu Pf Ra Py So De Ch Hu Ro Vp Zo DL BEGIN
    ACTION_IF NOT FILE_EXISTS_IN_GAME ~GWDg%dragon%D2.eff~ THEN BEGIN
        COPY_EXISTING ~GWDg%dragon%H2.eff~  ~override/GWDg%dragon%D2.eff~
            WRITE_LONG    0x10 179    // opcode = Spell Effect: Damage vs. Creature Type Modifier [179]
        BUT_ONLY
        OUTER_FOR (i=1 ; i<7 ; i +=1) BEGIN
            ACTION_IF NOT FILE_EXISTS_IN_GAME ~GWDg%dragon%H%i%.eff~ THEN BEGIN
                COPY_EXISTING ~GWDg%dragon%H2.eff~    ~override/GWDg%dragon%H%i%.eff~
                    WRITE_LONG 0x60 %i%    // Bonus-Malus (parameter3)
                BUT_ONLY
            END
        END
    END
END
COPY_EXISTING ~GWCDDgH1.eff~  ~override/GWCDDgD1.eff~
    WRITE_LONG    0x10 179    // opcode = Spell Effect: Damage vs. Creature Type Modifier [179]
BUT_ONLY

Next step is to create cre files from arrays. wallbash.gif

Link to comment

Sweeeet - on both counts!

 

@Gwendolyne, for patching .cres, Rogue Rebalancing has great stuff, by the way - all heavily commented and explained. And Mike1072 has some cool code laying about somewhere that actually does do the "create NPCs and bystanders using arrays" thing, but I an't remember which mod :( He's the dude to ask.

 

@Ardanis, thanks for the reference! Going to take a look at those .tph's right now...

Link to comment

Thanks, I will have a look at his codes, hoping to save time, the worst enemy for modders! ;)

 

Writing new lines of code is so... much brain consuming...

You can find what remains of those functions here. Warning: the code is old and you might find some things that are unused or unfinished. About 3 years ago I had this to say about it:

 

 

 

Berelinde, Shadow Hand has a CRE generator that Mike wrote that not only creates the CREs but also gives them the location, hair color, class, clothing color set, etc. I am probably repeating myself so I apologize, but it's pretty easy to implement. I used it a lot when making commoner NPCs for the mod.

HECK - I forgot about that - I wanted to use it, but I can't remember why I didn't - perhaps he had nt yet finished the code. I remember it was way cool. Is it in the ShadowHand files (so I can go raid it)?

 

Yep. I didn't finish it in the sense that I wanted it to be able to generate combat-ready creatures. Right now you should be able to make scenery NPCs / townsfolk with it, though. It has a few presets defined.

 

Link to comment

Cool!

 

I have played about, and I think this is a great line of inquiry - but I'd better just avoid the CREATE STO and patch an existing file, which I can do without creating a LPF for adding drinks to the structure and updating the relevant offsets. Learning the way things work is fun, but each time I pursue one of these things it distracts me from finishing my mod.

Link to comment

 

Thanks, I will have a look at his codes, hoping to save time, the worst enemy for modders! ;)

 

Writing new lines of code is so... much brain consuming...

You can find what remains of those functions here. Warning: the code is old and you might find some things that are unused or unfinished. About 3 years ago I had this to say about it:

 

 

Thanks a lot!

 

I have already begun to code: I create a txt file (creatures"s st, wi..., level, class, colours, and so on) with openoffice, then use it as an array and launch my tpa.

For the moment, it works. Mostly...

 

I check for the class and level and the tpa automatically writes the right ST, THAC0 and so on... I even wrote subroutines to assign pre-defined soundsets, lists of spells and equipment.. The first one is OK, but the two others really need to be improved.

 

I let you know the code when it will be done. But it may take time as I am not a WeiDU specialist... ;)

And everyday I discover a new fonction or a better way to proceed. Like the new CREATE command.

 

By the same way, I use a tpa to create my new spells for testting purpose. Once I am pleased with the result, I add them to the installation component.

Link to comment

@Mike1072 : Sorry for double posting, but I didn't want to edit my last message in case you already read it.

 

What a wonderful job!

 

I didn't study all the lines but some of the few ones I read made me understood why mine did not work as intended.

On another hand, it is very interesting and helpfull to see different ways of dealing with the same goals.

 

Even it I don't use random creation, I really like the way you create brand new creatures on random.

 

No doubt your work will help me to achieve my code, and simplify it! ;)

 

Let me... a couple of weeks ;), and I will share my final coding.

 

Link to comment

Just a piece of news : I am still working on it.

I am pleased with half of it which works: stats, random stats, ST, THAC0 (check and overwrite them if they are false), plus several other offsets (colours, animation, gender, reaction and many others).

 

The idea is to use an array (exported from openoffice.org) and either check its variables or calculate them. In fact, I wanted:

 

1. To create creatures on the fly while developping and lose as less time as possible. When I create a boss, I don't care about the ST and so on. I create it on the fly and just focus on its abilities.

2. Keep the possibility to install "random" creatures in order to make the game play more inpredictable.

 

That's why I added controls to enforce the stats (you choose if you want to bypass the calculated and checked variables and use your own ones : Stats - HP - ST - THAC0). And mike, I added the paladin ST check and decided to use 1 (and not 0) as the limit for ST. ;)

 

For now, the big part is the HP calculation. But it should be over soon.

 

For the soundsets, I already have a code that works, but I will see if I can change it.

 

I also intend to had controls to automatically give immunities according to the general value (undead for example) or other ones (dragons, elementals, fire creatures...)

 

But that's a long work.

Link to comment

Archived

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

×
×
  • Create New...