Jump to content


Photo

1.8 small code improvements


  • Please log in to reply
8 replies to this topic

#1 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 15 April 2006 - 10:24 PM

I will post some small code changes/suggestions here.

Starting with a simple change making jump attacks a bit better. I observed jump attacks while the jumping squad immediatly retreated.

Add this check to function Tactic:JumpAttack() should solve some problems.

	-- No jump if we are retreating
	if self.squad_ai:IsInStateMove() then
		return false
	end


#2 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 18 April 2006 - 05:45 PM

Hmm, that's a bit like killing the virus by killing the patient :) . Jumping while moving is important.

The problem is caused most likely by the 'on the fly' gathering attack code. I probably have to rework this since it seems to cause more problems than it solves (Sigh!).

#3 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 19 April 2006 - 12:23 AM

AFAIK any IsInStateMove() is a retreat move whereas IsInStateAttackMove() is fine for jump attacks.

Btw, I found lots of problems with substates like (broken/dance/avoid death etc) which were not that often/obvious before you changed the move code from plan to tactics. Investigation will take lots of time/debug effort and I'm not sure I will be ready to do this.

#4 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 19 April 2006 - 09:33 AM

AFAIK any IsInStateMove() is a retreat move whereas IsInStateAttackMove() is fine for jump attacks.

Oops, I've mistaken that with a general jump restriction for all movements. Sorry! The code change looks okay. ;)

In general I think the broken and dancing code works quiet good, though I'm not sure if the avoid death code is really working correct. The other movement parts need a better coordination. I will try to improve this soon. Not really a funny coding part... :(

#5 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 19 April 2006 - 10:00 AM

In general I think the broken and dancing code works quiet good,


It seems but there is something fishy.
Example : A squad is broken. Its tactic enters the substate for broken and the squad is listed in the table for InSubState(). Usually it will be removed from this table while no longer broken and it can return to its last tactic state.
Now often it is not removed from this table. It seems that some other code has erased/overruled the substate and therefore the standard function for resetting the substate is no longer called.
This happened once in a while with the old move code before you changed things. Now it happens much more often.
I have some extra emergency code, function InfantryTactic:SyncSubState(), which is now resetting states much more often.
Therefore I guess some/all of you move code is not checking for substates and just overwriting them with new move orders. All standard movements should check for moving only while InSubState(squad_id) is NOT true.

Will investigate further.
I think the avoid death is working as I see ranged squads break of while being outnumbered in firefight.

Edited by LarkinVB, 19 April 2006 - 10:02 AM.


#6 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 19 April 2006 - 12:01 PM

I think the only movement command overriding a substate movement was the jump code. The other parts all check for IsInSubState().

#7 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 19 April 2006 - 12:49 PM

Aren't you using Tactic:SetState() without checking for InSubState() and isn't this overwriting the substate ?

Example :

Your function InfantryTactic:BeginRetreatState() has no check for InSubState() though the old one had a necessary check.
Now you are replacing any substate (broken/dance) with Tactic.SetSubState(self, self.HoldState, "Holding"). This is not good.

Edited by LarkinVB, 19 April 2006 - 01:08 PM.


#8 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 19 April 2006 - 03:10 PM

I thought those substates are reseted by your special substate list, managed in the cpu_manager...
Anyway, it's definitely a good idea to combine those different states and don't let them 'fight' each other. I'll try to melt them somehow for 1.8. For 1.7 it was a bit too much for me...

#9 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 19 April 2006 - 06:25 PM

A rework of these parts would be fine. A workaround for my latest DoWpro AI is a check at the top of Tactic:SetState() :

function Tactic:SetState( state, name )

	dbAssert( state ~= nil )
	
	-- We are in substate, therefore only replace previous state with new one 
	if self.stateID ~= Tactic.StateID.NoState then
	
		--if you don't have a function for this, use idle state
		if( self.state_function_map[ state ] == nil ) then
			self.prev_sub_state = Tactic.IdleState
		else
			self.prev_sub_state = self.state_function_map[ state ]
		end
		self.prev_sub_state_name = state
		return
	end

EDIT :

Some other stuff must be changed too. Perhaps too complicated to show here. But it does work now as intended. Interesting to see troops dance nicely and broken squads retreat much better too. It was a mess before and not too obvious as troops start to dance/retreat while broken but never finish it properly.

EDIT:

Did send you my fixes. A rework might not be necessary as the fix is easy.

Edited by LarkinVB, 21 April 2006 - 09:25 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users