• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

JASS blatantly not working

Status
Not open for further replies.
Level 7
Joined
Aug 31, 2006
Messages
132
I don't know what's wrong with it.

To explain it. There are 2 teams. Every team has 5 players and a computer player (Orange, brown).

When the ability is used on a hero, he gets an ability which reduces sight and loses ally vision from all players from his team.

But for some reason the spell doesnt wanna do it. I even used the game message to show me who removes ally vision to whom. It said "5 unallied vision to 0", but that didnt happen, i still had vision of Orange's units. Just what is wrong with it?

*The code*
JASS:
function Trig_InvadeMind_Conditions takes nothing returns boolean
    if   GetSpellAbilityId() == 'A07U'  then
        return true
    endif
    return false
endfunction

function Trig_InvadeMind_Actions takes nothing returns nothing
local unit MindInvadedHero
local integer MindLoop = 0
set MindInvadedHero = GetSpellTargetUnit()
call DisplayTimedTextToForce( GetPlayersAll(), 5.00, I2S(GetPlayerId(GetOwningPlayer(MindInvadedHero))) )
    call UnitAddAbilityBJ( 'A07T', MindInvadedHero )
call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Ability added." )
    call SetUnitAbilityLevelSwapped( 'A07T', MindInvadedHero, GetUnitAbilityLevelSwapped('A07U', GetSpellAbilityUnit()) )
call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Ability adjusted." )
    if GetPlayerId(GetOwningPlayer(MindInvadedHero)) <= 5 then
call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Loop 1 started." )
        loop
            exitwhen MindLoop == 6
            if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != MindLoop then
                call SetPlayerAllianceBJ( ConvertedPlayer(MindLoop), ALLIANCE_SHARED_VISION, false, GetOwningPlayer(MindInvadedHero) )
call DisplayTimedTextToForce( GetPlayersAll(), 5.00, I2S(MindLoop) + " unallied sight with " + I2S(GetPlayerId(GetOwningPlayer(MindInvadedHero)))  )
            else
            endif
            set MindLoop = MindLoop + 1
        endloop
set MindLoop = 0
        call TriggerSleepAction( 10.00 )
        loop
            exitwhen MindLoop == 6
if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != MindLoop then
                call SetPlayerAllianceBJ( ConvertedPlayer(MindLoop), ALLIANCE_SHARED_VISION, true, GetOwningPlayer(MindInvadedHero) )
else
endif
            set MindLoop = MindLoop + 1
        endloop
set MindLoop = 0
    else
        loop
            exitwhen MindLoop == 6
            if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != (MindLoop + 6) then
                call SetPlayerAllianceBJ( ConvertedPlayer(( MindLoop + 12 )), ALLIANCE_SHARED_VISION, false, GetOwningPlayer(MindInvadedHero) )
            else
            endif
set MindLoop = MindLoop + 1
        endloop
set MindLoop = 0
        call TriggerSleepAction( 10.00 )
        loop
            exitwhen MindLoop == 6
            if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != (MindLoop + 6) then
                call SetPlayerAllianceBJ( ConvertedPlayer(( MindLoop + 12 )), ALLIANCE_SHARED_VISION, true, GetOwningPlayer(MindInvadedHero) )
else
endif
            set MindLoop = MindLoop + 1
        endloop
set MindLoop = 0
    endif
endfunction

//===========================================================================
function InitTrig_InvadeMind takes nothing returns nothing
    set gg_trg_InvadeMind = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_InvadeMind, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_InvadeMind, Condition( function Trig_InvadeMind_Conditions ) )
    call TriggerAddAction( gg_trg_InvadeMind, function Trig_InvadeMind_Actions )
endfunction
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
JASS:
function Trig_InvadeMind_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A07U'  
endfunction

function Trig_InvadeMind_Actions takes nothing returns nothing
    local unit MindInvadedHero
    local integer MindLoop = 0
    set MindInvadedHero = GetSpellTargetUnit()
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, I2S(GetPlayerId(GetOwningPlayer(MindInvadedHero))) )
    call UnitAddAbilityBJ( 'A07T', MindInvadedHero )
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Ability added." )
    call SetUnitAbilityLevelSwapped( 'A07T', MindInvadedHero, GetUnitAbilityLevelSwapped('A07U', GetSpellAbilityUnit()) )
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Ability adjusted." )
    if GetPlayerId(GetOwningPlayer(MindInvadedHero)) <= 5 then
        call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Loop 1 started." )
        loop
            exitwhen MindLoop == 6
            if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != MindLoop then
                call SetPlayerAllianceBJ( ConvertedPlayer(MindLoop), ALLIANCE_SHARED_VISION, false, GetOwningPlayer(MindInvadedHero) )
                call DisplayTimedTextToForce( GetPlayersAll(), 5.00, I2S(MindLoop) + " unallied sight with " + I2S(GetPlayerId(GetOwningPlayer(MindInvadedHero)))  )
            endif
            set MindLoop = MindLoop + 1
        endloop
        set MindLoop = 0
        call TriggerSleepAction(10)
        loop
            exitwhen MindLoop == 6
            if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != MindLoop then
                call SetPlayerAllianceBJ( ConvertedPlayer(MindLoop), ALLIANCE_SHARED_VISION, true, GetOwningPlayer(MindInvadedHero) )
            endif
            set MindLoop = MindLoop + 1
        endloop
        set MindLoop = 0
    else
        loop
            exitwhen MindLoop == 6
            if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != (MindLoop + 6) then
                call SetPlayerAllianceBJ( ConvertedPlayer(( MindLoop + 12 )), ALLIANCE_SHARED_VISION, false, GetOwningPlayer(MindInvadedHero) )
            endif
            set MindLoop = MindLoop + 1
        endloop
        set MindLoop = 0
        call TriggerSleepAction(10)
        loop
            exitwhen MindLoop == 6
            if GetPlayerId(GetOwningPlayer(MindInvadedHero)) != (MindLoop + 6) then
                call SetPlayerAllianceBJ( ConvertedPlayer(( MindLoop + 12 )), ALLIANCE_SHARED_VISION, true, GetOwningPlayer(MindInvadedHero) )
            endif
            set MindLoop = MindLoop + 1
        endloop
        set MindLoop = 0
    endif
endfunction

function InitTrig_InvadeMind takes nothing returns nothing
    set gg_trg_InvadeMind = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_InvadeMind, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_InvadeMind, Condition( function Trig_InvadeMind_Conditions ) )
    call TriggerAddAction( gg_trg_InvadeMind, function Trig_InvadeMind_Actions )
endfunction

I did not fix anything up yet, but I removed unneded code and generally made it more readable for people.
 
Level 6
Joined
May 7, 2009
Messages
228
I don't think the SetPlayerALlianceBJ is necessary, because all it does it checks whether the the two player arguments are the same before calling the native version, but you already did the check.
 
Status
Not open for further replies.
Top