Forged Alliance Forever Forged Alliance Forever Forums 2019-05-01T20:19:35+02:00 /feed.php?f=41&t=17496 2019-05-01T20:19:35+02:00 2019-05-01T20:19:35+02:00 /viewtopic.php?t=17496&p=174220#p174220 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
Code:
INFO: My table: {
INFO:   { <metatable=table: 2221CDC0>
INFO:     _c_object=userdata: CScriptObject* at 1F354434 = [CScriptObject at 0x21D80680]
INFO:   },
INFO:   { <metatable=table: 2221CDC0>
INFO:     _c_object=userdata: CScriptObject* at 22F3BF9C = [CScriptObject at 0x1E944F80]
INFO:   },
INFO:   { <metatable=table: 2221CDC0>
INFO:     _c_object=userdata: CScriptObject* at 230338D0 = [CScriptObject at 0x2164B880]
INFO:   }
INFO: }
That's with an attack order and two move orders. So yeah, I'm looking at that and thinking this is clearly not happening, unless there's a way to translate that there's no way to know what's what.

I've tried the SetImmobile idea too but that doesn't actually cancel anything, neither does abortmove (I mean, it might cancel a move order but it doesn't seem to do anything with an attack command).

Bah, maybe I'll come up with something else but my head hurts for now!

Statistics: Posted by Sabranan — 01 May 2019, 20:19


]]>
2019-05-01T18:07:54+02:00 2019-05-01T18:07:54+02:00 /viewtopic.php?t=17496&p=174211#p174211 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
Code:
LOG( 'My table: '..repr( table) )

Statistics: Posted by Uveso — 01 May 2019, 18:07


]]>
2019-05-01T15:40:30+02:00 2019-05-01T15:40:30+02:00 /viewtopic.php?t=17496&p=174204#p174204 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
Uveso wrote:
Or you could access the CommandQueue of the unit
Code:
local queue = unit:GetCommandQueue()


I feel like this one has potential, I'd only ever need to look at the first command in the list and I could potentially use that to determine if a unit has a current target. Then if it does (and it doesn't have a blip for it), delete the first command in the queue and reissue the remaining ones.

It's just, I can get that table with the above code but how can I look at what's in it?

Like for example I've got:

Code:
if unitCmdQ then
   for x, command in unitCmdQ do
      LOG('queue = ' .. x)
   end
else
   LOG('No queue found.')
end

Which tells me how many indexes are in the queue and that works, so I know there's "something" in the table. But if I try and look at "command" or "command[1]" I just get an error because it's a nil value.

Statistics: Posted by Sabranan — 01 May 2019, 15:40


]]>
2019-04-30T14:55:03+02:00 2019-04-30T14:55:03+02:00 /viewtopic.php?t=17496&p=174178#p174178 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
Code:
unit:GetNavigator():GetCurrentTargetPos()


the last way would be to loop over every weapon a unit has and call
Code:
UnitWeapon:GetCurrentTarget()
or
UnitWeapon:GetCurrentTargetPos()

Statistics: Posted by Uveso — 30 Apr 2019, 14:55


]]>
2019-04-30T14:46:37+02:00 2019-04-30T14:46:37+02:00 /viewtopic.php?t=17496&p=174177#p174177 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
You could try to stop the unit from moving (and all other orders) with:
Code:
unit:Stop()


You could try to access the units navigator:
Code:
unit:GetNavigator():AbortMove()


Maybe it will work if you set the unit to immobile:
Code:
Unit:SetImmobile(true)
WaitSeconds(0.1)
Unit:SetImmobile(false)


Or you could access the CommandQueue of the unit
Code:
local queue = unit:GetCommandQueue()

Thats a bit tricky. You need to filter the unneded commands,
clear the CommandQueue and then re-issue all needed commands.

Statistics: Posted by Uveso — 30 Apr 2019, 14:46


]]>
2019-04-30T14:37:42+02:00 2019-04-30T14:37:42+02:00 /viewtopic.php?t=17496&p=174176#p174176 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]> Statistics: Posted by Sabranan — 30 Apr 2019, 14:37


]]>
2019-04-30T13:21:02+02:00 2019-04-30T13:21:02+02:00 /viewtopic.php?t=17496&p=174173#p174173 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
I think the only question I have left is this, can I just cancel the current order of a unit without having to clear the lot of them?

I've tried IssueStop but it doesn't seem to do anything, IssueClearCommands cancels everything like the name implies. I suppose I could use IssueAggressiveMove but I imagine that would have the same problem in that it would cancel whatever else the unit had queued (and also I'd have to figure out what arguments it needs, unit and coords I guess?).

Statistics: Posted by Sabranan — 30 Apr 2019, 13:21


]]>
2019-04-30T05:38:50+02:00 2019-04-30T05:38:50+02:00 /viewtopic.php?t=17496&p=174160#p174160 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]> BreakAttackOnIntelLost-V1.zip

It will show some debuglines but does not issue any commands.
(read the comments inside the mods ScenarioUtilities.lua)

Statistics: Posted by Uveso — 30 Apr 2019, 05:38


]]>
2019-04-30T04:54:29+02:00 2019-04-30T04:54:29+02:00 /viewtopic.php?t=17496&p=174158#p174158 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
local unitlist = aiBrain:GetListOfUnits(category, false)
local target= unit:GetFocusUnit()
local blip = target:GetBlip(armyIndex)

But i guess those commands will not run from gamemain.lua.

Statistics: Posted by Uveso — 30 Apr 2019, 04:54


]]>
2019-04-30T00:35:38+02:00 2019-04-30T00:35:38+02:00 /viewtopic.php?t=17496&p=174152#p174152 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
That's progress!

Now I just gotta figure out how to build a list of every active unit, how to address their attack target (if there is one) and determine whether it can be seen visually or on radar, then how to cancel just that attack order without cancelling everything it's supposed to be doing...

So still some work to go!

Statistics: Posted by Sabranan — 30 Apr 2019, 00:35


]]>
2019-04-29T19:28:29+02:00 2019-04-29T19:28:29+02:00 /viewtopic.php?t=17496&p=174141#p174141 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>

Then I must be missing something because there's a load of "while true do" loops without any exit clauses I can see scattered around the lua, but these still run without locking it up.


They are made only under threads, not on the main sim execution.

Statistics: Posted by Franck83 — 29 Apr 2019, 19:28


]]>
2019-04-29T19:29:51+02:00 2019-04-29T19:23:38+02:00 /viewtopic.php?t=17496&p=174140#p174140 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
Code:
WaitTicks(1)  -- Waits 0.1 seconds


[edit] this will only work in case you forked a thread.

Statistics: Posted by Uveso — 29 Apr 2019, 19:23


]]>
2019-04-29T16:45:17+02:00 2019-04-29T16:45:17+02:00 /viewtopic.php?t=17496&p=174127#p174127 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]> Statistics: Posted by Sabranan — 29 Apr 2019, 16:45


]]>
2019-04-29T16:38:48+02:00 2019-04-29T16:38:48+02:00 /viewtopic.php?t=17496&p=174126#p174126 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]> Statistics: Posted by Franck83 — 29 Apr 2019, 16:38


]]>
2019-04-29T16:32:03+02:00 2019-04-29T16:32:03+02:00 /viewtopic.php?t=17496&p=174125#p174125 <![CDATA[Re: Trying to cancel attack orders when intel is lost]]>
I have an infinite loop which just posts a log to the console.

Problem is, that just freezes the game because it runs forever, but hey, at least I know it's doing something!

But that presents me with an issue, how can I have a loop running constantly but in its own thread so it doesn't completely stall everything else?

Statistics: Posted by Sabranan — 29 Apr 2019, 16:32


]]>