A simple pain; Tower Abilities

Tyman2007

Ya Rly >.
Reaction score
74
It seems as though I've ran into a problem here.

I've made a simple trigger enhanced spell to debug a function that I have created to show the range of each tower.

It seems as though that when a tower casts an ability, the trigger is not firing.
The trigger works when i put the ability on a non-structure unit.

Is there any event that I can use for tower abilities?
Would GTrigger work for such a thing?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
There's no reason I can think of that a spell's trigger would work on a non-structure unit when it doesn't work on a tower. Could you show your trigger and function?
 

Tyman2007

Ya Rly >.
Reaction score
74
My simple snippet;
JASS:
library GetRange

    //! textmacro AddTowerRange takes TOWERTYPE, RANGE
    elseif (i == $TOWERTYPE$) then
    return $RANGE$
    //! endtextmacro

    function GetRange takes integer i returns real
        if (i == 'hgtw') then
            return 700
        //! runtextmacro AddTowerRange("'hctw'", "800")
        endif
        return 0.00
    endfunction

endlibrary


My test trigger;
JASS:
scope Range initializer Init

    globals
        private constant integer ABIL_CODE = 'A002'
    endglobals

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == ABIL_CODE
    endfunction

    private function Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local integer i = GetUnitTypeId(u)
        local real r = GetRange(i)
    
        if r != 0 then
            call BJDebugMsg("r is not equal to 0")
        else
            call BJDebugMsg("r is equal to 0 and has not been set")
        endif
        
        if i != 0 then
            call BJDebugMsg("i is registered")
        else
            call BJDebugMsg("i has not been registered")
        endif
        
        if u != null then
            call BJDebugMsg("u is registered")
        else
            call BJDebugMsg("u has not been registered")
        endif
    endfunction

    private function Init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( trig, Condition( function Conditions ) )
        call TriggerAddAction( trig, function Actions )
    endfunction

endscope


I don't think anything's wrong on the triggering end.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Hm. Well, are you sure you gave the same ability to the towers as to the unit for which it worked? :D

I don't see anything obviously wrong, so just double-check all the values, and then: when everything looks correct, something else might be interfering. Do you have any other triggers dealing with spell events?
 

Tyman2007

Ya Rly >.
Reaction score
74
Sorry for the delayed reply, nope.

I didn't post the triggers because it doesn't seem like a trigger issue here.

I made sure that it was the same ability.

I have another trigger dealing with spell effects, but it's dealing with a different spell.

It only works on non-structure units, which is a bit strange.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Wait, can you use hashtable instead of if elseif endif.
O(1) is faster than O(n).
 

Tyman2007

Ya Rly >.
Reaction score
74
I've been hearing you say that a lot and I still don't understand what that means :p (O(1) is faster than O(n))

I really despise the use of hashtables, but if it's more efficient, then I will have to try it.

Please explain?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
I've been hearing you say that a lot and I still don't understand what that means :p (O(1) is faster than O(n))
Big O notation is a way to refer to computational efficiency.

O(n) means that the time it will take for some code to process a task depends on the task in a linear fashion - if you give it a data set with "n" number of elements, it will take twice as long as if you give it data with half as many elements. Your chain of [lJASS]elseif[/lJASS]s will take longer to find the correct result if you give it a tower rawcode at the end of the chain than if you give it a rawcode that's at the beginning; on average, if you give it rawcodes with an even probability between all the possible rawcodes, it will average O(n/2) = O(n) complexity, with n being the number of elseifs.

I say O(n/2) = O(n) because it's a measure of complexity, not a measure of actual speed. Multipliers don't matter, because you're looking for the trend of computational time, not the specifics. Common measures will be O(n), O(n^2) (which, as you can imagine, rapidly slows down with larger data sets), and O(n log n) which is often the complexity achieved by optimized sort algorithms.

O(1) means that no matter what task you give some code, it will take the same amount of time. Note that this does not necessarily mean it's faster, if your comparison is with an O(n) algorithm with which you would only use simple data sets.

Hashtables are O(1) because instead of going "is it this value? no? try the next one", you simply feed it a value and it retrieves the saved data in the same amount of time no matter what.

P.S. Your tower/non-tower problem is still baffling. :eek:
 

Tyman2007

Ya Rly >.
Reaction score
74
Oh I get it now! Thank you!

The problem is, is that I suck at hashtables. Took me 5 minutes to learn them and master them with GUI, but doing what you're saying I should do is the problem I am facing.

The trigger I made was more for me practicing the use of text macros.
Would just taking out the elseifs and replacing them with normal if/then's be something like what you're saying?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
No, it is like something like this...
JASS:
//Classical example for attaching data to rawcodes.
library GetRange initializer Init

    globals
        private hashtable hasht = InitHashtable()
    endglobals

    //! textmacro AddTowerRange takes TOWERTYPE, RANGE
    call SaveReal(hasht,$TOWERTYPE$,0,RANGE)
    //! endtextmacro

    function GetRange takes integer i returns real
        return LoadReal(hasht,$TOWERTYPE$,0)
    endfunction
    
    private function Init takes nothing returns nothing
        //! runtextmacro AddTowerRange("'hctw'", "800.")
    endfunction
endlibrary
 

Tyman2007

Ya Rly >.
Reaction score
74
Hate hashtables..

But thanks!

Seems a lot easier than the way I was going at it, lol

Just had to take that trigger and fix the couple of errors.

But now.. the main problem is still bugging me.. Towers can't use triggered abilities T.T
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/

      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