Jump to content

advice for power level of spells using opcode 146


Recommended Posts

I have a (large-ish) number of mods that replicate spellcasting by giving this or that kit innate abilities which use opcode 146/148 to cast the original spell, or which effectively modify a spell's level by making a new spell at the new spell which uses opcode 146/148 to cast the old spell.  Generally, the code looks something like this:

COPY_EXISTING ~%the_spell%.spl~ ~override/%clone_res%.spl~ 
	READ_LONG 0x34 plvl
	READ_LONG 0x64 abil_offset
	READ_SHORT 0x68 abil_number
	READ_BYTE (%abil_offset% + 0x0c) abil_target					
	READ_SHORT (%abil_offset% + 0x0e) abil_range
	READ_LONG 0x6a eff_offset
	WHILE (%abil_number% > 0) BEGIN
	  SET abil_number = (%abil_number% - 1)
	  WRITE_SHORT (%abil_offset% + 0x26 + (0x28 * %abil_number%)) 1
	END
	LPF DELETE_EFFECT END
	PATCH_IF (%abil_target% = 4) BEGIN
	  LPF ADD_SPELL_EFFECT INT_VAR opcode = 148 target = 1 power = %plvl% parameter1 = 0 parameter2 = 1 timing = 1 STR_VAR resource = EVAL ~%the_spell%~ END
	  PATCH_IF (%abil_range% < 35) BEGIN
		PATCH_IF (%abil_range% > 4) BEGIN
			LPF ALTER_SPELL_HEADER INT_VAR range = (%abil_range% - 3) END
		END
		PATCH_IF (%abil_range% < 5) BEGIN
		  LPF ALTER_SPELL_HEADER INT_VAR target = 5 END	
		END
	  END
	END
	ELSE BEGIN
	  LPF ADD_SPELL_EFFECT INT_VAR opcode = 146 target = 2 power = %plvl% parameter2 = 1 timing = 9 STR_VAR resource = EVAL ~%the_spell%~ END
	END

This deletes all of the clone's effects, and adds a single 146 or 148 effect, with the power level set to the spell level of the originals spell, which is being cast by the 146/148 effect.

My conundrum is, something came up recently where the power level of the clone got in the way... I forget exactly, but I think it interacted with a Spell Deflection in a weird way.  Maybe it ate more "spell levels" of protection than it should have?  Something like that.  The fix seems obvious: there is no need for the clone spell's effects to have a power level, because the spell cast via 146 has its own power level.  So why even bother with it?  I adapted five of my mods by replacing "ADD_SPELL_EFFECT INT_VAR opcode = 146 power = %plvl%" with "INT_VAR opcode = 146 power = 0." This seems fine to me - the clone spell will slip past Deflections and Globes and the like, but the spells they cast via 146 should then be blocked as appropriate... right?  This is hard to test extensively; in limited testing both versions seem okay, it is just the rare marginal case where I am seeing an issue that might need addressing.  So if anyone has experience using opcode 146/148, do you see anything immediately wrong with this idea of giving the 146/148 effect itself a power level of 0?

Thx.

Edited by subtledoctor
Link to comment

It wouldn't matter for op148, as it target's "Self" anyway.

Op146 only needs a power level when it's applying actual subspells, not when it's applying a base spell.  This will insure the proper projectile is checked for reflection.

If an op146 casting "Hold Person" had a power level, the entire spell could be reflected when it shouldn't (as it's normally an AoE spell).

Link to comment

In BG1EE/ with or without SoD; Try cast magic missiles... on a 1st level character ... and then a 9th. If your theory would be fine and not to bother with power levels, then you should see 1 magic missile and then 5... but the question is, do you ? Cause I have my doubts.

Edited by Jarno Mikkola
Link to comment
45 minutes ago, Jarno Mikkola said:

Try cast magic missiles... on a 1st level character ... and then a 9th.

You're talking about caster level, we're talking about the power level of an effect, which simulates spell level.  You can set the power level of Magic Missiles to aanything from 0 to 9, and they will still fire 1 missile for a 1st-level caster and 5 missiles for a 9th-level caster.  But if you set the power level to 6 or higher, then your Magic Missiles will be able to hit a lich (they will be considered a 6th-level spell).

If you have, say, a mage/thief like a Bard from Might & Guile use an innate ability which uses opcode 146 with parameter1=0 and parameter2=1 to cast the Magic Missile wizard spell, then the resulting effect will be cast a their normal caster level, because it is a wizard casting a wizard spell (even though it is through an innate ability with opcode 146).  You could even funnel the result through a cleric spell, which would normally use caster level 1 for a mage/thief; but if the end result is a wizard spell and the opcode 146 effect uses parameter1=0, then it will end up using your wizard caster level.

But again, the power level is a different issue.  That innate ability that casts Magic Missile will be able to hit a lich, which creates a place for problems to sneak through.  But since the spell it casts is 1st level, the lich should resist that even if the "carrier" spell hits him. 

That's my assumption (and hope) anyway.

Link to comment

But, did you do any testing ? Hopefully, yes. This consern comes from facts like; Mage uses their mage level as the caster level... but a fighter can't cast a innate cleric spell using their level as their caster level cause their caster level is 1... this is actually relevant with the Bhallspawns innate powers. So a clerics healing spell could potentially heal a lot more if it's effects are based on caster levels. And wands...

Now, the power level should be the original spells power level, unless you switch the spells "spell level", in which case it should be relative to the new level. I'll just use an example, a clerics1st level attack spell, lets say a mage could cast it as their 2nd level spell... so it now should have a power level 2 instead of 1. Same, be it innates, arcane or divine. If the original spells power level is 0, then the new spells power level should always be zero... and with dispel spells, there ought to be a ramp. A 1st level spell could dispel a 3rd level, a second levels should be able to dispel a 5th, or multiple of say 4th... etc, as the power levels are also used in dispel effects.

Edited by Jarno Mikkola
Link to comment
1 hour ago, Jarno Mikkola said:

In BG1EE/ with or without SoD; Try cast magic missiles... on a 1st level character ... and then a 9th. If your theory would be fine and not to bother with power levels, then you should see 1 magic missile and then 5... but the question is, do you ? Cause I have my doubts.

At the very least, it does work this way on a ToBEx game: level 1 character that casts carrier spell Larloch's Minor Drain with only one extended header that simply casts Magic Missiles with instant timing at 0th level will only create one missile; level up the character, and suddenly it's five missiles. Don't know about BG/2EE, I suppose - I *hope* it works that way.

(e): Although now in your latest post you're mentioning the fact that wrong class types can sometimes interfere, which is I believe true - a non-arcane user casting a mage spell at 0th level would cast it at 1st level, I think.

Edited by Bartimaeus
Link to comment

Yeah but 146 can fix that. As I say, a mage using an innate to cast a priest spell to cast a mage spell, will cast the result at their normal mage level as long as the 146 effects are set to “use caster level” in parameter1. 

That is wholly irrelevant to the power level of the 146 effects. Jarno’s 2nd post is also irrelevant - it makes sense for cloning spells but ignores any consequences relating to opcode 146.

But I’m confident in my decision now, thanks folks!

Link to comment
Guest Gob Oafenplug

You may want to null the School and Sectype fields as well on a triggered spell (decrementing immunity effects are used on occasion, and things can get odd with projectile delays or the autopause bug).

There are also probably some spells left over in the SPIN/SPCL namespace where instead of making a new explosion projectile, Bio used a play VVC effect with power 0 to fake it. In this case it's helpful to transfer the graphic onto the correct spell so everything continues to look nice. It'd be better to make real explosions for these (there aren't many), but given all of the busted LIGHTING_BOLT_DONT_BOUNCE_THIS_TIME_WE_REALLY_MEAN_IT_BUT_ALSO_HIT_SOMETHING_PLZ projectiles, it's clear that was not so easy back in the day :)

Link to comment

@kjeron

The same holds for "resist_dispel", right?

That is: you should set "power" and "resist_dispel" of op146 to non-zero if "power" and "resist_dispel" of the effects of the referenced subspell are zero; otherwise, set "power" and "resist_dispel" of op146 to zero.

In so doing, the various checks trigger only once.

Edited by Luke
Link to comment

Yes.  To clarify, I am specifically talking about a situation where you have an innate ability that says "Magic Missile," which is using opcode 146 to cast the real magic missile spell SPWI112.  Can call this something like "using a shell spell to cast the real spell."

That is distinct from a situation like, say, Spell Revisions putting 146 effects into Breach/SPWI513, and moving the spell's effect into those subspells.  Call this "using the real spell to cast a subspell."

In the former situation, I transpose the real spell's casting time to the shell spell; and set opcode 146 to "cast instantly" and "use caster level," with power level = 0 and resist_dispel = "not dispel/bypass MR."  The shell spell has no projectile.  This way:

  • The spell takes as long to cast as the original, and casting speed adjustments don't get applied twice
  • The shell spell bypasses Deflections, Globes, spell level immunity, and magic resistance to deliver the real spell
  • The real wizard spell is then subject to any Deflections, resistance, and immunities (including 206 immunity, so stuff like Shield vs. MM doesn't have to be touched)
  • The real wizard spell is applied using the caster's wizard caster level

Basically I'm just running this by other eyeballs to make sure I'm not missing anything that jumps out at you.

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