// Smart Pots
// by d00d
// Common Functions
F meInvincible = effectTime($SonicBarrier) > 0 or effectTime($ForceBarrier) or effectTime($CelestialShield) > 0 or effectTime($FlamesOfInvincibility) > 0 or effectTime($SublimeSelfSacrifice) > 0 or effectTime(3158) > 0 or effectTime(655) > 0 or effectTime(5576) > 0
F meDisabled = isStunned(me) or isMedused(me) or isTranced(me) or isAnchored(me) or isAfraid(me) or effectTime($HeroicDread) > 0 or effectTime(922) > 0
F mePhysMute = isSilenced(me) or effectTime($HeroicGrandeur) > 0 and effectTime($Silence) == 0 and effectTime($SealOfSilence) == 0 and effectTime($VoiceBind) == 0
F meRaidMute = effectTime(4215) > 0
F cpLimited = ( effectTime($SealOfLimit) > 0 ) and pcp(me) >= 33
F hpLimited = ( effectTime($SealOfLimit) > 0 ) and php(me) >= 33
F mpLimited = ( effectTime($SealOfLimit) > 0 ) and pmp(me) >= 33
F reuse_BCP = (now - env("BCP") > 180000)
F reuse_BHP = (now - env("BHP") > 180000)
F reuse_BMP = (now - env("BMP") > 180000)
F reuse_ECP = (now - env("ECP") > 300000)
F reuse_ESP = (now - env("ESP") > 300000)
F reuse_EHP = (now - env("EHP") > 300000)
F reuse_GCP = (now - env("GCP") > 500)
F reuse_LCP = (now - env("LCP") > 500)
F reuse_GHP = (now - env("GHP") > 15000)
S Assign ECP = -300000 ; Assign ESP = -300000 ; Assign EHP = -300000
S Assign BCP = -180000 ; Assign BMP = -180000 ; Assign BHP = -180000
S Assign GCP = -500 ; Assign LCP = -500 ; Assign GHP = -15000
@MagicSkillUser actor == me and skill == 2166 and level == 2: Assign GCP = now
@MagicSkillUser actor == me and skill == 2166 and level == 1: Assign LCP = now
@MagicSkillUser actor == me and skill == 2289 : Assign ECP = now
@MagicSkillUser actor == me and skill == 2402 : Assign BCP = now
@MagicSkillUser actor == me and skill == 2403 : Assign ESP = now
@MagicSkillUser actor == me and ( skill == 2287 or skill == 2288 ) : Assign EHP = now
@MagicSkillUser actor == me and skill == 2401 : Assign BMP = now
@MagicSkillUser actor == me and ( skill == 2037 or skill == 26025 ) : Assign GHP = now
?Potions T(100) reuse_GCP and eatcp(200) and zone ~= 12 and not (meDisabled or meInvincible or cpLimited) : UseItem 5592 // GCP
?Potions T(100) reuse_LCP and eatcp(50) and zone ~= 12 and not (meDisabled or meInvincible or cpLimited) : UseItem 5591 // CPP
?Potions T(1000) reuse_BCP and eatcp(1500) and zone == 11 and not (meDisabled or meInvincible or cpLimited) : UseItem 10154 // Battle CP Elixer
?Potions T(1000) reuse_ECP and eatcp(1500) and zone ~= 12 and not (meDisabled or meInvincible or cpLimited) : UseItem 8639 // Standard CP S-Grade
?Potions T(1000) reuse_ESP and eatcp(2900) and zone ~= 12 and not (meDisabled or meInvincible or cpLimited) : UseItem 10166 // Spring CP Elixer
?Potions T(250) reuse_BHP and php(me) < 70 and zone == 11 and not (meDisabled or meInvincible or hpLimited) : UseItem 10152 // Battle HP Elixer
?Potions T(250) reuse_EHP and php(me) < 70 and zone ~= 12 and not (meDisabled or meInvincible or hpLimited) : UseItem 8627 // Standard HP Elixer
?Potions T(250) reuse_BMP and pmp(me) < 90 and zone == 11 and not (meDisabled or meInvincible or mpLimited) : UseItem 10153 // Battle MP Elixer
?Potions T(100) reuse_GHP and eathp(1500) and zone ~= 12 and not (meDisabled or meInvincible or hpLimited) : UseItem 1539 // Standard GHP
?Potions T(100) reuse_GHP and eathp(1500) and zone ~= 12 and not (meDisabled or meInvincible or hpLimited) : UseItem 9206 // Event GHP 1
?Potions T(100) reuse_GHP and eathp(1500) and zone ~= 12 and not (meDisabled or meInvincible or hpLimited) : UseItem 14700 // Event GHP 2
?Potions T(100) reuse_GHP and eathp(1500) and zone ~= 12 and not (meDisabled or meInvincible or hpLimited) : UseItem 22025 // Event GHP 3
L EnableGroup Potions off
S EnableGroup Potions off
?QHP T(500) php(me) < 55 and zone ~= 12 and not (meDisabled or meInvincible or hpLimited) : UseItem 13750
L EnableGroup QHP off
S EnableGroup QHP off