I need help from experts

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
sorry that I can't write a more descriptive title :(

I have something that bugged me, more like "not sure", here are they:
  1. I want a "custom regeneration" system, that do the regeneration of units manually, so I add units to a group and use a 0.1s static timer to do the regeneration, but I got lag if there are too many units (about 40 units, I think)

    I think my method is not efficient so I think using AIDS and T32 would be better. Yea, T32 add a period timer to AIDS struct, and AIDS struct hold the unit's data. I only need 0.1s period for this.
    So will I be able to have more units before the lag ?
    (I know the lag would depend on what I do with each period, but assume that I do the same things with my method and with T32 )

    (I know this can be self-tested but currently, my remake map is in terraining so I can't test it myself)

  2. I make a filter system (for group enuming):

    JASS:
    scope CustomFilter
    
    globals
        private real X
        private real Y
        private real RANGE
        private unit GB_U = null
        private group GB_G = null
        private integer GB_ID = 0
        private integer array GB_Filter
    endglobals
    
    private function IsUnitTypeElite takes unit u returns boolean
        return IsUnitType(u, UNIT_TYPE_ANCIENT) and IsUnitType(u, UNIT_TYPE_GIANT )
    endfunction
    
    private function IsUnitTypeChampion takes unit u returns boolean
        return IsUnitType(u, UNIT_TYPE_SAPPER) and IsUnitType(u, UNIT_TYPE_TAUREN)
    endfunction
    
    private function IsUnitInvisibleEx takes unit u, player p returns boolean //thank to Flare
        local real ux = GetUnitX(u)
        local real uy = GetUnitY(u)
        local boolean invisible = false
        if IsUnitFogged(u,p) or IsUnitMasked(u,p) then
            call SetUnitX(u, tj_VisibleCheckerX )
            call SetUnitY(u, tj_VisibleCheckerY )
            set invisible = IsUnitInvisible(u,p)
            call SetUnitX(u, ux)
            call SetUnitY(u, uy )
        else
            set invisible = IsUnitInvisible(u,p)
        endif
        return invisible
    endfunction
    
    private function CustomBoolExprFilter takes nothing returns boolean
        local unit f = GetFilterUnit()
        local boolean array b
        local boolean ok = true
        local integer i
        
        if GetUnitAbilityLevel(f,NoNeedToCheck)>0 then //units that have "NoNeedToCheck" ability will never be enumed
            set f = null
            return false 
        endif
        set b[0] = not IsUnitInGroup(f,GB_G)
        set b[1] = GetUnitAbilityLevel(f,GB_ID) == 0
        set b[2] = not IsUnitInvulnerable(f) //check 'Avul' and data to detect the "SetUnitInvulnerable"
        set b[3] = (IsUnitIllusion(f) == false)
        set b[4] = not ( GetUnitState(f,UNIT_STATE_MAX_MANA) == 0 )
        set b[5] = (IsUnitType(f,UNIT_TYPE_MELEE_ATTACKER)==true)
        set b[6] = (IsUnitType(f,UNIT_TYPE_GROUND)==true)
        set b[7] = (IsUnitType(f,UNIT_TYPE_DEAD)==false)
        set b[8] = IsUnitEnemy(f,GetOwningPlayer(GB_U))
        set b[9] = not IsUnitTypeElite(f)
        set b[10] = not IsUnitTypeChampion(f)
        set b[11] = (IsUnitType(f,UNIT_TYPE_HERO)==false)
        set b[12] = (IsUnitType(f,UNIT_TYPE_MECHANICAL)==false)
        set b[13] = (IsUnitType(f,UNIT_TYPE_STRUCTURE)==false)
        set b[14] = (IsUnitType(f,UNIT_TYPE_MAGIC_IMMUNE)==false)
        set b[15] = (IsUnitType(f,UNIT_TYPE_ETHEREAL)==false)
        set b[16] = (GetUnitAbilityLevel(f,tj_IsWardCheck)==0) //an ability that all wards has
        set b[17] = (IsUnitFogged(f,GetOwningPlayer(GB_U))==false and IsUnitMasked(f,GetOwningPlayer(GB_U))==false)
        set b[18] = (IsUnitInvisibleEx(f,GetOwningPlayer(GB_U))==false)
        
        set i = 0
        loop
            exitwhen i > 18
            if not ( ( GB_Filter<i> == 0 ) or ( (GB_Filter<i> == 1) and b<i> ) or ( (GB_Filter<i> == 2) and not b<i> ) ) then
                set ok = false
            endif
            set i = i + 1
        endloop
        set f = null
        return ok
    endfunction
    
    private function CustomBoolExprFilterTrue takes nothing returns boolean
        return true
    endfunction
    
    function CustomBoolExprGet takes unit ufilter,integer buffid, group gfilter, string filter returns boolexpr
        local integer i = 0
        if filter == &quot;&quot; or filter == null then
            return Condition( function CustomBoolExprFilterTrue )
        endif
        loop
            exitwhen i &gt; 18
            set GB_Filter<i> = S2I(SubString(filter,i,i+1))
            set i = i + 1
        endloop
        set GB_G = gfilter
        set GB_U = ufilter
        set GB_ID = buffid
        return Condition( function CustomBoolExprFilter )
    endfunction
    
    endscope</i></i></i></i></i></i>


    so, when I want to enum units that are: has 'B000' buff, not invulnerable , alive, enemy of unitA, non-structure, non-magic immue, non-ward
    I will get boolexpr: [ljass]CustomBoolExprGet( A, 'B000', null, "0110000110000110100" )[/ljass]

    I have once told that boolexpr ( conditional functions) must be optimized as much as possible, but it's inconvenient for me to create filter for each spell (or for each group enum) so I use this CustomFilter, it's convenient for me but is it good for the game ?
    (I don't really need "good", I only need "not bad" or even "not too bad" :) )


    [*] How to calculate the maximum height of an arc projectile ? the height that projectile will reach when it fired at X range and its arc=Y.
    e.g: I have a projectile fired at 1000 range and arc = 0.15 => what is the maximum height ?
    I think I have seen this function before but I can't remember when/where so I will just ask.


thank you for reading and for the (later) answers :D
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
For #3:

This is all assuming you have a projectile speed.

I can't really remember how WC3 handles arcs, but if I recall correctly an arc value of 1.0 gives somewhat of an 90-ish degree. I'll assume the angle based on arc is ARC_VALUE*bj_PI/2. This constant can be changed if different info is given.

Some simple physics formulas tell us the following:

x = Vx * t = V0 * t * cos(a)
y = V0 * t * sin (a) - g * t^2 / 2 (unless you use some custom gravity system this can be set to V0 * t * sin (a) to simplify things).

V0 = PROJ_SPD
a = ARC_VALUE * bj_PI / 2
t[end] = RANGE / (PROJ_SPD * cos(a)) (The time for the whole arc to finish)

The time we wish to use would then be the one it takes to reach halfway through the arc, t[end] / 2

t = RANGE / (2 * PROJ_SPD * cos(a))

y[max] can then be calculated using the above formula for y:

y[max] = PROJ_SPD * RANGE / (2 * PROJ_SPD * cos(ARC_VALUE * bj_PI / 2)) * sin (ARC_VALUE * bj_PI / 2)
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
wow, kinda complex.... :eek:

I will see if I can understand these, thank anyways +rep :)
--
don't mind about 1) and 2)
  1. I do too much stuffs per period, yea, I'm just stupid
  2. now I decide to not lazy, i will write filter for each group enum
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
  1. I do too much stuffs per period, yea, I'm just stupid
  2. now I decide to not lazy, i will write filter for each group enum
Very wise. A filter system looping through a string is just plain BAD. The speed loss is absolutely NOT worth the saved time, especially if you take into account that string usage in wc3 is incredibly slow.


Just create your own naming convention for filters (so you do not need to check all the time wether you already have them) and fill up a custom library with all your filters, so you do not need to search in all your jass classes in order to find a particular one.

I recommend using "FilterUnitAliveAndP1" for example as naming convention, as it matches the way blizzard names their filters.
 

Happysmiley

New Member
Reaction score
22
He wanted an answer. Not a "I have AIDS and it's awesome.

I really was just saying this. I just started with JASS and it's to complicated for me and it seems to be vJASS, so whatever. Sorry :banghead:

I admit that the joke was unappropriate. Thanks though for the -6 rep :) No but seriously, as I didn't have any intelligent answer to his thread I thought, well, some attention is better than none, no?

And by the way, why would you assume I meant the disease and not the system?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Never once did he mention the disease. Regardless of which one you meant it provided nothing at all to the thread, which I personally think was what Chaos_Knight commented on.

As for Kazansky, figured I might point out that the Projectile Speed in question related to my previous post is (as most physics calculations) based on the SI-system, meaning it uses distance travelled per second and not interval. Might've been obvious but I decided to point it out regardless.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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