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

[Spell] Mass Teleport problem

Status
Not open for further replies.
Level 11
Joined
Sep 11, 2013
Messages
324
I want to teleport just in 2 buildings chosen by me
i don't want to teleport on each building
for example:
i have 3 buildings
1-tower x
2-base y
3-shop z
I want to teleport just in base and shop

-mass teleport is an item
how can i do?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Make a trigger and find out what order you give when you target something with that ability/item.
Then make an event when a unit is issued an order targeting an object.
Check if the order is equal to the order that you have when casting that ability.
Then make an If/Then/Else in the actions and check if the targeted unit is a base or a shop.
If not, then issue the ordered unit to stop.
There was one way how to do it but I haven't really found out how that works and I have also forgot what you have to do for that :D

So I use my own way to re-order units:
Copy this and paste it in the header file.
JASS:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Delayed Order Snippet
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function IssueOrderCallback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit whichUnit = LoadUnitHandle(udg_DelayedOrder_Hashtable, id, 0)
    local integer orderType = LoadInteger(udg_DelayedOrder_Hashtable, id, 1)
    local string order = LoadStr(udg_DelayedOrder_Hashtable, id, 2)
    local widget targetWidget
    local location targetLocation
    local integer unitTypeId
    
    if orderType == udg_DelayedOrder_TypeTarget then
        set targetWidget = LoadWidgetHandle(udg_DelayedOrder_Hashtable, id, 3)
        call IssueTargetOrder(whichUnit, order, targetWidget)
        set targetWidget = null
    elseif orderType == udg_DelayedOrder_TypePointTarget then
        set targetLocation = LoadLocationHandle(udg_DelayedOrder_Hashtable, id, 3)
        call IssuePointOrder(whichUnit, order, GetLocationX(targetLocation), GetLocationY(targetLocation))
        call RemoveLocation(targetLocation)
        set targetLocation = null
    elseif orderType == udg_DelayedOrder_TypeTrain then
        set unitTypeId = LoadInteger(udg_DelayedOrder_Hashtable, id, 3)
        call IssueImmediateOrderById(whichUnit, unitTypeId)
    elseif orderType == udg_DelayedOrder_TypeNoTarget then
        call IssueImmediateOrder(whichUnit, order)
    endif
    
    call FlushChildHashtable(udg_DelayedOrder_Hashtable, id)
    call DestroyTimer(t)
    set t = null
    set whichUnit = null
endfunction
function IssueTargetOrderDelayed takes unit whichUnit, string order, widget targetWidget, real delay returns nothing
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    
    call TimerStart(t, delay, false, function IssueOrderCallback)
    call SaveUnitHandle(udg_DelayedOrder_Hashtable, id, 0, whichUnit)
    call SaveInteger(udg_DelayedOrder_Hashtable, id, 1, udg_DelayedOrder_TypeTarget)
    call SaveStr(udg_DelayedOrder_Hashtable, id, 2, order)
    call SaveWidgetHandle(udg_DelayedOrder_Hashtable, id, 3, targetWidget)
    
    set t = null
endfunction
function IssuePointOrderDelayed takes unit whichUnit, string order, location targetLocation, real delay returns nothing
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    
    call TimerStart(t, delay, false, function IssueOrderCallback)
    call SaveUnitHandle(udg_DelayedOrder_Hashtable, id, 0, whichUnit)
    call SaveInteger(udg_DelayedOrder_Hashtable, id, 1, udg_DelayedOrder_TypePointTarget)
    call SaveStr(udg_DelayedOrder_Hashtable, id, 2, order)
    call SaveLocationHandle(udg_DelayedOrder_Hashtable, id, 3, targetLocation)
    
    set t = null
endfunction
function IssueTrainOrderDelayed takes unit whichUnit, integer unitTypeId, real delay returns nothing
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    
    call TimerStart(t, delay, false, function IssueOrderCallback)
    call SaveUnitHandle(udg_DelayedOrder_Hashtable, id, 0, whichUnit)
    call SaveInteger(udg_DelayedOrder_Hashtable, id, 1, udg_DelayedOrder_TypeNoTarget)
    call SaveInteger(udg_DelayedOrder_Hashtable, id, 3, unitTypeId)
    
    set t = null
endfunction
function IssueImmediateOrderDelayed takes unit whichUnit, string order, real delay returns nothing
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    
    call TimerStart(t, delay, false, function IssueOrderCallback)
    call SaveUnitHandle(udg_DelayedOrder_Hashtable, id, 0, whichUnit)
    call SaveInteger(udg_DelayedOrder_Hashtable, id, 1, udg_DelayedOrder_TypeNoTarget)
    call SaveStr(udg_DelayedOrder_Hashtable, id, 2, order)
    
    set t = null
endfunction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  End Delayed Order Snippet
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Make this trigger:
  • Delayed Order Configuration
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DelayedOrder_Hashtable = (Last created hashtable)
      • Set DelayedOrder_TypeNoTarget = 1
      • Set DelayedOrder_TypePointTarget = 2
      • Set DelayedOrder_TypeTarget = 3
      • Set DelayedOrder_TypeTrain = 4
Then when you want to stop the unit during an order-response, you do this:
  • Actions
    • Set TempUnit = (Triggering unit)
    • Custom script: call IssueImmediateOrderDelayed(udg_TempUnit, "stop", 0)
 
Status
Not open for further replies.
Top