- optimization: don't check spots already checked in previous loop
- increase max distance to 35, reduce to 25 if complex AI not allowed, reduce to 15 in realtime
CanDragPerson: use world movement cost instead of LOS check.
Say TAUNT_RELOAD, TAUNT_OUT_OF_AMMO taunts if mag size > 4 or Chance (CHANCE_SAY_ANNOYING_PHRASE).
SpotDangerLevel: also check Water and CorpseWarning for danger level = 1.
ManSeesMan: only call SetNewSituation if location or level are different to reduce frequency of AI re-evaluation.
Only allow radio animation on initial red alert, if sector is not jammed.
Press ESC to stop dragging.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8904 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Black AI:
- reduce stab attack attractiveness if target is not very close
- reduce stab attack attractiveness if soldier sees more than one opponent
- for HTH attacks, skills don't have effect on choosing attack type for boxers
- reduce HTH attack attractiveness if soldier sees more than one opponent
- allow to increase autofire bullets by reducing aim in NCTH if LIMIT_MAX_DEVIATION option is enabled
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8902 3b4a5df2-a311-0410-b5c6-a8a6f20db521
- new option AI_SAFE_SUPPRESSION adds additional checks for AI to avoid hitting friends when using suppression fire.
- chance to use suppression fire depends on actual chance to hit and SUPPRESSION_EFFECTIVENESS option
- reduced short burst to 2 bullets.
- improved code to use short burst
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8901 3b4a5df2-a311-0410-b5c6-a8a6f20db521
- set default bAimShotLocation when checking if shot is possible
- remove second CheckIfShotPossible() call
- only use reloading before suppression fire if weapon is autofire capable and can swap clips
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8896 3b4a5df2-a311-0410-b5c6-a8a6f20db521
- reload before suppression fire less often in dangerous situation, also check AP_MINIMUM so we don't reload when really low on APs
- use CanNPCAttack() check only for sniper and suppression fire as only these actions need usable gun
- when trying to step back to deploy mortar, check if we can reach the spot and have enough APs
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8895 3b4a5df2-a311-0410-b5c6-a8a6f20db521
CalcBestShot:
- improved hit rate calculation, take into account possible options INCREASE_AIMING_COSTS, FIRST_AIM_READY_COST_DIVISOR
- minor code improvements
New AI function LOS_Raised checks LOS with forced raised gun status, to get max view distance with scope
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8889 3b4a5df2-a311-0410-b5c6-a8a6f20db521
FindThrowableGrenade: allows to specify type and damage of searched grenade.
New counter SOLDIER_COUNTER_RETREAT allows to set number of turns which soldier will try to retreat and take cover.
FindBestNearbyCover: use PrepareThreatlist as unified function to make list of all known opponents.
Militia Control:
- start retreating mode for 2 turns when ordering retreat
- replace AI_ACTION_RUN_AWAY with AI_ACTION_TAKE_COVER order so that militia do not retreat from sector
New AI behavior:
- soldier can use smoke grenade to cover himself when under fire
- soldier can use use smoke grenade on his friend to cover him
- if soldier used smoke, he starts retreat mode for 2 turns
- added retreat code to Red, Black AI
- improved Main Red AI for civilians (they only run away)
Improved suppression code:
- less chance of suppression when opponent has high shock level
- prefer using suppression fire when soldier is in cover
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8879 3b4a5df2-a311-0410-b5c6-a8a6f20db521
CalcBestShot:
- added standard check for valid opponent
- use standard knowledge functions
- blind soldier can only attack seen/heard personally
- determine suppression fire (shooting at target nobody sees currently)
- don't shoot if target location is seen and empty
- no fire on unseen opponents with throwing knives
- only enemy team can use blind suppression fire
- only try to suppress alive and conscious human targets
- additional check to limit shooting through walls
- alt weapon holding scope mode is used only when ubAllowAlternativeWeaponHolding == 3
- hip firing allowed only for human bodytypes
- take into account direction when checking stance
- shoot heavy guns in standing stance only when using hip fire
- penalize suppression fire
Red AI suppression fire:
- check valid target
- check weapon/ammo requirements
- check that soldier is not sniper
- check friendly fire chance
- reduce chance to shoot if target is beyond weapon range
- check that we have spare ammo
Improved code to prepare suppression fire:
- change stance first of needed
- allow shooting with aiming
- reserve APs to hide if no cover or enemy is close
- added debug messages
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8878 3b4a5df2-a311-0410-b5c6-a8a6f20db521
ClosestKnownOpponent() now can return ID of closest opponent.
CalcCoverValue: improved code to avoid friendly fire.
EVENT_SoldierBeginPunchAttack: use supplied gridno as sTargetGridNo may not be set yet
Boxing:
- added possibility of counterattack after failed attack
- added possibility of opportunity attack a passing enemy
- bonus in CTH for boxers for attack from the back
Boxing AI:
- for boxers, always use high morale so that they attack
- cautious boxer approach, reserve AP for two attacks (only if not attacking from the back)
- try to avoid frontal attack
- sometimes boxer may decide to restore breath instead of moving and attacking
- boxer can step back to move away from opponent, if he is low on breath
- improved main boxer AI
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8876 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Friendly fire chance code also checks for soldiers of the same side and optionally neutral civilians.
CalcCoverValue: check friendly fire chance for each position, penalize position if friendly fire chance is high (needs AI_BETTER_COVER = TRUE)
UnderFire::Add:
- store friendly fire CTH for new added person
- use max value when replacing friendly fire CTH for existing person
CalcBestShot:
- check CTGT and friendly fire chance for every stance
- ignore possible shot if can hit friends in this stance
CalcMoraleNew: improved code to make enemy slightly more aggressive.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8873 3b4a5df2-a311-0410-b5c6-a8a6f20db521
- <InfectionChance_WOUND_FIRE> can cause infections when taking fire damage
- <InfectionChance_WOUND_GAS> can cause infections when taking non-fire gas damage
- <fSpecialFlagLimitedUseArms> causes the infected to be unable to use one arm
- <fSpecialFlagLimitedUseLegs> causes the infected to be unable to run, and walk and travel slowly
- JA2_options.ini option DISEASE_SEVERE_LIMITATIONS controls whether <fSpecialFlagContractDisability>, <fSpecialFlagLimitedUseArms> and <fSpecialFlagLimitedUseLegs> are used
For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=22099&goto=360451&#msg_360451
- Gas damage split up in fire and non-fire damage.
- Flamethrower projectile damaged is affected by fire resistance.
Requires GameDir >= r2553.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8828 3b4a5df2-a311-0410-b5c6-a8a6f20db521
- for mortars and grenade launchers, first try to find non smoke grenade/shell
- don't use mortar in building or underground
- don't use grenade launcher underground
- blinded soldier cannot use mortar/grenade launcher
- when calculating safety margin, correctly use BuddyItem defined for single shot RPG
- limit ubSafetyMargin to TACTICAL_RANGE / 2 in case radius set too high in XML
- use flares only at night
- use ValidOpponent() check to determine opponent
- use new knowledge functions
- allow attacking recently seen/heard opponents with mortar/grenade launcher
- improved code to spare grenade, don't spare: non lethal grenades, if some friends killed, when under attack, STATIONART/SNIPER, when on the roof, when there are friends under attack nearby
- increase possible distance from opponent when opponent in a building or when using gas grenade
- improved check for gas/smoke when using gas/smoke grenade
- don't use smoke grenade if there's already smoke nearby (it can spread to this tile later)
- improved code for AP to attack calculation
- when attacking enemy in a building with mortar, allow shooting on the roof above the enemy, hoping that roof will collapse
- limit RPG use, unless can hit several enemies, shooting at tank or opponent is in a room
- soldiers should use RPGs against tanks/jeeps more often
- modify smoke attack value depending on range (less effective if too far from opponent)
Red AI:
- improved code to prepare throw attack
- added code to change stance before throwing if needed
Black AI:
- simplified code to change stance before shooting, always change stance first if needed
- improved code to prepare attack, added code to change stance before throwing if needed
CalcBestShot:
- always change stance first, then turn
- don't allow going prone and turning at the same time
New AI functions:
- NightLight
- DuskLight
- InSmokeNearby
- CountTeamUnderAttack
- SectorCurfew
- TeamPercentKilled
- TeamHighPercentKilled
- ArmyPercentKilled
- ArmyPercentKilledTolerance
- Knowledge
- KnownLocation
- KnownLevel
- UsePersonalKnowledge
- PersonalKnowledge
- KnownPersonalLocation
- KnownPersonalLevel
- PublicKnowledge
- KnownPublicLocation
- KnownPublicLevel
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8791 3b4a5df2-a311-0410-b5c6-a8a6f20db521
- check that we can see enemy if we raise weapon when considering using noise spot as watched location
- prefer hiding first when in dangerous place if hiding is possible
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8790 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Suppression:
- when calculating suppression effectiveness for shotgun, modify damage for pellets.
- set attacker spot as watched location
- alert enemy soldier if he is under fire
Red AI:
- no Main Red AI for civilians
- set watched location to closest position where enemy can appear
- snipers and soldiers with scoped guns should decide watch more often
Improved Red AI watch code:
- crouch if not crouched
- raise weapon if not raised
- turn to watched location
- possibly go prone, if soldier has LOS to watched location
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8789 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Black AI: improved check to avoid friendly fire.
FindAIUsableObjClass: by default search for weapon with longest range, if fSidearm = TRUE search for fastest weapon.
AICalcChanceToHitGun: if AI_EXTRA_SUPPRESSION = TRUE, always return min 1% for AI.
RangeChangeDesire:
- civilians only want to run away
- added small bonus to range change desire if soldier has no gun or short range weapon
CalcBestShot, CheckIfShotPossible: always check if can shoot at target seen by another soldier.
CalcBestShot, CalcBestThrow, CalcBestStab: initialize attack data.
Removed obsolete code.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8782 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Moved zombie AI into separate file ZombieDecideAction.cpp
New zombie AI:
- simplified code
- advancing using cover
- if zombie cannot reach any opponent, he tries to hide
- if zombie cannot reach opponent and cannot hide and he is under fire, he will retreat, seeking cover away from known opponents
- if zombie doesn't know enemy location, he will try to run to closest friend who knows enemy location
- new zombie AI has extended AI logging
More water splash sounds (Data\Sounds\Misc\Splash1.ogg .. SplashN.ogg).
CalcCoverValue:
- allow moving into shallow water if it provides better position
- special calculations for zombies: zombie is very dangerous at close range
- if soldier has no gun, use different calculation based on distance instead of CTGT
FindBestNearbyCover: zombies only choose spots that provide sight cover.
Added functions for extended AI log.
ClosestReachableDisturbance:
- if soldier is zombie and he cannot climb, skip location
- zombies do not attack vehicles
- improved check to avoid choosing dying opponents
EstimatePathCostToLocation: return 0 if checking for zombie which cannot climb and path needs climbing.
RoamingRange: always max roaming range for zombies.
SightCoverAtSpot, ProneSightCoverAtSpot:
- improved max sight range calculation
- added option for unlimited sight range check
New AI functions:
- AIDirection
- AICheckIsSniper
- AICheckIsMarksman
- AICheckIsMedic
- AICheckIsMortarOperator
- AICheckIsGLOperator
- AICheckIsOfficer
- AICheckIsCommander
- AICheckIsMachinegunner
- AIGunInHandScoped
- AIGunScoped
- AIGunRange
- AIGunClass
- AIGunType
- AIGunDeadliness
- AIGunAmmo
- AIGunAutofireCapable
- FindObstacleNearSpot
- InSmoke
- CorpseWarning
- CorpseEnemyTeam
- CorpseMilitiaTeam
- AICheckUnderground
- AnyCoverAtSpot
- AICheckHasWeaponOfType
- AICheckHasGun
- AICheckShortWeaponRange
GetCorpseAtGridNo: additional check for valid gridno.
More zombie raise sounds (Data\Sounds\Misc\ZombieRaise1.ogg .. ZombieRaiseN.ogg).
GetCorpseRotFactor: improved code to return FLOAT value between 0 and 1.
New debug topic id TOPIC_DECISIONS for logging AI decisions.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8760 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Mercs always make movement noise when dragging.
Stop dragging if another merc starts dragging this merc/body.
Stop dragging if dragged merc gets up from collapsed state.
Stop dragging when changing stance/cowering under suppression.
Fixed grenade pin sound for signal smoke.
CalcBestShot: if new opponent is dying and best opponent is ok, ignore new opponent.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8759 3b4a5df2-a311-0410-b5c6-a8a6f20db521
CONSIDERED_NEUTRAL: removed dying check as it may cause problems with AI.
Improved code to avoid moving into gas/deep water/light/artillery danger zone.
ClosestReachableDisturbance:
- skip dying opponent if found not dying
- when in deep water, skip opponents in deep water
ClosestKnownOpponent: skip dying opponent if found not dying.
RedSmokeDanger: consider deep water as safe from artillery strike.
Allow deep water flanking for soldiers of ENEMY_TEAM with SEEKENEMY orders and CUNNINGSOLO attitude or athletics trait.
CalcBestShot:
- dying, cowering or unconscious soldiers have very low priority
- added safety checks
- if best opponent is dying and new opponent is ok, use new opponent
DecideAction: improved deep water checks.
Red, Black AI: when SEEKENEMY soldier is in deep water, move to closest opponent on the ground.
FindNearestUngassedLand:
- increased max search distance to 35
- added speed optimization
- removed max AP budget
FindNearbyDarkerSpot:
- increased max search range to 25
- added speed optimization
- removed max AP budget
FindFlankingSpot: added condition to allow deep water flanking
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8758 3b4a5df2-a311-0410-b5c6-a8a6f20db521
FindBestNearbyCover:
- penalty to locations in red smoke danger zone
- avoid moving into red smoke danger zone if not in red smoke danger already
FindNearestUngassedLand:
- improved code
- try not to move closer to known enemies.
- calculate path with correct movement mode
FindNearbyDarkerSpot:
- improved code
- calculate path with correct movement mode
FindFlankingSpot:
- avoid locations near bombs
- avoid moving into red smoke danger zone
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8753 3b4a5df2-a311-0410-b5c6-a8a6f20db521
- before deciding anything, stop cowering animation
- before deciding anything, stop giving aid animation
- before deciding to raise weapon, check if weapon can be raised
- simplified scope check
- removed duplicate code in Red AI
Added missing actions to gzActionStr[].
Fixed OKLIFE checks.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8740 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Added more restriction for using grenades in CalcBestThrow:
- blinded soldier can only attack recently seen/heard opponents
- limit explosives type when attacking zombies
- limit smoke grenade use
- limit explosives type when attacking robots, vehicles and tanks
- don't use grenades against dying enemies
- limit explosives type when attacking collapsed enemies
- don't use flare if soldier is in light
- don't use flares against opponents on roof
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8736 3b4a5df2-a311-0410-b5c6-a8a6f20db521
Moved options AI_YELLOW_FLANKING, AI_EXTRA_SUPPRESSION, AI_NEW_MORALE and AI_BETTER_COVER to [Tactical AI Settings]
AI_NEW_MORALE:
- zombies always have high morale
- always low morale when soldier is blinded
- neutrals always have low morale even if they have guns, so they don't run into the heat of battle
- prevent hopeless morale when not under attack
UpdateAniTiles: also check EXPLOSV_CREATUREGAS (from merc05's fixes)
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8721 3b4a5df2-a311-0410-b5c6-a8a6f20db521
SOLDIERTYPE::initialize: initialize additional data.
EVENT_FireSoldierWeapon: if shooting soldier is invisible, locate screen to target spot.
CancelAIAction: reset next AI action.
FindBestPath: improved gas avoiding code.
InGas: improved code, also check the spot itself.
LegalNPCDestination: disabled additional checks to prevent AI deadlock.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8695 3b4a5df2-a311-0410-b5c6-a8a6f20db521
LUA: added new functions SetgfBoxersResting(), SetgubBoxersRests() to change boxers status.
ResetBoxers(): keep gfBoxerFought[] unchanged as it will be reset every day at 15:00 by HourlyQuestUpdate() in HourlyUpdate.lua
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8687 3b4a5df2-a311-0410-b5c6-a8a6f20db521