grymlahv

warden modmain

Jul 1st, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. PrefabFiles = {
  2. "warden",
  3. "warden_none",
  4. }
  5.  
  6. Assets = {
  7. Asset( "IMAGE", "images/saveslot_portraits/warden.tex" ),
  8. Asset( "ATLAS", "images/saveslot_portraits/warden.xml" ),
  9.  
  10. Asset( "IMAGE", "images/selectscreen_portraits/warden.tex" ),
  11. Asset( "ATLAS", "images/selectscreen_portraits/warden.xml" ),
  12.  
  13. Asset( "IMAGE", "images/selectscreen_portraits/warden_silho.tex" ),
  14. Asset( "ATLAS", "images/selectscreen_portraits/warden_silho.xml" ),
  15.  
  16. Asset( "IMAGE", "bigportraits/warden.tex" ),
  17. Asset( "ATLAS", "bigportraits/warden.xml" ),
  18.  
  19. Asset( "IMAGE", "images/map_icons/warden.tex" ),
  20. Asset( "ATLAS", "images/map_icons/warden.xml" ),
  21.  
  22. Asset( "IMAGE", "images/avatars/avatar_warden.tex" ),
  23. Asset( "ATLAS", "images/avatars/avatar_warden.xml" ),
  24.  
  25. Asset( "IMAGE", "images/avatars/avatar_ghost_warden.tex" ),
  26. Asset( "ATLAS", "images/avatars/avatar_ghost_warden.xml" ),
  27.  
  28. Asset( "IMAGE", "images/avatars/self_inspect_warden.tex" ),
  29. Asset( "ATLAS", "images/avatars/self_inspect_warden.xml" ),
  30.  
  31. Asset( "IMAGE", "images/names_warden.tex" ),
  32. Asset( "ATLAS", "images/names_warden.xml" ),
  33.  
  34. Asset( "IMAGE", "images/names_gold_warden.tex" ),
  35. Asset( "ATLAS", "images/names_gold_warden.xml" ),
  36. }
  37.  
  38. AddMinimapAtlas("images/map_icons/warden.xml")
  39.  
  40. local require = GLOBAL.require
  41. local STRINGS = GLOBAL.STRINGS
  42.  
  43. -- The character select screen lines
  44. STRINGS.CHARACTER_TITLES.warden = "The Wall"
  45. STRINGS.CHARACTER_NAMES.warden = "Warden"
  46. STRINGS.CHARACTER_DESCRIPTIONS.warden = "*Tough\n*Hates Pickaxes\n*He is what he eats\n*Spreads Warmth\n*Slow"
  47. STRINGS.CHARACTER_QUOTES.warden = "\"Rock candy tastes nothing like rocks!\""
  48. STRINGS.CHARACTER_SURVIVABILITY.warden = "Rocky"
  49.  
  50. -- Custom speech strings
  51. STRINGS.CHARACTERS.WARDEN = require "speech_warden"
  52.  
  53. -- The character's name as appears in-game
  54. STRINGS.NAMES.WARDEN = "Warden"
  55. STRINGS.SKIN_NAMES.warden_none = "Warden"
  56.  
  57. -- The skins shown in the cycle view window on the character select screen.
  58. -- A good place to see what you can put in here is in skinutils.lua, in the function GetSkinModes
  59. local skin_modes = {
  60. {
  61. type = "ghost_skin",
  62. anim_bank = "ghost",
  63. idle_anim = "idle",
  64. scale = 0.75,
  65. offset = { 0, -25 }
  66. },
  67. }
  68.  
  69. -- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.
  70. AddModCharacter("warden", "ROBOT", skin_modes)
  71.  
  72. local food_stat_dict = {
  73. flint = { health = 0, hunger = 15 },
  74. rocks = { health = 0, hunger = 5 },
  75. goldnugget = { hunger = 0 },
  76. nitre = { health = 5, hunger = 5 },
  77. moonrocknugget = { health = 0, sanity = 10, hunger = 5 },
  78. redgem = { health = 50, sanity = 0, hunger = 0 },
  79. orangegem = { health = 25, sanity = 0, hunger = 25 },
  80. yellowgem = { health = 0, sanity = 0, hunger = 50 },
  81. greengem = { health = 0, sanity = 25, hunger = 25 },
  82. bluegem = { health = 0, sanity = 50, hunger = 0 },
  83. purplegem = { health = 25, sanity = 25, hunger = 0 },
  84. opalgem = { health = 50, sanity = 50, hunger = 50 },
  85. thulecite = { health = 300, sanity = 50, hunger = 100 },
  86. }
  87.  
  88.  
  89. for food_prefab, food_stats in pairs(food_stat_dict) do
  90. AddPrefabPostInit(food_prefab, function(inst)
  91. inst.components.edible.healthvalue = food_stats["health"] or 0
  92. inst.components.edible.hungervalue = food_stats["hunger"] or 0
  93. inst.components.edible.sanityvalue = food_stats["sanity"] or 0
  94. end)
  95. end
  96.  
  97. local ACTIONS = GLOBAL.ACTIONS
  98. local myactions = {}
  99. myactions[ACTIONS.MINE] = 3
  100. local multiact = AddAction("MULTI", "Work", function(act)
  101. if act.target.components.workable then
  102. local action = act.target.components.workable.action
  103. local numworks = myactions[action] or 1
  104. act.target.components.workable:WorkedBy(act.doer, numworks)
  105. end
  106. return true
  107. end)
  108.  
  109. multiact.lmb = trueAddStategraphActionHandler("wilson", GLOBAL.ActionHandler(multiact, "multi"))
  110.  
  111. AddStategraphState("wilson", GLOBAL.State { name = "multi", tags = {"notalking", "autopredict"}, onenter = function(inst)
  112.  
  113. inst.sg.statemem.action = inst:GetBufferedAction()
  114. local target = inst.sg.statemem.action and inst.sg.statemem.action.target or nil
  115. inst.components.locomotor:Stop()
  116. inst.AnimState:PlayAnimation("throw")
  117. inst.sg:SetTimeout(cooldown)
  118. if target and target:IsValid() then
  119. inst:FacePoint(target.Transform:GetWorldPosition())
  120. end
  121. end, timeline = {
  122. GLOBAL.TimeEvent(7 * GLOBAL.FRAMES, function(inst)
  123. inst:PerformBufferedAction() end),
  124. GLOBAL.TimeEvent(16 * GLOBAL.FRAMES, function(inst)
  125. if
  126. inst.components.playercontroller
  127. and inst.components.playercontroller:IsAnyOfControlsPressed(GLOBAL.CONTROL_SECONDARY,GLOBAL.CONTROL_ACTION, GLOBAL.CONTROL_CONTROLLER_ALTACTION)
  128. and inst.sg.statemem.action
  129. and inst.sg.statemem.action.target
  130. and inst.sg.statemem.action.target.components.workable
  131. and inst.sg.statemem.action.target.components.workable.workleft > 0 then
  132. inst:PushBufferedAction(inst.sg.statemem.action)
  133. end
  134. end),
  135. },
  136. events = {
  137. GLOBAL.EventHandler("animover", function(inst)
  138. if inst.AnimState:AnimDone() then
  139. inst.sg:GoToState("idle", true)
  140. end
  141. end),
  142. },
  143. })
  144.  
  145. --- --- ---
  146.  
  147. local function multiLeftActions(inst, target, position)
  148. if target and (target:HasTag("MINE_workable")) then
  149. -- use tags or replicas, not components
  150. return inst.components.playeractionpicker:SortActionList({ ACTIONS.MULTI }, target) -- hosts and clients have playeractionpicker component
  151. end return nil, true
  152. end-- this true enables the old right actionsend
  153.  
  154. AddComponentPostInit("playeractionpicker", function(self)
  155. if self.inst:HasTag("multitasker") then
  156. self.leftclickoverride = multiLeftActions
  157. end
  158. end)
Add Comment
Please, Sign In to add comment