• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Spellbooks question

Status
Not open for further replies.
Level 8
Joined
Jul 10, 2008
Messages
353
What happens if I disable a spellbook to a player that doesn't have at all that spellbook?

example:
JASS:
function FuncA969c takes nothing returns nothing
call SetPlayerAbilityAvailableBJ(false,'A964',GetEnumPlayer())
endfunction


function FuncA969b takes nothing returns nothing
    call UnitAddAbility(GetTriggerUnit(),'A964') // <--spellbook
    call ForForce(bj_FORCE_ALL_PLAYERS,function FuncA969c)
	call Func0001(25.)	// <-- triggersleepaction
	call UnitRemoveAbility(GetTriggerUnit(),'A964')
endfunction
1. There is a trigger detecting when skill A969 is used and calls FuncA969b.
2. TriggerUnit is common for team 1 or 2 (any player in team 1 or 2 respectively can click it to "pick" it up and use it).

Are there any underlying issues with such usage? (like lag, desyncs etc)
 
Level 8
Joined
Jan 28, 2016
Messages
486
AFAIK, it won't cause any lag or desyncs.

Alternatively you could disable the ability for all players at map init instead so when it's added later with your code, you won't need to worry about it.

  • Map Init 1
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Disable Custom Ability for (Picked player)
  • Map Init 2
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer TempInteger) from 1 to 10, do (Actions)
        • Loop - Actions
          • Player - Disable Custom Ability for (Player(TempInteger))
JASS:
function DisableSpell takes nothing returns nothing //Moved force call to Map Init
    call SetPlayerAbilityAvailable( GetEnumPlayer(), 'A964', false )
endfunction

function Map_Init_1 takes nothing returns nothing
    call ForForce( GetPlayersAll(), function DisableSpell() )
endfunction

JASS:
function Map_Init_2 takes nothing returns nothing //Removes the force call
    local integer loop = 1
    loop
        exitwhen loop > 10
        call SetPlayerAbilityAvailable( Player(loop-1), 'A964', false )
        set loop = loop + 1
    endloop
endfunction

JASS:
function FuncA969b takes nothing returns nothing
    call UnitAddAbility(GetTriggerUnit(),'A964')  //spellbook
    call Func0001(25.)  //triggersleepaction
    call UnitRemoveAbility(GetTriggerUnit(),'A964')
endfunction

function FuncA969a takes nothing returns boolean
    if GetSpellAbilityId()=='A969' then
        call FuncA969b()
    endif
    return false 
endfunction

//===========================================================================
function InitTrig_FuncA969 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function FuncA969a ) )
    set t = null
endfunction
 
Status
Not open for further replies.
Top