Hi, I'm looking to incorporate something similar to the last segment of MI2 in my game, with a character randomly entering the same room as the player character (like LeChuck with the Voodoo Doll).
I haven't a clue how to go about doing this. It would be done over a series of rooms, which makes it even more of a headache for me.
If anyone has any suggestions at all, they would be greatly appreciated. I'm in the dark on this one.
There's a couple of suggestions in this thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=29702.0). Are they any use? (I prefer KhrisMUC's, personally. It's a bit more work, but I think the result is better.)
Here's a shorter way:
Use the on_event function; something like this:
//global script
function repeatedly_execute() {
if (IsTimerExpired(1)) {
if (player.Room>=6 && player.Room<=9) CallRoomScript(1); // occurs in rooms 6-9
}
}
function on_event(EventType event, int data) {
if (event==eEventEnterRoomBeforeFadein) {
if (Random(2)==0) SetTimer(1, 160+Random(2)*40); // 33% Chance of entering the Room after 4 to 6 seconds
}
...
}
//room script in rooms 6-9
function on_call(int p) {
if ([p==1) {
// place LeChuck at an exit
}
}
Sorry for the late reply guys, and thanks for the code, it works perfectly.
I do have another request if anyone can help me out - I'd like to have a hotspot turn alternately on and off in 4 second intervals - it's an idea I have for a real time collision based puzzle - I was just wondering if it's possible to do this in the 'background', ie, non blocking. Any ideas?
Timers (SetTimer / IsTimerExpired) would seem to be made for that, or you could use your own variable and repeatedly_execute. Timers would be simpler, though.