Cant issue patrol order

Cant issue patrol order

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Cant issue patrol order

Post by code_man »

I have this simple gadged and well it the order i give doesnt get issued, tough things work fine if i issue the order by hand.

Code: Select all

function gadget:UnitFinished(unit, unit_def, team)
   if UnitDefs[unit_def].humanName == "Tiberium Refinery" then
       local x, y, z = Spring.GetUnitPosition(unit)
       local unitX = Spring.CreateUnit("harvester", x, y, z + 25, 0, team)
       Spring.GiveOrderToUnit(unitX, CMD.PATROL, {x, y, z}, {})
   end
end
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Cant issue patrol order

Post by knorke »

Should work like that. Possible causes:
-25 elmo distance might be too little so that lazy unit does not bother to patrol so small distance? (select it, press shift to see if it has waypoints) Put higher distance.
-unit is stuck in refinery?
-unit name in the if-condition is spelled different?
(imo it is best to always use the internal unitnames, otherwise it can get mixed up. Like here you have humanName ""Tiberium Refinery" but internal name "harvester")
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Re: Cant issue patrol order

Post by code_man »

I resolved the issue, it was something with the unit being "blocked" by the building.

Now maybe i fucked something up but does spring not allow to place patrol order on the same spot as a units current postion, or something similar?
Post Reply

Return to “Game Development”