• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How To Stop Neutral Units From Returning To Spawn Point

Status
Not open for further replies.
I'm having issues with units that are neutral (Player(12) to Player(15)) will return to their spawn point (set by CreateUnit) even though my units are moved via triggers (SetUnitX and SetUnitY) still move back to their original location (the 'guard point'). Even though my script still moves them. Once they are far enough away from their guard point they turn around and march right on back.

I would like a solution to be player specific (aka; not changing the gameplay constants). I have tried RemoveAllGuardPositions.
 
Level 7
Joined
Dec 28, 2009
Messages
257
Check Gameplay Constant, look for letter C, and there are few things like "Creep Return Range", timer, guard, etc.. try setting one of those (or all :D) to very big value, and it might fix it :D

Hope it helps :D
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
I'm currently trying RemoveGuardPosition(unit) and call SetUnitCreepGuard(unit, false) but haven't had any luck yet.

The only thing that worked was changing the gameplay constants, but doing that will screw with every other unit in the map and I do not want that.

*EDIT* I think I may have found the issue. Those functions don't work on heroes or peon-type units. The unit I'm using is based on the peasant. I'm going to try to change the unit base and see if it works.
 
Level 18
Joined
Nov 1, 2006
Messages
1,612
This issue was apparently solved back in 2006 in this thread.

However, I am not able to replicate those results. See the following script;

JASS:
function Trig_MovePorter_Actions takes nothing returns nothing
    local location ploc = GetUnitLoc(udg_porter)
    local location loc
    local integer i = GetRandomInt(1, 5)
    call SetUnitCreepGuard(udg_porter, false)
    if i == 1 then
        set loc = GetRandomLocInRect(gg_rct_Hunting_Rabbits)
    else
        if i == 2 then
            set loc = GetRandomLocInRect(gg_rct_Forest2)
        else
            if i == 3 then
                set loc = GetRandomLocInRect(gg_rct_Elf_Village)
            else
                if i == 4 then
                    set loc = GetRandomLocInRect(gg_rct_Lowlands)
                else
                    if i == 5 then
                        set loc = GetRandomLocInRect(gg_rct_Fountain)
                    endif
                endif
            endif
        endif
    endif
    call TimerStart(udg_Quest_Porter_Timer, (5.0 + (1.75 * (DistanceBetweenPoints(ploc, loc) / GetUnitMoveSpeed(udg_porter)))), false, null)
    call IssuePointOrderLoc(porter, "move", loc)
    call RemoveLocation(loc)
    call RemoveLocation(ploc)
    set loc = null
    set ploc = null
endfunction

//===========================================================================
function InitTrig_MovePorter takes nothing returns nothing
    set gg_trg_MovePorter = CreateTrigger(  )
    call TriggerRegisterTimerExpireEvent(gg_trg_MovePorter, udg_Quest_Porter_Timer)
    call TriggerAddAction( gg_trg_MovePorter, function Trig_MovePorter_Actions )
endfunction

The Porter moves for ~ 5 seconds and then just turns around and heads back. I've also tried using RemoveGuardPosition(udg_Porter) to no avail.

*EDIT* Okay I just found out that neither RemoveGuardPosition(unit) nor SetUnitCreepGuard(unit, false) work on Neutral units according to this thread. I'm going to try creating the unit for a PLAYER, calling those two functions, and then changing the owner to Neutral Passive. I'll let you know if that works.

*SOLVED* Neither RemoveGuardPosition(unit) nor SetUnitCreepGuard(unit, false) work on Neutral units. To get around this, the unit needs to be temporarily changed to a PLAYER owner and the SetUnitCreepGuard() function needs to be called. Then the unit can immediately be changed back to Neutral and will no longer try to fall back to it's guard position. Note, Player(9) is unused in my game AND I'm also using RemoveGuardPosition(unit) to be safe.

JASS:
function Trig_MovePorter_Actions takes nothing returns nothing
    local location ploc = GetUnitLoc(udg_porter)
    local location loc
    local integer i = GetRandomInt(1, 5)
    call SetUnitOwner(udg_porter, Player(9), false)
    call SetUnitCreepGuard(udg_porter, false)
    call RemoveGuardPosition(udg_porter)
    call SetUnitOwner(udg_porter, Player(PLAYER_NEUTRAL_PASSIVE), true)
    if i == 1 then
        set loc = GetRandomLocInRect(gg_rct_Hunting_Rabbits)
    else
        if i == 2 then
            set loc = GetRandomLocInRect(gg_rct_Forest2)
        else
            if i == 3 then
                set loc = GetRandomLocInRect(gg_rct_Elf_Village)
            else
                if i == 4 then
                    set loc = GetRandomLocInRect(gg_rct_Lowlands)
                else
                    if i == 5 then
                        set loc = GetRandomLocInRect(gg_rct_Fountain)
                    endif
                endif
            endif
        endif
    endif
    call TimerStart(udg_Quest_Porter_Timer, (3.0 + (1.75 * (DistanceBetweenPoints(ploc, loc) / GetUnitMoveSpeed(udg_porter)))), false, null)
    call IssuePointOrderLoc(udg_porter, "move", loc)
    call RemoveLocation(loc)
    call RemoveLocation(ploc)
    set loc = null
    set ploc = null
endfunction

//===========================================================================
function InitTrig_MovePorter takes nothing returns nothing
    set gg_trg_MovePorter = CreateTrigger(  )
    call TriggerRegisterTimerExpireEvent(gg_trg_MovePorter, udg_Quest_Porter_Timer)
    call TriggerAddAction( gg_trg_MovePorter, function Trig_MovePorter_Actions )
endfunction
 
Last edited:
Status
Not open for further replies.
Top