Ability.Filter vs FindFirstXXX() function
#1
Posted 13 January 2009 - 08:42 AM
local infantry = Ability.Filters.CloseInfantryEnemy( squad_pos, 15, 1 )
local vehicle = Ability.Filters.CloseVehicleEnemy( squad_pos, 10, 1 )
local commander = Ability.Filters.CloseCommanderEnemy( squad_pos, 10, 1 )
They are used to retrieved a specific unit in range of squad_pos, but what is the difference with :
local oEnemyUnit = cpu_manager.cpu_player:FindFirstEnemy(vSquadPos, iScanRange, 1)
oEnemyUnit:GetStats():GetClass()
and then checking the GetClass() returned value
Because it seems to me the Ability.Filters thing is more "elegant" vs FindFirstEnemy(), is there a major performance cost when using Ability.Filters ?
Do these 2 piece of code do the same thing ?
#2
Posted 13 January 2009 - 11:12 AM
Because it seems to me the Ability.Filters thing is more "elegant" vs FindFirstEnemy(), is there a major performance cost when using Ability.Filters ?
Do these 2 piece of code do the same thing ?
The ability filter functions are just wrapper functions using the SCAR function cpu_manager.cpu_player:FindFirstEnemy(...). Some of them contain some security checks to avoid CTD's or other unpleasant things. The general guide line is to use an ability filter function if one is available. However in some cases it is necessary to use the basic cpu_manager.cpu_player:FindFirstEnemy(...) function directly.
If you use expressions like oEnemyUnit:GetStats():GetClass(), you have to make sure that oEnemyUnit is not NIL (=> Execution error) and the unit has stats which is only the case for the active player units (=> CTD)...
#3
Posted 14 January 2009 - 11:10 AM
i am also having a look at tactic and infantrytactic files, in infantrytactic:Update() function it may be a good thing to perform checkfordeath() before checkforbroken(), checkfordance() because as a rule of thumb retreat shall be done when the squad is low on health no matter if it is morale broken or dancing, what are you thoughts on this subject ?
#4
Posted 15 January 2009 - 09:21 PM
But generally I find it units have their own tactic files like we did in v3.10 of the Advanced AI for SS then the AI more cleanly uses the unit's tactics.
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#5
Posted 19 January 2009 - 11:29 AM
IsInCombat() returns true only when CC fight happens ? IsAttacking() returns true when units are firing at sthing ?
@Thudo
One file for each unit type would be a huge step toward a more oriented object conception and would allow to remove a lot of specific tests and would make the code easier to understand, and changing a derived method in one class would be less risky to break something in another class
One question in the InfantryTactic:Update() function there is a call to self:InitAbilites() but it is already done at the end of the Tactic:__init() so i think it can be removed form InfantryTactic:Update() function unless i am missing sthing
Edited by troubadour, 19 January 2009 - 03:49 PM.
#6
Posted 20 January 2009 - 01:31 PM
IsAttacking() returns true if the unit is shooting or attacking/fighting in CC. IsInCombat() is very general. It returns true if IsAttacking() returns true, but also if it is 'hit'. I think it also stays a few seconds true even if a combat situation is over. It's possible that it's also true if an enemy unit is close, however that's just a guess. Like I said, it's very general and can be interpreted as a combat situation of any kind.What is the difference between IsAttacking() and IsInCombat() ?
IsInCombat() returns true only when CC fight happens ? IsAttacking() returns true when units are firing at sthing ?
90% of all tactic files are for unique units. But units without special abilities usually don't have a unique tactic file because they can use a general tactic, and all unique tactic files are derived from a general tactic file. Therefore the concept IS clean, however as soon as you want to add some special behaviour stuff for a unit without a tactic file, you have to create a new one and add some management code to the loader files. If you don't do that every day it can lead to errors because you've accidently forgotten something. If every unit already has a unique tactic file even if doesn't need one, then you don't have to add the management code anymore which reduces the risk of making mistakes. However, this doesn't have anything to do with the object oriented concept.One file for each unit type would be a huge step toward a more oriented object conception and would allow to remove a lot of specific tests and would make the code easier to understand, and changing a derived method in one class would be less risky to break something in another class
Just a hint: Remove it and then try to reload a saved game. You will get some 'interesting' results .One question in the InfantryTactic:Update() function there is a call to self:InitAbilites() but it is already done at the end of the Tactic:__init() so i think it can be removed form InfantryTactic:Update() function unless i am missing sthing
#7
Posted 22 January 2009 - 05:13 PM
I have another question reg InfantryTactic:Reinforce() function, what is the use of the check self.m_bPowerCos when a lot of classes just make a check vs Tactic.Options.can_reinforce, i am not a genius and is quite difficult to make an educated guess.
#8
Posted 26 January 2009 - 05:15 PM
I don't have the code present, but if I remember right, then there's a tier check nearby which ensures that in T1, when saving power for T2, only units are reinforced which have no power cost.
Reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users