Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Axis & Allies 1942 Online is now available in Early Access! Buy it on Steam. The FAQ is available.
New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Help with sequencers/contingencies

subtledoctorsubtledoctor Member Posts: 11,238
I started from @kjeron's advice here:
kjeron said:
This probably isn't the best way, but it should work:
COPY_EXISTING ~UI.MENU~ override
	REPLACE_TEXTUALLY ~function[ %TAB%%WNL%]+filterContingencyMageSpells()~
	~function	filterContingencyMageSpellsDisabled()~
Create M_*.lua file, with contents:
function	filterContingencyMageSpells()
	local out = {}
	if characters[id].mageSpells ~= nil and characters[id].mageSpells[currentSpellLevel] ~= nil then
		for k,v in pairs(characters[id].mageSpells[currentSpellLevel]) do
			if mageScreen:SpellAllowedForContingency(v.level, v.resref) then
				tableInsert(out, v)
			end
		end
	end
	if characters[id].priestSpells ~= nil and characters[id].priestSpells[currentSpellLevel] ~= nil then
		for k,v in pairs(characters[id].priestSpells[currentSpellLevel]) do
			if v.castableCount > 0 and mageScreen:SpellAllowedForContingency(v.level, v.resref) then
				tableInsert(out, v)
			end
		end
	end
	return out
end

--These add the correct labels/descriptions when setting the sequencer/contingency, the game crashes without them:
mageBookStrings['D5W4420'] = mageBookStrings['SPWI420'] -- Minor Sequencer clone
mageBookStrings['D5W4710'] = mageBookStrings['SPWI710'] -- Spell Sequencer
mageBookStrings['D5W4809'] = mageBookStrings['SPWI809'] -- Spell Trigger
mageBookStrings['D5W4617'] = mageBookStrings['SPWI617'] -- Contingency
mageBookStrings['D5W4908'] = mageBookStrings['SPWI908'] -- Chain Contingency
I'm having a slight issue with this:

1) Imoen can load a sequencer with any spells she knows, not just ones she has memorized... but IF she uses a memorized spell, one memorized instance will be spent, just as with a normal sequencer.  Whereas, if she chooses a spell she knows but does not have memorized, it works fine and nothing is spent.

Can it be made to leave her memorized spells memorized when they are loaded into the sequencer?  As it is now it's just kind of weird.

(Of course this would be eminently work-around-able if we could use opcode 261 in a reasonable way, like to restore the last spell spent... but whatever.)

Comments

  • subtledoctorsubtledoctor Member Posts: 11,238
    edited January 31
    Hmm, actually, I can't even get this to work with the fighter/sorcerer.  I copied spwi420d.spl to d5w4420d.spl, and spwi420p.spl to d5w4420p.spl... I can create a sequencer ability in my innates bar, but when I use it nothing happens, the loaded spells don't fire and my portrait retains the "sequencer active" icon, and when I try to cast Sequencer again it says I can't have another instance of a contingency applied.

    I also tried using opcode 146 in d5w4420.spl to cast spwi420.spl, but that doesn't seem to work.

    Man, it's frustrating trying to make the game do things it was never designed to do... :lol:

  • kjeronkjeron Member Posts: 2,039
    edited January 31
    If you want to avoid decrementing memorized spells, you would need to change these lines in UI menu:
    mageScreen:SequenceSpell( bookSpells[currentBookSpell].resref, bookSpells[currentBookSpell].masterResref )
    mageScreen:UnSequenceSpell( bottomSpells[currentBottomSpell].resref, bottomSpells[currentBottomSpell].masterResref )
    to
    mageScreen:SequenceSpell( bookSpells[currentBookSpell].resref, 'DEFAULT' )
    mageScreen:UnSequenceSpell( bottomSpells[currentBottomSpell].resref, 'DEFAULT' )
    There are multiple instances of the first line.

  • kjeronkjeron Member Posts: 2,039
    edited January 31
    Hmm, actually, I can't even get this to work with the fighter/sorcerer.  I copied spwi420d.spl to d5w4420d.spl, and spwi420p.spl to d5w4420p.spl... I can create a sequencer ability in my innates bar, but when I use it nothing happens, the loaded spells don't fire
    Just to check, you did rename the resource in their activation effect to match your own?

  • subtledoctorsubtledoctor Member Posts: 11,238
    Oh probably not. That makes sense!

    Also, weirdly, Imoen can cast an innate ability - d5_seq1.spl - that uses 146 to cast spwi420. So the 146 thing should work with the d5w4420.spl as well.

    In any event, if I can get that UI.menu replacement done in a reliable way, this new component will be ready.

  • kjeronkjeron Member Posts: 2,039
    If this is intended as a replacement feature for all sequencer/contingency spells, it just takes some REPLACE_TEXTUALLY patches.  I cannot currently show you in the forums, as using backslashes breaks the current post formatting.

    If it's only intended for these specific sequencer/contingency spells, you will need to filter it with an lua function.  You would still use the REPLACE_TEXTUALLY, but replace 'DEFAULT' with the function call.

    function filterMasterBookResRef()
    	if type(actionMasterBookSpell[contingencyResRef]) == 'function' then
    		actionMasterBookSpell(contingencyResRef)
    	else
    		return bookSpells[currentBookSpell].masterResref
    	end
    end
    function filterMasterBottomResRef()
    	if type(actionMasterBottomSpell[contingencyResRef]) == 'function' then
    		actionMasterBottomSpell(contingencyResRef)
    	else
    		return bottomSpells[currentBottomSpell].masterResref
    	end
    end
    actionMasterBookResRef = {}  -- Append this to BGEE.lua
    actionMasterBottomResRef = {}  -- Append this to BGEE.lua
    actionMasterBookResRef['d5w4420'] = function () return 'DEFAULT' end  -- repeat for each
    actionMasterBottomResRef['d5w4420'] = function () return 'DEFAULT' end  -- repeat for each
    This way others will be able to opt-in, define their own, or continue to use the existing functionality. Aside from the two lines specifying BGEE.lua, the rest would go in an M_*.lua file.

  • subtledoctorsubtledoctor Member Posts: 11,238
    edited February 2
    I don't understand why this isn't working:
     COPY_EXISTING ~UI.MENU~ ~override~
        REPLACE_TEXTUALLY ~function[ %TAB%%WNL%]+filterContingencyMageSpells()~ ~function    filterContingencyMageSpellsDisabled()~
     COPY_EXISTING ~UI.MENU~ ~override~
        REPLACE_TEXTUALLY ~mageScreen:SequenceSpell( bookSpells[currentBookSpell].resref, bookSpells[currentBookSpell].masterResref )~ ~mageScreen:SequenceSpell( bookSpells[currentBookSpell].resref, 'DEFAULT' )~
     COPY_EXISTING ~UI.MENU~ ~override~
        REPLACE_TEXTUALLY ~mageScreen:UnSequenceSpell( bottomSpells[currentBottomSpell].resref, bottomSpells[currentBottomSpell].masterResref )~ ~mageScreen:UnSequenceSpell( bottomSpells[currentBottomSpell].resref, 'DEFAULT' )~
    The first replacement gets made, but the second two commands have no effect.  I copied the strings to replace directly from UI.menu, so they definitely exist there.  But they're not being replaced.

    Does REPLACE_TEXTUALLY have some kind of problem with the square brackets, or parens, or some other character in the strings?

    EDIT - I tried to pare it down, but this still doesn't work:
    REPLACE_TEXTUALLY ~bottomSpells[currentBottomSpell].masterResref~ ~'DEFAULT'~


    (EDIT 2 - HATE what's going on with the forums right now...)



  • OlvynChuruOlvynChuru Member Posts: 2,306
    REPLACE_TEXTUALLY does have a problem with square brackets. Do \[ and\].

  • subtledoctorsubtledoctor Member Posts: 11,238
    REPLACE_TEXTUALLY does have a problem with square brackets. Do \[ and\].
    Huh.  Good to know.  And, for future reference and in case anyone reaches this thread from some search or other: REPLACE_TEXTUALLY needs the backslashes in the text to be replaced, but it should not have backslashes in the new text you are inserting in its place. 

  • kjeronkjeron Member Posts: 2,039
    REPLACE_TEXTUALLY does have a problem with square brackets. Do \[ and\].
    Huh.  Good to know.  And, for future reference and in case anyone reaches this thread from some search or other: REPLACE_TEXTUALLY needs the backslashes in the text to be replaced, but it should not have backslashes in the new text you are inserting in its place. 
    This is because REPLACE_TEXTUALLY uses regexp by default.

Sign In or Register to comment.