Hide and Seek
jaydee
09 Dec 2015, 10:44Hi All,
Need a little advice on how to script this, I'm looking at a section in my adventure where you have to avoid a wandering monster which moves from room to room, if it finds you I want situation based text to appear depending on the room you are in and your condition, so far the code I have only works if you directly enter into the room with the monster in which case it works fine....BUT.... If the monster enters into the same room as the player it simply updates the contents of the room, no message is played and the monster leaves, how can I change this?
Need a little advice on how to script this, I'm looking at a section in my adventure where you have to avoid a wandering monster which moves from room to room, if it finds you I want situation based text to appear depending on the room you are in and your condition, so far the code I have only works if you directly enter into the room with the monster in which case it works fine....BUT.... If the monster enters into the same room as the player it simply updates the contents of the room, no message is played and the monster leaves, how can I change this?
The Pixie
09 Dec 2015, 10:57We need more details on how you implemented what you have already done. What triggers the "if you directly enter into the room with the monster" thing? Is that a script in that room that checks or a turn script perhaps? Where have you implemented "situation based text to appear depending on the room you are in and your condition"?
The way I would do it is to have a function that tests if the player is in the same room as the monster, and if it is, do whatever. Have that called when the player enters one of the relevant rooms. Then have a turnscript to control moving the monster, and call the function after the monster moves a well.
The way I would do it is to have a function that tests if the player is in the same room as the monster, and if it is, do whatever. Have that called when the player enters one of the relevant rooms. Then have a turnscript to control moving the monster, and call the function after the monster moves a well.
jaydee
09 Dec 2015, 21:58Ok so far i have a timer based script that moves the monster character from room to room with intervals between 10secs - 60 secs, it has a attribute called hunting and its currently structured that if the attribute is true and the monster is in the same room as a player then situational based text should play, now the script works fine if the player moves into a room with the monster but nothing happens at all if the monster moves into a room already occupied by the player object.
I'm wondering if I change the script to have the player character removed and then moved back into the room when the monster enters would solve the problem?
I'm wondering if I change the script to have the player character removed and then moved back into the room when the monster enters would solve the problem?
HegemonKhan
09 Dec 2015, 23:15there's two parts to this, so conceptually those two parts are:
1. code that randomly moves your monster to a room (aka 'psuedo'-randomly selects a room from an objectlist of rooms for that monster to be in or 'moved to').
2. code that: (A) checks (the 'if' Script) if the monster is in same room as player every time (via the 'Turnscript Element or the special 'changedparent' Script) you move to a room (B) if so, then the code (the 'if' Script) checks for what room you're both in (to 1/2 determine what action~event occurs) and (C) to check (the 'if' Script) your condition (to 1/2 determine what action~event occurs), and lastly (D) that does an action~event based upon both the room you're in and what condition you're in (the 'if' Script's 'then' script).
1. code that randomly moves your monster to a room (aka 'psuedo'-randomly selects a room from an objectlist of rooms for that monster to be in or 'moved to').
2. code that: (A) checks (the 'if' Script) if the monster is in same room as player every time (via the 'Turnscript Element or the special 'changedparent' Script) you move to a room (B) if so, then the code (the 'if' Script) checks for what room you're both in (to 1/2 determine what action~event occurs) and (C) to check (the 'if' Script) your condition (to 1/2 determine what action~event occurs), and lastly (D) that does an action~event based upon both the room you're in and what condition you're in (the 'if' Script's 'then' script).
jaydee
09 Dec 2015, 23:331.ok so the first one i have already, a timer script that moves the monster in a set path so thats done.
2. what exactly is the "changedparent" script, cant seem to find it?
2. what exactly is the "changedparent" script, cant seem to find it?
jaydee
09 Dec 2015, 23:58This still doesn't seem to work since the script only seems to activate when entering into a room, but if you are already present in a room then nothing seems to refresh and the script doesn't become active
Marzipan
10 Dec 2015, 00:13HegemonKhan wrote:there's two parts to this, so conceptually those two parts are:
1. code that randomly moves your monster to a room (aka 'psuedo'-randomly selects a room from an objectlist of rooms for that monster to be in or 'moved to').
Hijacking the thread a bit here with a question of my own, but is there a straightforward way to have the NPC move realistically? A guard that always patrols a set route, for instance, where you'd want them walking down the street in a logical way instead of teleporting around. In ADRIFT you could set 'walks' for NPCs as a simple way to do this, and it's something I haven't been able to emulate yet in Quest.
jaydee
10 Dec 2015, 00:18Ohhh i think i have something, a cycling turn script which constantly checks every second for the monster until its detected, if the monster is present then the script de-activates for a period of time before enabling again.
jaydee
10 Dec 2015, 00:21as for the movement of an NPC i have mine set as a timer script which places the NPC at a set point, waits for a while then moves the NPC object to the next location that you want them to go to then keep repeating until the NPC has walked to everywhere you want them to go
HegemonKhan
10 Dec 2015, 07:07the way I was hinting at is done by having the player's special 'changed' (using 'changedparent' specifically) Script to randomly re-assign the monster to a room, as you move (re-assign yourself, lol) to a room.
http://docs.textadventures.co.uk/quest/ ... anges.html (the special 'changed' Script)
and then you use a (global) Turnscript Element to check if you and monster are in same room, and then to check what room you're both in, and to check what condition you're in, to determine what action(s)~event(s) (script~s) to do.
....
actually it may be better to do it all in the 'changedparent' Script... all you got to do would be to have the monster's room-assigning script(s) to occur first before the checking scripts:
you move
the monster moves
and then the checking
you move
the monster moves
and then the checking
you move
the monster moves
and then the checking
etc
etc
etc
http://docs.textadventures.co.uk/quest/ ... anges.html (the special 'changed' Script)
and then you use a (global) Turnscript Element to check if you and monster are in same room, and then to check what room you're both in, and to check what condition you're in, to determine what action(s)~event(s) (script~s) to do.
....
actually it may be better to do it all in the 'changedparent' Script... all you got to do would be to have the monster's room-assigning script(s) to occur first before the checking scripts:
you move
the monster moves
and then the checking
you move
the monster moves
and then the checking
you move
the monster moves
and then the checking
etc
etc
etc

Pertex
10 Dec 2015, 07:21Be careful with changedparent. The script is used in the Quest core so overwriting it could be dangerous
HegemonKhan
10 Dec 2015, 18:46that's not good... I guess then we can use the Turnscript Element, but that'd take a bit more code work (your movement: saving the previous room and new room, then comparing them for whether you actually moved to a new room, and etc possible coding stuff needed), as the 'changedparent' does some of that for you.
wow, I never realized I was overwritting the built-in code all this time with using 'changedparent' (in hindsight I'm stupid, laughs), well, I won't be using it any more now, as I may want the built-in stuff of it, and especially of course wouldn't want to wreck the game so it's unplayable, laughs.
wow, I never realized I was overwritting the built-in code all this time with using 'changedparent' (in hindsight I'm stupid, laughs), well, I won't be using it any more now, as I may want the built-in stuff of it, and especially of course wouldn't want to wreck the game so it's unplayable, laughs.
The Pixie
10 Dec 2015, 19:04Use the "roomenter" script on the game object (it even has a GUI, look on the Scripts tab).
HegemonKhan
10 Dec 2015, 19:12ah, is this a global 'on enter room', ie for all rooms you enter? I should learn more of the built-in stuff, laughs.
Thanks Pixie!
Thanks Pixie!
The Pixie
10 Dec 2015, 19:42Yes it is. I think it appeared fairly recently, 5.5 I think. If you started using Quest before that, you could easily miss it. I did for quite a while.