PROXiCiDE

Heimskr AI Code

Mar 31st, 2013
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.81 KB | None | 0 0
  1. Heimskr - Customized AI Code
  2. This is a old version, its being redone and cleaned up. AI is a test module to implement into a Morag Tong mod
  3.  
  4. ScriptName PDC1FollowerAliasAICombatScript Extends ReferenceAlias
  5.  
  6. ;=================================================================================
  7. ;PROXiCide aka Taewon
  8. ;Steam: http://steamcommunity.com/id/PROXiCiDE
  9. ;Nexus: http://skyrim.nexusmods.com/users/3018315
  10. ;Bethesda: http://forums.bethsoft.com/user/425376-taewon/
  11. ;=================================================================================
  12.  
  13. ;Code Needs Cleaned up Baddly
  14. ;Documented as well
  15.  
  16. ;=================================================================================
  17. ; Properties
  18. ;=================================================================================
  19.  
  20. Keyword Property PDC1MagicBuffTalosBlessing Auto
  21. Keyword Property PDC1MagicBuffGroupShield Auto
  22. Keyword Property PDC1MagicBuffGroupResist Auto
  23. Keyword Property PDC1MagicPriestDamage Auto
  24.  
  25. GlobalVariable Property PDC1HealCombatActiveHealthPercent Auto
  26. GlobalVariable Property PDC1HealHandsCombatActiveHealthPercent Auto
  27. GlobalVariable Property PDC1HealCombatNotActiveHealthPercent Auto
  28.  
  29. FormList Property PDC1PlayerFollowerExcludeResetSpells Auto
  30. FormList Property PDC1PlayerFollowerSpellDamageKeywords Auto
  31. FormList Property PDC1PlayerFollowerSpellResistKeywords Auto
  32. FormList Property PDC1PlayerFollowerSpellHealing Auto
  33. FormList Property PDC1PlayerFollowerSpellBuffs Auto
  34.  
  35. Quest Property PDC1AssaultDetection Auto
  36.  
  37.  
  38. PDC1HeimskrShellScript Property pShellScript Auto
  39. GlobalVariable Property PDC1PlayerFollowerCount Auto
  40.  
  41. Faction Property PDC1WaitFollowerFaction Auto
  42.  
  43. GlobalVariable Property PlayerFollowerCount Auto
  44.  
  45. GlobalVariable Property PDC1PlayerFollowerCastBuffType Auto
  46. GlobalVariable Property PDC1PlayerFollowerCastHealType Auto
  47. GlobalVariable Property PDC1PlayerFollowerCastDaulCast Auto
  48. GlobalVariable Property PDC1PlayerFollowerCastingSpell Auto
  49. GlobalVariable Property PDC1PlayerFollowerDaulCastChange Auto
  50.  
  51. FormList Property PDC1PlayerFollowerPackageBuff Auto
  52. FormList Property PDC1PlayerFollowerPackageHeal Auto
  53.  
  54. ;=================================================================================
  55. ; Globals
  56. ;=================================================================================
  57. Actor pCurrentFollower = None
  58. Actor pCastingTarget = None
  59.  
  60. ;=================================================================================
  61. ; AI Data
  62. ;=================================================================================
  63. Event OnUpdate()
  64. Actor pSelf = GetActorRef()
  65.  
  66. If pShellScript.IsFollowerPreachSceneRunning()
  67. Return
  68. EndIf
  69.  
  70. ; Debug.Trace("PDC1 - OnUpdate - AI Combat Alias")
  71. If pSelf.GetPlayerControls() || pSelf.IsDead() || pSelf.IsDisabled() || pSelf.GetCombatTarget() == Game.GetPlayer() ||\
  72. !pShellScript.IsFollower(Self.GetRef()) || pShellScript.IsFollowerDismissed()
  73. Return
  74. EndIf
  75.  
  76. If pShellScript.IsFollowerWaiting()
  77. If (Game.GetPlayer().GetDistance(pSelf) > 2000)
  78. Return
  79. EndIf
  80. EndIf
  81.  
  82. If Game.GetPlayer().IsInCombat()
  83. Debug.Trace("PDC1 - OnUpdate - Player In Combat")
  84. RunAI()
  85. Else
  86. If pSelf.IsInCombat()
  87. pSelf.StopCombatAlarm()
  88. pSelf.StopCombat()
  89. EndIf
  90.  
  91. Debug.Trace("PDC1 - OnUpdate - Player Not In Combat")
  92. ;Update Follower Reference
  93. UpdateFollowers()
  94. EndIf
  95.  
  96. EndEvent
  97.  
  98. ;=================================================================================
  99. ; Events
  100. ;=================================================================================
  101.  
  102. Function ResetSpellCasting()
  103. PDC1PlayerFollowerCastingSpell.SetValue(0)
  104. PDC1PlayerFollowerCastBuffType.SetValue(0)
  105. PDC1PlayerFollowerCastDaulCast.SetValue(0)
  106. PDC1PlayerFollowerCastHealType.SetValue(0)
  107. EndFunction
  108.  
  109. Event OnSpellCast(Form akSpell)
  110. Spell akSpellCast = akSpell As Spell
  111. If akSpellCast
  112. ; Debug.Trace("PDC1 - Casting Spell - " + akSpellCast.GetName())
  113. Bool bReset = False
  114. If PDC1PlayerFollowerExcludeResetSpells.HasForm(akSpellCast)
  115. bReset = True
  116. ;Determine if a healing spell is casted, if so make sure we have enough health before
  117. ;resetting spell casting, so spells like healing hands do not get packages interrupted
  118. If PDC1PlayerFollowerSpellHealing.HasForm(akSpellCast)
  119. If IsCastingSpell() && pCastingTarget != None
  120. If IsHealthValidForHealing(pCastingTarget)
  121. bReset = False
  122. EndIf
  123. EndIf
  124. EndIf
  125. EndIf
  126.  
  127. If bReset
  128. ResetSpellCasting()
  129. AIEvaluate()
  130. Utility.Wait(1)
  131. EndIf
  132. EndIf
  133. EndEvent
  134.  
  135. Event OnCombatStateChanged(Actor akTarget, Int aeCombatState)
  136. Actor pSelf = Self.GetActorRef()
  137. If !pSelf || pSelf.IsDead()
  138. Return
  139. EndIf
  140.  
  141. If akTarget && (akTarget.IsPlayerTeammate() || akTarget == Game.GetPlayer())
  142. Return
  143. EndIf
  144.  
  145. If aeCombatState == 0 ; Not in combat
  146. ; Debug.Trace("PDC1 - OnCombatStateChanged - Combat Ended")
  147. ResetStats()
  148. ResetSpellCasting()
  149. AIEvaluate()
  150. Utility.Wait(1)
  151. ElseIf aeCombatState == 1 ; In Combat
  152. ;Start Group Buff First
  153. ; Debug.Trace("PDC1 - OnCombatStateChanged - Combat Started")
  154.  
  155. pCurrentFollower = pShellScript.SelectCorrectActor(2)
  156.  
  157. ;Check Follower Vanilla Combat
  158. ElseIf aeCombatState == 2 ; Searching
  159. ; Debug.Trace("PDC1 - OnCombatStateChanged - Combat Searching")
  160. RunAI()
  161. EndIf
  162. EndEvent
  163.  
  164. Event OnDeath(Actor akKiller)
  165. ResetSpellCasting()
  166. EndEvent
  167.  
  168. Event OnLoad()
  169. ResetSpellCasting()
  170. EndEvent
  171.  
  172. Event OnUnload()
  173. ResetSpellCasting()
  174. EndEvent
  175.  
  176. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)
  177. ; Do Onhit code
  178.  
  179. Actor pSelf = Self.GetActorRef()
  180. If !pSelf
  181. Return
  182. EndIf
  183.  
  184. If pSelf.IsDead()
  185. Return
  186. EndIf
  187.  
  188. ;Manage Preaching Scene
  189. If pShellScript.PDC1PlayerFollowerPreaching.GetValueInt()
  190. EndIf
  191.  
  192. ;Manage Buffs
  193. AICastBuffResistGroupKeyword(akSource)
  194. EndEvent
  195.  
  196. ;=================================================================================
  197. ; AI
  198. ;---------------------------------------------------------------------------------
  199. ; Routines
  200. ;=================================================================================
  201.  
  202. Function AIEvaluate()
  203. Actor pSelf = Self.GetActorRef()
  204. If !pSelf
  205. Return
  206. EndIf
  207. pSelf.EvaluatePackage()
  208. EndFunction
  209.  
  210. Function UpdateFollowers()
  211.  
  212. Debug.Trace("PDC1 - UpdateFollowers")
  213. Actor pFollower = pShellScript.SelectCorrectActor(2)
  214. If pFollower && !pFollower.IsDead()
  215. If !pShellScript.pSkyrimFollower.GetActorRef()
  216. pShellScript.pSkyrimFollower.ForceRefTo(pFollower)
  217. EndIf
  218. EndIf
  219.  
  220. EndFunction
  221.  
  222. ;Specific AI Order
  223. Function RunAI()
  224. Actor pSelf = Self.GetActorRef()
  225. If !pSelf
  226. Return
  227. EndIf
  228.  
  229.  
  230. UpdateFollowers()
  231.  
  232. ;Madetory Buff, at start of Combat
  233. AICastBuffShieldGroup()
  234. AICastHealing()
  235.  
  236. If IsCastingSpell()
  237. ;Check for Reset
  238. If IsCastingHeal()
  239. Actor pTarget = GetSpellCastTarget()
  240. If pTarget
  241. If !IsHealthValidForHealing(pTarget)
  242. ResetSpellCasting()
  243. EndIf
  244. Else
  245. ;Invalid Target
  246. ResetSpellCasting()
  247. EndIf
  248. EndIf
  249.  
  250. AIEvaluate()
  251. EndIf
  252.  
  253. ;When Heimskr has no Target, and is not Casting
  254. If pSelf && pSelf.GetCombatTarget() == None && !IsCastingSpell() && Game.GetPlayer().IsInCombat()
  255. Actor pTarget = pShellScript.GetActiveHitTarget()
  256. If pTarget != None
  257. If pTarget.IsDead() || pTarget.GetAV("Health") <= 0
  258. pShellScript.ClearDeadHitTargets()
  259. Else
  260. pSelf.StartCombat(pTarget)
  261. EndIf
  262. EndIf
  263. EndIf
  264.  
  265. ;Let Update & AI Catchup
  266. Utility.Wait(1)
  267. EndFunction
  268.  
  269. ;=================================================================================
  270. ; AI
  271. ;---------------------------------------------------------------------------------
  272. ; Spell Casting
  273. ;=================================================================================
  274. EffectShader Property HealMysticFXS Auto
  275.  
  276. Spell[] Property PDC1Spells Auto
  277. Sound[] Property PDC1SpellSounds Auto
  278.  
  279. Perk Property Respite Auto
  280.  
  281. ;=================================================================================
  282. ; ResetStats()
  283. ;
  284. ; Priest Only
  285. ; Used to Reset the Stats [Health / Stamina / Magicka] when not in Combat
  286. ;=================================================================================
  287. Function ResetStats()
  288. Actor pSelf = Self.GetActorRef()
  289. If !pSelf
  290. Return
  291. EndIf
  292.  
  293. pSelf.RestoreAV("Health",10000)
  294. pSelf.RestoreAV("Magicka",10000)
  295. pSelf.RestoreAV("Stamina",10000)
  296. EndFunction
  297.  
  298. ;=================================================================================
  299. ; CastSpellByName(String sTarget, String sSpellName, Bool abDualCast = False)
  300. ;
  301. ; Depending on the way the AI is set up, it will cast Scripted or Packaged Spells
  302. ; Does not cast any spells if the AI is already casting a spell
  303. ;=================================================================================
  304. Function CastSpellByName(String sTarget, String sSpellName, Bool abDualCast = False)
  305. If IsCastingSpell()
  306. Return
  307. EndIf
  308. CastSpellByPackage(sTarget,sSpellName, abDualCast)
  309. EndFunction
  310.  
  311. ;=================================================================================
  312. ; Scripted AI Casting
  313. ; Need to find a way how to play Casting IDLES, ive tested plenty and none seem to work
  314. ; Even if i placed Heimskr out of Combat
  315. ;=================================================================================
  316. Function CastSpellByScript(String sTarget, String sSpellName, Bool abDualCast = False)
  317. Spell pSpell = None
  318. Sound pSound = None
  319. EffectShader pFX = None
  320. Idle pIdle = None
  321. Actor pTarget = None
  322. Actor pSelf = Self.GetActorRef()
  323. Actor pPlayer = Game.GetPlayer()
  324. Int iTarget = 1
  325.  
  326. Bool bTargetSelf = False
  327. If sTarget == "Player"
  328. pTarget = pPlayer
  329. ElseIf sTarget == "Self"
  330. pTarget = pSelf
  331. bTargetSelf = True
  332. ElseIf sTarget == "Follower"
  333. If pCurrentFollower && pCurrentFollower.IsDead()
  334. pTarget = pCurrentFollower
  335. Else
  336. pTarget = pShellScript.SelectCorrectActor(2)
  337. EndIf
  338. EndIf
  339.  
  340. If !pTarget
  341. Return
  342. EndIf
  343.  
  344. ;Heals
  345. Bool bHasRespitePerk = False
  346. If sSpellName == "Healing Hands"
  347. If sTarget == "Player"
  348. pSpell = PDC1Spells[0] ;PDC1HealingHands
  349. ElseIf sTarget == "Self"
  350. pSpell = PDC1Spells[0] ;PDC1HealingHands
  351. EndIf
  352. ElseIf sSpellName == "Heal"
  353. pSpell = PDC1Spells[2] ;PDC1HealOther
  354. ElseIf sSpellName == "Heal All"
  355. pSpell = PDC1Spells[3] ;PDC1HealEx
  356. ElseIf sSpellName == "Resurrect"
  357. pSpell = PDC1Spells[6] ;PDC1ResurrectLeftHand
  358. EndIf
  359.  
  360. ;Buffs
  361. Bool bBuff = False
  362. If sSpellName == "Shield Buff"
  363. pSpell = PDC1Spells[4] ;PDC1ShieldBuff
  364. pSound = PDC1SpellSounds[4]
  365. bBuff = True
  366. ElseIf sSpellName == "Resist Buff"
  367. pSpell = PDC1Spells[5] ;PDC1ResistBuff
  368. pSound = PDC1SpellSounds[5]
  369. bBuff = True
  370. EndIf
  371.  
  372. If PDC1PlayerFollowerSpellHealing.Find(pSpell) >= 0
  373. bHasRespitePerk = pSelf.HasPerk(Respite)
  374. pSound = PDC1SpellSounds[1]
  375. pFX = HealMysticFXS
  376. ; Debug.Trace("PDC1 - PDC1PlayerFollowerSpellHealing - Has Spell in Form")
  377. EndIf
  378.  
  379. pSelf.StopCombat()
  380.  
  381. Utility.Wait(2)
  382.  
  383. pCastingTarget = pTarget
  384.  
  385. If bTargetSelf
  386. pSpell.Cast(pSelf,pTarget)
  387. Else
  388. pSelf.DoCombatSpellApply(pSpell,pTarget)
  389. EndIf
  390.  
  391. If pFX != None
  392. pFX.Play(pTarget)
  393. EndIf
  394.  
  395. If pSound != None
  396. pSound.PlayAndWait(pTarget)
  397. EndIf
  398.  
  399. Utility.Wait(2)
  400.  
  401. If pFX != None
  402. pFX.Stop(pTarget)
  403. EndIf
  404. EndFunction
  405.  
  406. ;=================================================================================
  407. ; Package AI Casting Functions
  408. ; This has a more imersive feel to it, because it plays Casting Animations
  409. ;=================================================================================
  410. Bool Function IsCastingSpell()
  411. If PDC1PlayerFollowerCastingSpell.GetValue() > 0
  412. Return True
  413. EndIf
  414. Return False
  415. EndFunction
  416.  
  417. Actor Function GetSpellCastTarget()
  418. If !IsCastingSpell()
  419. Return None
  420. EndIf
  421.  
  422. Actor pSelf = Self.GetActorRef()
  423. Actor pPlayer = Game.GetPlayer()
  424. Actor pTarget = None
  425.  
  426. Int iTarget = PDC1PlayerFollowerCastingSpell.GetValueInt()
  427.  
  428. If iTarget == 1
  429. pTarget = pPlayer
  430. ElseIf iTarget == 2
  431. pTarget = pSelf
  432. ElseIf iTarget == 3
  433. If pCurrentFollower && pCurrentFollower.IsDead()
  434. pTarget = pCurrentFollower
  435. Else
  436. pTarget = pShellScript.SelectCorrectActor(2)
  437. EndIf
  438. EndIf
  439.  
  440. Return pTarget
  441. EndFunction
  442.  
  443. Int Function DetermineTarget()
  444. Int nResults = 1
  445. Actor pPlayer = Game.GetPlayer()
  446. Actor pSelf = Self.GetActorRef()
  447.  
  448. Float CurPlayerHP = pPlayer.GetActorValuePercentage("Health")
  449. Float CurSelfHP = pSelf.GetActorValuePercentage("Health")
  450.  
  451. If CurPlayerHP > CurSelfHP
  452. Return 2
  453. EndIf
  454.  
  455. Return nResults
  456. EndFunction
  457.  
  458. Bool Function IsHealthValidForHealing(Actor akTarget)
  459. If akTarget && !akTarget.IsDead()
  460. Float fCurHealthPercent = akTarget.GetActorValuePercentage("Health")
  461. If fCurHealthPercent <= PDC1HealCombatActiveHealthPercent.GetValue()
  462. Return True
  463. ElseIf fCurHealthPercent <= PDC1HealHandsCombatActiveHealthPercent.GetValue()
  464. Return True
  465. EndIf
  466. EndIf
  467. Return False
  468. EndFunction
  469.  
  470. Function CastSpellByPackage(String sTarget, String sSpellName, Bool abDualCast = False)
  471. Spell pSpell = None
  472. Sound pSound = None
  473. EffectShader pFX = None
  474. Idle pIdle = None
  475. Actor pTarget = None
  476. Actor pSelf = Self.GetActorRef()
  477. Actor pPlayer = Game.GetPlayer()
  478. Int iTarget = 1
  479. Int iSpell = 0
  480.  
  481. Bool bAllowedDualCast = abDualCast
  482. Bool bTargetSelf = False
  483. If sTarget == "Player"
  484. pTarget = pPlayer
  485. iTarget = 1
  486. ElseIf sTarget == "Self"
  487. iTarget = 2
  488. pTarget = pSelf
  489. ElseIf sTarget == "Follower"
  490. iTarget = 3
  491. If pCurrentFollower && pCurrentFollower.IsDead()
  492. pTarget = pCurrentFollower
  493. Else
  494. pTarget = pShellScript.SelectCorrectActor(2)
  495. EndIf
  496. EndIf
  497.  
  498. If !pTarget
  499. Return
  500. EndIf
  501.  
  502. ;Heals
  503. If sSpellName == "Healing Hands"
  504. If sTarget == "Player"
  505. iSpell = 1
  506. ElseIf sTarget == "Self"
  507. iSpell = 1
  508. EndIf
  509. ElseIf sSpellName == "Heal"
  510. iSpell = 2
  511. ElseIf sSpellName == "Heal All"
  512. iSpell = 3
  513. ElseIf sSpellName == "Resurrect"
  514. ispell = 4
  515. EndIf
  516.  
  517. If iSpell
  518. If !IsHealthValidForHealing(pTarget)
  519. iSpell = 0
  520. EndIf
  521. If iTarget == 2
  522. iSpell = 1
  523. EndIf
  524. EndIf
  525.  
  526. ;Buffs
  527. Bool bBuff = False
  528. If sSpellName == "Shield Buff"
  529. iSpell = 1
  530. bBuff = True
  531. ElseIf sSpellName == "Resist Buff"
  532. iSpell = 2
  533. bBuff = True
  534. EndIf
  535.  
  536. If iSpell > 0
  537. pCastingTarget = pTarget
  538.  
  539. If bBuff
  540. PDC1PlayerFollowerCastBuffType.SetValue(iSpell)
  541. Else
  542. PDC1PlayerFollowerCastHealType.SetValue(iSpell)
  543. EndIf
  544.  
  545. If bAllowedDualCast
  546. PDC1PlayerFollowerCastDaulCast.SetValue(1)
  547. Else
  548. PDC1PlayerFollowerCastDaulCast.SetValue(0)
  549. EndIf
  550. PDC1PlayerFollowerCastingSpell.SetValue(iTarget)
  551. Else
  552. ResetSpellCasting()
  553. EndIf
  554.  
  555. EndFunction
  556.  
  557. Bool Function IsUsingAIPackageFromList(FormList pList)
  558. Actor pSelf = Self.GetActorRef()
  559. If !pSelf || !pList
  560. Return False
  561. EndIf
  562.  
  563. If IsCastingSpell() && pList.HasForm(pSelf.GetCurrentPackage())
  564. Return True
  565. EndIf
  566.  
  567. Return False
  568. EndFunction
  569. ;=================================================================================
  570. ; AI
  571. ;---------------------------------------------------------------------------------
  572. ; HEALING
  573. ;=================================================================================
  574. Bool Function IsCastingHeal()
  575. If !IsCastingSpell()
  576. Return False
  577. EndIf
  578.  
  579. If PDC1PlayerFollowerCastHealType.GetValueInt() >= 1
  580. Return True
  581. EndIf
  582.  
  583. Return False
  584. EndFunction
  585.  
  586. Bool Function IsCastingBuff()
  587. If !IsCastingSpell()
  588. Return False
  589. EndIf
  590.  
  591. If PDC1PlayerFollowerCastBuffType.GetValueInt() >= 1
  592. Return True
  593. EndIf
  594.  
  595. Return False
  596. EndFunction
  597.  
  598. Bool Function IsUsingHealPackage()
  599. Actor pSelf = Self.GetActorRef()
  600. If !pSelf
  601. Return False
  602. EndIf
  603. Return IsUsingAIPackageFromList(PDC1PlayerFollowerPackageHeal)
  604. EndFunction
  605.  
  606. Function AICastHealing(Bool bIgnoreBuff = False)
  607. Actor pSelf = GetActorRef()
  608. Actor pPlayer = Game.GetPlayer()
  609.  
  610. If !pSelf
  611. Return
  612. EndIf
  613.  
  614. If bIgnoreBuff
  615. If pSelf.IsDead() || IsCastingBuff()
  616. Return
  617. EndIf
  618. Else
  619. If !IsPartyHaveShieldBuff() || pSelf.IsDead() || IsCastingBuff()
  620. Return
  621. EndIf
  622. EndIf
  623.  
  624. ;-------------------------------------
  625. ;Player Health
  626. ;-------------------------------------
  627. Float fCurHealthPercent = pPlayer.GetActorValuePercentage("Health")
  628.  
  629. Int iHealTargetCount = 0
  630. String sTarget = "Player"
  631. String sSpell = None
  632.  
  633. Bool bDualCast = False
  634. If Utility.RandomFloat(0.0,1.0) <= PDC1PlayerFollowerDaulCastChange.GetValue()
  635. bDualCast = True
  636. EndIf
  637.  
  638.  
  639. ;-------------------------------------
  640. ;Player Health
  641. ;-------------------------------------
  642. If (fCurHealthPercent > PDC1HealCombatActiveHealthPercent.GetValue()) && (fCurHealthPercent <= PDC1HealHandsCombatActiveHealthPercent.GetValue())
  643. iHealTargetCount += 1
  644. sSpell = "Healing Hands"
  645. ElseIf (fCurHealthPercent <= PDC1HealCombatActiveHealthPercent.GetValue())
  646. iHealTargetCount += 1
  647. sSpell = "Heal"
  648. bDualCast = False
  649. EndIf
  650.  
  651.  
  652. ;-------------------------------------
  653. ;Follower Health
  654. ;-------------------------------------
  655. If pCurrentFollower && !pCurrentFollower.IsDead() && iHealTargetCount == 0
  656. sTarget = "Follower"
  657. fCurHealthPercent = pCurrentFollower.GetActorValuePercentage("Health")
  658.  
  659. If (fCurHealthPercent > PDC1HealCombatActiveHealthPercent.GetValue()) && (fCurHealthPercent <= PDC1HealHandsCombatActiveHealthPercent.GetValue())
  660. iHealTargetCount += 1
  661. sSpell = "Healing Hands"
  662. ElseIf (fCurHealthPercent <= PDC1HealCombatActiveHealthPercent.GetValue())
  663. iHealTargetCount += 1
  664. sSpell = "Heal"
  665. bDualCast = False
  666. EndIf
  667. EndIf
  668.  
  669. ;-------------------------------------
  670. ;Self Health
  671. ;-------------------------------------
  672. fCurHealthPercent = pSelf.GetActorValuePercentage("Health")
  673.  
  674. If iHealTargetCount > 1 && (fCurHealthPercent <= PDC1HealCombatActiveHealthPercent.GetValue())
  675. iHealTargetCount += 1
  676. sTarget = "Self"
  677. sSpell = "Heal All"
  678. bDualCast = False
  679. EndIf
  680.  
  681. If iHealTargetCount == 0
  682. sTarget = "Self"
  683. If (fCurHealthPercent > PDC1HealCombatActiveHealthPercent.GetValue()) && (fCurHealthPercent <= PDC1HealHandsCombatActiveHealthPercent.GetValue())
  684. iHealTargetCount += 1
  685. sSpell = "Healing Hands"
  686. EndIf
  687. EndIf
  688.  
  689. If iHealTargetCount > 0
  690. CastSpellByName(sTarget,sSpell,bDualCast)
  691. EndIf
  692. EndFunction
  693.  
  694. ;=================================================================================
  695. ; AI
  696. ;---------------------------------------------------------------------------------
  697. ; BUFFS
  698. ;=================================================================================
  699. Bool Function IsUsingBuffackage()
  700. Actor pSelf = Self.GetActorRef()
  701. If !pSelf
  702. Return False
  703. EndIf
  704. Return IsUsingAIPackageFromList(PDC1PlayerFollowerPackageBuff)
  705. EndFunction
  706.  
  707. Bool Function IsPartyHaveShieldBuff()
  708. Actor pActor = Self.GetActorRef()
  709. If pActor && pActor.HasMagicEffectWithKeyword(PDC1MagicBuffGroupShield)
  710. Return True
  711. EndIf
  712.  
  713. Return False
  714. EndFunction
  715.  
  716. Bool Function IsPartyHaveResistBuff()
  717. Actor pActor = Self.GetActorRef()
  718. If pActor && pActor.HasMagicEffectWithKeyword(PDC1MagicBuffGroupResist)
  719. Return True
  720. EndIf
  721.  
  722. Return False
  723. EndFunction
  724.  
  725. Bool Function HasMagicEffectWithKeywordFromList(FormList fmList)
  726. If fmList != None
  727. Int iSize = fmList.GetSize()
  728. While iSize > 0
  729. iSize -= 1
  730. Keyword kEffect = fmList.GetAt(iSize) As Keyword
  731. If kEffect
  732. If (pShellScript.SelectCorrectActor(1).HasMagicEffectWithKeyword(kEffect) ||\
  733. Game.GetPlayer().HasMagicEffectWithKeyword(kEffect))
  734. Return True
  735. EndIf
  736.  
  737. Actor pFollower = pShellScript.SelectCorrectActor(2)
  738. If pFollower
  739. If pFollower.HasMagicEffectWithKeyword(kEffect)
  740. Return True
  741. EndIf
  742. EndIf
  743. EndIf
  744. EndWhile
  745. EndIf
  746. Return False
  747. EndFunction
  748.  
  749. Bool Function HasKeywordFromList(Form akSource, FormList fmList)
  750. If fmList != None
  751. Int iSize = fmList.GetSize()
  752. While iSize > 0
  753. iSize -= 1
  754. Keyword kEffect = fmList.GetAt(iSize) As Keyword
  755. If kEffect
  756. If akSource.HasKeyword(kEffect)
  757. Return True
  758. EndIf
  759. EndIf
  760. EndWhile
  761. EndIf
  762. Return False
  763. EndFunction
  764.  
  765. Function AICastBuffResistGroupKeyword(Form akSource)
  766. Int iDebuffCount = 0
  767.  
  768. If IsPartyHaveResistBuff() || !Game.GetPlayer().IsInCombat()
  769. Return
  770. EndIf
  771.  
  772. If akSource.HasKeyword(PDC1MagicPriestDamage)
  773. Return
  774. EndIf
  775.  
  776. If HasKeywordFromList(akSource, PDC1PlayerFollowerSpellDamageKeywords)
  777. CastSpellByName("Self","Resist Buff")
  778. EndIf
  779. EndFunction
  780.  
  781. Function AICastBuffShieldGroup()
  782. If IsPartyHaveShieldBuff() || !Game.GetPlayer().IsInCombat()
  783. Return
  784. EndIf
  785.  
  786. ; Debug.Trace("PDC1 - AICastBuffShieldGroup True")
  787. CastSpellByName("Self","Shield Buff")
  788. EndFunction
  789.  
  790. ;=================================================================================
  791. ; Current Follower Data
  792. ;=================================================================================
Advertisement
Add Comment
Please, Sign In to add comment