Jump to content


UnsureJedi

Member Since 18 Mar 2023
Offline Last Active May 28 2023 11:42 PM

Posts I've Made

In Topic: AI function to attack a specific enemy unit

19 March 2023 - 09:01 PM

I see the farseer code, it uses the filter functor to isolate an enemy unit meeting the requirements for the ability and use it if GetClosestSquad() finds the squad meeting the functor. Now, following this example, I just want the farseer to attack the found enemy (I know that in this example the target is friendly but let's suppose its not if I replace GetClosestSquad() with FindClosestEnemy()) instead of performing an ability on him. But I cannot find the DoAttack() function which I would put instead of DoSpecialAbilitySquad() function there. I know there are functions DoMove(), DoAttackMove(), DoStop(), DoRepair(), DoSpecialAbilitySquad(), DoReinforce(), etc., etc., all of which do what it says in the function name. Yet there is no function DoAttack(), or that's what it would be called.

 

I misunderstood your previous post a bit. Of course I won't be searching for specific unit names. That was just the test sample: "tau_ethereal_squad". I've even commented it for myself. I would later replace it with a functor like the one in farseer tactic.


In Topic: AI function to attack a specific enemy unit

19 March 2023 - 04:55 PM

Ok, so I have changed the "commander" effectiveness of assassin's exitus rifle to be higher than all his other effectivenesses and I can say with 100% certainty that it did not work. Here is the assassin field in guardunitstats.ai, where I've changed his commander armor effectiveness to 20.0. And I've also attached the screenshots a moment after the assassin's shot in game: a clean screenshot and with the console open (to see the printed output from the function above). Just as code in the original post was supposed to do, he detected an ethereal (top middle of the screen) in range of 50, activated the scope.... and then shot his bodyguard at the right of the screen, all despite the ethereal being closer and having supposedly higher effectiveness against. Back to square 1, unfortunately.

 

Speaking of targeting enemy units, thudo, isn't this what DoSpecialAbilitySquad() and DoSpecialAbilityEntity() do? They are used by all abilities that require a specific enemy target. For instance, tau commander's "Target Acquired", all of the psyker's abilities and so on, which the AI uses freely. Feels like replacing "do this ability on this target" with "do right-click on this target" (attack this target) should be the simplest of tasks if engine's source code was available. Feels weird why wasn't it implemented initially. Oh well.

{
		name = "Assassin",
		sbp_name = "guard_squad_assassin",
		ebp_name = "guard_leaders_assassin",
		class = UnitStatsAI.UC_Commander,
		rating = 7,
		potential =
		{
			{
				name = "guard_exitus_rifle",
				effectiveness = GenerateUnitEffectiveness(8.6,8.6,8.6,8.6,8.6,5.4,5.4,5.3,8.6,7.4,20.0,0.4,0.7,0.0,0.0,0.0,0.0),
				range = UnitStatsAI.RT_Ranged,
			},
			{
				name = "guard_exitus_pistol_assassin",
				effectiveness = GenerateUnitEffectiveness(7.6,8.1,7.9,7.9,7.1,4.5,4.8,0.0,7.7,0.0,6.7,7.9,6.6,5.8,0.0,0.0,0.0),
				range = UnitStatsAI.RT_Melee,
			},
		}
	},

In Topic: AI function to attack a specific enemy unit

18 March 2023 - 10:44 PM

Hi! Thanks for the hint! Indeed prioritizing the targets by their armor type (class) could be a workaround. I understand that units choose targets they are more effective against if left on their own in battle.
 
The following is my speculation, and I might be off the point here. I now looked at race loader (loader.ai) more closely and I see there is a "table.insert(UnitStats, GuardUnitStats)" (in case of imperial guard loader). The GuardUnitStats in turn is filled in guardunitstats.ai where among other data the "effectiveness" field is defined, which should be the given unit's effectiveness vs every armor type (class). The UnitStats table is only referenced in cpumanager.ai (function LoadUnitStats()). The LoadUnitStats() is not defined anywhere in dowai so I assume it and hence UnitStats are then used by the DOW engine itself? If so can UnitStats contents be changed midgame and have an immediate effect? I'm not yet fully acquainted with how "table" indexing works, so would accessing, say, "infantry low" effectiveness from UnitStats look like this: UnitStats[<race_index>][<unit_index + 1>][7][<weapon_index>][2][1]? Then, If I want to apply the changes I made to it I need to call LoadUnitStats(UnitStats) again. So by doing this I can change a unit's target priority midgame, when they have multiple enemies to choose from to attack. The problem I see here is huge overhead to call LoadUnitStats() every time a single effectiveness needs to be changed.
 
Again, I might be wrong here and to avoid the headache of this it might just be better to set the assassin's "commander" armor effectiveness to a higher value than all his other types of effectiveness and be done with it. Would that make it prioritize commander armor every time? I will test it tomorrow.