| 1 |
--[[ Copyright (c) 2009 Darrell "redneon" Blake |
| 2 |
|
| 3 |
Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 4 |
this software and associated documentation files (the "Software"), to deal in |
| 5 |
the Software without restriction, including without limitation the rights to |
| 6 |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| 7 |
of the Software, and to permit persons to whom the Software is furnished to do |
| 8 |
so, subject to the following conditions: |
| 9 |
|
| 10 |
The above copyright notice and this permission notice shall be included in all |
| 11 |
copies or substantial portions of the Software. |
| 12 |
|
| 13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 |
SOFTWARE. --]] |
| 20 |
|
| 21 |
class "VomitAction" (HumanoidAction) |
| 22 |
|
| 23 |
---@type VomitAction |
| 24 |
local VomitAction = _G["VomitAction"] |
| 25 |
|
| 26 |
function VomitAction:VomitAction() |
| 27 |
self:HumanoidAction("vomit") |
| 28 |
self:setMustHappen(true) |
| 29 |
end |
| 30 |
|
| 31 |
local action_vomit_end = permanent"action_vomit_end"( function(humanoid) |
| 32 |
local litter = humanoid.world:newObject("litter", humanoid.tile_x, humanoid.tile_y) |
| 33 |
litter:setLitterType("puke", humanoid.last_move_direction == "south" and 0 or 1) --For some reason the vomit is inverted. |
| 34 |
|
| 35 |
humanoid:finishAction() |
| 36 |
end) |
| 37 |
|
| 38 |
local function action_vomit_start(action, humanoid) |
| 39 |
if math.random(0, 1) == 1 then |
| 40 |
humanoid.last_move_direction = "east" |
| 41 |
else |
| 42 |
humanoid.last_move_direction = "south" |
| 43 |
end |
| 44 |
|
| 45 |
assert(humanoid.vomit_anim, "Error: no vomit animation for humanoid " .. humanoid.humanoid_class) |
| 46 |
action.must_happen = true |
| 47 |
humanoid:setAnimation(humanoid.vomit_anim, humanoid.last_move_direction == "east" and 0 or 1) |
| 48 |
humanoid:setTimer(TheApp.animation_manager:getAnimLength(humanoid.vomit_anim), action_vomit_end) |
| 49 |
end |
| 50 |
|
| 51 |
return action_vomit_start |