WC3Jass.com Forum Index WC3Jass.com
"The Jass Vault"
 
 FAQ   Search   Memberlist   Usergroups   Register 
 Profile   Log in to check your private messages   Log in  
 Forum   Scripts   Files   Chat   Pastebin   Function finder  
Affiliates
The HIVE Workshop Games Modding
The Hubb Wc3Campaigns
WC3-Mapping.net

Trackables (Mouse detection)
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    WC3Jass.com Forum Index -> Tutorials
View previous script :: View next script  

Author
Bobo_The_Kodo
Guest



Back to top
Message
PostPosted: Sun Mar 18, 2007 4:08 pm    Post subject: Reply with quote

i think that the handle vars aren't storing because i cant access any of them, though it was working earlier it just stopped suddenly, and i have used the handle vars properly

Author
Bobo_The_Kodo


Joined: 18 Mar 2007
Posts: 5
Back to top
Message
PostPosted: Sun Mar 18, 2007 8:52 pm    Post subject: Reply with quote

Update on the code, the GetLocalPlayer() on the event caused a Desync

Code:
function HitTrackable takes nothing returns nothing
    local trackable t = GetTriggeringTrackable()
    local player p = Player( GetHandleInt( t, "PlayerId" ) )
    local real x = GetHandleReal( t, "x" )
    local real y = GetHandleReal( t, "y" )
    local rect r
    local group UnitInTrackable = CreateGroup()
    local effect Effect
    call DisplayTextToForce( bj_FORCE_ALL_PLAYERS, "Player " + I2S( GetPlayerId( p ) ) + " just hit trackable " + GetHandleString( t, "TrackableName" ) )
    if udg_PlayerTurn == p then
        if udg_ActiveUnit == null then
            set r = Rect( x - 64, y - 64, x + 64, y + 64 )
            call GroupEnumUnitsInRect( UnitInTrackable, r, null )
            set udg_ActiveUnit = FirstOfGroup( UnitInTrackable )
            if GetOwningPlayer( udg_ActiveUnit ) != p and udg_ActiveUnit != null then
                set udg_ActiveUnit = null
                set Effect = AddSpecialEffect( "errorflash.mdx", x, y )
                call SimulateError( p, "That is not your unit" )
            elseif udg_ActiveUnit == null then
                set Effect = AddSpecialEffect( "errorflash.mdx", x, y )
                call SimulateError( p, "There is no unit in the spot where you targeted" )
            elseif GetOwningPlayer( udg_ActiveUnit ) == p and udg_ActiveUnit != null then
                call DisplayTextToPlayer( p, 0, 0, "You have selected the piece in " + GetHandleString( t, "TrackableName" ) )
            endif
        endif
    endif
    call TriggerSleepAction( .5 )
    call DestroyEffect( Effect )
    call DestroyGroup( UnitInTrackable )
    set UnitInTrackable = null
    set t = null
    set Effect = null
    set p = null
endfunction

function CreateTrackables takes nothing returns nothing
    local real x = GetRectMinX( bj_mapInitialPlayableArea ) + 128
    local real y = GetRectMinY( bj_mapInitialPlayableArea ) + 128
    local trackable t
    local integer PlayerInt = 0
    local trigger tr = CreateTrigger()
    local string path = ""
    local string TrackableId
    local integer array XYCoordinates
    local string array LetterTable
    set LetterTable[7] = "A"
    set LetterTable[6] = "B"
    set LetterTable[5] = "C"
    set LetterTable[4] = "D"
    set LetterTable[3] = "E"
    set LetterTable[2] = "F"
    set LetterTable[1] = "G"
    set LetterTable[0] = "H"
    set XYCoordinates[0] = 0
    set XYCoordinates[1] = 0
    loop
        exitwhen PlayerInt > 1
        if GetLocalPlayer() == Player( PlayerInt ) then
            set path = "Abilities\\Spells\\Human\\DevotionAura\\DevotionAura.mdl"
        elseif GetLocalPlayer() != Player( PlayerInt ) then
            set path = ""
        endif
    loop
        exitwhen x > GetRectMaxX( bj_mapInitialPlayableArea ) - 64
        set XYCoordinates[0] = XYCoordinates[0] + 1
        set t = CreateTrackable( path, x, y, 0 )
        call TriggerRegisterTrackableHitEvent( tr, t )
        set TrackableId = LetterTable[XYCoordinates[1]] + I2S( XYCoordinates[0] )
        call SetHandleReal( t, "x", x )
        call SetHandleReal( t, "y", y )
        call SetHandleString( t, "TrackableName", TrackableId )
        call SetHandleInt( t, "PlayerId", PlayerInt )
        loop
            set y = y + 128
            exitwhen y > GetRectMaxY( bj_mapInitialPlayableArea ) - 64
            set XYCoordinates[1] = XYCoordinates[1] + 1
            set t = CreateTrackable( path, x, y, 0 )
            call TriggerRegisterTrackableHitEvent( tr, t )
            set TrackableId = LetterTable[XYCoordinates[1]] + I2S( XYCoordinates[0] )
            call SetHandleReal( t, "x", x )
            call SetHandleReal( t, "y", y )
            call SetHandleString( t, "TrackableName", TrackableId )
            call SetHandleInt( t, "PlayerId", PlayerInt )
        endloop
        set XYCoordinates[1] = 0
        set x = x + 128
        set y = GetRectMinY( bj_mapInitialPlayableArea ) + 128
    endloop
    set PlayerInt = PlayerInt + 1
    endloop
    call TriggerAddAction( tr, function HitTrackable )
    set t = null
    set tr = null
endfunction

function InitTrig_Checkers takes nothing returns nothing
    call CreateTrackables()
endfunction


srry for the triple post... but i made an account now
View user's profile Send private message

Author
KaTTaNa
Site Admin

Joined: 04 Apr 2005
Posts: 655
Back to top
Message
PostPosted: Mon Mar 19, 2007 11:57 am    Post subject: Reply with quote

Code:
function InitTrig_Checkers takes nothing returns nothing
    call CreateTrackables()
endfunction

Are you sure you have created the Handle Var game cache at this point? This is called very early in the map initialization. If you are using a global variable for your handle var cache, you should make sure it is initialized first (that would explain why handle vars didn't seem to work).

I can't see anything else that could be wrong in your code.
View user's profile Send private message Send e-mail Visit poster's website

Author
Bobo_The_Kodo


Joined: 18 Mar 2007
Posts: 5
Back to top
Message
PostPosted: Tue Mar 20, 2007 12:09 am    Post subject: Reply with quote

lol ty, that was it

that explains why it used to work,

i used to have it in map cust script, but for a diff reason i had moved it into a trigger

-Bobo_The_Kodo
View user's profile Send private message

Author
TheSecretArts (really!)
Guest



Back to top
Message
PostPosted: Sun Jul 01, 2007 6:36 pm    Post subject: Reply with quote

Is it possible to create use trackables to detect where a mouse click is anywhere on the field...

Author
Bob666


Joined: 29 Jun 2007
Posts: 192
Back to top
Message
PostPosted: Sun Jul 01, 2007 7:27 pm    Post subject: Reply with quote

more or less...
you can add trackables everywhere on the map and then add events for all of them to a trigger, everytime the mouse hovers such a destructable set X/Y variables of mouse position... the smaller the trackables are the more precise you can locate the mouse but the more it laggs... i was thinking about a flexible cam pan system, so as soon as your mouse isnt in the center the screen will move slowly, and the more you are away from the center the faster it will move, but that will require _many_ of those trackables...
_________________
Projects:
SupCom | WC3 FlightSim | JASS Benchmark
View user's profile Send private message Visit poster's website

Author
TSA... again
Guest



Back to top
Message
PostPosted: Mon Jul 02, 2007 2:27 am    Post subject: Reply with quote

Is there anyway to lock trackable position to the mouse?

Author
KaTTaNa
Site Admin

Joined: 04 Apr 2005
Posts: 655
Back to top
Message
PostPosted: Mon Jul 02, 2007 9:49 pm    Post subject: Reply with quote

TSA... again wrote:
Is there anyway to lock trackable position to the mouse?

That doesn't make any sense to me, but I think the answer is "no". There are very few native functions working with trackables; they can't even be moved or destroyed.
View user's profile Send private message Send e-mail Visit poster's website

Author
Doom-Angel


Joined: 15 Nov 2007
Posts: 9
Back to top
Message
PostPosted: Thu Nov 15, 2007 10:03 pm    Post subject: Kattana i need your help Reply with quote

hi im Doom-Angel
i read your tutorial and i tried to work with them to detect when im left clicking on a point so i created them on every point of the map but the problem is that when im entering "" to the path to make them invisible it doesn't work when i click while when i made them with models of peon it was working great when i clicked on them except for the huge mass of lag....
i even tried using an inivisible model like you did in your bombs map but it didn't work either could you tell me why it doesn't work when invisible while it works while i make them visible?

thanks in advance Doom-Angel
View user's profile Send private message

Author
GuestZer
Guest



Back to top
Message
PostPosted: Sat Aug 30, 2008 5:33 am    Post subject: I've got a clue... well half of one Reply with quote

Hey, i know this is completely late, but if you ever get to seeing this post, I was wondering how you'd go about making it so that the camera moves from a first person view depending on where the mouse is.

For example, if you move the mouse left from the center, it'd turn the camera left.. the farther left you went, the faster it'd turn (hopefully not too fast, it involves a units turning, aswell), and teh same thing goes for up, down, and right.

I'm a pretty decent map maker; however, I only kno GUI and a tad bit of CustomScripting, and have never tried learning Trackables. Any assistance would be highly appreciated.

Author
KaTTaNa
Site Admin

Joined: 04 Apr 2005
Posts: 655
Back to top
Message
PostPosted: Sat Aug 30, 2008 7:06 am    Post subject: Reply with quote

I don't think that is going to work. It would extremely sloppy as trackables don't trigger that fast. You would have to cover the entire map with trackables as you can neither move them or destroy them.

Using a bit of math, you can get an estimate for the mouse position from the trackable location and camera position, but it's definitely not easy. You would have to calculate the camera's inverse view-projection matrix, and multiply the trackable's location relative to the camera with that.
View user's profile Send private message Send e-mail Visit poster's website

Author
MaxTM


Joined: 03 Oct 2008
Posts: 2
Back to top
Message
PostPosted: Fri Oct 03, 2008 4:00 pm    Post subject: Reply with quote

KaTTaNa, i dont understand your naming for 4x4Trackable...why 4x4 inst it 128x128?

Is there a way to make it for every x,y like 1x1, or it will lag and mess things up

Thx , hope you answer this asap
View user's profile Send private message

Author
KaTTaNa
Site Admin

Joined: 04 Apr 2005
Posts: 655
Back to top
Message
PostPosted: Fri Oct 03, 2008 6:53 pm    Post subject: Reply with quote

I think it was because a cell in the world editor is 32 units, but I honestly don't remember anymore. And yes, making them one unit wide will cause massive lag.
View user's profile Send private message Send e-mail Visit poster's website

Author
MaxTM


Joined: 03 Oct 2008
Posts: 2
Back to top
Message
PostPosted: Fri Oct 03, 2008 10:18 pm    Post subject: Reply with quote

well 1 cell in world editor actually have a 128x128 size, because of that i didnt get your naming for 4x4;

By the way, what tool you used for make this model, and how can i rezise it?
View user's profile Send private message

Display posts from previous:   
Post new topic   Reply to topic    WC3Jass.com Forum Index -> Tutorials All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


FSDark by SkaidonDesigns
Powered by phpBB © 2001, 2002 phpBB Group