Demo Map Full Command Cart

DioD

New Member
Reaction score
57
Full Command Cart is:

Jass code handler:
JASS:
library FCC initializer INIT
//FullCommandCart

globals

    unit WHO
    destructable DES
    item ITM
    unit UNT
    real X
    real Y
    timer TT = CreateTimer()
    trigger MZ = CreateTrigger()

endglobals

function order takes nothing returns nothing
    if DES != null then
        call IssueTargetOrder(WHO,"smart",DES)
    elseif ITM != null then
        call IssueTargetOrder(WHO,"smart",ITM)
    elseif UNT != null then
        if IsUnitAlly(UNT,GetOwningPlayer(WHO)) then
            call IssueTargetOrder(WHO,"smart",UNT)
        else
            call IssueTargetOrder(WHO,"attack",UNT)
        endif
    else
        call IssuePointOrder(WHO,"move",X,Y)
    endif
    call UnitAddAbility(WHO,'A000')
    call EnableTrigger(MZ)
endfunction

function FCC_MAIN takes nothing returns nothing
    if GetIssuedOrderId() != OrderId("smart") then
        return
    endif
    set WHO = GetTriggerUnit()
    set DES = GetOrderTargetDestructable()
    set ITM = GetOrderTargetItem()
    set UNT = GetOrderTargetUnit()
    set X = GetOrderPointX()
    set Y = GetOrderPointY()
    call DisableTrigger(MZ)
    call UnitRemoveAbility(WHO,'A000')
    call TimerStart(TT,0.0,false,function order)
endfunction

function INIT takes nothing returns nothing

    //This calls will block standart command cart buttorns for player 0
    call SetPlayerAlliance(Player(0), Player(0), ALLIANCE_SHARED_ADVANCED_CONTROL, false)
    call SetPlayerAlliance(Player(0), Player(0), ALLIANCE_SHARED_CONTROL, false)

    //this calls will disable attack notifications

    call SetPlayerAlliance(Player(0), Player(0), ALLIANCE_HELP_REQUEST, true)
    call SetPlayerAlliance(Player(0), Player(0), ALLIANCE_HELP_RESPONSE, true)
    
    //Remove "share control" message
    
    call ClearTextMessages()
    
//register event for channel hit
    call TriggerRegisterAnyUnitEventBJ( MZ, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerRegisterAnyUnitEventBJ( MZ, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerRegisterAnyUnitEventBJ( MZ, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddAction( MZ, function FCC_MAIN )
endfunction
endlibrary


and

Object trick (included as demo map) (Channel spell with smart order)

This allow you to have unit (or multiple up to unlimited number) with full command cart filled with spells without spellbooks (total 12).

And possible advanced controls (like double click handling, left mouse button handling and other - NOT INCLUDED this version).
 

Attachments

  • FCC 12 v 2.w3x
    37.1 KB · Views: 370

Romek

Super Moderator
Reaction score
963
What does this do?
How do you use it?

Also, make the functions that the user isn't going to use private.
 

DioD

New Member
Reaction score
57
This allow you to have unit (or multiple up to unlimited number) with full command cart filled with spells without spellbooks (total 12).

note:
also it allow you to enable-disable control over specific units onfly.

also this trick usefull for maps like castle fight, since you able to keep control over worker, and disable control over other units.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
If I order mass of units to one position, I doubt it can handle it successfully.
 

Laiev

Hey Listen!!
Reaction score
188
@DioD

select multiple units and order?

trigger (obvious some maps order multiple units to do the same thing at the same time, for example AoS's)
 

DioD

New Member
Reaction score
57
order multiple units at time and post replay or code or whatever if it will fail i will check and fix.

currently its failsafe.
 

Laiev

Hey Listen!!
Reaction score
188
@DioD

You have to do this test to prove to us that there are no errors, not unlike we do the test and prove to you that has some error.
the system is yours, you have to show us the efficiency of it, never the reverse.

And most of all, I never said there would be no mistakes, only pointed out ways for you to order several units to do some action simultaneously.
 

DioD

New Member
Reaction score
57
you dont know basics of warcraft's code execution, there is NO WAY to do something "simultaneously", all actions execute in order.
 

Laiev

Hey Listen!!
Reaction score
188
And most of all, I never said there would be no mistakes, only pointed out ways for you to order several units to do some action simultaneously.

You know what I mean with simultaneously in Warcraft.

Is your system, you do what you want with it.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
This is a very cool idea, but the code itself needs revision.

you dont know basics of warcraft's code execution, there is NO WAY to do something "simultaneously", all actions execute in order.
This is true, but it is possible for things to happen before the 1-tick delay imposed by a 0-second timer. The following trigger would break your system:
Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Unit - Order (Target unit of issued order) to Right-Click (Triggering unit)


I would recommend using TimerUtils, and having an actual interface instead of hard-coding which players should be affected. May I suggest this:
(note: this has not been tested to work or compile - it's just an overview)
JASS:
library HCC requires TimerUtils
// Copy this library into a trigger in your map.
// Requires JassHelper and TimerUtils.
//
// Usage:
// call HideCommandCart(whichPlayer, active) with your player and "true"
// if you wish to hide the command cart buttons for that player, or "false"
// to re-enable them.
//
// Each unit needs to have the dummy "smart" order handler ability to be
// able to receive "smart" (right-click) orders when the command cart is
// hidden.
globals
    private trigger array SMARTHANDLER
endglobals

public function HideCommandCart takes player whichPlayer, boolean active returns nothing
    //These calls will block standard command cart buttons
    call SetPlayerAlliance(whichPlayer, whichPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, not(active))
    call SetPlayerAlliance(whichPlayer, whichPlayer, ALLIANCE_SHARED_CONTROL, not(active))

    //These calls will disable attack notifications
    call SetPlayerAlliance(whichPlayer, whichPlayer, ALLIANCE_HELP_REQUEST, active)
    call SetPlayerAlliance(whichPlayer, whichPlayer, ALLIANCE_HELP_RESPONSE, active)
    
    //Remove "share control" message
    if GetLocalPlayer() == whichPlayer then
        call ClearTextMessages()
    endif

    //Enables/disables smart order handling
    if active then
        call EnableTrigger(SMARTHANDLER[GetPlayerId(whichPlayer)])
    else
        call DisableTrigger(SMARTHANDLER[GetPlayerId(whichPlayer)])
    endif
endfunction

private struct SmartHandler 
    unit orderedUnit
    destructable targetDestructable
    item targetItem
    unit targetUnit
    real targetX = 0
    real targetY = 0

    static method reissue takes nothing returns nothing
        local thistype this = thistype[GetTimerData(GetExpiredTimer())]
        call ReleaseTimer(GetExpiredTimer())
        
        call DisableTrigger(SMARTHANDLER[GetPlayerId(GetOwningPlayer(orderedUnit))])
        if targetDestructable != null then
            call IssueTargetOrder(orderedUnit, "smart", targetDestructable)
        elseif targetItem != null then
            call IssueTargetOrder(orderedUnit, "smart", targetItem)
        elseif targetUnit != null then
            call IssueTargetOrder(orderedUnit, "smart", targetUnit)
        else
            call IssuePointOrder(orderedUnit, "move", targetX, targetY)
        endif
        call EnableTrigger(SMARTHANDLER[GetPlayerId(GetOwningPlayer(orderedUnit))])
        
        call this.destroy()
    endmethod
    
    static method onOrder takes nothing returns boolean
        local thistype this
        local timer t
        if GetIssuedOrderId() == OrderId("smart") then
            set this = thistype.create()
            call SetTimerData(t, this)
            
            set orderedUnit = GetTriggerUnit()
            set targetDestructable = GetOrderTargetDestructable()
            set targetItem = GetOrderTargetItem()
            set targetUnit = GetOrderTargetUnit()
            set targetX = GetOrderPointX()
            set targetY = GetOrderPointY()
            
            call TimerStart(t, 0.0, false, function thistype.reissue)
            set t = null
        endif
        return false
    endmethod
    
    static method onInit takes nothing returns nothing
        local integer i = 0
        loop
            set SMARTHANDLER<i> = CreateTrigger()
            call TriggerRegisterPlayerUnitEvent(SMARTHANDLER<i>, Player(i), whichEvent, Condition(function thistype.onOrder))
            call DisableTrigger(SMARTHANDLER<i>)
            set i = i+1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
    endmethod
endstruct
endlibrary</i></i></i>


Also, the smart order ability can be reduced to having 1 level and needs to have its options set to have it as a Universal Ability (so it can target spell immune and can be cast while silenced).
 

DioD

New Member
Reaction score
57
@Weep
your sample will ruin any map, with any code, since you generate event from trigger registered to this event.

"smart" or right click shoud be used with care (there is no reason to use smart from code anyway, units will 'move' or 'attack') with command cart disabled player may not select more then 1 unit soo this is not issue at all.

structs (arrays) not needed, this system run without problems on single set of variables.

this cannot be enabled or disabled in runtime, if you set custom controls, you may disable control of individual units (remove handler and add ward class) but not players.

@Darthfett

This is not system, this is demomap (sample), it cannot be imported to map, since there is no way to "1click" setup it.

well "fixed" version will come this sunday (311010) this will be demo of castle fight like map.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
@Weep
your sample will ruin any map, with any code, since you generate event from trigger registered to this event.
OK, so I forgot to put a trigger disable/enable actions in my short GUI example. The point remains that, although unlikely to be used, a trigger ordering units to "smart" some other unit from an order event will overwrite your system's variables. It is a correctable fault.

"smart" or right click shoud be used with care (there is no reason to use smart from code anyway, units will 'move' or 'attack')
Why bother figuring out which will happen with a large set of "if" statements, when you can issue the "smart" order and let the game figure it out? It's not as simple as you might think.

For example, in your original system, you order a unit to attack if it had been smart-ordered onto an enemy. This is incorrect, however: if the enemy is invulnerable, the vanilla game's response is to have the ordered unit move to the enemy, not to attack (which simply presents the error message without the unit moving).

with command cart disabled player may not select more then 1 unit soo this is not issue at all.
Interesting, I didn't notice. This limitation should be mentioned in the code's documentation.

structs (arrays) not needed, this system run without problems on single set of variables.
False; see above. This system is so cool, I don't want to see it graveyarded just because you aren't realizing that flaws, even if rare to encounter, ought to be removed. :(

this cannot be enabled or disabled in runtime, if you set custom controls, you may disable control of individual units (remove handler and add ward class) but not players.
I don't understand what you mean, but if you mean that it doesn't work to enable/disable a player's self-control during the game, it's not true - you just need to reselect the unit for the control cart to update.

This is not system, this is demomap (sample), it cannot be imported to map, since there is no way to "1click" setup it.
Why not make it in such a way that it can?

well "fixed" version will come this sunday (311010) this will be demo of castle fight like map.
What fixes do you intend to make?
 

DioD

New Member
Reaction score
57
Everything noted in this thread will be checked and (possibly)fixed.

System will not be moved to arrays, this is not flaw or problem, it will ignore orders given by triggers (experemental methods + hooks).
There is completely no way for player to hit 0second timer limits.

For players who already hook IssueX functions direct arrays version will be included.
(act like structs+timer utils but dont need any additional importing).

Runtime player(enable-disable) and unit(enable-disable) controls will be added.

Experemental player 12-15 AI disabling will be added.

All profs and cons will be listed.
All limits will be listed.
Instal documentation will be included.
Demomap will be included.
 

Laiev

Hey Listen!!
Reaction score
188
All profs and cons will be listed.
All limits will be listed.
Instal documentation will be included.
Demomap will be included.

It's good to read :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top