NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

health.py (2192B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dogma\attributes\health.py
      2 from dogma.const import attributeHp, attributeDamage
      3 from dogma.const import attributeArmorHP, attributeArmorDamage
      4 from dogma.const import attributeShieldCharge, attributeShieldCapacity
      5 
      6 def GetCurrentArmorRatio(dogmaLM, itemId):
      7     maxArmorHP = GetMaxArmorAmount(dogmaLM, itemId)
      8     currentArmorHP = GetCurrentArmorDamage(dogmaLM, itemId)
      9     currentArmorRatio = (maxArmorHP - currentArmorHP) / maxArmorHP
     10     return currentArmorRatio
     11 
     12 
     13 def GetCurrentStructureDamage(dogmaLM, itemId):
     14     return dogmaLM.GetAttributeValue(itemId, attributeDamage)
     15 
     16 
     17 def GetMaxStructureAmount(dogmaLM, itemId):
     18     return dogmaLM.GetAttributeValue(itemId, attributeHp)
     19 
     20 
     21 def GetCurrentArmorDamage(dogmaLM, itemId):
     22     return dogmaLM.GetAttributeValue(itemId, attributeArmorDamage)
     23 
     24 
     25 def GetMaxArmorAmount(dogmaLM, itemId):
     26     return dogmaLM.GetAttributeValue(itemId, attributeArmorHP)
     27 
     28 
     29 def GetCurrentShieldAmount(dogmaLM, itemId):
     30     return dogmaLM.GetAttributeValue(itemId, attributeShieldCharge)
     31 
     32 
     33 def GetMaxShieldAmount(dogmaLM, itemId):
     34     return dogmaLM.GetAttributeValue(itemId, attributeShieldCapacity)
     35 
     36 
     37 def GetCurrentShieldRatio(dogmaLM, itemId):
     38     return GetCurrentShieldAmount(dogmaLM, itemId) / GetMaxShieldAmount(dogmaLM, itemId)
     39 
     40 
     41 def SetArmorAmount(dogmaLM, itemId, amount):
     42     dogmaLM.SetAttributeValue(itemId, attributeArmorDamage, amount)
     43 
     44 
     45 def SetArmorRatio(dogmaLM, itemId, ratio):
     46     maxArmorHP = GetMaxArmorAmount(dogmaLM, itemId)
     47     SetArmorAmount(dogmaLM, itemId, maxArmorHP * (1 - ratio))
     48 
     49 
     50 def SetShieldAmount(dogmaLM, itemId, amount):
     51     dogmaLM.SetAttributeValue(itemId, attributeShieldCapacity, amount)
     52 
     53 
     54 def SetShieldRatio(dogmaLM, itemId, ratio):
     55     maxShieldHp = GetMaxShieldAmount(dogmaLM, itemId)
     56     SetShieldAmount(dogmaLM, itemId, maxShieldHp * ratio)
     57 
     58 
     59 def SetStructureAmount(dogmaLM, itemId, amount):
     60     dogmaLM.SetAttributeValue(itemId, attributeDamage, amount)
     61 
     62 
     63 def SetStructureRatio(dogmaLM, itemId, ratio):
     64     maxStructureHp = GetMaxStructureAmount(dogmaLM, itemId)
     65     SetStructureAmount(dogmaLM, itemId, maxStructureHp * (1 - ratio))