• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

A tower that can't be controlled

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys I want to ask if this is possible, a peasant will build a tower and ofc the tower belongs to you when it is finished. However the tower that has been built cannot take orders from the player, meaning to say the player who owns the tower can't issue an order to the tower. Like attack or stop etc..... is this possible guys?
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
No I mean you can't control the tower or you can't give some orders on the tower, but the tower belongs to you.
 
Level 3
Joined
May 28, 2015
Messages
41
mby Loctus ability to make it unselectable?
btw if you make it to "issue order - hold position" wouldn't it still be possible to spam with smart order to make it stop attacking? i mean every time you order a unit to hold position the unit searces for target before an attack and if you make a new order that unit should be searching for a new target thus delaying a bit before an attack? cus i have that problem in my map though i use " move to point attacking "
 
Level 12
Joined
May 22, 2015
Messages
1,051
Might not be what you want, but the towers in my map use phoenix fire ability. The DOT lasts 0.01 seconds and the projectile model is an arrow. They shoot at random targets. They're not player controlled, but this would prevent targeting with them. The main problem is that they do magic damage.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
lol... award classifications... loctus ability...
weird discussion.

I know one way that will make you unable to select it... however, you cannot show it's default health bar any more.

The other way still interrupts the current order but re-orders the tower to do the last order that he was given. (Simply ignores your own order.)
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
The other way still interrupts the current order but re-orders the tower to do the last order that he was given. (Simply ignores your own order.)

This looks ok , could you show me how?
 
Level 3
Joined
May 28, 2015
Messages
41
try smth like this:

  • Events
  • Unit - issued order with no target
  • Unit - issued order targeting a point
  • Unit - issued order targeting a unit
  • Conditions
  • Actions
  • Trigger - turn of this trigger
  • Unit - issue triggering unit to guard
  • Trigger - turn on this trigger
 
Level 3
Joined
May 28, 2015
Messages
41
instead of diabling

if you meant "disabling" then would that condition prevent an infinite loop that causes my game to crash? i mean i use " move to point attacking " in my map and player can only give smart orders to move and attack cause units a "ward" classifications. So i need to add the condition of
  • boolean - issued order(move attacking) not equals yes
is that right?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You also have to pause the unit.
Disable the trigger and pause the unit, then give guard order then unpause and enable again.
(Do not know wether first disable and then pause or the other way around.)

If you dont do that, you will not give the new order.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
Some people say the solution lies with Locust and reversing it to some degree. It is allegedly possible to get a locust unit attackable but not targetable (outside of automatically) or selectable. I am not sure how but it is something like hiding and unhiding it, or morphing it.

All solutions with order cancelation require that you use a timer to wait 0 seconds. This is because the event fires before the order is actually issued to the unit so any order you issue immediately is cancel by the order the event responded to.

In StarCraft II you could make it uncontrollable and be done...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
This looks really difficult to do...... should I just follow Pinzu's triggers?
If they work. As I said the order event fires before the unit is given the actual order. As such issuing an order to it in response to the event does not work as it immediately gets replaced by the order that fired the event.

You need to use a 0 second timer to delay the cancelation order long enough for the event order to be applied and short enough that the order has no actions. TriggerSleepAction (GUI Wait) does not work as it has a minimum time of 0.1 seconds or worse which gives enough time for the order to have actions.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I am quite sure that there was something when turning the trigger off, pausing the unit then giving the order and unpause and enable that the old order was just deleted and the new order is given.

However I prefer my own interpretation of the orders as the DelayedOrder:
You can use it with a hashtable like this, with table (multiple hashtables in one) or by using a timer indexer.
JASS:
globals
    hashtable udg_DelayedOrder_Hashtable        = InitHashtable()
    integer udg_DelayedOrder_TypeTarget         = 1
    integer udg_DelayedOrder_TypePointTarget    = 2
    integer udg_DelayedOrder_TypeTrain          = 3
    integer udg_DelayedOrder_TypeNoTarget       = 4
endglobals





library delayedorder
    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
endlibrary
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
It works the same how Orders work in JASS.
You simply use the IssueImmediateOrderDelayed() instead of IssueImmediateOrder() and you specify a time value that will be the delay.
Same for IssuePointOrder() and IssueTargetOrder().

Ofcourse, you want 0 delay so you use 0.
In that case, you will still use the timer and it will work quite nice.
I am going to make a version with TimerUtils and TimerIndex to get optimized performance.
Will make some for IssueById as well.
 
Status
Not open for further replies.
Top