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

[Jass] Tank turrets including sponsons trigger request

Status
Not open for further replies.
I'm working on a map called, well, name is irrelevant, but, i want to make it so a tank can have multiple little dummy units following it.

This is what i have so far.

JASS:
globals
    unit array SponsonTopLeft
    unit array SponsonTopRight
    unit array SponsonBottomLeft
    unit array SponsonBottomRight
    unit array Front
    unit array Main
    unit array MainTop
endglobals

function Trig_Turrets_Actions takes nothing returns nothing
    local integer LOOP = 0
    loop
        exitwhen LOOP == 11
        //Top left
        call SetUnitX(SponsonTopLeft[LOOP], GetUnitX(Heros[LOOP]) + 83 * Cos((GetUnitFacing(Heros[LOOP])+120) * bj_DEGTORAD))
        call SetUnitY(SponsonTopLeft[LOOP], GetUnitY(Heros[LOOP]) + 83 * Sin((GetUnitFacing(Heros[LOOP])+120) * bj_DEGTORAD))
        if GetUnitCurrentOrder(SponsonTopLeft[LOOP]) != OrderId("attack") then
            call IssueImmediateOrder(SponsonTopLeft[LOOP], "stop")
            call SetUnitFacing(SponsonTopLeft[LOOP], GetUnitFacing(Heros[LOOP]))
        endif
        //Top right
        call SetUnitX(SponsonTopRight[LOOP], GetUnitX(Heros[LOOP]) + 83 * Cos((GetUnitFacing(Heros[LOOP])-120) * bj_DEGTORAD))
        call SetUnitY(SponsonTopRight[LOOP], GetUnitY(Heros[LOOP]) + 83 * Sin((GetUnitFacing(Heros[LOOP])-120) * bj_DEGTORAD))
        if GetUnitCurrentOrder(SponsonTopRight[LOOP]) != OrderId("attack") then
            call IssueImmediateOrder(SponsonTopLeft[LOOP], "stop")
            call SetUnitFacing(SponsonTopRight[LOOP], GetUnitFacing(Heros[LOOP]))
        endif
        //Bottom left
        call SetUnitX(SponsonBottomLeft[LOOP], GetUnitX(Heros[LOOP]) + 80 * Cos((GetUnitFacing(Heros[LOOP])+110) * bj_DEGTORAD))
        call SetUnitY(SponsonBottomLeft[LOOP], GetUnitY(Heros[LOOP]) + 80 * Sin((GetUnitFacing(Heros[LOOP])+110) * bj_DEGTORAD))
        if GetUnitCurrentOrder(SponsonBottomLeft[LOOP]) != OrderId("attack") then
            call IssueImmediateOrder(SponsonBottomLeft[LOOP], "stop")
            call SetUnitFacing(SponsonBottomLeft[LOOP], GetUnitFacing(Heros[LOOP]))
        endif
        //Bottom right
        call SetUnitX(SponsonBottomRight[LOOP], GetUnitX(Heros[LOOP]) + 80 * Cos((GetUnitFacing(Heros[LOOP])-110) * bj_DEGTORAD))
        call SetUnitY(SponsonBottomRight[LOOP], GetUnitY(Heros[LOOP]) + 80 * Sin((GetUnitFacing(Heros[LOOP])-110) * bj_DEGTORAD))
        if GetUnitCurrentOrder(SponsonBottomRight[LOOP]) != OrderId("attack") then
            call IssueImmediateOrder(SponsonBottomRight[LOOP], "stop")
            call SetUnitFacing(SponsonBottomRight[LOOP], GetUnitFacing(Heros[LOOP]))
        endif
        //Front
        call SetUnitX(Front[LOOP], GetUnitX(Heros[LOOP]) + 60 * Cos((GetUnitFacing(Heros[LOOP])-16) * bj_DEGTORAD))
        call SetUnitY(Front[LOOP], GetUnitY(Heros[LOOP]) + 60 * Sin((GetUnitFacing(Heros[LOOP])-16) * bj_DEGTORAD))
        if GetUnitCurrentOrder(Front[LOOP]) != OrderId("attack") then
            call IssueImmediateOrder(Front[LOOP], "stop")
            call SetUnitFacing(Front[LOOP], GetUnitFacing(Heros[LOOP]))
        endif
        //Main
        call SetUnitX(Main[LOOP], GetUnitX(Heros[LOOP]))
        call SetUnitY(Main[LOOP], GetUnitY(Heros[LOOP]))
        if GetUnitCurrentOrder(Main[LOOP]) != OrderId("attack") then
            call IssueImmediateOrder(Main[LOOP], "stop")
            call SetUnitFacing(Main[LOOP], GetUnitFacing(Heros[LOOP]))
        endif
        //Main top
        set LOOP = LOOP + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Turrets takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.02, true, function Trig_Turrets_Actions)
    set SponsonTopLeft[1] = CreateUnit(Player(1), 'h005', 0, 0, 0)
    call SetUnitFlyHeight(SponsonTopLeft[1], 58, 0)
    set SponsonTopRight[1] = CreateUnit(Player(1), 'h005', 0, 0, 0)
    call SetUnitFlyHeight(SponsonTopRight[1], 58, 0)
    set Front[1] = CreateUnit(Player(1), 'h005', 0, 0, 0)
    call SetUnitFlyHeight(Front[1], 38, 0)
    set SponsonBottomLeft[1] = CreateUnit(Player(1), 'h006', 0, 0, 0)
    call SetUnitFlyHeight(SponsonBottomLeft[1], 40, 0)
    set SponsonBottomRight[1] = CreateUnit(Player(1), 'h006', 0, 0, 0)
    call SetUnitFlyHeight(SponsonBottomRight[1], 40, 0)
    set Main[1] = CreateUnit(Player(1), 'h007', 0, 0, 0)
endfunction

So basically, this moves the turrets correctly, but. the turrets dont attack, for some reason, they attack once then just move as if they were trying to move but the setunitx/y's move it back into position, so it looks stupid.

I'm just asking if somone could do it so the sponson turrets (on the sides, as in they cant shoot on the opposite side of themselves) dont shoot wrongly, and make it so the front cannon doesn't shoot from right infront +- 50 degrees

Thanks.

+2 rep for any help, a demo map with riflemen and a siege tank would be appreatiated.
 
Level 3
Joined
Apr 20, 2010
Messages
46
Perhaps it would be better if the turrets weren't actively attacking and their units were complete dummies.

Use a trigger to control the target selection for the turrets, when it selects a valid target, move the turret into position and play the animation whenever it should shoot, either creating dummy projectiles or instantaneous effects and damage.

Hopefully that makes sense to more than just myself.
 
Status
Not open for further replies.
Top