(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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top