Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```lua
- function hitVape:perform() -- # Trigger when the action is completed
- -- // print("Action perform");
- if self.soundChannel ~= 0 and self.character:getEmitter():isPlaying(self.soundChannel) then
- self.character:getEmitter():stopSound(self.soundChannel);
- self.smokeSound = nil;
- end
- local isNotBurned = true;
- local grabbedName = self.item:getDisplayName()
- if grabbedName == "Gnome Bar (Empty)" then isNotBurned = false; end
- if isNotBurned then -- !! If the vape is a normal vape with charge
- local currentDelta = self.item:getDelta(); -- Get the current remaining charge in the vape
- local newDelta = currentDelta - .05; -- Remove 1/20th of a charge
- self.item:setDelta(newDelta); -- Give the vape the new charge value
- if newDelta <= .04 then -- If there's not enough charge to perform another action
- self.character:getInventory():Remove(self.item); -- Remove the discharged vape from the inventory
- self.character:getInventory():AddItems("GnomeBars.GBEmpty", 1); -- Add the empty Gnomebar item instead
- self.character:Say(getText("UI_vape_blink"));
- end
- local rand = ZombRand(1,10); -- !! 1/10 chance for the character to cough when smoking the vape
- if rand == 5 then
- self.character:Say(getText("UI_vape_cough0")) -- " *cough* *cough* "
- end
- elseif not isNotBurned then -- !! if the vape is an empty burned vape
- self.character:Say(getText("UI_vape_cough0")); -- " *cough* *cough* "
- local r = ZombRand(5)+1; -- Random roll to choose the next text
- -- // print(r)
- if r == 1 then
- self.character:Say(getText("UI_vape_cough1")); -- "This thing is out of juice..."
- elseif r == 2 then
- self.character:Say(getText("UI_vape_cough2")); -- "Nothing but burned cotton..."
- elseif r == 3 then
- self.character:Say(getText("UI_vape_cough3")); -- "I need a new vape..."
- elseif r == 4 then
- self.character:Say(getText("UI_vape_cough4")); -- "Time to go find another..."
- elseif r == 5 then
- self.character:Say(getText("UI_vape_cough5")); -- "mmmm... Burned cotton flavor... my favorite..."
- end
- self.character:getBodyDamage():setUnhappynessLevel(self.character:getBodyDamage():getUnhappynessLevel() + 5); -- !! Add unhappiness bonus when hitting an empty vape
- self.character:getStats():setStress(self.character:getStats():getStress() + 5); -- !! Add stress bonus when hitting an empty vape
- --self.character:playEmote("ceasefire")
- self.character:setActionAnim("Bob_EmoteCough")
- end```
Advertisement
Add Comment
Please, Sign In to add comment