No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

creature.lua 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. -- @docclass Creature
  2. -- @docconsts @{
  3. SkullNone = 0
  4. SkullYellow = 1
  5. SkullGreen = 2
  6. SkullWhite = 3
  7. SkullRed = 4
  8. SkullBlack = 5
  9. SkullOrange = 6
  10. ShieldNone = 0
  11. ShieldWhiteYellow = 1
  12. ShieldWhiteBlue = 2
  13. ShieldBlue = 3
  14. ShieldYellow = 4
  15. ShieldBlueSharedExp = 5
  16. ShieldYellowSharedExp = 6
  17. ShieldBlueNoSharedExpBlink = 7
  18. ShieldYellowNoSharedExpBlink = 8
  19. ShieldBlueNoSharedExp = 9
  20. ShieldYellowNoSharedExp = 10
  21. EmblemNone = 0
  22. EmblemGreen = 1
  23. EmblemRed = 2
  24. EmblemBlue = 3
  25. NpcIconNone = 0
  26. NpcIconChat = 1
  27. NpcIconTrade = 2
  28. NpcIconQuest = 3
  29. NpcIconTradeQuest = 4
  30. CreatureTypePlayer = 0
  31. CreatureTypeMonster = 1
  32. CreatureTypeNpc = 2
  33. CreatureTypeSummonOwn = 3
  34. CreatureTypeSummonOther = 4
  35. -- @}
  36. function getNextSkullId(skullId)
  37. if skullId == SkullRed or skullId == SkullBlack then
  38. return SkullBlack
  39. end
  40. return SkullRed
  41. end
  42. function getSkullImagePath(skullId)
  43. local path
  44. if skullId == SkullYellow then
  45. path = '/images/game/skulls/skull_yellow'
  46. elseif skullId == SkullGreen then
  47. path = '/images/game/skulls/skull_green'
  48. elseif skullId == SkullWhite then
  49. path = '/images/game/skulls/skull_white'
  50. elseif skullId == SkullRed then
  51. path = '/images/game/skulls/skull_red'
  52. elseif skullId == SkullBlack then
  53. path = '/images/game/skulls/skull_black'
  54. elseif skullId == SkullOrange then
  55. path = '/images/game/skulls/skull_orange'
  56. end
  57. return path
  58. end
  59. function getShieldImagePathAndBlink(shieldId)
  60. local path, blink
  61. if shieldId == ShieldWhiteYellow then
  62. path, blink = '/images/game/shields/shield_yellow_white', false
  63. elseif shieldId == ShieldWhiteBlue then
  64. path, blink = '/images/game/shields/shield_blue_white', false
  65. elseif shieldId == ShieldBlue then
  66. path, blink = '/images/game/shields/shield_blue', false
  67. elseif shieldId == ShieldYellow then
  68. path, blink = '/images/game/shields/shield_yellow', false
  69. elseif shieldId == ShieldBlueSharedExp then
  70. path, blink = '/images/game/shields/shield_blue_shared', false
  71. elseif shieldId == ShieldYellowSharedExp then
  72. path, blink = '/images/game/shields/shield_yellow_shared', false
  73. elseif shieldId == ShieldBlueNoSharedExpBlink then
  74. path, blink = '/images/game/shields/shield_blue_not_shared', true
  75. elseif shieldId == ShieldYellowNoSharedExpBlink then
  76. path, blink = '/images/game/shields/shield_yellow_not_shared', true
  77. elseif shieldId == ShieldBlueNoSharedExp then
  78. path, blink = '/images/game/shields/shield_blue_not_shared', false
  79. elseif shieldId == ShieldYellowNoSharedExp then
  80. path, blink = '/images/game/shields/shield_yellow_not_shared', false
  81. elseif shieldId == ShieldGray then
  82. path, blink = '/images/game/shields/shield_gray', false
  83. end
  84. return path, blink
  85. end
  86. function getEmblemImagePath(emblemId)
  87. local path
  88. if emblemId == EmblemGreen then
  89. path = '/images/game/emblems/emblem_green'
  90. elseif emblemId == EmblemRed then
  91. path = '/images/game/emblems/emblem_red'
  92. elseif emblemId == EmblemBlue then
  93. path = '/images/game/emblems/emblem_blue'
  94. elseif emblemId == EmblemMember then
  95. path = '/images/game/emblems/emblem_member'
  96. elseif emblemId == EmblemOther then
  97. path = '/images/game/emblems/emblem_other'
  98. end
  99. return path
  100. end
  101. function getTypeImagePath(creatureType)
  102. local path
  103. if creatureType == CreatureTypeSummonOwn then
  104. path = '/images/game/creaturetype/summon_own'
  105. elseif creatureType == CreatureTypeSummonOther then
  106. path = '/images/game/creaturetype/summon_other'
  107. end
  108. return path
  109. end
  110. function getIconImagePath(iconId)
  111. local path
  112. if iconId == NpcIconChat then
  113. path = '/images/game/npcicons/icon_chat'
  114. elseif iconId == NpcIconTrade then
  115. path = '/images/game/npcicons/icon_trade'
  116. elseif iconId == NpcIconQuest then
  117. path = '/images/game/npcicons/icon_quest'
  118. elseif iconId == NpcIconTradeQuest then
  119. path = '/images/game/npcicons/icon_tradequest'
  120. end
  121. return path
  122. end
  123. function Creature:onSkullChange(skullId)
  124. local imagePath = getSkullImagePath(skullId)
  125. if imagePath then
  126. self:setSkullTexture(imagePath)
  127. end
  128. end
  129. function Creature:onShieldChange(shieldId)
  130. local imagePath, blink = getShieldImagePathAndBlink(shieldId)
  131. if imagePath then
  132. self:setShieldTexture(imagePath, blink)
  133. end
  134. end
  135. function Creature:onEmblemChange(emblemId)
  136. local imagePath = getEmblemImagePath(emblemId)
  137. if imagePath then
  138. self:setEmblemTexture(imagePath)
  139. end
  140. end
  141. function Creature:onTypeChange(typeId)
  142. local imagePath = getTypeImagePath(typeId)
  143. if imagePath then
  144. self:setTypeTexture(imagePath)
  145. end
  146. end
  147. function Creature:onIconChange(iconId)
  148. local imagePath = getIconImagePath(iconId)
  149. if imagePath then
  150. self:setIconTexture(imagePath)
  151. end
  152. end