(Another) Bug I encountered (very strange one)

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
This code gives me errors, as in:
Doesn't run any function/group-action based on target/triggering unit locations from that point on since it seems to think they (target and triggering unit) are positioned at the center of the map.

JASS:
function Trig_Hook_Up_Actions takes nothing returns nothing
    local boolexpr b = Condition(function OOTU2F)
    local string s = "Must target a Famous DJ's tower that you own."
    local string s2 = "This Speaker System is already hooked up to that DJ."
    local location l
    local group g
    local integer a = 0
    if (Hook_Up_VT()) then
        if(AlreadyHookedUp()) then
            call DisplayTextToForce( GetPlayersMatching(b),s2)
        else
            if (GetSpellAbilityId() == 'A00R') then
                call UnitRemoveAbility(GetTriggerUnit(),'A00R')
                call UnitAddAbility(GetTriggerUnit(),'A00U')
            endif
            if (GetSpellAbilityId() == 'A00S') then
                set a = 1
                call UnitRemoveAbility(GetTriggerUnit(),'A00S')
                call UnitAddAbility(GetTriggerUnit(),'A00W')
            endif
            if (GetSpellAbilityId() == 'A00T') then
                set a = 2
                call UnitRemoveAbility(GetTriggerUnit(),'A00T')
                call UnitAddAbility(GetTriggerUnit(),'A00X')
            endif
            call CreateSpeakerEffect(GetSpellTargetUnit(),GetUnitUserData(GetTriggerUnit())+a)
            set l = GetUnitLoc(GetSpellTargetUnit())
            call CreateNUnitsAtLoc( 1, 'n003', GetOwningPlayer(GetTriggerUnit()), l, bj_UNIT_FACING )
            call RemoveLocation (l)
            set l = null
            call SetUnitUserData( GetLastCreatedUnit(), (GetUnitUserData(GetTriggerUnit())+a) )
            call SetUnitUserData( GetSpellTargetUnit(), ( GetUnitUserData(GetSpellTargetUnit()) + 1 ) )
            set l = GetUnitLoc(GetTriggerUnit())
            set g = GetUnitsInRangeOfLocMatching(24.00, l, Condition(function AddAbilitiesToDummy_VT))
            call ForGroup( g, function AddAbilitiesToDummy )
            call RemoveLocation (l)
            call DestroyGroup  (g)
            set l = null
            set g = null            
        endif
    else
        call DisplayTextToForce( GetPlayersMatching(b),s)
    endif
endfunction


Removing the small part with abilityIDs suddenyl makes it work :/
(trigger with "buggy part" removed below)
JASS:
function Trig_Hook_Up_Actions takes nothing returns nothing
    local boolexpr b = Condition(function OOTU2F)
    local string s = "Must target a Famous DJ's tower that you own."
    local string s2 = "This Speaker System is already hooked up to that DJ."
    local location l
    local group g
    local integer a = 0
    if (Hook_Up_VT()) then
        if(AlreadyHookedUp()) then
            call DisplayTextToForce( GetPlayersMatching(b),s2)
        else
            call CreateSpeakerEffect(GetSpellTargetUnit(),GetUnitUserData(GetTriggerUnit())+a)
            set l = GetUnitLoc(GetSpellTargetUnit())
            call CreateNUnitsAtLoc( 1, 'n003', GetOwningPlayer(GetTriggerUnit()), l, bj_UNIT_FACING )
            call RemoveLocation (l)
            set l = null
            call SetUnitUserData( GetLastCreatedUnit(), (GetUnitUserData(GetTriggerUnit())+a) )
            call SetUnitUserData( GetSpellTargetUnit(), ( GetUnitUserData(GetSpellTargetUnit()) + 1 ) )
            set l = GetUnitLoc(GetTriggerUnit())
            set g = GetUnitsInRangeOfLocMatching(24.00, l, Condition(function AddAbilitiesToDummy_VT))
            call ForGroup( g, function AddAbilitiesToDummy )
            call RemoveLocation (l)
            call DestroyGroup  (g)
            set l = null
            set g = null            
        endif
    else
        call DisplayTextToForce( GetPlayersMatching(b),s)
    endif
endfunction


What's going on? As I do -need- to base my "integer a" and the to-remove/to-add abilities off of the used ability :/
 

Omni

Ultra Cool Member
Reaction score
37
JASS:
local group g


use

JASS:
local group g = CreateGroup()

dunno but you always gotta do that :p (unless refering to another group variable)

and use createunit not the GUI createNunitsblabla
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
I checked your buggy part with JSP. It's totally fine. So your error must be somewhere else.
 

Omni

Ultra Cool Member
Reaction score
37
then it would probably be in the addabilitiestodummies function (or whatever it was) for the picked unit loop

post it.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
I don't know why, but changing it to the following seems to have worked
JASS:
function CreateDummyAndHookUp takes integer i returns nothing
    local location l
    local group g
    call CreateSpeakerEffect(GetSpellTargetUnit(),GetUnitUserData(GetTriggerUnit())+i)
    set l = GetUnitLoc(GetSpellTargetUnit())
    call CreateNUnitsAtLoc( 1, 'n003', GetOwningPlayer(GetTriggerUnit()), l, bj_UNIT_FACING )
    call RemoveLocation (l)
    set l = null
    call SetUnitUserData( GetLastCreatedUnit(), (GetUnitUserData(GetTriggerUnit())+i) )
    call SetUnitUserData( GetSpellTargetUnit(), ( GetUnitUserData(GetSpellTargetUnit()) + 1 ) )
    set l = GetUnitLoc(GetTriggerUnit())
    set g = GetUnitsInRangeOfLocMatching(24.00, l, Condition(function AddAbilitiesToDummy_VT))
    call ForGroup( g, function AddAbilitiesToDummy )
    call RemoveLocation (l)
    call DestroyGroup  (g)
    set l = null
    set g = null    
endfunction

function Trig_Hook_Up_Actions takes nothing returns nothing
    local boolexpr b = Condition(function OOTU2F)
    local string s = "Must target a Famous DJ's tower that you own."
    local string s2 = "This Speaker System is already hooked up to that DJ."
    local location l
    local group g
    if (Hook_Up_VT()) then
        if(not(AlreadyHookedUp())) then
            if (GetSpellAbilityId() == 'A00R') then
                call CreateDummyAndHookUp(0)
                call UnitRemoveAbility(GetTriggerUnit(),'A00R')
                call UnitAddAbility(GetTriggerUnit(),'A00U')
            elseif (GetSpellAbilityId() == 'A00S') then
                call CreateDummyAndHookUp(1)
                call UnitRemoveAbility(GetTriggerUnit(),'A00S')
                call UnitAddAbility(GetTriggerUnit(),'A00W')
            elseif (GetSpellAbilityId() == 'A00T') then
                call CreateDummyAndHookUp(2)
                call UnitRemoveAbility(GetTriggerUnit(),'A00T')
                call UnitAddAbility(GetTriggerUnit(),'A00X')
            endif
        else
            call DisplayTextToForce( GetPlayersMatching(b),s2)            
        endif
    else
        call DisplayTextToForce( GetPlayersMatching(b),s)
    endif
endfunction


Seems every standard thing like triggering unit etc gets flushed after the add and remove ability part :/


Anyhow, for you ease's sake, here's the full trigger, please don't steal my idea, as it's part of my tower contest submission :(

JASS:
function Trig_Hook_Up_Conditions takes nothing returns boolean
    local integer SpellID = GetSpellAbilityId()
    if ( SpellID == 'A00R' or SpellID == 'A00S' or SpellID == 'A00T' ) then
        return true
    endif
    return false
endfunction

function Hook_Up_VT takes nothing returns boolean
    local integer TargetID = GetUnitTypeId(GetSpellTargetUnit())
    local player CasterOwner = GetOwningPlayer(GetTriggerUnit())
    local player TargetOwner = GetOwningPlayer(GetSpellTargetUnit())
    if (IsUnitType(GetSpellTargetUnit(), UNIT_TYPE_STRUCTURE) == true and CasterOwner == TargetOwner and TargetID != 'n002' and TargetID != 'h009' and TargetID != 'h01O' and TargetID != 'h01P' and TargetID != 'h01Q' and TargetID != 'h00A' and TargetID != 'h00B' and TargetID != 'h00C' and TargetID != 'h00E' and TargetID != 'h00F' and TargetID != 'h00G' and TargetID != 'h00H' and TargetID != 'h00I' and TargetID != 'h00L') then
        return true
    else
        return false
    endif
endfunction

function IsLinkedDummy takes nothing returns boolean
    local integer i = GetUnitUserData(GetFilterUnit())
    local integer j = GetUnitUserData(GetTriggerUnit())
    return ( GetSpellTargetUnit() != GetFilterUnit() and GetUnitTypeId(GetFilterUnit()) == 'n003' and (i==j or i==(j+1) or i==(j+2)))
endfunction

function AlreadyHookedUp takes nothing returns boolean
    local location l
    local group g
    local integer i = 0
    if ( GetUnitUserData(GetSpellTargetUnit()) > 0 ) then
        set l = GetUnitLoc(GetSpellTargetUnit())
        set g = GetUnitsInRangeOfLocMatching(24.00, l, Condition(function IsLinkedDummy))
        call RemoveLocation (l)
        set l = null
        set i = CountUnitsInGroup(g)
        call DestroyGroup(g)
        set g = null
        if ( i > 0) then
            return true
        endif
    endif
    return false
endfunction

function AddAbilitiesToDummy_VT takes nothing returns boolean
    local integer a = 0
    if (GetSpellAbilityId() == 'A00S') then
        set a = 1
    elseif (GetSpellAbilityId() == 'A00T') then
        set a = 2
    endif    
    return ( GetFilterUnit() != GetTriggerUnit() and GetUnitTypeId(GetFilterUnit()) == 'n003' and GetUnitUserData(GetFilterUnit()) == (GetUnitUserData(GetTriggerUnit())+a))
endfunction

function AddAbilitiesToDummy takes nothing returns nothing
    local integer i
    set i = 1
    loop
        exitwhen i > udg_Integer_FDJAbil_Count
        if ( GetUnitAbilityLevelSwapped(udg_Ability_FDJAbil<i>, GetSpellTargetUnit()) &gt; 0 ) then
            call UnitAddAbilityBJ( udg_Ability_FDJAbil<i>, GetEnumUnit() )
            call SetUnitAbilityLevelSwapped( udg_Ability_FDJAbil<i>, GetEnumUnit(), GetUnitAbilityLevelSwapped(udg_Ability_FDJAbil<i>, GetSpellTargetUnit()) )
        endif
        set i = i + 1
    endloop
endfunction

function CreateDummyAndHookUp takes integer i returns nothing
    local location l
    local group g
    call CreateSpeakerEffect(GetSpellTargetUnit(),GetUnitUserData(GetTriggerUnit())+i)
    set l = GetUnitLoc(GetSpellTargetUnit())
    call CreateNUnitsAtLoc( 1, &#039;n003&#039;, GetOwningPlayer(GetTriggerUnit()), l, bj_UNIT_FACING )
    call RemoveLocation (l)
    set l = null
    call SetUnitUserData( GetLastCreatedUnit(), (GetUnitUserData(GetTriggerUnit())+i) )
    call SetUnitUserData( GetSpellTargetUnit(), ( GetUnitUserData(GetSpellTargetUnit()) + 1 ) )
    set l = GetUnitLoc(GetTriggerUnit())
    set g = GetUnitsInRangeOfLocMatching(24.00, l, Condition(function AddAbilitiesToDummy_VT))
    call ForGroup( g, function AddAbilitiesToDummy )
    call RemoveLocation (l)
    call DestroyGroup  (g)
    set l = null
    set g = null    
endfunction

function Trig_Hook_Up_Actions takes nothing returns nothing
    local boolexpr b = Condition(function OOTU2F)
    local string s = &quot;Must target a Famous DJ&#039;s tower that you own.&quot;
    local string s2 = &quot;This Speaker System is already hooked up to that DJ.&quot;
    local location l
    local group g
    if (Hook_Up_VT()) then
        if(not(AlreadyHookedUp())) then
            if (GetSpellAbilityId() == &#039;A00R&#039;) then
                call CreateDummyAndHookUp(0)
                call UnitRemoveAbility(GetTriggerUnit(),&#039;A00R&#039;)
                call UnitAddAbility(GetTriggerUnit(),&#039;A00U&#039;)
            elseif (GetSpellAbilityId() == &#039;A00S&#039;) then
                call CreateDummyAndHookUp(1)
                call UnitRemoveAbility(GetTriggerUnit(),&#039;A00S&#039;)
                call UnitAddAbility(GetTriggerUnit(),&#039;A00W&#039;)
            elseif (GetSpellAbilityId() == &#039;A00T&#039;) then
                call CreateDummyAndHookUp(2)
                call UnitRemoveAbility(GetTriggerUnit(),&#039;A00T&#039;)
                call UnitAddAbility(GetTriggerUnit(),&#039;A00X&#039;)
            endif
        else
            call DisplayTextToForce( GetPlayersMatching(b),s2)            
        endif
    else
        call DisplayTextToForce( GetPlayersMatching(b),s)
    endif
endfunction

//===========================================================================
function InitTrig_Hook_Up takes nothing returns nothing
    set gg_trg_Hook_Up = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hook_Up, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Hook_Up, Condition( function Trig_Hook_Up_Conditions ) )
    call TriggerAddAction( gg_trg_Hook_Up, function Trig_Hook_Up_Actions )
endfunction</i></i></i></i>
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
OFF TOPIC: Have you considered using a local unit instead of 18 GetTriggerUnits? Seems better to me.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Yes I have, but that camouflaged some issues, so for ease's sake i left them like that
 

Sooda

Diversity enchants
Reaction score
318
> Yes I have, but that camouflaged some issues, so for ease's sake i left them like that

Then don' t expect your made JASS would be better than GUI made actions.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
> Yes I have, but that camouflaged some issues, so for ease's sake i left them like that

Then don' t expect your made JASS would be better than GUI made actions.

I mean: If I left them like that, the error messages and eroneous actions would occur, if i used a local unit, the actions would still be messed up, but the error messages wouldn't even show...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top