daily pastebin goal
62%
SHARE
TWEET

Ragnarok Mobile HP

a guest Jan 13th, 2019 92 in 9 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ***************************************************
  2. -- * Show Details in HP Target Cell
  3. -- ***************************************************
  4. autoImport("Creature_SceneBottomUI")
  5. if not Creature_SceneBottomUI_SetHp then
  6.     Creature_SceneBottomUI_SetHp = Creature_SceneBottomUI.SetHp
  7. end
  8. function Creature_SceneBottomUI:SetHp(ncreature)
  9.     Creature_SceneBottomUI_SetHp(self, ncreature)
  10.     EventManager.Me():PassEvent("XK_UpdateMyCell", self.id)
  11. end
  12.  
  13. autoImport("HeadImageData")
  14. if not HeadImageData_TransformByCreature then
  15.     HeadImageData_TransformByCreature = HeadImageData.TransformByCreature
  16. end
  17. function HeadImageData:TransformByCreature(creature)
  18.     HeadImageData_TransformByCreature(self, creature)
  19.     self.creature_data = creature.data.staticData
  20.     if creature.data.props then
  21.         self._hp = creature.data.props.Hp:GetValue()
  22.         self._maxhp = creature.data.props.MaxHp:GetValue()
  23.     end
  24. end
  25.  
  26. autoImport("TargetHeadCell")
  27. GLOBAL_VARS.is_ShowHPCell = true
  28. if not TargetHeadCell_SetData then
  29.     TargetHeadCell_SetData = TargetHeadCell.SetData
  30. end
  31. function TargetHeadCell:SetData(data)
  32.     TargetHeadCell_SetData(self, data)
  33.     if not self.default_name then
  34.         self.default_name = {
  35.             color = self.headBg.color,
  36.             width = self.headBg.width,
  37.             loc = self.headBg.transform.localPosition
  38.         }
  39.     end
  40.     if GLOBAL_VARS.is_ShowHPCell == true then
  41.         self.name.width = 1000
  42.         self.name.height = 300
  43.         self.name.alignment = 1
  44.         self.name.transform.localPosition = Vector3(580, 5, 0)
  45.         self.name.fontSize = 33 --self.level.fontSize
  46.         self.name.color = Color(1, 1, 1, 1)
  47.         self.name.effectColor = Color(194 / 255, 191 / 255, 249 / 255, 185 / 255)
  48.         --Color(116/255,154/255,196/255)
  49.         self.name.effectStyle = UILabel.Effect.Outline
  50.         self.headBg.color = Color(0, 0, 0, 0.7)
  51.         self.headBg.width = 300
  52.         self.headBg.transform.localPosition = Vector3(220, 0, 0)
  53.         self.name.text =
  54.             string.format(
  55.             "%s\n%s",
  56.             data.name,
  57.             data._maxhp ~= 0 and
  58.                 StringUtil.NumThousandFormat(data._hp) .. " / " .. StringUtil.NumThousandFormat(data._maxhp) or
  59.                 "[NPC]"
  60.         )
  61.         if data.isMonster then
  62.             self.name.text =
  63.                 string.format(
  64.                 "%s\n%s / %s / %s",
  65.                 self.name.text,
  66.                 data.creature_data.Race,
  67.                 data.creature_data.Nature,
  68.                 data.creature_data.Shape
  69.             )
  70.         end
  71.     else
  72.         -- FIXME: Set back to default data once HP is off
  73.         self.headBg.color = self.default_name.color
  74.         self.headBg.width = self.default_name.width
  75.         self.headBg.transform.localPosition = self.default_name.loc
  76.         self.name.text = ""
  77.     end
  78. end
  79.  
  80. autoImport("MainViewHeadPage")
  81. GLOBAL_VARS.is_ShowHPCell_Initialize = false
  82. if not MainViewHeadPage_UpdateTargetHeadCell then
  83.     MainViewHeadPage_UpdateTargetHeadCell = MainViewHeadPage.UpdateTargetHeadCell
  84. end
  85. function MainViewHeadPage:UpdateTargetHeadCell(creature)
  86.     MainViewHeadPage_UpdateTargetHeadCell(self, creature)
  87.     if GLOBAL_VARS.is_ShowHPCell_Initialize == false then
  88.         EventManager.Me():AddEventListener("XK_UpdateMyCell", self.XKUpdate, self)
  89.         GLOBAL_VARS.is_ShowHPCell_Initialize = true
  90.     end
  91. end
  92.  
  93. function MainViewHeadPage:XKUpdate(creature_id)
  94.     if self.targetId ~= creature_id then
  95.         return
  96.     end
  97.     local creature = SceneCreatureProxy.FindCreature(creature_id)
  98.     local headData = HeadImageData.new()
  99.     headData:TransformByCreature(creature)
  100.     self.targetHeadCell:SetData(headData)
  101. end
  102.  
  103. MY_COMMANDS["@hp"] = function(params)
  104.     if params[2] == "on" then
  105.         GLOBAL_VARS.is_ShowHPCell = true
  106.         SendMsg.Float("Target Info enabled.")
  107.     elseif params[2] == "off" then
  108.         GLOBAL_VARS.is_ShowHPCell = false
  109.         SendMsg.Float("Target Info disabled.")
  110.     end
  111. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top