Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

CombopointListener

Discussion in 'Graveyard' started by xD.Schurke, Jun 6, 2009.

  1. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
  2. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Ok, this system as it is right now is too limited for me to approve. I think the KEY thing missing here is a lack of functionality for having combo points reset to 0 after a certain time limit (it doesn't make sense if I can keep getting combos even after 5 min of inactivity). Another thing is that combo points are reset whenever you cast a spell on a different target, which probably makes sense most of the time, but there's definitely cases where a user might not want this. You should give them the option to choose.

    And once again more flexibility with awarding combo points would be nice (but I'm prepared to approve this even if this one isn't implemented). Like I said earlier, you can either use function interfaces or stub methods for this, or some other way. I don't really care as long as it works.
     
  3. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    finally added new version, which now supports auto combopoint reset
     
  4. azlier

    azlier

    Joined:
    Oct 3, 2008
    Messages:
    353
    Resources:
    4
    JASS:
    4
    Resources:
    4
    Good to see that you've come to fix it up.

    First, using that single global timer... I'm quite sure that that'll cause MUI issues.

    Second, you should merge your conditions and actions to reduce code length and function calls.

    Third, and least important, you should probably give your constant globals STANDARD_NAMING_SCHEMES.
     
  5. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    1. One global Timer doesn't cause MUI issues
    2. I won't merge the action/condition functions to reduce count of function calls.
    there wouldn't be less lines. It's also much better readable like this
    3. Yes this thing could be done, I will update this.

    Updated to v0.6a
     
  6. azlier

    azlier

    Joined:
    Oct 3, 2008
    Messages:
    353
    Resources:
    4
    JASS:
    4
    Resources:
    4
    >One global Timer doesn't cause MUI issues

    So you tested automatic combopoint decay on multiple units, then?

    >there wouldn't be less lines. It's also much better readable like this

    YOU LIE.

    Code (vJASS):
    private static method condition takes nothing returns boolean
            local unit u = GetTriggerUnit()
            local thistype this = thistype.regTable[u]
            local boolean b = false
            if this != 0 or this != null then
                set b = Table[I2S(GetHandleId(u))].exists(GetSpellAbilityId())
            endif
            set u = null
            return b
        endmethod

        private static method action takes nothing returns nothing
            local unit u = GetTriggerUnit()
            local unit tar = GetSpellTargetUnit()
            local thistype this = thistype.regTable[u]
            if this.onSwitch and tar != this.curTarget then
                call this.resetCombopoints()
                set this.curTarget = tar
            endif
            set this.cp = this.cp + Table[I2S(GetHandleId(u))][GetSpellAbilityId()]
            if this.cp > this.maxCombopoints then
                set this.cp = this.maxCombopoints
            endif
            set this.time = 0.0
            set u = null
            set tar = null
        endmethod


    Something like this looks much better, methinks. Well that is if I'm Tabling correctly. I feel I made a mistake somewhere. I don't use Table.
    Code (vJASS):
    private static method condition takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local unit tar = GetSpellTargetUnit()
        local thistype this = thistype.regTable[u]
        local Table tb
        if this != 0 or this != null then
            set tb = Table[I2S(GetHandleId(u))][GetSpellAbilityId()]
            if tb.exists() then
                if this.onSwitch and tar != this.curTarget then
                    call this.resetCombopoints()
                    set this.curTarget = tar
                endif
                set this.cp = this.cp + tb
                if this.cp > this.maxCombopoints then
                    set this.cp = this.maxCombopoints
                endif
                set this.time = 0
            endif
        endif
        set u = null
        set tar = null
    endmethod
     
  7. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    ehm like I said with actions it's better readable

    2nd your example wouldnt work :O
    set tb = Table[I2S(GetHandleId(u))][GetSpellAbilityId()]


    maybe you didn't understand what the condition thing did but the returned value isn't a table

    also there is nothing returned
     
  8. azlier

    azlier

    Joined:
    Oct 3, 2008
    Messages:
    353
    Resources:
    4
    JASS:
    4
    Resources:
    4
    I know my example won't work. I don't use Table.

    And yes, it doesn't return anything. That was an error.

    >ehm like I said with actions it's better readable

    I find the combination to be much more readable. And it's more efficient, and shorter.
     
  9. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    there is just one problem with this... each time a spell is casted on the map wc3 runs through the whole condition block to check if things are false/true
     
  10. azlier

    azlier

    Joined:
    Oct 3, 2008
    Messages:
    353
    Resources:
    4
    JASS:
    4
    Resources:
    4
    Yours and mine have about the same amount of function calls with every spell cast.
     
  11. azlier

    azlier

    Joined:
    Oct 3, 2008
    Messages:
    353
    Resources:
    4
    JASS:
    4
    Resources:
    4
    It's been some time. Some extra Table calls still there. Attachment to unit ids? Madness. Graveyarded for now.