pushMission (attack)

GIR

It'sNotStupidIt'sAdvanced
Joined
Jul 12, 2005
Messages
886
Location
EU
I want to force a unit to attack a certain enemy unit next to my unit.
I use the pushMission command:
VOID pushMission(MissionType eMission, INT iData1, INT iData2, INT iFlags, BOOL bAppend, BOOL bManual, MissionAIType eMissionAI, CyPlot pMissionAIPlot, CyUnit pMissionAIUnit)

It’s no problem to let the unit use the fortify, airpatrol or move to a certain plot (plot without enemy unit) with the pushMision command but I don’t know how I can force my unit to attack the enemy unit. ( I tried the mission_move_to, mission_move_to_unit, mission_begin_combat lines but the unit didn’t attack :(

Someone can help??
and what is the iFlags variable for?
 
You use CvSelectionGroup::groupAttack() within a MISSION_MOVE_TO.

Take a look at CvSelectionGroup::continueMission().

Dale
 
what is the iFlags variable for?

The flags come from some defines at the top of CvDefines.h. I think you want to use MOVE_DIRECT_ATTACK.

Gee, like old times, eh Dale.

You might also want to look at the method bool CvUnitAI::AI_anyAttack.
 
Ok, I saw it, but I don’t understand. I’m not a programmer.
That’s my code:
My Artillery (artiX, artiY) should attack an enemy Unit (enemyX, enemyY) <-- next to my unit.
Code:
pGroup = pUnit.getGroup()
pGroup.popMission()
pPlot = pGroup.plot()
artiX = pPlot.getX()
artiY = pPlot.getY
pGroup.pushMission(MissionTypes.MISSION_MOVE_TO, enemyX, enemyY, 0 , false, true, MissionAITypes.NO_MISSIONAI, pPlot, pUnit )

So, what do I have to change to get this code to work?
 
GIR said:
can somebody help me with this??

I'm not sure if this will work, but try making the "iFlags" argument in your pushMission call 0x10:

Code:
pGroup.pushMission(MissionTypes.MISSION_MOVE_TO, enemyX, enemyY, [b]0x10[/b] , false, true, MissionAITypes.NO_MISSIONAI, pPlot, pUnit )
 
Hi Gerikes,
thx for trying to help!

Unfortunately the 0x10 iFlag value don’t work (I also tried the long version 0x0…010).


Do you understand what Dale means with:
Dale said:
You use CvSelectionGroup::groupAttack() within a MISSION_MOVE_TO.

Take a look at CvSelectionGroup::continueMission().

Dale
groupAttack() only gives me a True or a Fales, but i can’t force my unit to attack with this command.
Any idea?
 
GIR said:
Hi Gerikes,
thx for trying to help!

Unfortunately the 0x10 iFlag value don&#8217;t work (I also tried the long version 0x0&#8230;010).


Do you understand what Dale means with:
groupAttack() only gives me a True or a Fales, but i can&#8217;t force my unit to attack with this command.
Any idea?

Does it ever return true? The True and False should be whether or not it attacks or not. So, if it returns true, then it should have done the attack. Perhaps it is but just not doing the animation?


Edit:I just tried it out, and was able to get my warrior to attack a barbarian using:

pUnit.getGroup().pushMoveToMission(54,9)
 
Back
Top Bottom