Inventory dependant hotspots

Started by NeuroticNugg, Mon 07/02/2011 22:04:24

Previous topic - Next topic

NeuroticNugg

Hi everyone,

I'm still making progress on the game I mentioned in my post over Christmas, only I've gotten stuck again...

I want to make a room where the hotspot is dependant on you having been to another room and seen/experienced the event that happens.

So I have 4 or 5 rooms which all lead together, and the last one - let's say this is room4, is dependant on you having walked into room2 and having seen a scene. If you go in before it will just give you a random message saying "No" or something.

In my head it looks like:

if cEgo [has been to] room2 [then take action x]
if cEgo [has not been to] room 2 [then Display("No, you can't use that yet.");

Can anyone help? I had thought of maybe making the final string in room 4's code so that it adds an inventory item, which if you have allows you to use the hotspot (as I'm not using the inventory for the purposes of this game), but I couldn't figure this out either... If anyone can help either way I'd appreciate it immensely!

Many thanks

NeuroticNugg
[Newb who laughs at his own failure]

NeuroticNugg

Sorry - misleading heading - Didn't think before posting... Either inventory dependant or some other dependancy I'm still to figure out.

Thanks again!

NN

Dualnames

#2
1) Declare variable on Global Variables


Name: beenonroom2
Type: boolean
Value: false


Code: ags

function on_event (EventType event, int data) { //Global Script
if ((event==eEventEnterRoomBeforeFadein) && (data==2)) {
if (Game.DoOnceOnly("justonce")) beenonroom2=true;
}



Code: ags

function room_RepExec(){//this is on room 4 additionally this can go on the on event. Not sure exactly from your description
 if (beenonroom2) {
 // [then take action x]
 }
 else {
  Display("No, you can't use that yet.");
 }
}

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

NeuroticNugg

Ok, so I've set up the global variable, pardon my denseness, but do I put the first code in room 2 as a new function or mix it up with the event??? My event on entering the room is:

// room script file

function room_FirstLoad()
{
  cPlayer2.Say("Speech text");
  cPlayer1.Say("Speech text");
  cPlayer2.Say("Speech text");
}

The way I'm understanding it I add your code in after this part as a new function?

Thanks for your help!

NN

Dualnames

This code goes into the global script. Not the room.

Code: ags

function on_event (EventType event, int data) { //Global Script
if ((event==eEventEnterRoomBeforeFadein) && (data==2)) {
if (Game.DoOnceOnly("justonce")) beenonroom2=true;
}


Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

There's a function for this condition:

HasPlayerBeenInRoom()

In general though, stuff like this is done with variables, yes (NOT WITH INVENTORY ITEMS, JEEZ).

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk