Advertisement
Guest User

ROG Hat

a guest
Feb 4th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.57 KB | None | 0 0
  1. --replace wodbhat with your hat's name
  2.  
  3. local assets=
  4. {
  5.     Asset("ANIM", "anim/wodbhat.zip"),
  6.         Asset("IMAGE", "images/inventoryimages/wodbhat.tex"),
  7.     Asset("ATLAS", "images/inventoryimages/wodbhat.xml"),
  8. }
  9.  
  10. --this is what happens when you equip the hat
  11. local function onequip(inst, owner)
  12.     owner.AnimState:OverrideSymbol("swap_hat", "wodbhat", "swap_hat")
  13.     owner.AnimState:Show("HAT")
  14.     owner.AnimState:Show("HAT_HAIR")
  15.     owner.AnimState:Hide("HAIR_NOHAT")
  16.     owner.AnimState:Hide("HAIR")
  17.  
  18.     owner.components.health:SetAbsorptionAmount(.375)
  19.    
  20.     owner.components.health.maxhealth = 20
  21.     owner.components.health:DoDelta(0, true)  -- this updates the health badge
  22.  
  23.     if owner:HasTag("player") then
  24.         owner.AnimState:Hide("HEAD")
  25.         owner.AnimState:Show("HEAD_HAIR")
  26.        
  27.     end
  28.  
  29.     --this tells it to start losing durability when you equip it
  30.     if inst.components.fueled then
  31.         inst.components.fueled:StartConsuming()        
  32.     end
  33.    
  34.     inst.temperatureTask = inst:DoTaskInTime(5, function(inst)
  35.         if GetSeasonManager():GetCurrentTemperature() > 35 then
  36.             inst.components.insulator:SetSummer()
  37.         else
  38.             inst.components.insulator:SetWinter()
  39.         end
  40.     end)
  41. end
  42.  
  43.                
  44.  
  45. --this is what happens when you unequip the hat
  46. local function onunequip(inst, owner)
  47.     owner.AnimState:Hide("HAT")
  48.     owner.AnimState:Hide("HAT_HAIR")
  49.     owner.AnimState:Show("HAIR_NOHAT")
  50.     owner.AnimState:Show("HAIR")
  51.    
  52.    
  53.     owner.components.health:SetAbsorptionAmount(0)
  54.  
  55.     owner.components.health.maxhealth = 5
  56.     owner.components.health:DoDelta(0, true)  -- this updates the health badge
  57.  
  58.     if owner:HasTag("player") then
  59.         owner.AnimState:Show("HEAD")
  60.         owner.AnimState:Hide("HEAD_HAIR")
  61.     end
  62.  
  63.     --this tells it to stop losing durability when you unequip it
  64.     if inst.components.fueled then
  65.         inst.components.fueled:StopConsuming()
  66.     end
  67.  
  68.     inst.temperatureTask:Cancel()
  69. end
  70.  
  71.                
  72.  
  73. --I have no idea why this is called spider_perish but it helps the hat perish!
  74. -- Nik Mik here! It's because the top hat and spider hat use the same function to be destroyed when they run out of fuel.
  75.     local function spider_perish(inst)
  76.         --spider_disable(inst) ain't needed, Fiddoop. That's telling the item to go to another function. E.G if you had the spider_disable_inst and a function with the same name that made the character fart unicorns, the code on this line would tell it to do that function.
  77.         inst:Remove()
  78.         -- This destroys it.
  79.     end
  80.        
  81. local function fn(Sim)
  82.         local inst = CreateEntity()
  83.         local trans = inst.entity:AddTransform()
  84.         local anim = inst.entity:AddAnimState()
  85.     MakeInventoryPhysics(inst)
  86.    
  87.     inst:AddTag("hat")
  88.    
  89.         --it is important that you use the original hat's prefab name for bank (if you used wodbhat then leave it featherhat)
  90.     anim:SetBank("featherhat")
  91.        
  92.         --this is what you put in the build.bin when making the hat's .zip file
  93.     anim:SetBuild("wodbhat")
  94.        
  95.         --this is just the animation it plays leave it where it's at unless you use a different hat and run into problems
  96.     anim:PlayAnimation("anim")  
  97.        
  98.     --you want to be able to be examined it right?
  99.     inst:AddComponent("inspectable")
  100.    
  101.         --to be honest I don't know what this does
  102.     inst:AddTag("irreplaceable")
  103.  -- I think it means lureplants can't eat it, or something. Nik Mik.
  104.    
  105.         --this is so you can carry it in your inventory
  106.     inst:AddComponent("inventoryitem")
  107.     inst.components.inventoryitem.atlasname = "images/inventoryimages/wodbhat.xml"
  108.    
  109.         --this adds a sanity boost to your hat! this is half of what top hat gives
  110.     inst:AddComponent("waterproofer")
  111.     inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE)
  112.    
  113.    
  114.         --this is so the game knows to put it on your head
  115.     inst:AddComponent("equippable")
  116.     inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
  117. -- You can also do EQUIPSLOTS.BODY or EQUIPSLOTS.HANDS to make it use different slots.
  118.     inst:AddComponent("insulator")
  119.  
  120.  
  121.   inst.components.insulator:SetInsulation(TUNING.INSULATION_LARGE)
  122.        
  123.        
  124.  
  125.         --this is so the game knows there is a onequip and onunequip function
  126.     inst.components.equippable:SetOnEquip( onequip )
  127.     inst.components.equippable:SetOnUnequip( onunequip )
  128.        
  129.        
  130.     return inst
  131. end
  132.  
  133. return Prefab( "common/inventory/wodbhat", fn, assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement