Jump to content


Photo

squad is moving or stationary, coding problem


7 replies to this topic

#1 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 12 August 2005 - 08:27 PM

I was wondering why certain functions in which I do use

not self.squad_ai:IsInStateMove() and not self.squad_ai:IsInStateAttackMove()

to check for stationary squads did not work as expected.

These functions only return wether a squad was ordered normal or attack move. This can result in a squad with attack move is stationary while attacking or a squad has a different move command and is moving though both functions return false.

How can I check wether a squad is really moving or not ?

#2 Flenser

Flenser

    title available

  • Members
  • 316 posts
  • Location:Glasgow, Scotland
  • Projects:Dawn of War AI Skirmish

Posted 13 August 2005 - 11:02 AM

How can I check wether a squad is really moving or not ?

<{POST_SNAPBACK}>

Check if the squad's target position is the same as the squad's actual position.

Flenser

#3 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 13 August 2005 - 03:02 PM

You mean with GetTargetPos() ? Never knew it did exist until I checked the WiKi after reading your comment.

Edit: No, that doesn't work. Just checked. Target position is different from move position though squad is stationary.

Edited by LarkinVB, 13 August 2005 - 04:11 PM.


#4 Flenser

Flenser

    title available

  • Members
  • 316 posts
  • Location:Glasgow, Scotland
  • Projects:Dawn of War AI Skirmish

Posted 13 August 2005 - 04:25 PM

You mean with GetTargetPos() ? Never knew it did exist until I checked the WiKi after reading your comment.

Edit: No, that doesn't work. Just checked. Target position is different from move position though squad is stationary.

<{POST_SNAPBACK}>

I didn't know it existed either! You can do it another way, but if there is a function to do it already - give it a try :lol:

Flenser

#5 Flenser

Flenser

    title available

  • Members
  • 316 posts
  • Location:Glasgow, Scotland
  • Projects:Dawn of War AI Skirmish

Posted 13 August 2005 - 04:33 PM

Here is a snippet of the code I used:-

  	 local tactic = self.attack_units[i]:GetTactic()
   	 local target = tactic.target
                    aitrace( self.attack_units[i]:GetStats():GetSquadName()..": "..self.attack_units[i]:GetID().." is attacking "..vec2str( target ) )
                    aitrace("Current target of the attack plan is "..vec2str( self.cc_attack_pos ) )
                    aitrace("Current gather point of the attack plan is "..vec2str( self.gather_pos ) )
   	 --if the target is not the attack_now_pos, attack_pos or gather_pos then this squad is in use

As you can see I found out the target of the squad in question on the 2nd line with the local variable 'target'. Just compare that with the squad's current position. If they are the same then the squad is not moving since it has reached where it is going to. If they are not the same then the squad still has some moving to do.

Flenser

Edited by Flenser, 13 August 2005 - 04:34 PM.


#6 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 13 August 2005 - 05:53 PM

No. The squad position can be different while the squad is stationary firing at the target position. It doesn't catch cases like 'flag_capture' or 'post builder' too. All these have tactic.target == nil.

#7 Flenser

Flenser

    title available

  • Members
  • 316 posts
  • Location:Glasgow, Scotland
  • Projects:Dawn of War AI Skirmish

Posted 13 August 2005 - 06:29 PM

No. The squad position can be different while the squad is stationary firing at the target position. It doesn't catch cases like 'flag_capture' or 'post builder' too. All these have tactic.target == nil.

<{POST_SNAPBACK}>

OK, well one way to be sure is to keep a note of lastsquadposition for each squad, but that would be a real pain, keeping track of new squads and getting rid of dead ones.

If I can think of anything else I will post again - gotta run and feed the kids :lol:

Flenser

#8 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 13 August 2005 - 07:59 PM

OK, well one way to be sure is to keep a note of lastsquadposition for each squad, but that would be a real pain, keeping track of new squads and getting rid of dead ones.


Thats what I'm trying now...

Edit: Guess I found a workable solution. I write down the position once a sec after all tactics are updated and delete any entry which wasn't updated in the last 30 secs. So I don't have to mess with IsValid().

Edited by LarkinVB, 14 August 2005 - 10:19 PM.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users