home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
bathtubChar.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
11KB
|
433 lines
-- bathtub character state machine
beginStateMachine()
onEnter(function(msg)
print("bath character state machine onEnter");
local bathtub = getStateObjectFromID(msg.sender);
storeStateObject("bathtub", bathtub);
storeData("initOutfit", getParent().getOutfit());
if (bathtub) then
-- bathtub does exist
local actionPointName = retrieveData("actionPointName");
local actionPoint = getParent().getFreeActionPoint(bathtub, actionPointName);
if exitIfWrongPosition(getParent(), bathtub, actionPointName) then return end;
if (actionPoint) then
-- action point is free
getParent().lockActionPoints(bathtub);
if (actionPointName == "water2") then
storeData("mirrorAnims", true);
else
storeData("mirrorAnims", false);
end
else
-- action point is not free anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
else
-- bathtub does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
local bathtub = retrieveStateObject("bathtub");
-- if (bathtub) then
-- getParent().unlockActionPoints(bathtub);
-- getParent().stopAllActivities(bathtub);
-- removeStateObject("bathtub");
-- end;
unlockAll("bathtub");
local water = bathtub.findChildGO("water");
if (water) then
bathtub.setChildEnable("water", false);
water.stopSkeletonAnimation();
end;
end )
onReturn(function(msg)
print("bath character state machine onReturn");
local actionPointName = retrieveData("actionPointName");
if (actionPointName == "enter2") then
storeData("mirrorAnims", true);
else
storeData("mirrorAnims", false);
end
setState("undressOutside");
end )
state("openWater")
onEnter(function(msg)
print("openWater onEnter");
startAnimation("bathtubWater", retrieveData("mirrorAnims"));
sendDelayedMsgThis("waterSound", 1500);
end )
onMsg("waterSound", function(msg)
local bathtub = retrieveStateObject("bathtub");
bathtub.playSound("bathWaterIn");
end )
onMsg("end", function(msg)
if testCancel() then
exitStateMachine();
else
--setState("enterTub");
local bathtub = retrieveStateObject("bathtub");
local actionPoint = getParent().getClosestFreeActionPoint(getParent(), bathtub, {"enter1", "enter2"});
if (actionPoint) then
if (walkToPointImmediate(actionPoint)) then
print("enterStateMachine subwalk");
storeData("actionPointName", actionPoint.getName());
enterStateMachine("subwalk.walk");
else
print("no path found");
getParent().setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
else
print("no action point found");
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
end
end )
-- onMsg("end", function(msg)
-- if testCancel() then
-- exitStateMachine();
-- else
-- --setState("enterTub");
-- local bathtub = retrieveStateObject("bathtub");
--
-- exitStateMachine();
--
-- local actionPoint = getParent().getClosestFreeActionPoint(getParent(), bathtub, {"enter1", "enter2"});
-- if (actionPoint) then
-- if (walkToActionPoint(actionPoint)) then
-- queueStateMachine("bathtubChar.undressOutside", bathtub);
-- else
-- print("no path found");
-- getParent().setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
-- sendMsg("emoThink", getParent().walkSO);
-- exitStateMachine();
-- end
-- else
-- print("no action point found");
-- getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
-- sendMsg("emoThink", getParent().walkSO);
-- exitStateMachine();
-- end
--
--
-- end
-- end )
-- undress outside the tub
state("undressOutside")
onEnter(function(msg)
local character = getParent();
local other, result = getDisturbingChar(character, "showNaked");
if (other) then
exitStateMachine();
character.setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
other.sendMsg("emoShameChar", character.walkSO);
return
end;
-- local character = getParent();
-- local others = character.getCharactersInRoom();
--
-- for c = 1, getn(others) do
-- local other = others[c];
-- --print("checkShyness other found");
-- if (not activityPossible(character, "showInUnderwear", other)) then
-- exitStateMachine();
-- --print("checkShyness sendMsg emoShame");
-- character.setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
-- other.sendMsg("emoShameChar", character.walkSO);
-- return
-- end;
-- end;
--
local bathtub = retrieveStateObject("bathtub");
if testCancel() or bathtub.isBroken() then
exitStateMachine();
else
--startAnimation("ausziehen2");
startAnimation(getChangeOutfitAnim(getParent()));
sendDelayedMsgThis("underwear", 1600);
--local water = bathtub.loadGameObjectIntoGameObject("StandardGO","bathtubWater");
local water = bathtub.findChildGO("water");
bathtub.setChildEnable("water", true);
water.startSkeletonAnimation("waves");
--storeStateObject("water", water);
end
end )
onMsg("underwear", function(msg)
getParent().changeOutfit(NOTHING);
end )
onMsg("end", function(msg)
if testCancel() then
local initOutfit = retrieveData("initOutfit");
getParent().changeOutfit(initOutfit);
--local water = retrieveStateObject("water");
--removeStateObject("water");
--water.deleteGameObject();
-- local water = bathtub.findChildGO("water");
-- bathtub.setChildEnable("water", false);
-- water.stopSkeletonAnimation();
exitStateMachine();
else
setState("enterTub");
sendDelayedMsgThis("act", 5000);
end
end )
state("enterTub")
onEnter(function(msg)
print("enterTub onEnter");
startAnimation("bathtubEnter", retrieveData("mirrorAnims"));
--getParent().enableBlend(true);
sendDelayedMsgThis("splashSound", 3800);
end )
onMsg("splashSound", function(msg)
getParent().playSound("splashSoft");
end )
onMsg("end", function(msg)
if testCancel() then
setState("exitTub");
else
setState("lay");
end
end )
-- lay
state("lay")
onEnter(function(msg)
local bathtub = retrieveStateObject("bathtub");
local bath = getParent().startActivity("bath", bathtub);
local length, scale = getActivityLength(bath);
storeData("scale", scale);
sendDelayedMsgThis("complete", length);
--actionComplete();
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
startAnimation("bathtubLay", retrieveData("mirrorAnims"));
bathtub.loopSound("bathLoop");
dirtify(bathtub, DIRTIFY_PER_BATH);
end )
onExit(function(msg)
local bathtub = retrieveStateObject("bathtub");
getParent().stopAllActivities(bathtub);
bathtub.stopSound("bathLoop");
bathtub.playSound("bathWaterOut");
end )
onMsg("complete", function(msg)
setState("exitTub");
end )
onMsg("queue", function(msg)
setState("exitTub");
end )
onMsg("end", function(msg)
startAnimation("bathtubLay", retrieveData("mirrorAnims"));
end )
onMsg("testCancel", function(msg)
if testCancel() or (not this.getParent().getCurrentActivityGain()) then
setState("exitTub");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
-- stand up from tub
state("exitTub")
onEnter(function(msg)
print("exitTub onEnter");
startAnimation("bathtubExit", retrieveData("mirrorAnims"));
sendDelayedMsgThis("splashSound", 1000);
sendDelayedMsgThis("towel", 3000);
end )
onMsg("splashSound", function(msg)
local bathtub = retrieveStateObject("bathtub");
bathtub.playSound("splashSoft");
end )
onMsg("towel", function(msg)
getParent().changeOutfit(TOWEL);
end )
onMsg("end", function(msg)
print("exitTub onExit");
-- local initOutfit = retrieveData("initOutfit");
-- print(" initOutfit onExit", initOutfit);
-- getParent().changeOutfit(initOutfit);
--local water = retrieveStateObject("water");
--water.deleteGameObject();
--getParent().enableBlend(false);
-- local bathtub = retrieveStateObject("bathtub");
--
-- local water = bathtub.findChildGO("water");
-- water.stopSkeletonAnimation();
-- bathtub.setChildEnable("water", false);
exitStateMachine();
end )
state("cleanStart")
onEnter(function(msg)
-- grab sponge
print("cleanStart onEnter");
local sponge = getParent().loadGameObject("StandardGO","sponge");
getParent().attachRightObjectHolder(sponge);
storeStateObject("sponge", sponge);
startAnimation("cleanBathtubStart");
end )
onMsg("end", function(msg)
if (testCancel()) then
exitStateMachine();
else
setState("clean");
end
end )
-- clean up
state("clean")
onEnter(function(msg)
local bathtub = retrieveStateObject("bathtub");
local clean = getParent().startActivity("clean", bathtub);
local length, scale = getActivityLength(clean);
storeData("scale", scale);
startAnimation("cleanBathtubLoop", false, scale);
bathtub.playSound("cleanBathtub", 0.25);
--sendDelayedMsgThis("complete", length);
--this.actionComplete();
end )
onExit(function(msg)
local bathtub = retrieveStateObject("bathtub");
--bathtub.stopSound("cleanBathtub");
end )
-- onMsg("cancel", function(msg)
--
-- getParent().stopActivity("clean", retrieveStateObject("bathtub"));
-- setState("cleanEnd");
-- end )
--
-- onMsg("gueue", function(msg)
-- sendMsgThis("complete");
-- end )
onMsg("complete", function(msg)
getParent().stopActivity("clean", retrieveStateObject("bathtub"));
setState("cleanEnd");
end )
onMsg("end", function(msg)
local bathtub = retrieveStateObject("bathtub");
local dirt = bathtub.getDirtiness();
if (testCancel() or dirt<0.01) then
sendMsgThis("complete");
else
local scale = retrieveData("scale");
startAnimation("cleanBathtubLoop", false, scale);
bathtub.playSound("cleanBathtub", 0.25);
clean(bathtub, CLEAN_PER_LOOP);
end
end )
state("cleanEnd")
onEnter(function(msg)
-- remove sponge
local sponge = getParent().getRightHeldObject()
getParent().detachRightObjectHolder();
if (sponge) then sponge.deleteGameObject(); end
removeStateObject("sponge");
startAnimation("cleanBathtubEnd");
end )
onMsg("end", function(msg)
if (not testCancel()) then queueNextClean(getParent()) end;
exitStateMachine();
end )
endStateMachine()