Hero attacks! (Most specifically for Yak)

A place to talk about general WC3 and EotA related stuff.
Message
Author
User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Hero attacks! (Most specifically for Yak)

#1 Post by Perhaps »

As custom script.

Code: Select all

function Filta takes nothing returns boolean
    local unit u = GetFilterUnit()
    
    if IsUnitType(u, UNIT_TYPE_HERO) then
        return true
    endif
    return false
endfunction
As trigger.

Code: Select all

function Hero_Attacks takes nothing returns nothing
    //DO THINGS!
endfunction

//==========================================================================
function InitTrig_Hero_Attacks takes nothing returns nothing
    set gg_trg_Hero_Attacks = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(0), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(1), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(2), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(3), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(4), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(5), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(6), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(7), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(8), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(9), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(10), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Hero_Attacks, Player(11), EVENT_PLAYER_UNIT_ATTACKED, Condition(function Filta) )
    call TriggerAddAction( gg_trg_Hero_Attacks, function Hero_Attacks )
endfunction

Trigger will fire ONLY when a hero attacks. Tested. Works. Is Dynamic, no registering needed for new heroes.

So, now make cool abilities that involve attacking!
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#2 Post by DarnYak »

I think i've explained this before, but you clearly didn't get it if so.

EotA tends ot have around 100 active units per side at all times, for 200 units actively in combat (with buildings and non red/blue units, it's probably more like 250-300).

For every swing (probably averages in the 1.75 seconds per swing, so lets say 130 swings per second), the filter trigger must be executed.

For every "on hero attacks" skill added, a new check for that hero must be added, which means an extra X checks per second per hero skill based on the next swing.

I've known this possibility exists for a long time, its just unrealistic to add more then one or two of these to EotA before it'll start impacting game performance.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#3 Post by Perhaps »

Filters am supa fast since they have little traffic. You can have a flow of check for hero in filter function, which firing off a lot probably wouldn't be problematic, and it would only fire the trigger off to do checks for specific skills in actions and do actions (and of course you can use returns for terminal endings of the instances when they don't need to look any farther).

So while the filter would be firing off for many units (which I don't think would be problematic, me and Something have done similar with a bulk of units).

The trigger that contains the meaty stuff would only fire off for 10 units (heroes). Meaning any additional checks for skill level will not pertain to non-hero units running the filter. If it doesn't pass the filter that it's a hero, it won't do the checks or actions, so no, it won't have to do all those skill checks for all those non-hero units.

And really it's not much different than using unit specific events. Warcraft III still has to check every unit that attacks and checks "is registered? if so, to what?"
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#4 Post by DarnYak »

And really it's not much different than using unit specific events. Warcraft III still has to check every unit that attacks and checks "is registered? if so, to what?"
WC3, checking internally, runs native cpu code. A filter, on the other hand, has to create a script stack, and then interpret said script. There's a magniture of difference in the cpu speeds.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#5 Post by Perhaps »

So I did a test run of it with 200 riflemen on player 1 and 200 riflemen on Player 2 with it, it ran just fine. Except for actually looking at all of the riflemen at once (which is an entirely different story). Take in to consideration my computer is only like 4ghz total with 1gb ram total, while needing a clean up and under spyware. So filters really do run fast.

I tried it with taking off the filter from the event, my computer shat a brick without it. Proving that skill checks or any other checks that come after the filter are irrelevant to units they don't pass the filter.

Performance tweak, lul. I should put false statement first since it would occur more.

Code: Select all

function Filta takes nothing returns boolean
    local unit u = GetFilterUnit()
    
    if (not IsUnitType(u, UNIT_TYPE_HERO)) then
        return false
    endif
    return true
endfunction
Image

User avatar
Discombobulator
Retired
Retired
Posts: 710
Joined: September 19th, 2006, 4:16 pm
Battle.net name: Karunecm
Contact:

Re: Hero attacks! (Most specifically for Yak)

#6 Post by Discombobulator »

Perhaps wrote:So I did a test run of it with 200 riflemen on player 1 and 200 riflemen on Player 2 with it, it ran just fine. Except for actually looking at all of the riflemen at once (which is an entirely different story). Take in to consideration my computer is only like 4ghz total with 1gb ram total, while needing a clean up and under spyware. So filters really do run fast.

I tried it with taking off the filter from the event, my computer shat a brick without it. Proving that skill checks or any other checks that come after the filter are irrelevant to units they don't pass the filter.

Performance tweak, lul. I should put false statement first since it would occur more.

Code: Select all

function Filta takes nothing returns boolean
    local unit u = GetFilterUnit()
    
    if (not IsUnitType(u, UNIT_TYPE_HERO)) then
        return false
    endif
    return true
endfunction
Now test the trigger in a map which already has a reputation for lagging horribly.
I'm this forum's MVP.

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#7 Post by DarnYak »

Performance tweak, lul. I should put false statement first since it would occur more.
If you really care about performance then it'd be

Code: Select all

return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true
You aren't setting u to null, btw, so that version also leaks. The '== true' part is almsot redundant, except IsUnitType acts slightly funky (returns integer -1 instead of 1), and i believe the filters bug out if you return a raw IsUnitType value
I tried it with taking off the filter from the event, my computer shat a brick without it. Proving that skill checks or any other checks that come after the filter are irrelevant to units they don't pass the filter
I do find it interesting the filter has this significant of an impact, which makes me inclined to investigate it a bit more. But you're test is also ignoring all the other shit going on. You're ignoring what i've been trying to say: the method exists, and is usuable in an isolated enviornment. In a map as bogged down as EotA already is, its a disproportionate effect on lag compared to the small benefit it provides.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#8 Post by Perhaps »

Forgot to put it in the return, I was confused with it not letting me use (val > x) as a boolean return [which is stupid].

I've stopped nulling local variables. Destroying/Removing should be the only thing needed to be done. So far I haven't noticed performance drops. Something I want to find out if it's even worth bothering doing.


Also Trigger Conditions while not faster than the filter in unit event, they're faster than Trigger Actions. So as ugly as Trigger Conditions are, you should use them when you can. A good line of Flow cut down as many possibilities with a simple boolean expression (avoid packing it up), then narrow down as much as you can further with Trigger Conditions (this is probably where you'd want to apply loop checks if possible), then finally in trigger actions. >_>
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#9 Post by DarnYak »

I've stopped nulling local variables. Destroying/Removing should be the only thing needed to be done.
Should, if the language worked right. Its a bug in wc3 though, which they haven't fixed so far as I know.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#10 Post by Perhaps »

So I had a lot of tabs in Chrome with different pages open, starcraft running, and photoshop running to bog my computer down quite a bit. Because the riflemen were spawned all at once they fire at the same time, so I noticed periodic chunks. So I cut and pasted the code to notepad, saved, and tried it again. No difference in performance.
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#11 Post by DarnYak »

Try explaining you're last post again please. Didn't understand what you were saying at all, besides you did notice lag while the trigger ran.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#12 Post by Perhaps »

Basically I opened crap to take up computer resources. It chunked upon the rifleman's periodic fire at once scenario, but the same amount of chunk factor for with the trigger and without the trigger. Or in short, lag with = lag without.
Image

User avatar
Discombobulator
Retired
Retired
Posts: 710
Joined: September 19th, 2006, 4:16 pm
Battle.net name: Karunecm
Contact:

Re: Hero attacks! (Most specifically for Yak)

#13 Post by Discombobulator »

Perhaps wrote:Basically I opened crap to take up computer resources. It chunked upon the rifleman's periodic fire at once scenario, but the same amount of chunk factor for with the trigger and without the trigger. Or in short, lag with = lag without.
You should read up a bit on scientific method.
I'm this forum's MVP.

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#14 Post by Perhaps »

I'm basing on what I've seen Vexorian said, then confirmed for myself. Did a test in this instance, it checks out; a test that anyone else could easily do as well in case they don't trust me. It was tested in a harsh scenario, and still checked out. Even if I did bring up solid number, I'm sure I'd get more crap, so really the only thing left would be to test it within EotA, which really shouldn't be hard to implement and remove if problematic.

I've come to a possibility that one of the reasons EotA gets bad lag no matter what he does, is because any object that gets made in a game session gets a handle made for it, that exists until the game session is over, even if the object is removed/destroyed and cleared from variables. There's a long list of objects that have handles created for, timers, units, destructibles, triggger (he doesn't use dynamic triggers so no worry there), points, unit groups, pretty much anything that's not a string, integer, or real that can also be stored in variable. Which would be rectified with recycling, which I think Yak does, because I can't explain else as to why units that spawn shortly after someone does an AoE buff within the spawning area have the buff.
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#15 Post by DarnYak »

There's a long list of objects that have handles created for, timers, units, destructibles, triggger (he doesn't use dynamic triggers so no worry there), points, unit groups, pretty much anything that's not a string, integer, or real that can also be stored in variable. Which would be rectified with recycling, which I think Yak does, because I can't explain else as to why units that spawn shortly after someone does an AoE buff within the spawning area have the buff.
Units are definitely recycled to the extent its practical. If there's any residual leftovers for the other handles even after destroyed...well, most of them can't be helped, but I'm sure some could. Some, like unit groups, probably can't be helped if so.
so really the only thing left would be to test it within EotA, which really shouldn't be hard to implement and remove if problematic
Which is something I may do, but as I brought up before, I don't feel a significant need for the most part right now.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#16 Post by Perhaps »

Which probably explains the lag of no return scenario, unless you precreate all the units including towers, or do you have them get stored as new ones are built?
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#17 Post by DarnYak »

All spawns get recycled, which is the vast bulk of units that get created. Summons don't, but those generally don't add up too high. Dummy units like casters or missiles are also reused. No buildings are.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#18 Post by Perhaps »

Though not my question I was wondering that. But what I was asking about is are the all created to start or created as necessary? For example...

Scenario 1) 60 footman, 20 archer, and 20 sorceresses are created at the start and are stored to variables/groups.

Scenario 2) 3 footmen are created, 1 archer is created, 1 sorc is created and are stored to variable/group. They all die, and are reused, while all alive 3 more footmen, 1 more archer, and 1 more sorc is created and are stacked into the storage.
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#19 Post by DarnYak »

Created as needed.

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#20 Post by Perhaps »

While on the topic, has you considered limiting a spawn of something per lane, and in compensating for having more spawn towers than can spawn, have the reward for more of the spawn be quicker respawn (allowed to spawn out of cycle)? Or giving them revival upon death based on how many more towers? Along with a mercenary spawn limit per lane using similar concept as the suggested latter?
Image

User avatar
DarnYak
Site Admin
Site Admin
Posts: 2364
Joined: August 12th, 2006, 2:54 pm

Re: Hero attacks! (Most specifically for Yak)

#21 Post by DarnYak »

I haven't, but I should probably redo towers anyway (add stuff like the ability to shift between spawn types)

DarnYak

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#22 Post by Perhaps »

You could implement "buffer towers" that beef units that spawn at the place they're in.
Image

User avatar
Setokaiva
Resident
Resident
Posts: 106
Joined: March 3rd, 2009, 7:09 am
Realm: Azeroth (U.S. East)
Battle.net name: Setokaiva

Re: Hero attacks! (Most specifically for Yak)

#23 Post by Setokaiva »

sounds like a good idea, but we already have things like Banners and Stormspires to give units an advantage. Especially considering the fact that other Elven Battalion heroes can add their own aura to the Tactician's banner to make it more powerful, buffer towers would barely be necessary. And if you have none of the above, just make more units, period.
BOOOHNE~STORRRRRRRRM

User avatar
Perhaps
Retired
Retired
Posts: 811
Joined: September 14th, 2007, 1:24 am
Contact:

Re: Hero attacks! (Most specifically for Yak)

#24 Post by Perhaps »

I don't see where banners and storm spires devalidate the concept of buff towers. Improved Unit + Banner > Unit With Banner, it's pretty fundamental. And another thing to look into as perspective, the units that spawn by default cover three different types of damage, normal, pierce, and magic, improving them could easily make the worth of another unit.

The main concept is to encourage less units to be spawn, which for some people would mean less lag, or the excessive lag appearing later than the current.

An approach that could be done, is triple core creation/generation/income rate, triple the core cost of spawn towers, and have buffing tower (vary possible) cost 2 cores.
Image

User avatar
Setokaiva
Resident
Resident
Posts: 106
Joined: March 3rd, 2009, 7:09 am
Realm: Azeroth (U.S. East)
Battle.net name: Setokaiva

Re: Hero attacks! (Most specifically for Yak)

#25 Post by Setokaiva »

That could work, we could have banner carriers as another option for spawns. But why don't we simply keep tower core production as it is and simply make banner carriers cost 2 cores?
BOOOHNE~STORRRRRRRRM

Post Reply