• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Tron Tail Problem

Status
Not open for further replies.
Level 4
Joined
Dec 4, 2007
Messages
76
Okay, so for those of you familiar with the game "Tron" you will know that a tail follows you as you go, and you use arrow keys to manuever. Well i'm trying to remake this on wc3, but im having a problem with turns.

In the game tron when you turn, your tail should have a sharp turn to it like an L or something. However, in my game I can't get a sharp turn like that, and that's what I need help with. When I turn my tail is like an L but with a tile misplaced to the side. Kinda like...
|
-—

Its a crude drawing but you get the gist of things. There is one misplaced tile and I dont know how to fix it. Here is one of the triggers, maybe you can help.
  • RedKeyLeft
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
      • Right[1] Equal to False
    • Actions
      • Set Left[1] = True
      • Set Right[1] = False
      • Set Down[1] = False
      • Set Up[1] = False
      • Unit - Make Tails1[1] face 180.00 over 0.00 seconds
This checks if when he presses the Left arrow, is he facing right. If he is, he cant turn because he would turn into his own tail, but if he isint facing right, it turns him to face left. However, because of unit turn rates, it isint instant and the tile is subsequently misplaced. i've tried setting my units turn rate to the max (3) and that didnt work so I tried the Shift+Enter thing and set it to 900, it still didn't work. Any help would be appreciated. (Also, current trigger to move forward is a sliding trigger, here is the trigger)

JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
//function PolarProjectionBJ takes location source, real dist, real angle returns location
//    local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
//    local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
//    return Location(x, y)
//endfunction

//the above is a copy of PolarProjectionBJ I put it there to show you how it works
constant function Speed takes nothing returns real //Just modify the value in the 'return' to make it go faster/slower
return 10.00
endfunction


function Trig_MoveUnits_Actions takes nothing returns nothing
//    local location unitspot //Locations are slow
    local real facing
//    local location newspot
    local group ArenaUnits = CreateGroup() //Replaced with natives
    local unit u
    local real MoveX
    local real MoveY
    
    call GroupEnumUnitsInRect(ArenaUnits, gg_rct_CamView, null) //Some more natives used to replace the previous group method
    
    loop
    exitwhen CountUnitsInGroup( ArenaUnits ) <= 0
        set u = GroupPickRandomUnit( ArenaUnits )
        set facing = GetUnitFacing( u )
        set MoveX = GetUnitX(u) + Speed() * Cos(facing * bj_DEGTORAD) //the bj_DEGTORAD is just a constant, so its ok to use
        set MoveY = GetUnitY(u) + Speed() * Sin(facing * bj_DEGTORAD) //This is exactly what polarbj does except without the locations!
        call SetUnitX(u,MoveX) //This is a super fast native which doesn't cancel orders!!!
        call SetUnitY(u,MoveY)
        call GroupRemoveUnit( ArenaUnits, u )
        call IssueImmediateOrder(u,"stop") //Effectivley cancels orders! (Otherwise unit goes in circles)
    endloop
    
    if not (ArenaUnits == null) then //This stops it from trying to destroy the group if theres nothing in it
        call DestroyGroup( ArenaUnits )
    endif
    set ArenaUnits = null //Your only suppose to null it AFTER you destroy it!!!!!
    set u = null
endfunction

//===========================================================================
function InitTrig_MoveUnits takes nothing returns nothing
    set gg_trg_MoveUnits = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_MoveUnits, 0.02 )
    call TriggerAddAction( gg_trg_MoveUnits, function Trig_MoveUnits_Actions )
endfunction
 
  • Angry
Reactions: Rui
Status
Not open for further replies.
Top