Look and Global Turn [SOLVED]

Anonynn
I was wondering, how do you skip a global turn? And how do you remove "look" from being a turn?

I know when you create a turn-script and have a specific thing advancing like ...

Set this.blahscript = this.blahscript + 1
if (this.blahscript=10)
then blah blah.

The reason I ask is simply because I would like for enemies not to immediately attack a player but to give them a turn to read things and spot the enemy and even "look" at their surroundings or the enemies without having the crap kicked out of them :P

XanMag
Brace yourself for next level stupidity...

Here's what initially came to mind. Go to the built-in commands and add a script to the functions that you don't want to count as a turn (like 'look', 'lookat'). Something like this.turnscript - 1 to counter the built-in +1? :lol: Or call a function that adds + 0 to this.turnscript in those commands? Would that override the built-in?

There are a LOT of assumptions in that thought... I don't know enough about the built-in functions to manipulate the code behind them. Just enough to screw up the whole damned game...

Is it in here somewhere?
SetTurnTimeOut (I think was the name)
this.turncount = this.turncount + 1
if (this.turncount >= this.triggerturncount) {
this.enabled = false
invoke (this.timeoutscript)
destroy (this.name)
}


I realize I should never volunteer personal ideas I have about code... :roll:

HegemonKhan
see Pixie's post on using 'notarealturn' in the link below:

viewtopic.php?f=10&t=5267&p=36333&hilit=notarealturn#p36326

essentially conceptually, all you do is to create a Turnscript that will be your unversal-game-master Turnscript, have a script that checks a custom (your own created) Boolean Attribute (Pixie's 'notarealturn' custom Boolean Attribute), so you can control/prevent scripts from occuring. Have all the scripts that use up a game turn be the scripts for when that 'if boolean attribute is true', and all the scripts that don't use up a turn be the scripts for the 'else'. Thus you can use the Boolean Attribute as a flag for when a turn occurs and when it doesn't. Also you create your own 'turn' Integer Attribute, so you can control it, whereas you'd otherwise need to delve into the built-in code and how it handles its "internal turns"... better not do this, unless you know programming well, lol. Create your own turns, much easier:

<game name="xxx">
<attr name="game_advancement" type="boolean">true</attr>
<attr name="game_turn" type="int">0</attr>
</game>

<turnscript name="global_turnscript">
<enabled />
<script>
if (game.game_advancement) { // if (game.game_advancement = true)
// all your scripts that advance the game turn count
game.game_turn = game.game_turn + 1
} else { // if (game.game_advancement = false)
// all your scripts that don't advance the game turn count
}
</script>
</turnscript>


// and for every action, you'll need to "set" (game.game_advancement = true) or "clear" (game.game_advancement = false), as needed

// and/or you can also "outsource" the control of the scripts and the amount that the 'game.game-turn' increases by, from the global turnscript to the individual actions, so you have greater control. This way, you can have each individual action advance the turns by 5 or 10 or 1 or whatever

XanMag
See... That makes more sense!

HegemonKhan
Pixie's code shows how to do it more correctly/functionally, "outsourcing" the handling to the individual actions (which is much better than my code example of trying to have those actions inside of the Turnscript - as actions inside of the turnscript would have to be universal/turn-constantly occuring actions for when the boolean is set to true, and the same universality/non-turn constantly occuring for the non-turn actions when the boolean is set to false), by having the global/universal/master Turnscript, only handling the increase of the turn count or not.

------

for example (expanded the design, combining Pixie's "outsourcing" and my global actions and added in an extra functionality too):

my global action is the checking script to end the game if the player is dead: player.current_life <= 0, as this is a global action it's in the global/master turnscript

whereas, the "info" and "sleep" and "rest" and "nap" Commands, are individual actions, and thus their scripts aren't inside the global/master turnscript, as we want to uniquely specify how many turns they use up (or if they don't use up a turn at all) and when they occur (we don't want them to be always occuring, lol. Whereas we do want to be always checking the player's life to see if he/she is dead, ending the game if he/she is dead).

added extra functionality:
notice how I'm using the 'previous_game_turn' to determine/handle whether to increase the game turn by 1 or not. This is because you don't want to "sleep" (+8 hrs) and then also have it advance another turn too (+1), for a total of +9 hrs, when you want sleeping to just be +8 hrs. Also, as +1 game turn (1 turn = 1 hr) is our smallest/default value (in this example game we don't want to use minutes / fractional-decimal hours), we're putting it in the turnscript, so that we only need to do this once, as we don't want to be doing/writing/coding it in multiple times - in every individual action that only increases the game turn by 1, lol.

(HK Edit: I just finished editing in all the small mistakes I've had priorly to now, so refresh and look at the current and corrected code of mine below)

<game name="xxx">
<attr name="game_advancement" type="boolean">true</attr>
<attr name="current_game_turn" type="int">0</attr>
<attr name="previous_game_turn" type="int">0</attr>
</game>

<command name="info_command">
<pattern>info</pattern>
<script>
game.game_advancement = false // this prevents a turn from occuring (see the turnscript code for why/how)
ClearScreen
msg ("Name: " + player.alias)
// etc etc etc
wait {
ClearScreen
}
// the turnscript will change the game.game_advancement's value back to 'true', so game turns/advancement will occur again, so we don't need to do it here, as the turnscript does it for us.
</script>
</command>

<command name="sleep_command">
<pattern>sleep</pattern>
<script>
game.previous_game_turn = game.current_game_turn
msg ("You sleep for 8 hrs.") // 1 hr = 1 turn
game.current_game_turn = game.current_game_turn + 8
</script>
</command>

<command name="rest_command">
<pattern>rest</pattern>
<script>
game.previous_game_turn = game.current_game_turn
msg ("You rest for 4 hrs.") // 1 hr = 1 turn
game.current_game_turn = game.current_game_turn + 4
</script>
</command>

<command name="nap_command">
<pattern>nap</pattern>
<script>
game.previous_game_turn = game.current_game_turn
msg ("You nap for an hour.") // 1 hr = 1 turn
// the turnscript will advance the turn by 1, so you don't need to do it here
</script>
</command>

<turnscript name="global_turnscript">
<enabled />
<script>
if (player.current_life <= 0) {
msg ("You're dead or you've died.")
msg ("GAME OVER")
finish
} else if (game.game_advancement and game.current_game_turn = game.previous_game_turn) {
game.current_game_turn = game.current_game_turn + 1
} else if (not game.game_advancement) {
game.game_advancement = true
}
</script>
</turnscript>


// a global Turnscript is for handling the "game state", for example:

if you're dead, the game should end
if the game is set to advance, and the individual action hasn't increased the turns, then increase the turns by 1
if the game is not set to advance, set it to advance
etc etc etc universal/global "game state" handling stuff (some other examples: weather/day-night/seasons/climate/etc effects, game events, npc movement, whatever else you can think of)

Anonynn
Hm. Well, I set up Pixie's notarealturn thing on my "lookat" command and "search_room" command which was a big issue but now isn't! But I still don't know how to skip a single global turn. I don't really need a new turn-script or attribute because I just need the universal turn-script to pause in one specific instance like entering a new room and then resuming once the player is inside. To prevent enemies from instantly attacking.

Would it be something like...

game.turnscript = game.turnscript = 0

or something?

Also, appreciate you both: Xan and HK for chiming in so far! :D

UPDATE:

Actually, this...

game.turnscript = game.turnscript + 1 from Pix's code is causing arithmetic errors @_@

HegemonKhan
I edited in more (code and text) to my previous post, it covers how to handle whether an action is a turn or not. Though, it's deisgn will take quite a bit of added in implementation, for your game.

use the same design concept for individual rooms... if you don't have or want a global turnscript, you can create a local turnscript for that specific room

the key is having your own: 'turn' Integer Attribute and a 'notarealturn' Boolean Attribute, allowing you to control (code in) where/when you want the turns to increase (and by how much) or to not increase.

HegemonKhan
Neonayon wrote:But I still don't know how to skip a single global turn. I don't really need a new turn-script or attribute because I just need the universal turn-script to pause in one specific instance like entering a new room and then resuming once the player is inside. To prevent enemies from instantly attacking.

Would it be something like...

game.turnscript = game.turnscript = 0

or something?

Also, appreciate you both: Xan and HK for chiming in so far! :D

UPDATE:

Actually, this...

game.turnscript = game.turnscript + 1 from Pix's code is causing arithmetic errors @_@


I don't think you want to name-label your Integer Attribute as 'turnscript' (this may even cause errors/issues for quest's compiler's parsing), name-label it as 'turn' or 'game_turn' or whatever:

game.turn
game.game_turn
game.turns
game.turn_count
game.turn_integer
game.current_game_turn
etc etc etc
etc etc etc
(you don't have to use the 'game' Game Object as well, you could use whatever Object you want)

-----------

as for getting your rooms to work with not advancing a turn, hopefully this will not be too much work for you to, adapt-for and implement-into, your game:

for example, using your 'onenterroom' Script (but apply the below code, adjusted for your game of course, for any/all relevant scripts, not just the 'onenterroom' Script):

for each relevant room:

(you'll need some script beforehand to determine what is the value of your Boolean Attribute, of course)

'whatever' Room Object -> ?Scripts/Room Description? (whichever it is, meh) Tab -> 'onenterroom' -> run as script -> add new script -> (see below)

(I'll use 'turn_flag' but you can use 'notarealturn' if you prefer as the name-label for your Boolean Attribute, though beware that our true/false logic is inverse/opposite to each other, aka: 'game.turn_flag = true ==== game.notarealturn = false' and 'game.turn_flag = false ==== game.notarealturn = true', and/or: 'game.turn_flag ==== not game.notarealturn' and 'not game.turn_flag ==== game.notarealturn' )

if (not game.turn_flag) { // if (not game.turn_flag = true) // if (not true) // if (false) // aka: not a real/active turn
show menu ("You cautiously enter the room, noticing it filled with webbing... and you spot a giant spider in the upper left corner... luckily, it hasn't seen you yet, giving you enough time to decide what to do...", split ("back out of the room very carefully; use your lit torch to ignite the webbing; etc etc etc", ";"), false) {
switch (result) {
case ("back out of the room very carefully") {
msg ("As you try to move carefully back out of the room, unfortunately a part of your body touches a web strand, sending vibrations to the giant spider, which with surprising speed is right behind you as you run into the previous room... FIGHT and win... or get eaten...")
invoke (spider.fight_script_attribute)
}
case ("use your lit torch to ignite the webbing") {
msg ("Despite that the giant spider would have probably eaten you, you feel terrible as you watch the spider burn alive, screaming just as if it were human being burnt alive. You shudder at the cruelty posed by the situation you found yourself in, though you are glad that you're the one alive...")
}
// etc etc etc
}
} else { // if (not game.turn_flag = false) //if (not false) // if (true) // aka: a real/active turn
msg ("You cautiously enter the room, noticing it filled with webbing... and you spot a giant spider in the upper left corner... unfortunately, it sees you too...")
invoke (spider.fight_script_attribute)
}

The Pixie
Just to be clear, here is what you need to do:

This goes in your turn script:
if (not game.notarealturn) {
game.turncount = game.turncount + 1
}
game.notarealturn = false

Go to the Attributes tab of the game object, and add these attributes:
turncount, an integer set to 0
notarealturn, a boolean set to false
unresolvedcommandhandler, script set to game.notarealturn = true

You then need to override the look command. Set the filter at the very bottom left to show everything, then look for the Look command. The script is this:
ShowRoomDescription

Copy the command to your game (button top right) and just add:
game.notarealturn = true

Anonynn
Yup. I did all of that already, but when I type "look" and "x me" the enemies still attack.

HegemonKhan
maybe you could post one of your relevant 'look' Verbs/Script Attributes, your relevant code pieces of Pixie's 'notarealturn and whatever' stuff, and one your enemy attacking code stuff (however you have it setup), so we can see if we can spot why it might not be working.

Anonynn
Sure thing :p

Lookat

if (GetBoolean(object, "hidechildren")) {
object.hidechildren = false
}
if (TypeOf(object, "look") = "script") {
do (object, "look")
}
else {
lookdesc = ""
if (HasString(object, "look")) {
lookdesc = object.look
}
if (LengthOf(lookdesc) = 0) {
lookdesc = Template("DefaultObjectDescription")
}
if (GetBoolean(object, "switchedon")) {
if (HasString(object, "switchedondesc")) {
lookdesc = lookdesc + " " + object.switchedondesc
}
}
else {
if (HasString(object, "switchedoffdesc")) {
lookdesc = lookdesc + " " + object.switchedoffdesc
}
}
isDark = CheckDarkness()
if (isDark and not GetBoolean(object, "lightsource")) {
lookdesc = DynamicTemplate("LookAtDarkness", object)
}
msg (lookdesc)
}
ListObjectContents (object)
game.notarealturn = True


Look

ShowRoomDescription
game.notarealturn = True



Attack Turn-Script

foreach (o, GetDirectChildren(player.parent)) {
if (GetBoolean(o, "attacking_player")) {
if (o.health > 1) {
do (o, "attackplayer")
}
}
}

HegemonKhan
try putting the 'game.notarealturn = true' at the top of your codes/scriptings:

Lookat (edited):

game.notarealturn = True
if (GetBoolean(object, "hidechildren")) {
object.hidechildren = false
}
if (TypeOf(object, "look") = "script") {
do (object, "look")
}
else {
lookdesc = ""
if (HasString(object, "look")) {
lookdesc = object.look
}
if (LengthOf(lookdesc) = 0) {
lookdesc = Template("DefaultObjectDescription")
}
if (GetBoolean(object, "switchedon")) {
if (HasString(object, "switchedondesc")) {
lookdesc = lookdesc + " " + object.switchedondesc
}
}
else {
if (HasString(object, "switchedoffdesc")) {
lookdesc = lookdesc + " " + object.switchedoffdesc
}
}
isDark = CheckDarkness()
if (isDark and not GetBoolean(object, "lightsource")) {
lookdesc = DynamicTemplate("LookAtDarkness", object)
}
msg (lookdesc)
}
ListObjectContents (object)


Look (edited):

game.notarealturn = True
ShowRoomDescription


and for your 'attacking' Turnscript, you're missing the needed code for handling whether to attack right away or not, the edited code is shown below:

foreach (o, GetDirectChildren(player.parent)) {
if (GetBoolean(o, "attacking_player")) {
if (o.health > 1) {
if (game.notarealturn) {
do (o, "attackplayer")
}
// since this is a Turnscript, it'll keep checking/running, and thus, if/when 'game.notarealturn = true', the enemy will attack, and if/when 'game.notarealturn = false', the enemy will not attack.
}
}
}


lastly, you do need to have Pixie's global Turnscript (or if you already have a global Turnscript, then it needs the code below inside of it), for all of this to work, with using this same implementation as Pixie's:

<game name="xxx">
</game>
// the 'game' Object, is just added to show that the Turnscript below is a global Turnscript, and not a local Turnscript for a specific room

<turnscript name="xxx">
<enabled />
<script>
if (not game.notarealturn) {
game.turn = game.turn + 1 // or whatever is your Integer Attribute's name/label for your turns
}
game.notarealturn = false
</script>
</turnscript>

The Pixie
Neonayon wrote:Yup. I did all of that already, but when I type "look" and "x me" the enemies still attack.

Ah that is something different. In fact two different things. HK has pretty much said this but...

First "x me" is the lookat command, so you will need to copy that to your game too, and add:
game.notarealturn = true

... to that too (it will apply to looking at anything by the way).

To stop monsters attacking, you will need to combine your monster attack turnscript with the turn counting turnscript, because we need to be sure the monster attack bit is done first. I would start by copying both scripts to a text file as a back up.

The new script needs to look like this:

if (not game.notarealturn) {
[everything from the monster attack script]
}
[everything from the turn counting script]

You also need to delete the old scripts (or the monsters will attack twice!).

HegemonKhan
sorry about the/my incorrect monster scripting, neonayon (and Pixie too).

Do as Pixie correctly instructs about how it's to be done.

Anonynn
Ah okay!

I didn't want the monster's to never attack but to delay their attacks when you enter a room for 1 turn. Like for example...

Player enters room with monster.
nothing happens.
player picks up object.
Monster attacks player.

UPDATE:

Also, still getting attacked when looking. Hm.

HegemonKhan
for that, you're going to need to implement two 'turn' Integer Attributes:

game.previous_turn // or however you want to name/label it
game.current_turn // or however you have it already named/labeled

*************
the default/basic concept of what system you're doing:

initial setting:
game.previous_turn = 0
game.current_turn = 0

(1) first (1 turn) action -> game.current_turn = game.current_turn + 1

// game.current_turn = 1
// game.previous_turn = 0

(2) save the new previous turn via: game.previous_turn = game.current_turn // game.previous_turn = game.current_turn = 1

// game.current_turn = 1
// game.previous_turn = 1

(3) second (1 turn) action -> game.current_turn = game.current_turn + 1

// game.current_turn = 2
// game.previous_turn = 1

(4) save the new previous turn via: game.previous_turn = game.current_turn // game.previous_turn = game.current_turn = 2

// game.current_turn = 2
// game.previous_turn = 2

(5) third (1 turn) action -> game.current_turn = game.current_turn + 1

// game.current_turn = 3
// game.previous_turn = 2

(6) save the new previous turn via: game.previous_turn = game.current_turn // game.previous_turn = game.current_turn = 3

// game.current_turn = 3
// game.previous_turn = 3

(7) fourth (1 turn) action -> game.current_turn = game.current_turn + 1

// game.current_turn = 4
// game.previous_turn = 3

etc etc etc

// or you do an action that increases the turn count by more than 1... (the above only samples when you're increasing the turns by 1 each time)... example of dynamic turn increasing (non-default of +1 turns) below:

initial setting:
game.previous_turn = 0
game.current_turn = 0

(1) first (5 turn) action -> game.current_turn = game.current_turn + 5

// game.current_turn = 5
// game.previous_turn = 0

(2) save the new previous turn via: game.previous_turn = game.current_turn // game.previous_turn = game.current_turn = 5

// game.current_turn = 5
// game.previous_turn = 5

(3) second (3 turn) action -> game.current_turn = game.current_turn + 3

// game.current_turn = 8
// game.previous_turn = 5

(4) save the new previous turn via: game.previous_turn = game.current_turn // game.previous_turn = game.current_turn = 8

// game.current_turn = 8
// game.previous_turn = 8

(5) third (7 turn) action -> game.current_turn = game.current_turn + 7

// game.current_turn = 15
// game.previous_turn = 8

(6) save the new previous turn via: game.previous_turn = game.current_turn // game.previous_turn = game.current_turn = 15

// game.current_turn = 15
// game.previous_turn = 15

(7) fourth (5 turn) action -> game.current_turn = game.current_turn + 5

// game.current_turn = 20
// game.previous_turn = 15

etc etc etc

---

this is the same design ( of using two Attributes, 'old/previous' and 'new/current' ) for how to be able to return to whatever previous room you were in, and also is used for the returning to the original simple 'object.alias' vs the ' object.alias + "(equipped)" ', in Chase's/Pixie's equipment code systems)

****************

which, now allows you to:

as you got to compare the new/current turn amount to the old/previous turn amount, and if they're not equal, then a turn has occured obviously, and thus now the monster attacks, and if they're equal, then obviously a turn has NOT occured, and thus the monster waits for you to do an action (real turn) first.

see this code of mine (or wait for Pixie to help you with implementing it in a much better/easier way/design than how I've done it, lol):

viewtopic.php?f=10&t=6269#p42499

as I'm much more lazy than Pixie is, lol

Anonynn
I'd rather get the looks working first before trying to delay the attacks @_@

HegemonKhan
actually, depending on what design you want to use for your game, the implementation can be much more simple than my complex implementation of throwing in having to work with and check upon 'new/current' vs 'old/previous' turns... in dealing with/handling if/when the monster in a room attacks.

Anonynn
Turns out I had a script resetting the notarealturn scripting! Oops! :D

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums