Entirely the problem thud: again, we don't know what this does. If I knew, I'd even have been able to properly help (I don't entirely know the ability code activation so I just altered what you put forward).
[RESOLVED] Toggle AI Code to allow activation in Combat but..
Started by thudo, Apr 18 2006 04:26 PM
26 replies to this topic
#21
Posted 21 April 2006 - 06:42 PM
#22
Posted 22 April 2006 - 03:40 AM
Larkin.. I put it in your mail tonight with the instructions. From that you'll run the mod and yer golden. You'll see what I mean. I can give you the AI with the stuff pre-coded with what works sofar then, if you wish, add your own quick code, and do a quick test and yer set. Look for the email.
Yeaaa I should not be so vague.. its not like this is a state super-secret mod.. its the the Night_Shift mod basically toggling ON/OFF with a searchlight.
Yeaaa I should not be so vague.. its not like this is a state super-secret mod.. its the the Night_Shift mod basically toggling ON/OFF with a searchlight.
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#23
Posted 23 April 2006 - 02:17 PM
Try this. I didn't test but it should be what you want according to your email description.
Melee is now true if the unit is set on assault stance, on attack move and in proximity of enemy.
I didn't test as I don't like the mod. Why should I play a game where I can't see anything but some lights ?
with this
Melee is now true if the unit is set on assault stance, on attack move and in proximity of enemy.
I didn't test as I don't like the mod. Why should I play a game where I can't see anything but some lights ?
function CpuManager:IsInMelee( squad_ai ) -- Unit on ranged stanced if squad_ai:GetMeleeStance() == SquadAI.MSTANCE_Ranged then return false end -- Unit not in combat or not on attack move if not squad_ai:IsInCombat() or not squad_ai:IsInStateAttackMove() then return false end local squad_pos = squad_ai:GetPosition() local infantry = Ability.Filters.CloseInfantryEnemy( squad_pos, 5, 1 ) if infantry ~= nil then return true end local vehicle = Ability.Filters.CloseVehicleEnemy( squad_pos, 5, 1 ) if vehicle ~= nil then return true end local commander = Ability.Filters.CloseCommanderEnemy( squad_pos, 5, 1 ) if commander ~= nil then return true end return false end
with this
--toggle ability to be used at high (>40%) health DoAbilityToggleIfHighHealth = function( squad_ai, id ) if squad_ai:CanDoAbility( id ) then local using = squad_ai:IsUsingAbility( id ) local healthpercent = squad_ai:GetHealthPercentage() local melee = cpu_manager:IsInMelee( squad_ai ) if (using == false and melee == false and healthpercent > 0.4) or (using == true and (melee == true or healthpercent < 0.4)) then squad_ai:DoSpecialAbility( id ) end end end,
Edited by LarkinVB, 23 April 2006 - 02:33 PM.
#24
Posted 23 April 2006 - 06:00 PM
Thanks Larkin!
Just tested your above scripts - melee is still not disengaging the searchlight. 40% Health works as expected so I think I'll just keep it the way it is now. I mean.. what I could do is make such melee units have a higher health threshold of, say, 60% as they will likely anyway be hit more often then ranged units so these melee units which require the light to be off during CC will likely have to have it off anyway due to being hit so violently. Thats a good compromise.
There is a MAJOR following for this mod, Night Shift, plus it allows the AI to engage itself a little differently and allows us to research new scripts -- just for fun of course. Thanks for your help Larkin! A Saint's Job!
Just tested your above scripts - melee is still not disengaging the searchlight. 40% Health works as expected so I think I'll just keep it the way it is now. I mean.. what I could do is make such melee units have a higher health threshold of, say, 60% as they will likely anyway be hit more often then ranged units so these melee units which require the light to be off during CC will likely have to have it off anyway due to being hit so violently. Thats a good compromise.
There is a MAJOR following for this mod, Night Shift, plus it allows the AI to engage itself a little differently and allows us to research new scripts -- just for fun of course. Thanks for your help Larkin! A Saint's Job!
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#25
Posted 23 April 2006 - 07:49 PM
Hmm. No idea why it won't work.
Try to increase the range from 5 to 10 in the checks for close enemies (infantry/commander/vehicle) and remove the check for 'not squad_ai:IsInStateAttackMove()'
Try to increase the range from 5 to 10 in the checks for close enemies (infantry/commander/vehicle) and remove the check for 'not squad_ai:IsInStateAttackMove()'
#26
Posted 23 April 2006 - 09:14 PM
YIPEE! I believe its working now! HOORRARY..
Code looks like:
And in ability.ai
Code looks like:
function CpuManager:IsInMelee( squad_ai ) -- Unit on ranged stanced if squad_ai:GetMeleeStance() == SquadAI.MSTANCE_Ranged then return false end -- Unit not in combat or not on attack move if not squad_ai:IsInCombat() then return false end local squad_pos = squad_ai:GetPosition() local infantry = Ability.Filters.CloseInfantryEnemy( squad_pos, 10, 1 ) if infantry ~= nil then return true end local vehicle = Ability.Filters.CloseVehicleEnemy( squad_pos, 15, 1 ) if vehicle ~= nil then return true end local commander = Ability.Filters.CloseCommanderEnemy( squad_pos, 15, 1 ) if commander ~= nil then return true end return false end
And in ability.ai
--toggle ability to be used at high (>40%) health --relevant for Dreads and Defilers DoAbilityToggleIfHighHealth = function( squad_ai, id ) if squad_ai:CanDoAbility( id ) then local using = squad_ai:IsUsingAbility( id ) local healthpercent = squad_ai:GetHealthPercentage() local melee = cpu_manager:IsInMelee( squad_ai ) if (using == false and melee == false and healthpercent > 0.4) or (using == true and (melee == true or healthpercent < 0.4)) then squad_ai:DoSpecialAbility( id ) end end end,Will be testing further but the Dreads and Defilers will turn their searchlights OFF during Melee then reenable it once out of melee provided they are NOT below 40% health! BRILLIANT sir! I think we have a winner! Will test more tonight!
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#27
Posted 26 April 2006 - 03:12 AM
Update - marking this one completed now!
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users