Snippet Trackable2

Sevion

The DIY Ninja
Reaction score
413
It actually was really easy to implement. Created a few functions then edited my UI.

Wait. I should double check the code a second. OK. Nevermind. I thought there was an error. :p
 

Azlier

Old World Ghost
Reaction score
461
Before you go crazy, Sevion, the struct has an instance limit of about 810, due to the trackable array. Still, a decently made map won't need nearly that many Trackables.
 

saw792

Is known to say things. That is all.
Reaction score
280
I think CreateTrackableForPlayer() was a far better function than just a straight CreateTrackableEx(), as then not only can the owning player be saved in the struct but you don't have to create trackables for all players when you don't actually want to. Some maps may want trackables for only some players, or may want trackables for different players in different locations. If that was the situation in my (hypothetical) map I would not want 11 extra handles every time I wanted a trackable created.
 

Azlier

Old World Ghost
Reaction score
461
I knew someone would say something. I got the thinking "I'll just delete this, since we can now detect who clicks a normal trackable." Then, I got the idea you have now. I wasn't going to put it back in until someone wanted it, and so be it.
 

Romek

Super Moderator
Reaction score
963
JASS:
trackable array Tracked[11]

Should be trackable array Tracked[12]
Indices 0-11.

JASS:
set p = Player(i)
        if IsPlayerInForce(p, forForce) then
            if GetLocalPlayer() != Player(i) then


What's the point in setting the player, then using Player(i) afterwards?

Instead of creating/destroying a local destructable, you could create 1 at Map Init, and then show/hide it when needed.

> exitwhen i > 12
exitwhen i == 12

Why the symbol changing? ^_^
You do that multiple times.

> IsTriggerTrackable
Could you rename that to IsTriggeringTrackable? IsTriggerTrackable sounds very misleading...

In the CreateTrackableForPlayer function, a player ID can't possibly be < 0.
Also, if it's > 11, then you leak the destructable.

That wasn't even a detailed look. Just scrolling up and down a few times, finding errors each time. :p
 

Azlier

Old World Ghost
Reaction score
461
I don't see why Tracked must be 12.

>exitwhen i > 12
I was never any good with loops! I always mess up exitwhens.

>IsTriggerTrackable

So be it.

>Player ID < 0
Don't know why I put that there. Gotta look into that.

>Leaked destructible
Gotta look into that.
 

Romek

Super Moderator
Reaction score
963
> I don't see why Tracked must be 12.
There are 12 players.

I assumed that's what the array was for..?

> Don't know why I put that there. Gotta look into that.
Because you didn't know that Player(-1) crashed the game? ;)

I also took the liberty of purging the thread of bumps and useless discussion.
 

Azlier

Old World Ghost
Reaction score
461
Yes there are 12 players. Can I not use index 0 on a struct, or is there something I missed...?

As for the whole player index thing, I was thinking that someone stupid would supply a negative player. That would crash the game on its own, something I forgot.
 

Romek

Super Moderator
Reaction score
963
Having an array size of 12 means you can use indices 0-11.
Having an array size of 11 means you can use 0-10.

The size isn't the index of the highest available one, but the total amount of usable ones.
 

Azlier

Old World Ghost
Reaction score
461
>The size isn't the index of the highest available one, but the total amount of usable ones.

Very enlightening. Fixed.
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
Well, here's my code:

JASS:
// Some code

Why the fuck would you ever use Integer to Trackable? So, in your GUI interface you force the users to implement use of I2H which can mess up a complete map if they wants to use this.... Nice interface then.

Some info for you :)
http://www.wc3campaigns.net/showthread.php?t=85984 (Read the whole thread)
http://www.wc3c.net/showthread.php?t=101255&highlight=Dynamic+Triggers (Read the whole thread)
http://www.wc3c.net/showthread.php?t=104679 (Read the whole thread)
 

Sevion

The DIY Ninja
Reaction score
413
Why the fuck would you ever use Integer to Trackable? So, in your GUI interface you force the users to implement use of I2H which can mess up a complete map if they wants to use this.... Nice interface then.

Some info for you :)
http://www.wc3campaigns.net/showthread.php?t=85984 (Read the whole thread)
http://www.wc3c.net/showthread.php?t=101255&highlight=Dynamic+Triggers (Read the whole thread)
http://www.wc3c.net/showthread.php?t=104679 (Read the whole thread)

I2T:

JASS:
function CreateTrackableEGUI takes string path, location loc, real facing returns trackable
    if TrackableMaxArrayTrackable2 &gt; 8190 then
        set TrackableMaxArrayTrackable2 = 0
        set T[TrackableMaxArrayTrackable2] =  CreateTrackableEx(path, GetLocationX(loc), GetLocationY(loc), GetLocationZ(loc), facing)
    else
        set T[TrackableMaxArrayTrackable2] =  CreateTrackableEx(path, GetLocationX(loc), GetLocationY(loc), GetLocationZ(loc), facing)
        set TrackableMaxArrayTrackable2 = TrackableMaxArrayTrackable2 + 1
    endif
    set bj_lastCreatedTrackable = I2T(T[TrackableMaxArrayTrackable2])
    
    return bj_lastCreatedTrackable
endfunction


If you can show me a better way to some how do this, we can eliminate I2T.

Plox don't insult EGUI.

I plan to make EGUI only require EGUI Core and Timer Utils.

I didn't plan on making LHV required. Burningice did that.

Info:

Thanks.
 

Azlier

Old World Ghost
Reaction score
461
So, Sevion... What about CreateTrackableForForce and such? You did choose a rather early point in production to add this into EGUI.
 

Viikuna

No Marlo no game.
Reaction score
265
JASS:
function T2I takes trackable t returns integer
    return t
    return 0
endfunction

function I2T takes integer i returns trackable
    local trackable t = null
    return i
    return t
endfunction

I dont thing using return bug to covert integer to trackable is so dangerous, because trackables can not be destroyed ( so there is no risk of handle stack corruption )

If you dont fuck up and convert a wrong integer to trackable, it should work just fine.
 

Azlier

Old World Ghost
Reaction score
461
B-b-b-bump. Last one before I let this fall into the unapproved halls of history :(.
 

Azlier

Old World Ghost
Reaction score
461
Or not. I decided to rewrite this totally. Much more usable.
 

Jesus4Lyf

Good Idea™
Reaction score
397
I believe this can be done without H2I, and still O(1) complexity. This would make it more stable.

Here's a design suggestion...
Instead of making the fired trigger drive the trackable functions, have the trackable functions drive the trigger. In other words, when you create a trackable, also create two triggers. Hit, and Track. Have these triggers fire the real triggers and load a struct into a global variable which is accessed by your Get...() functions. This means no GetTriggeringTrackable2() and integer stuff. Only then can you remove H2I completely through GetTriggerExecCount of the dummy triggers. ;)

Thereafter, implementing linkedlists can even allow you to trigger multiple triggers off one trackable, for both events! :D

Make your Get...() functions inline.
JASS:
function GetTrackable2$NAME$ takes integer which returns $TYPE$
    local Data d = Data(which)
    return d.$NAME$
endfunction

JASS:
function GetTrackable2$NAME$ takes Data d returns $TYPE$
    return d.$NAME$
endfunction

And you can make "d" a global as described above. It's nicer than the user wondering why he's storing trackables as an integer, imho.
 

Azlier

Old World Ghost
Reaction score
461
Uh, yeah... I have no idea how to do any of that. Load struct? Make dummy triggers fire the real triggers? Totally lost here, Jesus.

However, the inline thing, done. For some reason I remember doing it that way giving me syntax errors :nuts:.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top