Jump to content

Checking for points of fire damage


temnix

Recommended Posts

Who can tell me if Weidu be used to check all weapons and all spells for damage effects, for the fire type of damage, and add a Set local variable effect equal to Amount, if Number of dice rolled for random damage is 0, or equal to Number of dice rolled + Amount if it is above zero? What I aim at is to make attacks leave a mark on the creature reflecting the minimum number of points of fire damage dealt, at least. Here there may be an obstacle in the form of active elemental protection spells, which would reduce the damage that goes through, but there is no other way to find out the number of damage points inflicted except by writing something on the attack side, is there?

Link to comment

This isn't possible.  Creating a variable for fixed damage could be done, but there is no way WeiDU can know in advance what number the engine will roll for variable damage, and no way to obtain this value in-game.  You can detect the fact that a creature has suffered fire damage, but (unless you hack the engine) there is no reliable way to tell how much.

Link to comment

There is, if you start from actual values of the damage. Then you know what to record. :) I'm using this scheme right now: patching all spells and items with CLONE_EFFECT, targeting opcode 12 and copying its values to an opcode 309 (Set local variable). This variable will later be checked in creature scripts. I can't know how many points of damage will be rolled, but I can clone damage effects twice: once for fixed damage in Amount and nothing for Number of dice rolled, and once for Number of dice rolled and nothing for Amount. This way a spell that does 1d8 + 3 damage will imprint the target with two local variable increases, one for 1 point and the other for 3 points. It is a kind of bare minimum, of course, and there is the problem of "save for half" effects, where the target won't get any variable points on a successful save, because the damage and the 309 share a saving throw. It's all or nothing. But that can't be helped, I think.

What I need right now is to know how to read damage type from effects with Weidu. This is the code that should check for damage with 5 dice rolled:

LPF CLONE_EFFECT INT_VAR check_globals = 0 silent = 1  match_opcode = 12 match_target = 2 match_dicenumber = 5 opcode = 309 dicenumber = 0 dicesize = 0 parameter1 = 5 parameter2 = 1 STR_VAR insert = ~below~ resource = ~SPECDAM~ END

This increases SPECDAM by 5, but I need these checks only for FIRE damage, which is neither parameter1 nor parameter2. There is some crafty and esoteric way to read these things, and that's what I want to know. And for acid, too.

Edited by temnix
Link to comment

If you read the description of opcode #12 in IESDP, it shouldn't be very difficult that damage type is determined by parameter2.  It's actually a bit field, BIT16 = acid and BIT24 = fire.  But in almost all cases only one bit is ever set so most modders just test by value, 65536 = acid, 524288 = fire.

Figuring the minimum damage an effect can do does indeed work as you describe, but there is no way to know if such damage was actually done, the target could have made a saving throw, MR roll or be resistant/immune.

I understand that you wish to achieve some sort of scarring effect.  One way to go at it might be to use CLONE_EFFECT to patch everything that deals fire damage to also have some sort of permanent or long-lasting effect, like lowering max HP a bit.  Then you could patch every item or spell that gives more than, say, 50% fire resistance to give immunity to that effect.

Link to comment
10 hours ago, Angel said:

I understand that you wish to achieve some sort of scarring effect.  One way to go at it might be to use CLONE_EFFECT to patch everything that deals fire damage to also have some sort of permanent or long-lasting effect, like lowering max HP a bit.

That's just what I'm doing! Saving throws and magic resistance are not a problem - the CLONE copies those, so they will be packed in the same dice roll. (And by the way, CLONE takes the match_damage_type parameter, not listed in the readme.) Resistance to fire damage... Yes, that's a good idea, but only for 100% resistance. The next thing I need to do is to figure out a way to take stock of reduced maximum hit points. When the creature has been burned down to the absolute minimum, which is 1 hp for level. The hit point total can't be lowered beyond that. I don't know if Constitution bonuses add to this. Anyway, I can write a bunch of script checks for every HD: if this many levels and maximum hit points is the same number, then remove regeneration. That's what this is all about, obviously. 

Link to comment

Max hit points can be checked by op326/318/324, I believe. My hit point-based psionics drop your max hp but will not reduce you below 1 (you just fall unconscious instead). No need for scripts, you can just  put the scarring effect in a subspell/eff and precede the 146/177 effect triggering it with an op318 effect.

Edited by subtledoctor
Link to comment

I mean, I’m doing it right now. The code is somewhere in here.

Ah, here:

APPEND ~splprot.2da~ ~D5_MXHP_LT%TAB%1%TAB%-1%TAB%2~

COPY_EXISTING ~splprot.2da~ ~override~
  COUNT_2DA_COLS cols
  READ_2DA_ENTRIES_NOW rows cols
  FOR (row = 1; row < rows; ++row) BEGIN
    READ_2DA_ENTRY_FORMER rows row 0 ~stat~
    PATCH_IF ~%stat%~ STRING_EQUAL_CASE ~D5_MXHP_LT~ BEGIN
      SET maxhp_lt = %row%
    END
  END
BUT_ONLY

COPY ~some_spell.spl~ ~override~
  LPF ADD_SPELL_EFFECT INT_VAR insert_point = 0 opcode = 318 target = 1 parameter1 = 7 parameter2 = %maxhp_lt% timing = 0 duration = 1 STR_VAR resource = ~d5psmx6~ END

That prevents subsequent effects from occurring if the caster has 6 or fewer max hit points. 

(EDIT - fixed formatting.)

Edited by subtledoctor
Link to comment

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...