Hey guys.
I had this idea last night for the game but not sure if possible
Since I'm still new to this.
Would it be possible to have an item in inventory that when
Used on the character a NPC appears next to the player
And you can then ask questions on tips and control help.
All I can think of is either place a character to appear in different
Hotspots or regions but that would just be a mess
Or I could have the character change room to like lets say inside this NPC's
Home and when done it would take you back to previous room.
I don't know tho.
I did look at previous topics on placing items anywhere and thought maybe I
Could change item to character but doesn't seem they found a way and those topics were
From 2007. So maybe it's possible now.
You mean like you rub a lamp and a genie appears, or something like that? Certainly it's possible.
I'm not sure exactly what the problem is, actually. To place a character at coordinates x,y in the current room, you can write:
cGenie.ChangeRoom(player.Room, x, y);
And to make them appear right next to the player, you can use the player's coordinates: cGenie.ChangeRoom(player.Room, player.x + 20, player.y);
You can even check for walkable areas first, and choose a suitable position (using GetWalkableAreaAt(), found under Room functions).
You could also set a position for each room:
// in each room_Load
genieX = 123;
genieY = 150;
Say the interaction will make the player walk there first, then display the NPC at genieX + 20, genieY. Now simply choose an appropriate spot for each room, away from walls and inside the main walkable area.
(genieX and genieY would be global variables created by you.)
You could certainly make it appear as if an inventory item changed into a character (lamp becomes genie).
I'll make up an example. Maybe the genie fades in and out of view, and if you use the lamp on him you get to talk to him.
GENIE_IS_VISIBLE = false // global variable
bool genie_partial = false;
function room_Load()
{
cGenie.Transparency = 100;
// you probably also have to place him somewhere in the room where no one bumps into him
}
function room_RepExec()
{
int i = 0;
// partially appear approx. once per 25 seconds
if (Random(1000) == 0 && !GENIE_IS_VISIBLE) {
// appears next to Ego
cGenie.x = cEgo.x + 20;
cGenie.y = cEgo.y;
while (i < 30) {
// bring him partially from hiding
cGenie.Transparency = 100 - i;
i++;
Wait(1);
}
// flag that he is now partially visible
genie_partial = true;
}
//else if (!genie_is_visible) {
// hide him when not talking to him
//cGenie.Transparency = 100;
//}
else if (genie_partial && Random(200) == 0) {
i = 0;
while (i < 30) {
// fade him away within approx 5 seconds
if (cGenie.Transparency < 100) cGenie.Transparency = 70 + i;
i++;
Wait(1);
}
genie_partial = false;
}
}
function cGenie_UseInv()
{
// Ego uses lamp on genie only when he is partially visible
if (cEgo.ActiveInventory == iLamp && genie_partial) {
cGenie.Transparency = 0;
// flag to avoid RepExec code
GENIE_IS_VISIBLE = true;
genie_partial = false;
// remove lamp from inventory
cEgo.LoseInventory(iLamp);
// remove lamp cursor
mouse.Mode = eModePointer; // or any mode you want
// start dialog
dTalkToGenie.Start();
}
}
Dialog dTalkToGenie
@S
Genie: You rang master?
return
@1
Genie: <answer question>
return
@2
Genie: I have answered your questions
Genie: I am leaving you now
// make him disappear
int i;
while (i < 101) {
cGenie.Transparency = i;
Wait(1);
i++;
}
GENIE_IS_VISIBLE = false;
// lamp back in inventory
cEgo.AddInventory(iLamp);
stop
Hopefully someone will jump in if I made a mistake or has a better idea!
Edit: Code had mistakes
sorry for not replying sooner. been having connection problems.
will definitely try those once I get to the part of the game story. will then let you guys know if I have any problems getting it right.
Got my Characters creature appearing next to her
Whenever I use an inventory item on her. Also I made it so that
The character changes room to where the player is and
Automatically start dialog and then dissapears again when dialog has ended.
Took me awhile to figure out how to make him go away at end of dialog and to also say
Something different every time his summoned.