System Advanced Indexing & Data Storage

mysteriis

New Member
Reaction score
0
The error happens when I try to save it for the first time. When I delete the "!" it goes okay. I think we should save it first with the "!" and then reopen the map and delete, right?
 

tooltiperror

Super Moderator
Reaction score
231
No. Simply delete the "!" and get it to save, then copy the ability, then scroll down to this line in the script:
JASS:
        private constant integer LEAVE_DETECTION_ABILITY = 'AIDS'

And go to the ability in your World Editor, and press CTRL-D to see its rawcode. Replace [ljass]'AIDS'[/ljass] with your rawcode.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
So, I've never used one of your systems J4L, because frankly, you confuse me :p
But it's come to my attention that using Damage will greatly benefit my map, so I'm going to use it.

But I have a quick question.
I didn't see it anywhere in the documentation, but I've heard that AIDS 'breaks' [ljass]GetUnitUserData()[/ljass] and [ljass]SetUnitUserData()[/ljass]?
Now, I see [ljass]GetUnitIndex()[/ljass], which I assume is the replacement for [ljass]GetUnitUserData()[/ljass];
However, I didn't see a [ljass]SetUnitIndex()[/ljass] function?

My 'combo point' system in my map uses user data's, so how would I go about fixing that 'system' to work with AIDS so that, ultimately, I can finally use Damage :p ?

Oh, and also, where's the TESH highlighting for this system ;) ?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Oh God, what :p ?
I know this system is too advanced for me, at least at this time, but I need it for Damage :eek:
 

tooltiperror

Super Moderator
Reaction score
231
You can't use [LJASS]SetUnitUserData[/LJASS] if you use AIDS, or else you break it.

Instead, you use AIDS structs. You use a textmacro because Jesus4Lyf is a lazy bastard [noparse]<3[/noparse]

An AIDS struct is a struct which is made every time a unit enters the map, and the unit is then available as [ljass]this.unit[/ljass].

You make an AIDS struct by putting [LJASS]//! runtextmacro AIDS()[/LJASS] at the very last line of your struct, right before [ljass]endstruct[/ljass]. You also have to extend array. Then you get access to a few cool methods:
  1. [ljass]static method AIDS_filter takes unit u returns boolean[/ljass] --- Every unit that enters the map is passed to this method. If true, it creates a struct of this kind.
  2. [ljass]method AIDS_onCreate takes nothing returns nothing[/LJASS] --- This is run for units that pass the filter. You can now use [LJASS]this.unit[/LJASS].
  3. [ljass]method AIDS_onDestroy takes nothing returns nothing[/LJASS] --- Ran when a unit is killed.
  4. [ljass]static method AIDS_onInit takes nothing returns nothing[/LJASS] --- This is because Jesus4Lyf took your onInit method.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Hmm..
Like I said, too advanced I think.

I have to create a struct for every script that wants to use UserData?

Maybe you could take a look at my system, and edit it to use AIDS?
I could probably figure it out once I see my own script changed to use it.
To avoid posting code unrelated to AIDS here, I'll just link to pastebin.
I don't like people doing stuff for me (Considering that's not what we're here for), but like I said, seeing my own script modified for AIDS would probably help me get it.
 

tooltiperror

Super Moderator
Reaction score
231
If I understand your script, this should be good.
Also, I don't see why you would need Damage for this :p
JASS:
struct Combo extends array
    integer combo // The number of combo points a unit has

    private static method AIDS_onEffect takes nothing returns boolean
        local thistype this
        local boolean spell = GetSpellAbilityId()==mangle or GetSpellAbilityId()==claw // Because hardcoding is bad

        if GetUnitTypeId(GetTriggerUnit())==feralDruid and spell then
            set this=thistype[GetTriggerUnit()] // thistype[x] - Return the Combo struct for the unit x
            if this.combo!=5 then
                call UnitRemoveAbility(this.unit, combo[this.combo]) // Does JASS allow combo and combo[]? I hope so, else you have to rename combo.
                set this.combo=this.combo+1
                call UnitAddAbility(u, combo[this.combo])
            endif
        endif
        return false
    endmethod
    private static method AIDS_onCreate takes nothing returns nothing
        set this.combo=0 // in case of revival and such
    endmethod
    private static method AIDS_onInit takes nothing returns nothing
        local trigger trig=CreateTrigger()
        local integer index=0
        
        call TriggerAddCondition(trig, Condition(thistype.onEffect))
        loop
            call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index=index+1
            exitwhen index==bj_MAX_PLAYER_SLOTS
        endloop
    endmethod
    //! runtextmacro AIDS()
endstruct
 

Ayanami

칼리
Reaction score
288
Couldn't he do this?

JASS:

library Combo initializer OnInit uses AIDS, GT

globals
    private constant integer UNIT_ID = 'h000' // raw code of unit feral druid
    private constant integer MANGLE_ID = 'A000' // raw code of ability mangle
    private constant integer CLAW_ID = 'A001' // raw code of ability claw
    private integer array COMBO
    
    public integer array Data
endglobals

private function OnCast takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local integer id
    
    if GetUnitTypeId(u) == UNIT_ID then
        set id = GetUnitId(u)
        if Data[id] != 5 then
            call UnitRemoveAbility(u, COMBO[Data[id]])
            set Data[id] = Data[id] + 1
            call UnitAddAbility(u, COMBO[Data[id]])
        endif
    endif

    set u = null
    return false
endfunction

private function OnInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call GT_RegisterStartsEffectEvent(t, MANGLE_ID)
    call GT_RegisterStartsEffectEvent(t, CLAW_ID)
    call TriggerAddCondition(t, Condition(function OnCast))
    set t = null
    
    // set up your COMBO array values
endfunction

endlibrary


Then for your Combo system, if you ever need to use GetUnitUserData() or SetUnitUserData() outside of the Combo library, you could just do:

JASS:

library Example uses Combo
    private function Example takes nothing returns nothing
        local unit u = SomeUnit // just an example, let's say it's a unit
        local integer i

        set Combo_Data[GetUnitId(u)] = 1 // use this instead of SetUnitUserData(u, 1)
        
        set i = Combo_Data[GetUnitId(u)] // use this instead of GetUnitUserData(u)
    endfunction
endlibrary


This would work, right?
 

tooltiperror

Super Moderator
Reaction score
231
Yeah, that's a good way if you like procedural/functional programming.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I thought I needed to trigger all damage in my map when using Damage?
Also, maybe you modifying it won't help :p , still confusing.
 

Laiev

Hey Listen!!
Reaction score
187
You need, but in some cases (like mine), I'll trigger damage dealt by units attacks too, so Damage is not like the most perfect as should be, but still my choice to use it (since I use most of resources by Jesus4Lyf)
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Here's the ComboPoints library:
JASS:
library ComboPoints initializer onInit uses AIDS, GT

    globals
        integer array COMBO
        public integer array Data
    endglobals

    private function onCast takes nothing returns boolean
        local unit u = GetTriggerUnit()
        local integer id
        
        if GetUnitTypeId(u) == feralDruid then
            set id = GetUnitId(u)
            if Data[id] != 5 then
                call UnitRemoveAbility(u, COMBO[Data[id]])
                set Data[id] = Data[id] + 1
                call UnitAddAbility(u, COMBO[Data[id]])
            endif
        endif
        set u = null
        return false
    endfunction
    
    private function OnInit takes nothing returns nothing
        call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), mangle), Condition(function onCast))
        call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), claw), Condition(function onCast))
        
        // set up your COMBO array values
        set COMBO[0] = 'A009'
        set COMBO[1] = 'A00E'
        set COMBO[2] = 'A00F'
        set COMBO[3] = 'A00G'
        set COMBO[4] = 'A00H'
        set COMBO[5] = 'A00I'
    endfunction

endlibrary
I think that's all good and fine, it compiles with no errors.
However, my one spell where it uses up combo points has a compile error:
Undeclared variable COMBO_Data (On the local integer)
JASS:
scope FerociousBite initializer init

    private function Chance takes integer level returns integer
        return level * 2
    endfunction

    private function Damage takes integer level returns real
        return (level * 0.5) + 0.5
    endfunction
    
    private function Conditions takes nothing returns boolean
        local real fbDamage
        local unit u = GetTriggerUnit()
        //local integer ud = GetUnitUserData(u)
        local integer UD = COMBO_Data[GetUnitId(u)]
        
        if (GetSpellAbilityId() == ferociousBite and UD &gt; 0) then
            set fbDamage = (GetHeroAgi(u, true) * Damage(UD))
            call UnitDamageTarget(u, GetSpellTargetUnit(), fbDamage, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            call UnitRemoveAbility(u, COMBO[UD])
            if (GetRandomInt(1, 100) &lt;= Chance(GetUnitAbilityLevel(u, ferociousBite)) and UD &gt;= 4) then
                //call SetUnitUserData(u, ud - 3)
                set UD = UD - 3
            else
                //call SetUnitUserData(u, 0)
                set UD = 0
            endif
            call UnitAddAbility(u, COMBO[UD])
        elseif (GetSpellAbilityId() == ferociousBite and UD &lt;= 0) then
            call IssueImmediateOrder(u, &quot;stop&quot;)
            call SimError(GetOwningPlayer(u), &quot;You need at least one combo point!&quot;)
        endif
        set u = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer index = 0
        
        loop    
            call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endscope
 

Ayanami

칼리
Reaction score
288
Public global's prefix is basically the library name. So, it should be "ComboPoints_Data".

JASS:
library Test
    globals
        public integer MyInt // you would need to refer this as Test_MyInt outside of the Test library
    endglobals
endlibrary

library Wow
    globals
        public integer MyInt // you would need to refer this as Wow_MyInt outside of the Wow library
    endglobals
endlibrary

library Combo
    globals
        public integer MyInt // you would need to refer this as Combo_MyInt outside of the Combo library
    endglobals
endlibrary
 

dudeim

New Member
Reaction score
22
Well if you remove the Public before it, it can be used anywhere so it's public right? I don't really get why you should even put public before a variable but whatever.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Public global's prefix is basically the library name. So, it should be "ComboPoints_Data".
Those three little examples were honestly a perfect explanation.

Thank you!
Although my ComboPoints library doesn't work, I"ll post in the JASS Help section, instead of spamming the AIDS thread with this.
Sorry J4L :p
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
In the function OnUndefendTimer the line:

[ljass] if GetUnitUserData(IndexUnit[UndefendExpiringIndex[0]]) == 0 then[/ljass]

should be

[ljass] if GetUnitUserData(IndexUnit[UndefendExpiringIndex[0]]) != 0 then[/ljass]

otherwise the user's AIDS_onDestroy is never called.
 

Bribe

vJass errors are legion
Reaction score
67
No, because after the timer the unit's user data will already be 0.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • tom_mai78101 tom_mai78101:
    Starting this upcoming Thursday, I will be in Japan for 10 days.
  • tom_mai78101 tom_mai78101:
    Thursday - Friday will be my Japan arrival flight. 9 days later, on a Sunday, will be my return departure flight.
    +2
  • The Helper The Helper:
    Hope you have safe travels my friend!
    +1
  • vypur85 vypur85:
    Wow spring time in Japan is awesome. Enjoy!
  • The Helper The Helper:
    Hopefully it will be more pleasure than work
  • vypur85 vypur85:
    Recently tried out ChatGPT about WE triggering. Wow it's capable of giving a somewhat legitimate response.
  • The Helper The Helper:
    I am sure it has read all the info on the forums here
  • The Helper The Helper:
    i think triggering is just scripting and chatgpt is real good at code
  • vypur85 vypur85:
    Yeah I suppose so. It's interesting how it can explain in so much detail.
  • vypur85 vypur85:
    But yet it won't work.
  • The Helper The Helper:
    it does a bad ass job doing excel vba code it has leveled me up at my job when I deal with excel that is for sure
  • vypur85 vypur85:
    Nice! I love Excel coding as well. Has always been using Google to help me. Maybe I'll use ChatGPT next time when I need it.
  • The Helper The Helper:
    yeah whatever it puts out even if it is not perfect I can fix it and the latest version of chatgpt can create websites from pictures it will not be long until it can do that with almost all the tools
    +1
  • The Helper The Helper:
    These new Chat AI programs are going to change everything everyone better Buckle the Fuck Up!
  • The Helper The Helper:
    oh and Happy Tuesday Evening! :)
    +1
  • jonas jonas:
    Im worried they'll change things for worse
  • jonas jonas:
    A lot more low quality content, a lot more half-baked stuff.
  • jonas jonas:
    If you're good enough to spot the mistakes of the answers you don't need it in the first place. If you aren't good enough, you're gonna rely on some half-correct stuff
  • The Helper The Helper:
    the earlier AI is and has been used extensively for publishing news and other content for a while now
  • jonas jonas:
    I used to be active on quora, it's now flooded with extremely similar, superficial answers that often miss the point of the question
  • N NJJ:
    hi
  • N NJJ:
    Hello, gathering all my old accounts… :)
    +1
  • The Helper The Helper:
    by all means gather it all up!

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top