implemented drinking guard time challenge

svn-id: r45769
This commit is contained in:
Vladimir Menshakov 2009-11-08 23:32:01 +00:00
parent 8edfd6b56c
commit 83713e92fa
4 changed files with 56 additions and 18 deletions

View File

@ -754,20 +754,29 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
if (CHECK_FLAG(0xDB9C, 1))
return true;
SET_FLAG(0xDB9C, 1); //guard's drinking, boo!
SET_FLAG(0, 3);
setTimerCallback(0x516d, 40); //fail
playAnimation(544, 0);
return true;
case 0x516d:
SET_FLAG(0, 0);
return true;
case 0x5189:
SET_FLAG(0, 0);
setTimerCallback(0, 0);
scene->cancelAnimation(0);
SET_FLAG(0xDB9C, 1); //guard's drinking, boo!
displayAsyncMessage(0x3563, 320 * 130 + 300, 1, 5);
setOns(0, 16);
enableObject(2);
playSound(17, 5);
displayAsyncMessageInSlot(0x3563, 1, 60, 70);
playAnimation(545, 0);
Dialog::show(scene, 0x0917, 0, 546, 0xd1, 0xd9, 0, 1);
playActorAnimation(546);
SET_FLAG(0xDA96, 1);
SET_FLAG(0xDA97, 0);
return true;
@ -2235,16 +2244,16 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return false;
case 0x8117:
Dialog::show(scene, 0x0a41, 529);
Dialog::show(scene, 0x0a41, 0, 529, 0xd1, 0xd9, 0, 1);
playSound(5, 2);
playSound(5, 44);
playAnimation(642, 1, true);
playAnimation(642, 0, true);
playActorAnimation(641, true);
waitAnimation();
Dialog::show(scene, 0x0aff, 529);
Dialog::show(scene, 0x0ba0, 529);
Dialog::show(scene, 0x0aff, 0, 529, 0xd1, 0xd9, 0, 1);
Dialog::show(scene, 0x0ba0, 0, 529, 0xd1, 0xd9, 0, 1);
moveRel(0, 1, 0);
Dialog::show(scene, 0x0c10, 529);
Dialog::show(scene, 0x0c10, 0, 529, 0xd1, 0xd9, 0, 1);
inventory->remove(50);
processCallback(0x9d45);
return true;
@ -3857,16 +3866,18 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
return true;
case 0x9de5:
hideActor();
loadScene(30, scene->getPosition());
playAnimation(887, 1, true);
playAnimation(888, 2, true);
waitAnimation();
Dialog::show(scene, 0x6fb8);
Dialog::show(scene, 0x6fb8, 889, 890, 0xd9, 0xd0, 2, 3);
playSound(26, 3);
playAnimation(891, 1, true);
playAnimation(892, 2, true);
waitAnimation();
Dialog::show(scene, 0x6ff0);
Dialog::show(scene, 0x6ff0, 890, 889, 0xd0, 0xd9, 3, 2);
showActor();
return true;
case 0x9e54:

View File

@ -37,7 +37,7 @@ Scene::Scene() : intro(false), _engine(NULL),
_system(NULL),
_id(0), ons(0),
orientation(Object::kActorRight),
message_timer(0), message_first_frame(0), message_last_frame(0),
message_timer(0), message_first_frame(0), message_last_frame(0), message_animation(NULL),
current_event(SceneEvent::kNone), hide_actor(false), callback(0), callback_timer(0) {}
void Scene::warp(const Common::Point &_point, byte o) {
@ -294,6 +294,16 @@ void Scene::playActorAnimation(uint id, bool loop) {
actor_animation.loop = loop;
}
bool Scene::cancelAnimation(byte slot) {
assert(slot < 4);
if (custom_animation[slot].empty())
return false;
else {
custom_animation[slot].free();
return true;
}
}
void Scene::push(const SceneEvent &event) {
//debug(0, "push");
//event.dump();
@ -485,8 +495,9 @@ bool Scene::render(OSystem *system) {
if (!message.empty()) {
bool visible = true;
if (message_first_frame != 0) {
int index = actor_animation.currentIndex() + 1;
if (message_first_frame != 0 && message_animation != NULL) {
int index = message_animation->currentIndex() + 1;
debug(0, "message: %s first: %u index: %u", message.c_str(), message_first_frame, index);
if (index < message_first_frame)
visible = false;
if (index > message_last_frame) {
@ -501,7 +512,7 @@ bool Scene::render(OSystem *system) {
}
}
if (!busy && callback_timer) {
if (callback_timer) {
if (--callback_timer == 0) {
if (_engine->inventory->active())
_engine->inventory->activate(false);
@ -597,10 +608,18 @@ bool Scene::processEventQueue() {
case SceneEvent::kCreditsMessage:
case SceneEvent::kMessage: {
message = current_event.message;
message_animation = NULL;
if (current_event.first_frame) {
message_timer = 0;
message_first_frame = current_event.first_frame;
message_last_frame = current_event.last_frame;
if (current_event.slot < 4) {
message_animation = custom_animation + current_event.slot;
//else if (!animation[current_event.slot].empty())
// message_animation = animation + current_event.slot;
} else
message_animation = &actor_animation;
debug(0, "async message %d-%d (slot %u)", message_first_frame, message_last_frame, current_event.slot);
} else {
message_timer = messageDuration(message);
message_first_frame = message_last_frame = 0;
@ -798,6 +817,7 @@ void Scene::clearMessage() {
message_color = 0xd1;
message_first_frame = 0;
message_last_frame = 0;
message_animation = NULL;
}
} // End of namespace TeenAgent

View File

@ -148,6 +148,7 @@ public:
Object *findObject(const Common::Point &point);
void loadObjectData();
bool cancelAnimation(byte slot);
private:
void loadOns();
@ -192,6 +193,7 @@ private:
uint message_timer;
byte message_first_frame;
byte message_last_frame;
Animation * message_animation;
typedef Common::List<SceneEvent> EventList;
EventList events;

View File

@ -300,10 +300,15 @@ Common::Error TeenAgentEngine::run() {
}
break;
case Common::EVENT_LBUTTONDOWN:
examine(event.mouse, current_object);
break;
case Common::EVENT_RBUTTONDOWN:
use(current_object);
if (res->dseg.get_byte(0) == 3) {
processCallback(0x5189); //boo!
break;
}
if (event.type == Common::EVENT_LBUTTONDOWN)
examine(event.mouse, current_object);
else
use(current_object);
break;
case Common::EVENT_MOUSEMOVE:
mouse = event.mouse;