-- bed character state machine
beginStateMachine()
onEnter(function(msg)
local bed = getStateObjectFromID(msg.sender);
storeStateObject("bed", bed);
if (bed) then
-- bed does exist
local actionPointName = retrieveData("actionPointName");
local actionPoint = getParent().getFreeActionPoint(bed, actionPointName);
if exitIfWrongPosition(getParent(), bed, actionPointName) then return end;
if (actionPoint) then
-- action point is free
getParent().lockActionPoints(bed);
if (actionPointName == "layDown2") then
storeData("mirrorAnims", true);
else
storeData("mirrorAnims", false);
end
local blanket = bed.findChildGO("blanket");
if (not blanket) then
print("blanket not found");
else
storeStateObject("blanket", blanket);
end
else
-- action point is not free anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
else
-- bed does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
print("EXIT: bedChar SM");
-- local bed = retrieveStateObject("bed");
-- if (bed) then
-- getParent().unlockActionPoints(bed);
-- getParent().stopAllActivities(bed);
-- removeStateObject("bed");
-- end;
unlockAll("bed");
getParent().stopAllActivities();
-- removeStateObject("blanket");
end )
-- test if we need to cancel
onMsg("test", function(msg)
if testCancel() or testCancelSleeping() then
setState("outOfBed");
else
sendDelayedMsgThis("test", 1000);
end
end )
state("undress")
onEnter(function(msg)
--startAnimation("ausziehen2");
startAnimation(getChangeOutfitAnim(getParent()));
sendDelayedMsgThis("underwear", 1600);
end )
onMsg("underwear", function(msg)
changeOutfit(getParent(), "UNDERWEAR")
end )
onMsg("end", function(msg)
setState("layDown");
end )
-- lay down on bed
state("layDown")
onEnter(function(msg)
-- if (not hasOutfit(getParent(), "UNDERWEAR") and not hasOutfit(getParent(), "NOTHING")) then
local dressCode = getParent().getDressCode();
if ((dressCode ~= UNDERWEAR) and (dressCode~= NAKED)) then
setState("undress");
return
end
startAnimation("laydownBed", retrieveData("mirrorAnims"));
local bed = retrieveStateObject("bed");
bed.playSound("bedLaydown");
local blanket = retrieveStateObject("blanket");
blanket.startSkeletonAnimation("blanketLayDownBed", retrieveData("mirrorAnims"));
end )
onMsg("end", function(msg)
if testCancel() or testCancelSleeping() then
setState("outOfBedFast");
else
setState("lieInBed");
end
end )
-- sleeping - lying down quietly
state("lieInBed")
onEnter(function(msg)
local bed = retrieveStateObject("bed");
getParent().startActivity("sleep", bed);
-- character now sleeping
getParent().setSleeping(true);
startAnimation("lieInBed", retrieveData("mirrorAnims"));
sendMsg("eyeClose", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_SLEEPING);
end )
onMsg("end", function(msg)
if testCancel() or testCancelSleeping() then
setState("outOfBed");
else
sendDelayedMsgThis("test", 1000);
setDelayedState("sleepingTurnToLeftSide", math.random(5000, 10000));
end
end )
-- sleeping - turn to to left side
state("sleepingTurnToLeftSide")
onEnter(function(msg)
startAnimation("sleepingTurnToLeftSide", retrieveData("mirrorAnims"));
local blanket = retrieveStateObject("blanket");
blanket.startSkeletonAnimation("blanketTurnToLeftSide", retrieveData("mirrorAnims"));
end )
onMsg("end", function(msg)
if testCancel() or testCancelSleeping() then
setState("outOfBed");
else
sendDelayedMsgThis("test", 1000);
setDelayedState("sleepingTurnToTommy", math.random(5000, 10000));
end
end )
-- sleeping - turn to to tummy
state("sleepingTurnToTommy")
onEnter(function(msg)
startAnimation("sleepingTurnToTommy", retrieveData("mirrorAnims"));
local blanket = retrieveStateObject("blanket");
blanket.startSkeletonAnimation("blanketTurnToTommy", retrieveData("mirrorAnims"));
end )
onMsg("end", function(msg)
if testCancel() or testCancelSleeping() then
setState("outOfBed");
else
sendDelayedMsgThis("test", 1000);
setDelayedState("sleepingTurnToRightSide", math.random(5000, 10000));
end
end )
-- sleeping - turn to to tummy
state("sleepingTurnToRightSide")
onEnter(function(msg)
startAnimation("sleepingTurnToRightSide", retrieveData("mirrorAnims"));
local blanket = retrieveStateObject("blanket");
blanket.startSkeletonAnimation("blanketTurnToRightSide", retrieveData("mirrorAnims"));
end )
onMsg("end", function(msg)
if testCancel() or testCancelSleeping() then
setState("outOfBed");
else
sendDelayedMsgThis("test", 1000);
setDelayedState("sleepingTurnToBack", math.random(5000, 10000));
end
end )
-- sleeping - turn to back
state("sleepingTurnToBack")
onEnter(function(msg)
startAnimation("sleepingTurnToBack", retrieveData("mirrorAnims"));
local blanket = retrieveStateObject("blanket");
blanket.startSkeletonAnimation("blanketTurnToBack", retrieveData("mirrorAnims"));
end )
onMsg("end", function(msg)
if testCancel() or testCancelSleeping() then
setState("outOfBed")
else
sendDelayedMsgThis("test", 1000);
setDelayedState("lieInBed", math.random(5000, 10000));
end
end )
-- get out of bed
state("outOfBed")
onEnter(function(msg)
startAnimation(genderize(getParent(), "standupBed"), retrieveData("mirrorAnims"));
-- character not sleeping anymore
getParent().setSleeping(false);
sendMsg("neutral", getParent().mimicSO);
getParent().setEmoticon("");
getParent().playSound(genderizeReal(getParent(), "wakeUp"));
local blanket = retrieveStateObject("blanket");
local blanketAnimSpeed = cond(getParent().isMale(), 1.0, 2.0)
blanket.startSkeletonAnimation("blanketStandupBed", retrieveData("mirrorAnims"), blanketAnimSpeed);
local bed = retrieveStateObject("bed");
--bed.stopSound("Bettgerausch");
getParent().stopAllActivities(bed);
end )
onMsg("end", function(msg)
--local blanket = retrieveStateObject("blanket");
--blanket.startSkeletonAnimation("blanketStoodupBed", retrieveData("mirrorAnims"));
flipPoseDirection();
setCurrentPosition();
exitStateMachine();
end )
-- get out of bed
state("outOfBedFast")
onEnter(function(msg)
startAnimation("laydownBed", retrieveData("mirrorAnims"), -1.0, 1000);
-- character not sleeping anymore
getParent().setSleeping(false);
sendMsg("neutral", getParent().mimicSO);
getParent().setEmoticon("");
local blanket = retrieveStateObject("blanket");
blanket.startSkeletonAnimation("blanketStandupBed", retrieveData("mirrorAnims"), 5.0);
local bed = retrieveStateObject("bed");
--bed.stopSound("Bettgerausch");
getParent().stopAllActivities(bed);
end )
onMsg("end", function(msg)
flipPoseDirection();
setCurrentPosition();
exitStateMachine();
end )
endStateMachine()
Alles anzeigen