[Trigger] [SOLVED] Automatically Cast Hidden Spell (Reforged)

===========================================================================
EDIT: [SOLVED]

Thanks to Chonky Dwarf. Putting negative value to button position lets you have it "hidden".
Side Note: to input negative value for button position into object editor, hold shift before opening the field.
===========================================================================




===========================================================================
SIMPLIFIED GOAL:

- When you attack, attempt to cast chain lightning IF it isnt on cooldown
- Dont have this spell visually clogging up the ridiculously limited UI slots


SIMPLIFIED ISSUE:

- hidden spells cant be cast by "issue order"
- Spells within a spellbook (trying the "disable spellbook trick) cant be cast via issue order


---------------------------------------------
If you could just solve this --- a way to cast a spell (with a cooldown) by trigger, without the spell being visible --- that's what i am hoping to figure out

You can ignore the rest I write below this... I included it only for if the above is not possible.

===========================================================================




===========================================================================
Explained Further:

The Actual Goal is a bit more complicated. (but most of the goals written below this are already solved --- only issue being that I have to make the chain lightning and forked lightning visible when i dont want it to be)

In other words, I only write this to explain why my trigger I post is complicated and why i am reluctant to just try and simulate chain lightning via triggers (as I dont want to just throw away all the effort I put into already making it work)

- learn spells (like chain lightning) via a spell book
- re-add these spells when returning from a morphed form
- be able to have each spell get its own spellbook (within the initial one) that lets you learn upgrades to things like range, dmg, etc)
- autocast chain lightning when attacking
- autocast forked lightning, if it has been learnt, and cant cast chain lightning
- autocasted forked lightning will do basic attack damage to primary target.

---------------------------------------------
Additional Notes:

Doing this in reforged version if that's important. I imagine it may be. I would honestly prefer just having a bigger set of abilities available to be seen in the UI --- this issue is entirely due to me trying to solve for only having like 6-7 slots.

The "Add to player gold" was just my way to test that it did actually meet the conditions and attempt to cast.

The trigger I write below WORKS - but not for hidden spells.

I would really like to avoid creating a new "trigger spell" where I just try to simulate chain lightning. I guess it wouldnt be impossible, and I could just use a timer or something for the cooldown?

===========================================================================




===========================================================================
What I have Currently (That Works IF the spells are VISIBLE):
  • KludgeAttackLightning
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Eredar Lord (lightning)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Learnt_LIGHT_Fork Equal to True
          • ((Region centered at (Position of (Attacking unit)) with size (((Real(INT_Fork_Range_total)) x 2.00), ((Real(INT_Fork_Range_total)) x 2.00))) contains (Triggering unit)) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Learnt_LIGHT_Chain Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ability Cooldown Remaining of (Attacking unit) for ability Chain Lightning ..) Not equal to 0.00
                • Then - Actions
                  • Unit - Order (Attacking unit) to Neutral Sea Witch - Forked Lightning (Attacked unit)
                  • Wait 0.30 seconds
                  • Set VariableSet TempDmg = ((Unit: (Attacking unit)'s Weapon Integer Field: Attack Damage Number Of Dice ('ua1d') at Index:0) x (Random integer number between 1 and (Dice Sides of (Attacking unit) for weapon index 0)))
                  • Set VariableSet TempDmg = (TempDmg + (Unit: (Attacking unit)'s Weapon Integer Field: Attack Damage Base ('ua1b') at Index:0))
                  • Set VariableSet TempDmg = (TempDmg - INT_Fork_Dmg_total)
                  • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Real(TempDmg)))
                • Else - Actions
            • Else - Actions
              • Unit - Order (Attacking unit) to Neutral Sea Witch - Forked Lightning (Attacked unit)
              • Wait 0.30 seconds
              • Set VariableSet TempDmg = ((Unit: (Attacking unit)'s Weapon Integer Field: Attack Damage Number Of Dice ('ua1d') at Index:0) x (Random integer number between 1 and (Dice Sides of (Attacking unit) for weapon index 0)))
              • Set VariableSet TempDmg = (TempDmg + (Unit: (Attacking unit)'s Weapon Integer Field: Attack Damage Base ('ua1b') at Index:0))
              • Set VariableSet TempDmg = (TempDmg - INT_Fork_Dmg_total)
              • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Real(TempDmg)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Region centered at (Position of (Attacking unit)) with size (1400.00, 1400.00)) contains (Triggering unit)) Equal to True
          • Learnt_LIGHT_Chain Equal to True
          • (Ability Cooldown Remaining of (Attacking unit) for ability Chain Lightning ..) Equal to 0.00
        • Then - Actions
          • Unit - Order (Attacking unit) to Orc Far Seer - Chain Lightning (Attacked unit)
          • Player - Add 1000 to Player 1 (Red).Current gold
          • Set VariableSet TriggeredChainLightning = True
        • Else - Actions
          • Set VariableSet TriggeredChainLightning = False



I am guessing my solution is just going to be simulating chain lightning and forked lightning by doing a unit group command, then adding a timer for a cooldown. But Id really like to avoid this.
 
Last edited:
If you hide the ability by using 0, -11 button positions you can order the unit to use it. Or you can just use a dummy unit to cast the ability.
Building on this idea, you can also use a custom ability based on Item Attack Slow Bonus (raw code AIsb), which provides a field that specifies the ability it casts when activated. In that field, refer to the (custom) hidden chain lightning ability that you already have in place.

However, by using this solution, you'll have to factor in the possibility that the unit with the custom chain lightning ability might not be issued an order to attack, which will not activate the chain lightning ability but still charge the unit according to its manacost.

1745150017225.png


1745150068925.png
 
If you hide the ability by using 0, -11 button positions you can order the unit to use it. Or you can just use a dummy unit to cast the ability.
Could explain how to do this? When i try to change it in object editor, it doesnt allow me to input a negative value

When i try to do it via trigger editor, when i click the integer "0" to change it, it just pops up a window with the title "Unknown" and nothing inside it... (I tried for both X and Y to see if i could change either. same issue for both)

  • Ability - Set Ability: (Unit: DemonUnit's Ability with Ability Code: Chain Lightning )'s Integer Field: Button Position - Normal (X) ('abpx') to 0
  • Ability - Set Ability: (Unit: DemonUnit's Ability with Ability Code: Chain Lightning )'s Integer Field: Button Position - Normal (Y) ('abpy') to 0
EDIT:

Nvm, i found it. I tried looking it up before, and read it wasnt possible. So i didnt try looking further. Having you say this though, made me look harder assuming it WAS possible


Answer: Hold "shift" when opening the object editor field to edit value with a negative
 
Top