Guest User

Untitled

a guest
Mar 30th, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. ```lua
  2. function hitVape:perform() -- # Trigger when the action is completed
  3. -- // print("Action perform");
  4.  
  5. if self.soundChannel ~= 0 and self.character:getEmitter():isPlaying(self.soundChannel) then
  6. self.character:getEmitter():stopSound(self.soundChannel);
  7. self.smokeSound = nil;
  8. end
  9.  
  10. local isNotBurned = true;
  11. local grabbedName = self.item:getDisplayName()
  12. if grabbedName == "Gnome Bar (Empty)" then isNotBurned = false; end
  13.  
  14.  
  15. if isNotBurned then -- !! If the vape is a normal vape with charge
  16. local currentDelta = self.item:getDelta(); -- Get the current remaining charge in the vape
  17. local newDelta = currentDelta - .05; -- Remove 1/20th of a charge
  18. self.item:setDelta(newDelta); -- Give the vape the new charge value
  19.  
  20. if newDelta <= .04 then -- If there's not enough charge to perform another action
  21. self.character:getInventory():Remove(self.item); -- Remove the discharged vape from the inventory
  22. self.character:getInventory():AddItems("GnomeBars.GBEmpty", 1); -- Add the empty Gnomebar item instead
  23. self.character:Say(getText("UI_vape_blink"));
  24. end
  25.  
  26. local rand = ZombRand(1,10); -- !! 1/10 chance for the character to cough when smoking the vape
  27. if rand == 5 then
  28. self.character:Say(getText("UI_vape_cough0")) -- " *cough* *cough* "
  29. end
  30.  
  31. elseif not isNotBurned then -- !! if the vape is an empty burned vape
  32. self.character:Say(getText("UI_vape_cough0")); -- " *cough* *cough* "
  33.  
  34. local r = ZombRand(5)+1; -- Random roll to choose the next text
  35. -- // print(r)
  36.  
  37. if r == 1 then
  38. self.character:Say(getText("UI_vape_cough1")); -- "This thing is out of juice..."
  39. elseif r == 2 then
  40. self.character:Say(getText("UI_vape_cough2")); -- "Nothing but burned cotton..."
  41. elseif r == 3 then
  42. self.character:Say(getText("UI_vape_cough3")); -- "I need a new vape..."
  43. elseif r == 4 then
  44. self.character:Say(getText("UI_vape_cough4")); -- "Time to go find another..."
  45. elseif r == 5 then
  46. self.character:Say(getText("UI_vape_cough5")); -- "mmmm... Burned cotton flavor... my favorite..."
  47. end
  48.  
  49. self.character:getBodyDamage():setUnhappynessLevel(self.character:getBodyDamage():getUnhappynessLevel() + 5); -- !! Add unhappiness bonus when hitting an empty vape
  50. self.character:getStats():setStress(self.character:getStats():getStress() + 5); -- !! Add stress bonus when hitting an empty vape
  51.  
  52. --self.character:playEmote("ceasefire")
  53. self.character:setActionAnim("Bob_EmoteCough")
  54. end```
Advertisement
Add Comment
Please, Sign In to add comment