home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles (French)
/
Singles-FrenchVersion-Win95.iso
/
data1.cab
/
Statemachine
/
interaction.lua
< prev
next >
Wrap
Text File
|
2004-03-05
|
36KB
|
1,212 lines
-- character interaction state machine
beginStateMachine()
onEnter(function(msg)
print("----- entering " .. getParent().getCharacterName() .. " interaction -----");
setPose(archize(getParent(), "stand1"));
local partner = retrieveStateObject("partner");
if (getParent().isOneActionPointLocked(partner.getParent())) then
print("----- entering " .. getParent().getCharacterName() .. " interaction isOneActionPointLocked-----");
-- action point is locked
exitStateMachine();
else
getParent().lockActionPoints(partner.getParent());
end
end )
onExit(function(msg)
print("----- exiting " .. getParent().getCharacterName() .. " interaction -----");
local partner = retrieveStateObject("partner");
if (partner) then
getParent().unlockActionPoints(partner.getParent());
getParent().stopAllActivities(partner.getParent());
removeStateObject("partner");
end;
removeData("activePart");
removeData("activityPossible");
end )
-- kissGeneric -----------------------------------------------------------------------------------------------
state("kiss")
onEnter(function(msg)
local kissType = retrieveData("kissType", "Friendly");
local activePart = retrieveData("activePart");
if (activePart == true) then
print("----- " .. getParent().getCharacterName() .. " is waiting to kiss -----");
else
print("----- " .. getParent().getCharacterName() .. " is waiting to be kissed -----");
end
storeActivityPossible("kiss" .. kissType);
-- if (activityPossible(getParent(), getState(), retrieveStateObject("partner").getParent())) then
-- storeData("activityPossible", true)
-- else
-- storeData("activityPossible", false)
-- end
-- periodically send a message to the other
-- character that this character is ready
sendDelayedMsgThis("ready", 1000);
-- or, after a longer period of waiting, stop waiting
sendDelayedMsgThis("stop", getInteractionWaitTime());
-- listen to queue message
-- actionComplete();
end )
-- onMsg("end", function(msg)
-- actionComplete();
-- end )
onMsg("queue", function(msg)
--exitStateMachine();
sendMsgThis("partnerfailed");
end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting -----");
--exitStateMachine();
sendMsgThis("partnerfailed");
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
if (testCancel()) then
sendMsgThis("partnerfailed");
else
if (retrieveData("activityPossible")) then
sendMsg("partnerReady", partner);
else
sendMsgThis("partnerfailed");
end
sendDelayedMsgThis("ready", 1000);
end
-- send a message to the partner
-- local partner = retrieveStateObject("partner");
-- if (retrieveData("activityPossible") == true) then
-- sendMsg("partnerReady", partner);
-- else
-- sendMsg("partnerfailed", partner);
-- end
-- sendDelayedMsgThis("ready", 1000);
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("doKiss");
sendMsg("partnerReady", partner);
end )
onMsg("partnerfailed", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " failed -----");
local partner = retrieveStateObject("partner");
setState("failKiss");
sendMsg("partnerfailed", partner);
end )
-- doKiss
state("doKiss")
onEnter(function(msg)
local kissType = retrieveData("kissType", "Friendly");
local partner = retrieveStateObject("partner");
local activePart = retrieveData("activePart");
if (activePart) then
this.getParent().startActivity("kiss" .. kissType, partner.getParent())
startAnimation(genderize(getParent(), "kiss" .. kissType));
else
startAnimation(genderize(getParent(), "kissed" .. kissType));
end
sendMsg("stop", getParent().mimicSO);
end )
onMsg("end", function(msg)
exitStateMachine();
end )
onExit(function(msg)
local partner = retrieveStateObject("partner");
getParent().stopAllActivities(partner.getParent());
end )
-- failKiss
state("failKiss")
onEnter(function(msg)
local activePart = retrieveData("activePart");
if (activePart == true) then
sendMsg("sad", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_SAD, EMOTICON_DELAY);
else
sendMsg("angry", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_ANGRY, EMOTICON_DELAY);
end
exitStateMachine();
end )
-- kissSexy -----------------------------------------------------------------------------------------------
state("kissSexy")
onEnter(function(msg)
-- local kissType = retrieveData("kissType", "Friendly");
local activePart = retrieveData("activePart");
if (activePart == true) then
print("----- " .. getParent().getCharacterName() .. " is waiting to kissSexy -----");
else
print("----- " .. getParent().getCharacterName() .. " is waiting to be kissedSexy -----");
end
storeActivityPossible("kissSexy");
-- local active = cond(activePart, getParent(), retrieveStateObject("partner").getParent());
-- local passive = cond(activePart, retrieveStateObject("partner").getParent(), getParent());
---- if (activityPossible(getParent(), getState(), retrieveStateObject("partner").getParent())) then
-- if activityPossible(active, "kissSexy", passive) then
-- storeData("activityPossible", true)
-- else
-- storeData("activityPossible", false)
-- end
-- periodically send a message to the other
-- character that this character is ready
sendDelayedMsgThis("ready", 1000);
-- or, after a longer period of waiting, stop waiting
sendDelayedMsgThis("stop", getInteractionWaitTime());
-- listen to queue message
-- actionComplete();
end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting -----");
exitStateMachine();
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
if (testCancel()) then
--sendMsgThis("partnerfailed");
sendMsgThis("cancel");
else
if (retrieveData("activityPossible")) then
sendMsg("partnerReady", partner);
else
sendMsgThis("partnerfailed");
end
sendDelayedMsgThis("ready", 1000);
end
-- send a message to the partner
-- local partner = retrieveStateObject("partner");
-- if (retrieveData("activityPossible") == true) then
-- sendMsg("partnerReady", partner);
-- else
-- sendMsg("partnerfailed", partner);
-- end
-- sendDelayedMsgThis("ready", 1000);
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("kissSexyStart");
sendMsg("partnerReady", partner);
end )
onMsg("partnerfailed", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " failed -----");
local partner = retrieveStateObject("partner");
setState("failKissSexy");
sendMsg("partnerfailed", partner);
end )
onMsg("cancel", function(msg)
print("-----kissSexy cancel " .. getParent().getCharacterName() .. " -----");
local partner = retrieveStateObject("partner");
setState("kissSexyStop");
sendMsg("partnerCancel", partner);
end )
onMsg("partnerCancel", function(msg)
print("-----kissSexy partner of " .. getParent().getCharacterName() .. " cancelled -----");
setState("kissSexyStop");
end )
-- kissSexyStart
state("kissSexyStart")
onEnter(function(msg)
print("kissSexyStart ".. getParent().getCharacterName());
startAnimation(genderize(getParent(), "kissSexyStart"));
sendMsg("stop", getParent().mimicSO);
end )
onMsg("end", function(msg)
if (testCancel()) then
--setState("kissSexyStop");
sendMsgThis("cancel");
else
setState("kissSexyLoop");
end
end )
onMsg("partnerfailed", function(msg)
print("-----kissSexyStart partner of " .. getParent().getCharacterName() .. " failed -----");
local partner = retrieveStateObject("partner");
setState("failTalk");
sendMsg("partnerfailed", partner);
end )
onMsg("cancel", function(msg)
print("-----kissSexyStart cancel " .. getParent().getCharacterName() .. " -----");
local partner = retrieveStateObject("partner");
setState("kissSexyStop");
sendMsg("partnerCancel", partner);
end )
onMsg("partnerCancel", function(msg)
print("-----kissSexyStart partner of " .. getParent().getCharacterName() .. " cancelled -----");
setState("kissSexyStop");
end )
onExit(function(msg)
local partner = retrieveStateObject("partner");
getParent().stopAllActivities(partner.getParent());
end )
-- kissSexyLoop
state("kissSexyLoop")
onEnter(function(msg)
print("kissSexyLoop " .. getParent().getCharacterName());
startAnimation(genderize(getParent(), "kissSexyLoop"));
local partner = retrieveStateObject("partner");
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
if (retrieveData("activePart", true)) then
local kissSexy = this.getParent().startActivity("kissSexy", partner.getParent());
local length = getActivityLength(kissSexy);
sendDelayedMsgThis("kissSexyComplete", length);
end
end )
onMsg("testCancel", function(msg)
if testCancel() then
--sendMsgThis("kissSexyComplete");
sendMsgThis("cancel");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("kissSexyComplete", function(msg)
setState("kissSexyStop")
local partner = retrieveStateObject("partner");
sendMsg("kissSexyComplete", partner);
end )
onMsg("end", function(msg)
if (testCancel()) then
sendMsgThis("kissSexyComplete");
else
startAnimation(genderize(getParent(), "kissSexyLoop"));
end
end )
onExit(function(msg)
local partner = retrieveStateObject("partner");
getParent().stopAllActivities(partner.getParent());
sendMsg("neutral", getParent().mimicSO);
end )
onMsg("cancel", function(msg)
print("-----kissSexyLoop cancel " .. getParent().getCharacterName() .. " -----");
local partner = retrieveStateObject("partner");
setState("kissSexyStop");
sendMsg("partnerCancel", partner);
end )
onMsg("partnerCancel", function(msg)
print("-----kissSexyLoop partner of " .. getParent().getCharacterName() .. " cancelled -----");
setState("kissSexyStop");
end )
-- kissSexyStop
state("kissSexyStop")
onEnter(function(msg)
print("print kissSexyStop" .. getParent().getCharacterName());
startAnimation(genderize(getParent(), "kissSexyStart"), false, -1.0, 1000);
end )
onMsg("end", function(msg)
exitStateMachine();
end )
-- failKissSexy
state("failKissSexy")
onEnter(function(msg)
local activePart = retrieveData("activePart");
if (activePart == true) then
sendMsg("sad", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_SAD, EMOTICON_DELAY);
else
sendMsg("angry", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_ANGRY, EMOTICON_DELAY);
end
exitStateMachine();
end )
-- holdNice -----------------------------------------------------------------------------------------------
state("holdNice")
onEnter(function(msg)
storeActivityPossible("holdNice");
-- if (activityPossible(getParent(), getState(), retrieveStateObject("partner").getParent())) then
-- storeData("activityPossible", true)
-- else
-- storeData("activityPossible", false)
-- end
-- periodically send a message to the other
-- character that this character is ready
sendDelayedMsgThis("ready", 1000);
-- or, after a longer period of waiting, stop waiting
sendDelayedMsgThis("stop", getInteractionWaitTime());
-- listen to queue message
-- actionComplete();
end )
-- onMsg("end", function(msg)
-- actionComplete();
-- end )
onMsg("queue", function(msg)
exitStateMachine();
end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting -----");
exitStateMachine();
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
if (testCancel()) then
sendMsgThis("partnerfailed");
else
if (retrieveData("activityPossible")) then
sendMsg("partnerReady", partner);
else
sendMsgThis("partnerfailed");
end
sendDelayedMsgThis("ready", 1000);
end
-- -- send a message to the partner
-- local partner = retrieveStateObject("partner");
-- if (retrieveData("activityPossible") == true) then
-- sendMsg("partnerReady", partner);
-- else
-- sendMsg("partnerfailed", partner);
-- end
-- sendDelayedMsgThis("ready", 1000);
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("doHoldNice");
sendMsg("partnerReady", partner);
end )
onMsg("partnerfailed", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " failed -----");
local partner = retrieveStateObject("partner");
setState("failHoldNice");
sendMsg("partnerfailed", partner);
end )
-- doHoldNice
state("doHoldNice")
onEnter(function(msg)
startAnimation(genderize(getParent(), "holdNice"));
sendMsg("stop", getParent().mimicSO);
if (retrieveData("activePart", true)) then
local partner = retrieveStateObject("partner");
this.getParent().startActivity("holdNice", partner.getParent())
end
end )
onMsg("end", function(msg)
exitStateMachine();
end )
onExit(function(msg)
local partner = retrieveStateObject("partner");
this.getParent().stopAllActivities(partner.getParent());
end )
-- failHoldNice
state("failHoldNice")
onEnter(function(msg)
local activePart = retrieveData("activePart");
if (activePart == true) then
sendMsg("sad", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_SAD, EMOTICON_DELAY);
else
sendMsg("angry", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_ANGRY, EMOTICON_DELAY);
end
exitStateMachine();
end )
-- holdBehind -----------------------------------------------------------------------------------------------
state("holdBehind")
onEnter(function(msg)
storeActivityPossible("holdBehind");
-- if (activityPossible(getParent(), getState(), retrieveStateObject("partner").getParent())) then
-- storeData("activityPossible", true)
-- else
-- storeData("activityPossible", false)
-- end
-- periodically send a message to the other
-- character that this character is ready
sendDelayedMsgThis("ready", 1000);
-- or, after a longer period of waiting, stop waiting
sendDelayedMsgThis("stop", getInteractionWaitTime());
end )
onMsg("queue", function(msg)
exitStateMachine();
end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting -----");
exitStateMachine();
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
if (testCancel()) then
sendMsgThis("partnerfailed");
else
if (retrieveData("activityPossible")) then
sendMsg("partnerReady", partner);
else
sendMsgThis("partnerfailed");
end
sendDelayedMsgThis("ready", 1000);
end
-- -- send a message to the partner
-- local partner = retrieveStateObject("partner");
-- if (retrieveData("activityPossible") == true) then
-- sendMsg("partnerReady", partner);
-- else
-- sendMsg("partnerfailed", partner);
-- end
-- sendDelayedMsgThis("ready", 1000);
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("doHoldBehind");
sendMsg("partnerReady", partner);
end )
onMsg("partnerfailed", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " failed -----");
local partner = retrieveStateObject("partner");
setState("failHoldBehind");
sendMsg("partnerfailed", partner);
end )
-- doHoldBehind
state("doHoldBehind")
onEnter(function(msg)
local activePart = retrieveData("activePart");
startAnimation(genderize(getParent(), "holdBehind"));
sendMsg("stop", getParent().mimicSO);
if (retrieveData("activePart", true)) then
local partner = retrieveStateObject("partner");
this.getParent().startActivity("holdBehind", partner.getParent())
end
end )
onMsg("end", function(msg)
exitStateMachine();
end )
onExit(function(msg)
local partner = retrieveStateObject("partner");
this.getParent().stopAllActivities(partner.getParent());
end )
-- failHoldBehind
state("failHoldBehind")
onEnter(function(msg)
local activePart = retrieveData("activePart");
if (activePart == true) then
sendMsg("sad", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_SAD, EMOTICON_DELAY);
else
sendMsg("angry", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_ANGRY, EMOTICON_DELAY);
end
exitStateMachine();
end )
-- talkGeneric-----------------------------------------------------------------------------------------------
state("talk")
onEnter(function(msg)
local talkType = retrieveData("talkType", "Casual");
print("--talk" .. talkType .." onEnter--- " .. getParent().getCharacterName());
storeActivityPossible("talk" .. talkType);
-- if (activityPossible(getParent(), getState() .. talkType, retrieveStateObject("partner").getParent())) then
-- storeData("activityPossible", true)
-- else
-- storeData("activityPossible", false)
-- end
--
-- periodically send a message to the other
-- character that this character is ready
sendDelayedMsgThis("ready", 1000);
-- or, after a longer period of waiting, stop waiting
sendDelayedMsgThis("stop", getInteractionWaitTime());
if (retrieveData("activePart")) then
startAnimation("emoSwingArms");
sendDelayedMsgThis("emoticon", EMOTICON_DELAY);
end;
-- listen to queue message
-- actionComplete();
end )
onMsg("emoticon", function(msg)
getParent().setEmoticon(EMOTICON_WAIT, EMOTICON_DELAY);
sendDelayedMsgThis("emoticon", EMOTICON_DELAY * 2);
end )
onMsg("end", function(msg)
startAnimation("emoSwingArms");
end )
-- onMsg("queue", function(msg)
-- exitStateMachine();
-- end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting ----- " .. retrieveData("talkType", "?"));
-- exitStateMachine();
sendMsgThis("partnerfailed");
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready ----- cancel: " .. tostring(testCancel()));
-- send a message to the partner
local partner = retrieveStateObject("partner");
if (testCancel()) then
sendMsgThis("partnerfailed");
else
if (retrieveData("activityPossible")) then
sendMsg("partnerReady", partner);
sendDelayedMsgThis("ready", 1000);
else
sendMsgThis("partnerfailed");
end
end
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----" .. retrieveData("talkType", "?"));
local partner = retrieveStateObject("partner");
setState("doTalk");
sendMsg("partnerReady", partner);
end )
onMsg("partnerfailed", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " failed -----" .. retrieveData("talkType", "?"));
local partner = retrieveStateObject("partner");
setState("failTalk");
sendMsg("partnerfailed", partner);
end )
-- doTalk
state("doTalk")
onEnter(function(msg)
local talkType = retrieveData("talkType", "Casual");
local activePart = retrieveData("activePart");
local diff = activeDiff("talk" .. talkType);
local text = ""; if (activePart) then text = "is active"; end;
print("--doTalk" .. talkType .." onEnter--- " .. getParent().getCharacterName() .. " " .. text);
sendMsg("stop", getParent().mimicSO);
if (diff) then
-- talk has passive version
if (activePart == true) then
startAnimation(genderize(getParent(), "talk" .. talkType));
else
startAnimation(genderize(getParent(), "talked" .. talkType));
end
else
-- talk has only active version
-- if (activePart == true) then
-- getParent().playSound("talk" .. talkType, SPEECH);
-- end
startAnimation(genderize(getParent(), "talk" .. talkType));
end
if (activePart or (not isMonologue("talk" .. talkType))) then
getParent().playSound(genderizeSpeech(getParent(), "talk" .. talkType, activePart, diff), 1.0, SPEECH, true);
end
local partner = retrieveStateObject("partner");
if (activePart) then
this.getParent().startActivity("talk" .. talkType, partner.getParent());
end
if (talkType == "Argue") then
-- give trouble point
if (activePart) then
this.getParent().incRelationshipCondition(partner.getParent().getCharacterID(), REL_TROUBLE, 1);
end
-- balance justice
this.getParent().setCondition(NEED_JUSTICE, 1.0);
end
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
if (activePart == true) then
getParent().setEmoticon(getIconForAction("talk" .. talkType));
else
print("--pushQueueEntry" .. talkType .." into " .. getParent().getCharacterName());
setTopQueueEntry(getParent(), "pm_talk" .. talkType);
end;
end )
onMsg("testCancel", function(msg)
if testCancel() then
local partner = retrieveStateObject("partner");
sendMsgThis("talkCanceled");
sendMsg("talkCanceled", partner);
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("talkCanceled", function(msg)
local talkType = retrieveData("talkType", "Casual");
print("--talk" .. talkType .." Canceled--- " .. getParent().getCharacterName());
-- local activePart = retrieveData("activePart");
-- if (activePart == true) then
-- if (activeDiff("talk" .. talkType)) then
-- getParent().stopSound(genderize(getParent(), "talk".. talkType));
-- else
-- getParent().stopSound("talk".. talkType);
-- end
-- end
exitStateMachine();
end )
onMsg("end", function(msg)
print("---------------------------------------------talk" .. retrieveData("talkType", "?") .." end --- " .. getParent().getCharacterName());
exitStateMachine();
end )
onMsg("exit", function(msg)
print("--talk" .. retrieveData("talkType", "?") .." exit --- " .. getParent().getCharacterName());
exitStateMachine();
end )
onExit(function(msg)
print("--talk" .. retrieveData("talkType", "?") .." onExit --- " .. getParent().getCharacterName());
local partner = retrieveStateObject("partner");
-- local activePart = retrieveData("activePart");
-- if (activePart == false) then
-- getParent().popDummyQueueEntry();
-- end
getParent().stopAllSounds();
this.getParent().stopAllActivities(partner.getParent());
getParent().setEmoticon("");
end )
-- failTalk
state("failTalk")
onEnter(function(msg)
print("--talk" .. retrieveData("talkType", "?") .." onEnter--- " .. getParent().getCharacterName());
local activePart = retrieveData("activePart");
if (activePart == true) then
sendMsg("sad", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_SAD, EMOTICON_DELAY);
else
sendMsg("angry", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_ANGRY, EMOTICON_DELAY);
end
exitStateMachine();
end )
-- talkCutscene-----------------------------------------------------------------------------------------------
state("talkCutscene")
onEnter(function(msg)
print("--talkCutscene onEnter--- " .. getParent().getCharacterName());
setTopQueueEntry(getParent(), "pm_talkCutscene");
-- periodically send a message to the other
-- character that this character is ready
sendDelayedMsgThis("ready", 1000);
-- or, after a longer period of waiting, stop waiting
--sendDelayedMsgThis("stop", getInteractionWaitTime());
end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting -----");
--exitStateMachine();
sendMsgThis("partnerfailed");
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
if (testCancel()) then
print("----- " .. getParent().getCharacterName() .. " ready testCancel == true -----");
sendMsgThis("partnerfailed");
else
sendMsg("partnerReady", partner);
sendDelayedMsgThis("ready", 1000);
end
-- -- send a message to the partner
-- local partner = retrieveStateObject("partner");
-- sendMsg("partnerReady", partner);
-- sendDelayedMsgThis("ready", 1000);
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("doTalkCutscene");
sendMsg("partnerReady", partner);
end )
onMsg("partnerfailed", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " failed -----");
local partner = retrieveStateObject("partner");
setState("failTalkCutscene");
sendMsg("partnerfailed", partner);
end )
onMsg("talkingCancelled", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " talkingCancelled -----");
if retrieveData("topic") == msg.data then
print(" ------ cancelling:" .. msg.data);
sendMsgThis("partnerfailed");
end
end )
-- doTalk
state("doTalkCutscene")
onEnter(function(msg)
-- local talkType = retrieveData("talkType", "Cutscene");
local activePart = retrieveData("activePart");
print("--doTalkCutscene onEnter--- " .. getParent().getCharacterName() .. " active " .. tostring(activePart) .. " " .. tostring(retrieveData("topic")));
sendMsg("stop", getParent().mimicSO);
-- send amessage to the mission that the quests can do something (e.g. start conversation)
if activePart then
local topic = retrieveData("topic"); if not topic then topic = ""; end;
getParent().sendMsg("talking", getParent().getGameObjectServer().mission, topic);
end
sendMsgThis("startLoop");
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end )
onMsg("startLoop", function(msg)
local activePart = retrieveData("activePart");
if (activePart) then
startAnimation(genderize(getParent(), "talkCasual"));
else
startAnimation(genderize(getParent(), "talkedCasual"));
end
getParent().playSound(genderizeSpeech(getParent(), "talkCasual", activePart, true), 1.0, SPEECH, true);
end )
onMsg("testCancel", function(msg)
if testCancel() then -- or (this.getParent().getActivityQueueCount() > 1)
local partner = retrieveStateObject("partner");
sendMsgThis("talkCanceled");
sendMsg("talkCanceled", partner);
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("talkCanceled", function(msg)
--local talkType = retrieveData("talkType", "Casual");
print("--talkCutscene Canceled--- " .. getParent().getCharacterName());
-- local activePart = retrieveData("activePart");
-- if (activePart == true) then
-- if (activeDiff("talk" .. talkType)) then
-- getParent().stopSound(genderize(getParent(), "talk".. talkType));
-- else
-- getParent().stopSound("talk".. talkType);
-- end
-- end
exitStateMachine();
end )
onMsg("end", function(msg)
print("--talkCutscene end --- " .. getParent().getCharacterName());
if testCancel() then
local partner = retrieveStateObject("partner");
sendMsgThis("talkCanceled");
sendMsg("talkCanceled", partner);
else
sendMsgThis("startLoop");
end
end )
onExit(function(msg)
print("--talkCutscene onExit --- " .. getParent().getCharacterName());
getParent().stopAllSounds();
-- local partner = retrieveStateObject("partner");
-- local activePart = retrieveData("activePart");
-- if (not activePart == false) then
-- getParent().popDummyQueueEntry();
-- end
-- this.getParent().stopAllActivities(partner.getParent());
-- getParent().setEmoticon("");
end )
-- failTalk
state("failTalkCutscene")
onEnter(function(msg)
print("--failTalkCutscene onEnter--- " .. getParent().getCharacterName());
local activePart = retrieveData("activePart");
if (activePart) then
local topic = retrieveData("topic"); if not topic then topic = ""; end;
getParent().sendMsg("talking", getParent().getGameObjectServer().mission, topic);
end
exitStateMachine();
end )
-- giveGift -----------------------------------------------------------------------------------------------
state("giveGift")
onEnter(function(msg)
print("----- " .. getParent().getCharacterName() .. " onEnter giveGift " .. tostring(testCancel()));
storeActivityPossible("giveGift");
-- if (activityPossible(getParent(), getState(), retrieveStateObject("partner").getParent())) then
-- storeData("activityPossible", true)
-- else
-- storeData("activityPossible", false)
-- end
-- periodically send a message to the other
-- character that this character is ready
sendDelayedMsgThis("ready", 1000);
-- or, after a longer period of waiting, stop waiting
sendDelayedMsgThis("stop", getInteractionWaitTime());
-- listen to queue message
-- actionComplete();
end )
-- onMsg("end", function(msg)
-- actionComplete();
-- end )
onMsg("queue", function(msg)
exitStateMachine();
end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting -----");
--exitStateMachine();
sendMsgThis("partnerfailed");
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
if (testCancel()) then
sendMsgThis("partnerfailed");
else
sendMsg("partnerReady", partner);
sendDelayedMsgThis("ready", 1000);
end
-- send a message to the partner
-- local partner = retrieveStateObject("partner");
-- if (retrieveData("activityPossible") == true) then
-- sendMsg("partnerReady", partner);
-- else
-- sendMsg("partnerfailed", partner);
-- end
-- sendDelayedMsgThis("ready", 1000);
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("doGiveGift");
sendMsg("partnerReady", partner);
end )
onMsg("partnerfailed", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " failed -----");
local partner = retrieveStateObject("partner");
setState("failGiveGift");
sendMsg("partnerfailed", partner);
end )
-- doGiveGift
state("doGiveGift")
onEnter(function(msg)
local activePart = retrieveData("activePart");
if (activePart == true) then
print("mike giving gift:" .. activePart);
getParent().handSO.stopAnimation(0.0);
startAnimation("giveGift", false, 1.0, 0.0);
local partner = retrieveStateObject("partner");
getParent().startActivity("giveGift", partner.getParent())
else
--print("" .. getParent().getCharacterName() .. " gets talked:" .. activePart);
freeHands(getParent());
startAnimation("takeGift");
sendDelayedMsgThis("transferGift", 4480);
end
end )
onMsg("transferGift", function(msg)
local partner = retrieveStateObject("partner");
local gift = partner.getParent().getRightHeldObject();
partner.getParent().detachRightObjectHolder();
getParent().attachRightObjectHolder(gift);
gift.buy();
end )
onMsg("end", function(msg)
if (activePart == true) then
exitStateMachine();
else
setState("checkGift");
end
end )
onExit(function(msg)
local partner = retrieveStateObject("partner");
this.getParent().stopAllActivities(partner.getParent());
print("stop giveGift");
end )
-- checkGift
state("checkGift")
onEnter(function(msg)
local gift = getParent().getRightHeldObject();
if (not gift) then exitStateMachine(); return end;
local checkGift = this.getParent().startActivity("checkGift", gift);
local length = getActivityLength(checkGift);
sendDelayedMsgThis("complete", length);
startAnimation("checkGift", false, 0.1, 1000);
sendMsg("smile", getParent().mimicSO);
end )
onMsg("complete", function(msg)
local gift = getParent().getRightHeldObject();
if (gift) then print("stop checkGift"); getParent().stopAllActivities(gift); end;
freeHands(getParent());
sendMsg("neutral", getParent().mimicSO);
exitStateMachine();
end )
onMsg("startAnim", function(msg)
startAnimation("checkGift");
end )
onMsg("end", function(msg)
if (testCancel()) then
sendMsgThis("complete")
else
startAnimation("checkGift", false, 0.1, 1000);
--sendDelayedMsgThis("startAnim", random(500,1000));
end
end )
-- failGiveGift
state("failGiveGift")
onEnter(function(msg)
local activePart = retrieveData("activePart");
if (activePart == true) then
freeHands(getParent());
sendMsg("sad", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_SAD, EMOTICON_DELAY);
else
sendMsg("angry", getParent().mimicSO);
getParent().setEmoticon(EMOTICON_ANGRY, EMOTICON_DELAY);
end
exitStateMachine();
end )
endStateMachine()