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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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

      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