[Wurst] Abilities of a unit don't appear

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,928
Hello, I made a backpack based on a unit that has its own abilities, the thing is the abilities don't appear, I checked everything, its mine because I checked the owner; is not paused, because I checked if its paused; it has the ability, because I checked the level and appears 1; what else could be wrong? (I could share the script, but is too long, so I will do it if is necessary).
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
The code is written in wurst (maybe should be moved to the Trigger and Scripts section), here it is (I have to erase everything that is not related to the problem):
Wurst:
package Circles

import AbilityData

public constant BACKPACK = compiletime(UNIT_ID_GEN.next())

public unit array backpack

let SELECT_BACKPACK = compiletime(ABIL_ID_GEN.next())
let TOWER_RANGE = compiletime(ABIL_ID_GEN.next())
public constant ZOOM_IN = compiletime(ABIL_ID_GEN.next())
public constant ZOOM_OUT = compiletime(ABIL_ID_GEN.next())
let PICK_ITEMS = compiletime(ABIL_ID_GEN.next())
let DROP_ITEMS = compiletime(ABIL_ID_GEN.next())

init
    for i = 1 to 10
        backpack[i] = createUnit(players[bj_PLAYER_NEUTRAL_VICTIM], BACKPACK)

    registerSpellEffectEvent(SELECT_BACKPACK, () -> begin
        let owner = GetSpellAbilityUnit().getOwner()
        let i = owner.getNumber()
        backpack[i].setOwner(owner, false)
        owner.selectSingle(backpack[i])
        doAfter(0.4) ->
            print(backpack[i].getAbilityLevel(PICK_ITEMS))
            print(backpack[i].getOwner().getName())
            print(backpack[i].isPaused())
            print(backpack[i].issueImmediateOrderById(Orders.stunned))
    end)

    registerPlayerUnitEvent(EVENT_PLAYER_UNIT_DESELECTED, () -> begin
        if GetTriggerUnit().getTypeId() == BACKPACK
            GetTriggerUnit().setOwner(players[bj_PLAYER_NEUTRAL_VICTIM], false)
    end)

@compiletime function gen()
    new UnitDefinition(BACKPACK, 'ncop')
        ..setHideMinimapDisplay(true)
        ..setSightRadiusDay(1)
        ..setSightRadiusNight(1)
        ..setSelectionScale(-1.)
        ..setModelFile("dummy.mdl")
        ..setNormalAbilities(commaList(PICK_ITEMS, DROP_ITEMS, ZOOM_IN, ZOOM_OUT, TOWER_RANGE, COURIER_INV, AbilityIds.invulnerable, AbilityIds.permanentInvisibility))
        ..setName("Backpack")

    new ChannelAbilityPreset(ASK_HELP, 1, true)
        ..setHeroAbility(false)
        ..presetTargetTypes(Targettype.POINT)
        ..presetOption(Option.TARGETIMAGE, true)
        ..setBaseOrderID(1, "roar")
        ..setAreaofEffect(1, 300.)
        ..setCastRange(1, 99999.)
        ..setCooldown(1, 120.)
        ..setIconNormal(Icons.bTNHornOfCenarius)
        ..setButtonPositionNormalX(0)
        ..setButtonPositionNormalY(0)
        ..setHotkeyNormal("Q")
        ..setTooltipNormal(1, "[|cffffcc00Q|r] Ask help")
        ..setTooltipNormalExtended(1, "Orders a group of ally units up to 4, to go to help at you, if your hero dies, they will return to their previous objective.")
        ..setName("Ask help")

    new ChannelAbilityPreset(SELECT_BACKPACK, 1, true)
        ..setHeroAbility(false)
        ..setIconNormal(Icons.bTNDustOfAppearance)
        ..setButtonPositionNormalX(0)
        ..setButtonPositionNormalY(1)
        ..setHotkeyNormal("A")
        ..setTooltipNormal(1, "[|cffffcc00A|r] Select backpack")
        ..setTooltipNormalExtended(1, "")
        ..setName("Select backpack")

    new ChannelAbilityPreset(ZOOM_IN, 1, true)
        ..setHeroAbility(false)
        ..setArtCaster("")
        ..setIconNormal(Imports.bTNCrZoomIn)
        ..setButtonPositionNormalX(1)
        ..setButtonPositionNormalY(1)
        ..setHotkeyNormal("S")
        ..setTooltipNormal(1, "[|cffffcc00S|r] Zoom In")
        ..setTooltipNormalExtended(1, "Zoom in on the camera view.")
        ..setName("Zoom In")

    new ChannelAbilityPreset(ZOOM_OUT, 1, true)
        ..setHeroAbility(false)
        ..setArtCaster("")
        ..setIconTurnOff(Imports.bTNCrZoomOut)
        ..setIconNormal(Imports.bTNCrZoomOut)
        ..setButtonPositionNormalX(2)
        ..setButtonPositionNormalY(1)
        ..setHotkeyNormal("D")
        ..setTooltipNormal(1, "[|cffffcc00D|r] Zoom Out")
        ..setTooltipNormalExtended(1, "Zoom out the camera view.")
        ..setName("Zoom Out")

    let NO_IMMO = BUFF_ID_GEN.next()

    new AbilityDefinitionImmolationcreep(TOWER_RANGE)
        ..setDamageperInterval(1, 0)
        ..setManaDrainedperSecond(1, 0)
        ..setBufferManaRequired(1, 0)
        ..setBuffs(1, NO_IMMO.toRawCode())
        ..setManaCost(1, 0)
        ..setAreaofEffect(1, 0)
        ..setIconTurnOff(Imports.bTNRadar2)
        ..setIconNormal(Imports.bTNRadar1)
        ..setButtonPositionNormalX(3)
        ..setButtonPositionNormalY(0)
        ..setButtonPositionTurnOffX(3)
        ..setButtonPositionTurnOffY(0)
        ..setHotkeyTurnOff("R")
        ..setHotkeyNormal("R")
        ..setTooltipTurnOff(1, "[|cffffcc00R|r] Hide range of towers")
        ..setTooltipTurnOffExtended(1, "")
        ..setTooltipNormal(1, "[|cffffcc00R|r] Show range of towers")
        ..setTooltipNormalExtended(1, "")
        ..setName("Tower Range")

    new BuffDefinition(NO_IMMO, 'BEim')
        ..setArtSpecial(1, "")
        ..setArtTarget(1, "")
        ..setName("No immo")

    new ChannelAbilityPreset(PICK_ITEMS, 1, true)
        ..setHeroAbility(false)
        ..setIconNormal(Icons.bTNLoad)
        ..setButtonPositionNormalX(0)
        ..setButtonPositionNormalY(2)
        ..setHotkeyNormal("Z")
        ..setTooltipTurnOff(1, "[|cffffcc00Z|r] Pick items")
        ..setTooltipTurnOffExtended(1, "Picks up your nearby items.")
        ..setTooltipNormal(1, "[|cffffcc00Z|r] Pick items")
        ..setTooltipNormalExtended(1, "Picks up your nearby items.")
        ..setName("Pick items")

    new ChannelAbilityPreset(DROP_ITEMS, 1, true)
        ..setHeroAbility(false)
        ..setIconNormal(Icons.bTNUnLoad)
        ..setButtonPositionNormalX(1)
        ..setButtonPositionNormalY(2)
        ..setHotkeyNormal("X")
        ..setTooltipTurnOff(1, "[|cffffcc00X|r] Drop items")
        ..setTooltipTurnOffExtended(1, "Drop the items in the inventory.")
        ..setTooltipNormal(1, "[|cffffcc00X|r] Drop items")
        ..setTooltipNormalExtended(1, "Drop the items in the inventory.")
        ..setName("Drop items")
And here is the project: GitHub - HerlySQR/The-escape-of-draenei-2
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
The abilities created by Wurst at compiletime are probably overwriting whatever versions of those abilities are present in the map that you're looking at and seeing they're set to be visible. AFAIK it re-generates the ability every time you save/compile. None of the channel ability definitions in Wurst have the visible flag activated, which I presume would be set like this but I don't know because I don't Wurst:
Wurst:
..presetOption(Option.VISIBLE, true)
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
That is true, but in the constructor gives you the option of automatically set that:

Wurst:
// Look the third argument
new ChannelAbilityPreset(ZOOM_IN, 1, true)

// This is how it does it
public class ChannelAbilityPreset extends AbilityDefinitionIllidanChannel
    construct(int newId, int lvls, boolean removeChannelProperties)
        super(newId)
        setup(lvls, removeChannelProperties)
   
    function setup(int lvls, boolean removeChannelProperties)
        this.lvls = lvls
        tooltipStartListen()
        setLevels(lvls)
        tooltipStopListen(false)
        orderString = odf.getOrderString(true)
        presetBaseOrderID(_lvl -> orderString)
        if removeChannelProperties
            removeChannelProperties(true)

    function removeChannelProperties(boolean removeVisuals)
        removeChannelProperties(removeVisuals, true)

    function removeChannelProperties(boolean removeVisuals, boolean makeVisible)
        presetDisableOtherAbilities(lvl -> false)
        presetFollowThroughTime(lvl -> 0.)
        presetArtDuration(lvl -> 0.)
        if makeVisible
            presetOption(Option.VISIBLE, true) // Here it is
        if removeVisuals
            setArtCaster("")
            setArtEffect("")
            setArtSpecial("")
            setArtTarget("")

In fact, the abilities appear if I run the Wurst map, but without the scripts running, so I wanna know, what thing could cause it?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Then your units are classified as wards (basic commands would be hidden too), all the abilities have (0,-11) button position (they don't), or they're workers and you're getting the command card wiped because of how you're ordering units and deselecting them (unlikely). In my opinion something is removing the abilities right after you check to make sure the unit has them.

You're going to have to learn how to troubleshoot yourself.
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
It turns out, it wasn't anything of that, and thanks for the advice, but I was hours trying to figuring it out the problem before making this thread, after that I think I found it:
For some reason if the ability that selects the backpack is in the spellbook, the backpack don't show the abilities, but if the hero has the ability and cast it, the backpack actually shows the abilities, that is bizarre.

Edit: The spellbook is cursed, it seems that if I have opened the spellbook menu and then runs the trigger that selects the backpack, the abilities don't appear, but if I quickly exit the spellbook menu, the abilities appear, it seems that this problem has to do with the internal functioning of the spellbook.
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
What you’re experiencing is the third option I mentioned about workers and selecting. I just didn’t think it was relevant because I didn’t know both involved units were using a spellbook.

Basically you can’t go from within one spellbook on unit A to within a second spellbook on unit B instantaneously. The selection code wigs out if you do it too fast.

You can see an analysis of this bug about halfway down this thread: [Solved] - Build order causing all player builders to open build menu
 
Status
Not open for further replies.
Top