• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[System] Track

Is there a way to know the mouse cursor is inside a region ??

I'm bored with the selection event so I tried to learn this.
I need it !! I want to learn(then master) this system, please teach me :grin:
(silly boy is dreaming again)

Thank you very much

There isn't a way to know the exact location of the mouse coordinates.

The only way to mimic that effect is to create a grid of invisible trackables (like I did in the demo map). Then you can figure out where the mouse is (but it isn't super precise, test the demo map to see the imprecision). You'll also end up using a lot of handles to fill up the region, so it is generally only practical for small regions.
 
Level 10
Joined
Dec 15, 2012
Messages
650
There isn't a way to know the exact location of the mouse coordinates.

The only way to mimic that effect is to create a grid of invisible trackables (like I did in the demo map). Then you can figure out where the mouse is (but it isn't super precise, test the demo map to see the imprecision). You'll also end up using a lot of handles to fill up the region, so it is generally only practical for small regions.
Thank you :ogre_haosis:
I will seek for help again when I'm uncertain about something :grin:
 
Level 5
Joined
Dec 1, 2008
Messages
120
Using Invisible Platform 'OTip' to set z-values is not accurate.

Prove it? Create one with z-value of 128.0, then create an unit on top of it and use a proper function to get it's z-value. Be surprised when the result is 130.948. Very minimal difference, but still inaccurate.

Looking at the InvisiblePlatform.mdl we can see it's geoset is a bit above the ground level:
Code:
Vertices 4 {
	{ -73.5998, -73.5998, [B]2.94794[/B] },
	{ 73.5999, -73.5998, [B]2.94787[/B] },
	{ -73.5998, 73.5998, [B]2.94794[/B] },
	{ 73.5999, 73.5998, [B]2.94787[/B] },
}

EDIT: I haven't found a replacement, so I made this attached model.

EDIT2: Also looking at the system code, it seems you aren't properly removing data from TrackTable. In the destroy method you are only removing GetHandleId(thistype.object) from the Table, when there can be total of 12 trackables that have data stored in it.

EDIT3: Previous model used 12 vertices instead of the required 4 and had wrong normals.
 

Attachments

  • rectangle-8x8.mdx
    1.1 KB · Views: 71
  • rectangle-16x16.mdx
    1.1 KB · Views: 76
  • rectangle-32x32.mdx
    1.1 KB · Views: 77
  • rectangle-64x64.mdx
    1.1 KB · Views: 76
Last edited:
Thanks for the report! Both of those statements are true. I didn't know the platform was raised slightly. When I get back to my PC (1 week?) I'll try to make the update. As for TrackTable, it was a careless error on my part. Thanks for noticing it, I don't know what I was thinking of. In fact, it shouldn't even be removing .object at all since that is just a static pointer to an event object, not the object of the instance method. :p So I guess I made a doubly error.

I'll recode that part, likely using a separate Table instance per instance and just using flush.
 
Level 5
Joined
Dec 1, 2008
Messages
120
JASS:
method operator enabled= takes boolean flag returns nothing
    set this.flag = flag
endmethod
method operator enabled takes nothing returns boolean
    return this.flag
endmethod
->
JASS:
boolean enabled

Do triggerconditions leak if not removed before destroying trigger?
 
^ As Ceday said.

They should not leak (tested with task manager, and memory stayed pretty much stationary iirc). With triggeractions, memory used rose.

And thanks for that operator fix, I'll update that as well. When I made it, I was under the impression that I would actually do something when it was enabled (hence the operator). I guess I never did. :p
 
Updated to 3.1.0.0

3.1.0.0
  • Updated documentation to note the imprecision in Z-values when using the invisible platform (thanks to Uberplayer).
  • Updated Table instancing, and fixed .destroy() so that it properly flushes all the data created by that instance.
  • Removed event recursion--there is no way for the trigger to re-evaluate in the trigger callbacks (since you can't force a user to click a trackable), so I removed the recursion support.
  • Removed operators for enabled--added a simple "enabled" boolean. This change does not change the API or functionality in any way.
  • Added registerInteract and RegisterInteractEvent, which are more efficient in terms of triggers/triggerconditions compared to registerClick and registerHover. (registerAnyClick and registerAnyHover is fine)
  • Updated demo, updated thread attachment.

Thanks to Uberplayer for the error reports. I also added a method "registerInteract" in case people want a more efficient event handler (since registerClick and registerHover both involve a new trigger and a triggercondition).

When should you use registerClick/registerHover vs registerInteract? Well, registerInteract is more clunky, since it runs the code on both a click and a hover (so you have to use GetTriggerEventId() to split the code up). See the demo map/"Test New" for a demonstration. If you don't care too much about extra memory, just keep using registerClick and registerHover as is.
 
Level 11
Joined
Dec 3, 2011
Messages
366
Idk why you do like this. Can you explain me ^^!

JASS:
/* Create a separate trackable for each player playing */
            loop
                set p = Player(i)
                if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
                    if GetLocalPlayer() == p then
                        set s = modelPath
                    else
                        set s = ""
                    endif 
                    set tr = CreateTrackable(s, .x, .y, .facing)
                    call TriggerRegisterTrackableHitEvent(.reg, tr)
                    call TriggerRegisterTrackableTrackEvent(.reg, tr)
                    set .playerIndex[GetHandleId(tr)] = i
                    exitwhen j != null
                endif
                exitwhen i == 0
                set i = i - 1
            endloop
 
Level 7
Joined
Oct 11, 2008
Messages
304
Idk why you do like this. Can you explain me ^^!

JASS:
/* Create a separate trackable for each player playing */
            loop
                set p = Player(i)
                if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then
                    if GetLocalPlayer() == p then
                        set s = modelPath
                    else
                        set s = ""
                    endif 
                    set tr = CreateTrackable(s, .x, .y, .facing)
                    call TriggerRegisterTrackableHitEvent(.reg, tr)
                    call TriggerRegisterTrackableTrackEvent(.reg, tr)
                    set .playerIndex[GetHandleId(tr)] = i
                    exitwhen j != null
                endif
                exitwhen i == 0
                set i = i - 1
            endloop

Because if he do in other way, he will probably causa a desync.
 
^This.

I'm guessing you're confused because I use that function from createForPlayer(). In the helper function "createTrack", I have a parameter player j. If I specify a player, then it doesn't actually go through the loop. It breaks as soon as it reaches the line exitwhen j != null. If I pass "null" into that parameter, it will loop through all playing players and create trackables for them.

It sounds convoluted, but I just did it so I could consolidate creating a trackable for all players and creating a trackable for one player into a single helper function.
 
I have a very basic questions. For invisible model files like the 64x64.mdl a z-offset must not be considered at all. It's more or less only a visual parameter.

Am I wrong with this assumption?

It can make some slight differences. Let's say you have a top-down view. You can use z-offset to layer one trackable over another (e.g. if they are overlapping), or you can use it to fine-tune the selection size a bit (things with a higher z-offset will be closer to the camera, and thus they'll end up a bit bigger).

However, creating the platforms is pretty expensive (creating widgets is expensive in general). So I would use it only when it is needed. My system checks if the z is 0 before creating the platform--it was the main reason I made this system instead of just using Azlier's Trackable2.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
It may be not the best place for asking but still
If WC3 has delay for all LAN-based actions like selections, how trackable threated? Does callback fires for all players at once with delay on source side or it's async?
Does trackables affects gameflow in large amounts? I mean like 240+ trackables for each of 10 players - will it affect perfomance anyhow or just like timers/triggers, we won't feel the difference?
 
Level 9
Joined
Jul 30, 2012
Messages
156
It may be not the best place for asking but still
If WC3 has delay for all LAN-based actions like selections, how trackable threated? Does callback fires for all players at once with delay on source side or it's async?
Does trackables affects gameflow in large amounts? I mean like 240+ trackables for each of 10 players - will it affect perfomance anyhow or just like timers/triggers, we won't feel the difference?

When a trackable is clicked the game will send a message to all players saying "Trackable X has been clicked", and if there are any triggers registered to that trackable, they will run. Since this event does not have "GetTriggerPlayer" data, the only way to know who clicked on that trackable is to make sure that only 1 player can click it. This is done by locally setting the trackable's model to null, for all players except one.

So you're right, there's indeed a small delay between the player clicking the trackable and the events running, but it's not very noticeable, it's pretty much the same delay between clicking a button in the command card and the unit performing the corresponding action. Obviously this delay will be bigger if the player has a high ping.

As for the performance, I haven't tested it much, but I believe that trackables with a null model will not affect performance signficantly, and since only 1 out of X trackables will have a model, it shouldn't be an issue (X being the number of human players in the game).
 
Level 11
Joined
Dec 3, 2011
Messages
366
It may be not the best place for asking but still
If WC3 has delay for all LAN-based actions like selections, how trackable threated? Does callback fires for all players at once with delay on source side or it's async?
Does trackables affects gameflow in large amounts? I mean like 240+ trackables for each of 10 players - will it affect perfomance anyhow or just like timers/triggers, we won't feel the difference?

I think We won't feel the difference coz I used to test many fullsreen inventory with too many trackables but the game fps doesn't drop. :ogre_kawaii:
 
Top