Jump to content

Looking for some help with a complicated Weidu setup


temnix

Recommended Posts

Posted

I hesitated before asking, there are so many idiots on these boards. But then, there are not idiots, and what I'm thinking of making won't be just for myself. Nothing I've made was. So let me address myself to that second category of people. I'm trying to patch spells in a complicated way, and on my own this will either take a very long time or I'll settle for something simpler and less effective and impressive. This is for a new system of magic. This part of change gives casters of wizard spells a chance to learn them (better) when they use them. By "learn better" I mean that they may get another use of this particular power. All wizard spells are being converted to innate abilities, usable once in a day as usual for them. When you learn a spell from a scroll, you get one daily use of, say, Armor. If you want to be able to cast Armor a second time, you either find another scroll, or you can practice the spell. But I want it so that the spell makes a separate learning check for every target affected by it. This way a wizard is not going to learn more about fireballing people unless he can catch some in the area of effect. Just casting Fireball on a patch of ground is not going to give an upgrade chance.

On the level of SLP files I know how to implement this. I can patch spells to apply an Original caster-targeted Give spell effect, and that will be exactly one learning check for every target. The problem is that this is only a 5% chance, and the check should be made separately for every creature caught in the fireball, or once in case of a caster-targeting spell like Armor. But the engine makes only one roll for all targets. If it is a 5% chance and a dozen creatures get blasted, then 5% of the time the caster will get 12 upgrades at once and the rest of the time nothing. Obviously this is not how it should work, so I'm being forced to go through Weidu and get it to make custom sub-spells to be put on "Original caster." The probability rolls will be inside those spells. I also would like to include a Display string message for learning something, so that removes the ultimate teaching spells by another tier. The whole arrangement is going to look a lot like the INNER_ACTION tutorial from the Weidu doc, but I don't understand that well enough. The system in outline is like this:

1. Patch wizard spell 1, %number%, with opcode 146, Original caster, 100-0, casting sub-spell "1%number%.SPL," from a template "1.SPL," containing 146, Original caster, 100-95.

2. Patch sub-spell "1%number%.SPL" with inserted reference to "2%number%.SPL" from template "2.SPL," containing 139 and 171, Original caster, 100-0.

Because only one roll is going to be made in every sub-spell's case, there have to be two tiers, with the message and the learning in the same 100-0 package, otherwise the message and the learning would be processed separately.

So this is the intention: wide patching, two special sub-spells generated for every wizard spell, the first sub-spell inserted with the second and the original spell with the first. Ideally the string given by the message could be custom, too, but that's not strictly necessary. Here is what I have so far:

COPY_EXISTING_REGEXP GLOB ~.*\.SPL~ ~override~

PATCH_IF (SOURCE_SIZE > 0x113) THEN BEGIN

READ_SHORT 0x1C type
READ_SHORT 0x68 abs
READ_STRREF 0x08 name
READ_BYTE 0x50 desc1
READ_BYTE 0x08 name2
READ_LONG 0x34 level

PATCH_IF type = 1 & abs > 0 & !(~%name%~ STRING_EQUAL ~<NO TEXT>~) & !(~%name%~ STRING_EQUAL ~<No such index~) & desc1 > 0 & name2 > 0 THEN BEGIN

WRITE_SHORT 0x1C 4

INNER_ACTION BEGIN

OUTER_SET number = number + 1

COPY ~Sorcery - Hunger for Knowledge/The Specials/DUDSS1_#.SPL~ ~override/SS1%number%_#.SPL~

LPF ADD_SPELL_EFFECT INT_VAR opcode = 146 target = 9 timing = 6 duration = 4320 parameter2 = 1 STR_VAR resource = EVAL ~%SOURCE_RES%~ END
LPF ADD_SPELL_EFFECT INT_VAR opcode = 93 target = 9 timing = 0 duration = 360 parameter1 = EVAL ~%level%~ parameter2 = 0 END

END

END
END



I know there may be problems with the number of ENDs here and so on, but that's not where I get stopped. I have this confusing INNER_ACTION arrangement that is supposed to get a number, starting from 1, and insert it in the name of the first template spell, DUDSS1_#, as SS%number%_#. _# is my personal suffix, and SS is for "sorcery," but between them there should be enough space for up to 9999 digits. Going like this, incrementing by one, the code should copy over the template sub-spell 1. Never mind sub-spell 2 for now! I just want to get this part in, but "number" is not set inside the inner action, and I don't know how to set it once somewhere in the beginning or start counting from 1. This may be something simple for Weidu experts, but it isn't for me. If you lend me a hand here, I'll certainly credit you in the mod. And you'll be doing humanity an untold amount of good.

The second effect being added in the main spell is the fatigue bonus from casting, also for every affected target, which will be limiting wizards' casting power.

Posted (edited)

A function that counts up should use this: 

    SET x = 0 - 1       //done so it starts from zero
BEGIN
    x += 1              //and here we count that up

...
END

Should be easy.

And no, you don't want to use the outer_set... unless you do it at the very begining of the mod, as that is used only to reset the variable to a constant. 

As well as writing a custom string based on that number, it depends if you want to display it above the players creature in the main window; using .baf to .bcs conversion:

ActionOverride(Player1,DisplayStringHead(Myself,~custom string with %x% and yes the x is evaluated  no need to worry about that~))

Or just the dialog window:

ActionOverride(Player1,DisplayString(Myself,~custom string with %x% and yes the x is evaluated  no need to worry about that~))

 

Here's a live example of using both of these:


COPY_EXISTING_REGEXP ~.*\.bcs$~ ~override~ 
    SET x = 0 - 1
    DECOMPILE_BCS_TO_BAF 
        REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN
                        x += 1
                END ~~~~~\1
        ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~))~~~~~
  COMPILE_BAF_TO_BCS
BUT_ONLY

It uses the decompile_BCS ... which today is replaced with decompile_and_patch funtion, unless you know what you are doing.

So somehow you sound like you are talking about me, but lets not go into that.

Edited by Jarno Mikkola
Posted

You're confusing as always, Imp, but it looks like you are trying to help. So let's try to straighten this out to a useful form. The BAF business I don't think I'm going to need - none of this is about scripts. The string is to be shown in Display string effects, saying something like "I might have learned more about %spellname%." The result would need to be inserted at the string offset of the Display string in sub-spell 2. At 9E, for simplicity. I suppose it would take fetching the name of the main spell, putting it in a variable, then generating a new string from the template string and that variable and inserting the strref for the new string at 9E in sub-spell 2. I don't know how to do that, because it would take even more bobbing and weaving in and out of INNER_ACTION or INNER_PATCH, but, like I said, it's not strictly necessary. I could just print a generic string. What I really need a hand with is the main function: generating sub-spell 1 for every main spell (every wizard spell), then generating sub-spell 2 for every sub-spell 1 and inserting  the name of the main spell in sub-spell 2's Give innate ability effect offset. Then inserting the main spell's name in sub-spell 2.

In short: fetch SPWI315.SPL, start counting %number% from 1, copy over DUDSS1_#.SPL as 1S%number%_#.SPL, copy over DUDSS2_#.SPL as 2S%number%_#.SPL, patch SPWI315.SPL with the resource name 1S%number%_#.SPL, patch 1S%number%_#.SPL with the resource name 2S%number%_#.SPL and finally patch 2S%number%_#.SPL with the resource name SPWI315. Repeat for all wizard spells in turn.

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

×
×
  • Create New...