• 🏆 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!

[Trigger] Two things, very simple: why don't they work?

Status
Not open for further replies.
Level 6
Joined
Mar 17, 2012
Messages
105
I've got this dragon rider guy. He has four abilities; Move Up, Move Down, Turn Right, and Turn Left. When an ability is cast, his Current Height or Facing Degree is increased or decreased depending on the ability used. Here are the four triggers with each one:

Move Up
  • Move up
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Go Upwards
    • Actions
      • Set Dragon_Height = (Current flying height of Dragon Rider 0001 <gen>)
      • Animation - Change Dragon Rider 0001 <gen> flying height to (Dragon_Height + 50.00) at 50.00
Move Down
  • Move down
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Go Downwards
    • Actions
      • Set Dragon_Height = (Current flying height of Dragon Rider 0001 <gen>)
      • Animation - Change Dragon Rider 0001 <gen> flying height to (Dragon_Height - 50.00) at 50.00
Turn Right
  • Move right
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Turn Right
    • Actions
      • Set FacingDegree = (Facing of Dragon Rider 0001 <gen>)
      • Unit - Make Dragon Rider 0001 <gen> face (FacingDegree + 50.00) over 1.00 seconds
Turn Left
  • Move left
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Turn Left
    • Actions
      • Set FacingDegree = (Facing of Dragon Rider 0001 <gen>)
      • Unit - Make Dragon Rider 0001 <gen> face (FacingDegree - 50.00) over 1.00 seconds
NOW, the problem. When I used arrow keys to use this triggers (instead of A unit Begins casting an ability, it was Keyboard Event - Up/Left/Right/Down Arrow Key is Pressed), there were no problems; everything worked great. So, now, switching to the abilities, the dragon only turns left. Whether I am doing Move Up, Move Right, Move Down, or Move Left, the dragon only turns left. If anyone knows a solution to this, please help!

The Second Problem

I want my dragon rider fellow to be constantly moving forward, whether I am turning, going up, or going down; he should be in constant motion. I've tried making him move to a variable point set at an offset that would urge him to move forward after a second, but that didn't work; he only wanted to move to that single point even after he turned (the variable was set within the periodic event, so it should have changed?). So, if anyone can help me with this, it would be very much appreciated. Thank you.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Are the ablities all based off of the same base ability / same base order id? (meaning you copied the same abiltiy 4 times). If so, than you should switch to "Instant" channel spells, each with unique base order ids.

on 2nd one

  • Untitled Trigger 004
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in YourGroupOfUnitsToMove and do (Actions)
        • Loop - Actions
          • Set TempLoc = (Position of (Picked unit))
          • Set TempLoc2 = (TempLoc2 offset by 25.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Order PickedUnit to Move To TempLoc2
          • Custom script: call RemoveLocation(udg_TempLoc)
          • Custom script: call RemoveLocation(udg_TempLoc2)
if ur only moving one unit, you can just remove the unit group and change picked unit to your unit
 
Level 2
Joined
Apr 20, 2011
Messages
20
I'm not sure but, to set the fly heights of units, I think you have to give them the ability Crow Form and remove it.

As for your second problem, just make a periodic event that moves him every .03 seconds?

  • Constant Movement
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set NewPoint = ((Position of Dragon) offset by 30.00 towards (Facing of (Dragon)) degrees)
      • Unit - Move (Dragon) instantly to NewPoint
NewPoint is a point variable, Dragon is the unit that is being moved. For this trigger to work, you have to set Dragon to the unit you want moved in your map. You do this by using

  • Set Dragon
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set Dragon = (Which Unit)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I'm not sure but, to set the fly heights of units, I think you have to give them the ability Crow Form and remove it.

As for your second problem, just make a periodic event that moves him every .03 seconds?

  • Constant Movement
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set NewPoint = ((Position of Dragon) offset by 30.00 towards (Facing of (Dragon)) degrees)
      • Unit - Move (Dragon) instantly to NewPoint
NewPoint is a point variable, Dragon is the unit that is being moved. For this trigger to work, you have to set Dragon to the unit you want moved in your map. You do this by using

  • Set Dragon
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set Dragon = (Which Unit)

For this case, it's better for him to use the SetUnitX/Y as it does not interrupt orders (and making the unit to be able to cast or receive another orders from Players)

If you use Move Unit (Instantly) function, it will make that unit pretty much impossible for it to cast any other spell (for him to cast the spell Move Up/Down/Left/Right)
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
1) Maybe you use the same ability, it will conflict the orderID's, change it...

2) Use this...

JASS:
library MoveForward uses optional BoundSentinel
//BoundSentinel - [url]http://www.wc3c.net/showthread.php?t=102576[/url]

globals
    private hashtable HT = InitHashtable()
    private timer T = CreateTimer()
    private integer COUNT = 0
    private group GRP = CreateGroup()
endglobals

native UnitAlive takes unit u returns boolean

private function Recycle takes unit u returns nothing
    set COUNT = COUNT - 1
    call GroupRemoveUnit(GRP,u)
    if COUNT==0 then
        call PauseTimer(T)
    endif 
    call FlushChildHashtable(HT,GetHandleId(u))
endfunction

private function MoveForward takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real speed 
    local real angle
    if UnitAlive(u) then
        set speed = LoadReal(HT,GetHandleId(u),1) 
        set angle = GetUnitFacing(u)*bj_DEGTORAD
        call SetUnitX(u,GetUnitX(u)+speed*Cos(angle))
        call SetUnitY(u,GetUnitY(u)+speed*Sin(angle))
    else
        call Recycle(u)           
    endif  
    set u = null
endfunction

private function Looper takes nothing returns nothing
    call ForGroup(GRP,function MoveForward)   
endfunction

function RemoveUnitMoveForward takes unit u returns nothing
    if HaveSavedReal(HT,GetHandleId(u),1) then
        call Recycle(u)
    else
        debug call BJDebugMsg("ERROR: This unit has not been registered...wrong ID!")
    endif
endfunction

function AddUnitMoveForward takes unit u, real speed returns nothing
    call SaveReal(HT,GetHandleId(u),1,speed)
    set COUNT = COUNT + 1
    call GroupAddUnit(GRP,u)
    if COUNT==1 then
        call TimerStart(T,0.03125,true,function Looper)
    endif
endfunction

endlibrary

HOW TO USE:
  • MoveForwardDEMO
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • -------- 3 is the speed --------
      • Custom script: call AddUnitMoveForward(GetTriggerUnit(), 3)
      • Wait 7.00 seconds
      • Custom script: call RemoveUnitMoveForward(GetTriggerUnit())
 
Status
Not open for further replies.
Top