1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger Viewer

Simple Toggleable Spell System 0.0.1.w3x
Variables
STSS
LIBRARY
TOGGLEABLES
CAST
Ignore this
Ok see it
Escribe debajo el código del guión personalizado especial para el mapa. El texto se incluirá en el guión del mapa después de declarar las variables y antes de los códigos de los detonadores.

		
Name Type Is Array Initial Value
globals
    hashtable toggleableSpells = InitHashtable()
    integer TEST_SPELL = 'A000'
    integer STRENGTH_SPELL = 'A001'

endglobals

library STSS

   //  * onTOoff: you have the ON state, description have turn off
   //  * offTOon: you have the OFF state, description have turn on

   function CreateToggleableSpell takes integer spell, string onTOoffT, string onTOoffET, string onTOoffI, string offTOonT, string offTOonET, string offTOonI returns nothing
      call SaveBoolean(toggleableSpells, spell, 0, false)
      call SaveStr(toggleableSpells, spell, 1, onTOoffT)
      call SaveStr(toggleableSpells, spell, 2, onTOoffET)
      call SaveStr(toggleableSpells, spell, 3, onTOoffI)
      call SaveStr(toggleableSpells, spell, 4, offTOonT)
      call SaveStr(toggleableSpells, spell, 5, offTOonET)
      call SaveStr(toggleableSpells, spell, 6, offTOonI)
   endfunction

   function ToggleSpell takes unit u, integer spell returns boolean
       local integer spellLevel = GetUnitAbilityLevel(u, spell) - 1
       local boolean currentState = LoadBoolean(toggleableSpells, spell, 0)
       local string tooltip
       local string eTooltip
       local string icon

       if (currentState == true) then
           set currentState = false
           call SaveBoolean(toggleableSpells, spell, 0, currentState)
           set tooltip = LoadStr(toggleableSpells, spell, 4)
           set eTooltip = LoadStr(toggleableSpells, spell, 5)
           set icon = LoadStr(toggleableSpells, spell, 6)

       else
           set currentState = true
           call SaveBoolean(toggleableSpells, spell, 0, currentState)
           set tooltip = LoadStr(toggleableSpells, spell, 1)
           set eTooltip = LoadStr(toggleableSpells, spell, 2)
           set icon = LoadStr(toggleableSpells, spell, 3)

       endif

       call BlzSetAbilityTooltip(spell, tooltip, spellLevel)
       call BlzSetAbilityExtendedTooltip(spell, eTooltip, spellLevel)
       call BlzSetAbilityIcon(spell, icon)

       return currentState
   endfunction



endlibrary
 
function tgca takes nothing returns nothing

    local integer spell
    local string onTOoffT
    local string onTOoffET
    local string onTOoffI
    local string offTOonT
    local string offTOonET
    local string offTOonI

    // HELP
    //  spell tooltip and icon need be per default: OFF
    //  in this case Sell is green icon, and hire is red
    //  * onTOoff: here you need the ON icon and tooltip
    //  * offTOon: here you need the OFF icon and tooltip

    // CONFIGURATION START HERE
    set spell = 'A000'
    set onTOoffT = "TURN SPELL |cffff0000OFF|r"
    set onTOoffET = "HotKey [|cffffff00Q|r]|nCURREN STATE: |cff00ff00ON|r"
    set onTOoffI = "ReplaceableTextures\\CommandButtons\\BTNSell.blp"
    set offTOonT = "TURN SPELL |cff00ff00ON|r"
    set offTOonET = "HotKey [|cffffff00Q|r]|nCURREN STATE: |cffff0000OFF|r"
    set offTOonI = "ReplaceableTextures\\CommandButtons\\BTNHire.blp"
    call CreateToggleableSpell(spell, onTOoffT, onTOoffET, onTOoffI, offTOonT, offTOonET, offTOonI)
    // CONFIGURATION END HERE

    // CONFIGURATION START HERE
    set spell = 'A001'
    set onTOoffT = "Rest"
    set onTOoffET = "HotKey [|cffffff00W|r]|nCURREN STATE: |cff00ff00ON|r"
    set onTOoffI = "ReplaceableTextures\\CommandButtons\\BTNSleep.blp"
    set offTOonT = "Get More Strength"
    set offTOonET = "HotKey [|cffffff00W|r]|nCURREN STATE: |cffff0000OFF|r"
    set offTOonI = "ReplaceableTextures\\CommandButtons\\BTNSerpentWard.blp"
    call CreateToggleableSpell(spell, onTOoffT, onTOoffET, onTOoffI, offTOonT, offTOonET, offTOonI)
    // CONFIGURATION END HERE

    call BJDebugMsg("|cffffff00Simple Toggleable Spell System|r By Allknowledge aka iam20842")
    call BJDebugMsg("1, Create a dummy spell like the example in  |cff00ffffobject editor|r")
    call BJDebugMsg("2. Save the raw code in global variable |cff00fffflibrary|r trigger")
    call BJDebugMsg("3. Create the toggleable spell |cff00fffftoggleables|r trigger")
    call BJDebugMsg("3.1 Needs on\\off tooltip")
    call BJDebugMsg("3.2 Needs on\\off extended tooltip")
    call BJDebugMsg("3.3 Needs on\\off icon")
    call BJDebugMsg("4. Manage the \"callback\", |cff00ffffcast|r trigger")
    call BJDebugMsg("5. Done")

endfunction

//===========================================================================
function InitTrig_TOGGLEABLES takes nothing returns nothing
    local trigger tg = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( tg, 0.00 )
    call TriggerAddAction( tg, function tgca )
endfunction

 
function tga takes nothing returns nothing
    local unit u
    local integer sp
    local boolean cs

    if ( GetSpellAbilityId() == TEST_SPELL) then

        set u = GetSpellAbilityUnit()
        set sp = GetSpellAbilityId()
        set cs = ToggleSpell(u, sp)

        if (cs == true) then
            call BJDebugMsg("Spell is on")
       
        else
            call BJDebugMsg("Spell is off")
        endif
    endif

    if ( GetSpellAbilityId() == STRENGTH_SPELL) then
        set u = GetSpellAbilityUnit()
        set sp = GetSpellAbilityId()
        set cs = ToggleSpell(u, sp)

        if (cs == true) then
            call BlzSetUnitIntegerField(u, UNIT_IF_STRENGTH, 9999)    
        else
            call BlzSetUnitIntegerField(u, UNIT_IF_STRENGTH, 14)
        endif
    endif
    set u = null
   
   

endfunction

//===========================================================================
function InitTrig_CAST takes nothing returns nothing
    local trigger tg = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( tg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( tg, function tga )
endfunction
Ok see it
  Events
    Map initialization
  Conditions
  Actions
    Trigger - Turn off (This trigger)
    Visibility - Disable fog of war
    Visibility - Disable black mask
    Selection - Select Archmage 0001 <gen> for Player 1 (Red)
    Camera - Lock camera target for Player 1 (Red) to Archmage 0001 <gen>, offset by (0, 0) using Default rotation