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

Help! why the enemy stop moving and attacking!

Status
Not open for further replies.
Level 1
Joined
Jul 20, 2020
Messages
2
Help! why the enemy stop moving and attacking!


I create some units to attack my main hero.
but when i moving my main hero left <-> right around many times , the created enemys stop moving and attacking ,they seems to be suspend!
how can i make them moving and attacking again!
Thanks!

[v 1.32.9]

JASS:
library startInit initializer init_function
globals
    private unit mainHero
    private group enemyG
endglobals


private function oderUnit_attack takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real x =GetUnitX(mainHero)
    local real y =GetUnitY(mainHero)

    if IsUnitType(u, UNIT_TYPE_DEAD) then
        call GroupRemoveUnit(enemyG  ,  u )
    else
        call  IssuePointOrder( u , "attack" ,x , y )
        // call IssuePointOrder( u , "attack" ,x , y )
        // call IssuePointOrderLoc( u , "attack" , l )
    endif
endfunction

private function startOderUnit takes nothing returns nothing
    call ForGroup(enemyG ,function oderUnit_attack )
endfunction

private function createEnemy takes nothing returns nothing
    local unit u
    local real x = GetUnitX(mainHero)
    local real y = GetUnitY(mainHero)
    local location l = Location(x , y)

    set u = CreateUnit(Player(5),'Hmkg',3000,3000,0)
    call SetUnitAcquireRange(u, 2000.00)
    call RemoveGuardPosition(u)
    // call GroupAddUnit( enemyG,u)
    // call IssuePointOrder( u , "attack" ,x , y )
    call IssuePointOrderLoc( u , "attack" ,l )

    call RemoveLocation(l)
    // call BJDebugMsg(R2S(x) + " , " + R2S(y))
    set u = null
    set l = null
endfunction

private function createHero takes nothing returns nothing
    set mainHero = CreateUnit(Player(0) , 'Hmkg' ,0 , 0 , 0 )
endfunction

private function initMap takes nothing returns nothing
    call FogMaskEnableOff()
    call FogEnableOff()
    call SetCameraFieldForPlayer(Player(0), CAMERA_FIELD_TARGET_DISTANCE, 2200.00, 0)

    call SetMapName("testMap")
    call SetMapDescription("testMap")
    call SetPlayers(5)
    call SetTeams(5)

    call BJDebugMsg("testMap inited!")
endfunction


    private function init_function takes nothing returns nothing
        local timer timer_createEnemy = CreateTimer()
        local timer timer_oderEnemy = CreateTimer()
        set enemyG = CreateGroup()

        call initMap()
        call createHero()
        call createEnemy()

        call TimerStart( timer_createEnemy , 0.5 , true , function createEnemy)
        // call TimerStart( timer_oderEnemy , 0.03 , true , function startOderUnit)
      
    endfunction
endlibrary
 

Attachments

  • testMapClip.gif
    testMapClip.gif
    4.7 MB · Views: 23
  • testMap.w3x
    21.6 KB · Views: 17
Level 1
Joined
Jul 20, 2020
Messages
2
it works! thank you verymuch!
Warcraft 3 supports only a limited amount of moving units per player at the same time I think something like 100. Split your attackers into multiple players (so that no player reaches that limit), then they all can move again.
 
Status
Not open for further replies.
Top