Should I be using Turn Script for this?

JenniferKline
23 Jun 2017, 10:22

Heya all,

I've got a question about something I'm trying to do.

Pregnancy. Because going Alien and xenomorph in a game is always fun. Anyway, we have our father, that for now, we will reference as a Goblin.

Player currently becomes pregnant through a verb, because I'm still testing.

SetInc (500)
if (player.race = "Human") {
  if (not GetBoolean(player, "Contra")) {
    if (RandomChance(75)) {
      set (player, "pregnantwith", "Goblin")
      set (player, "pregnant", True)
    }
  }
}

That works fine and dandy. The event takes 500 minutes, only affects those playing as a human with compatible DNA, and there's a 75% chance they are going to get a goblin 'chest burster' due to the chance of having your systems fight it off (Something I plan to give stat boosts later)

Now we move onto actually trying to get the Pregnancy. Now it's not just one cutscene where the player is defeated, RIP and doom, but they get the chance to be able to unpregnate themselves, either by system boosters or surgery pods, etc. If they can get there in time or figure it out.

For this, I've been using a Turn Script.

if (player.pregnant = True) {
  CreateEvent (1000, "pregnancy") {
    if (player.race = "human") {
      msg ("You've given birth to a {player.pregnantwith}.")
    }
  }
  firsttime {
    msg ("You can feel something writhing around in your chest.")
  }
}
else {
}

This gives the playe 1000 minutes to do something about it. I've not gotten that far yet, which brings me to my issues here. I've not used turn scripts much because they seem a pain, especially when printing messages. Like I was getting the "You feel something writhing around in your chest." Every turn, which was annoying, so I put it as a first time. But, the player will likely have this same event happen to them multiple times in play, as its a defeat when fighting a boss.

And now I get the 'You've given birth to a goblin message every turn, and if I keep playing the encounter, I manage to even get burst by four at once. Oh dear.

Now I know this is probably down to the turn script being something looked at every turn, so my question is, should I be using a different feature of Quest for this? I'm still quite a novice and rarely go into code mode unless I have to, which is what made this a little harder for me.

I'd like to add a function too that, as the pregnancy trait progresses, various messages of increasing urgency come up.

"You feel something small squirming in your chest." "There's a painful spiking between your lungs." "Breathing is getting difficult." Etc. They could come up every 200 minutes of in-game time or so. I'm using Pixie's time and date library, and currently the numbers are more of a placeholder until I get things balanced properly. Anyway, if my rambling can be understood, if any advice on how to lay this out is about, it would be greatly appreciated!


XanMag
23 Jun 2017, 11:14

I did something similar in X3 (WIP) and I think I used a turnscript coupled with a random chance. Basically, after every turn, there was a percent chance that a message would print. To complicate matters more, the percent chance was set on Booleans through If/Else If scripts.

In my game, I have 'time of day' linked to number of turns via a turn script and my object 'bats'. If the time of day was midnight, the messages about bats popped up more frequently and during the day, much less so. It seems you could do something similar with pregnancy. Messages increase based on flags set as the months draw closer to your birth date.

I'm not 100% sure this helps with your question but... there you have it. Best of luck!

If you have questions, let me know and I'll dig through my code and see if I can clarify! =)

EDIT: as I think about this a little more, I'm not sure if you would even need a turnscript? It's too early for me. Forgive me. haha


The Pixie
23 Jun 2017, 11:38

There is a turn script aready running in the game (in ClockLib), and that will handle this.

Delete the SetInc (500) - that will just make 500 minutes pass before the player can do anything. What you really want to do is create events that will fire at the right time. Here is an example:

if (player.race = "Human") {
  if (not GetBoolean(player, "Contra")) {
    if (RandomChance(75)) {
      set (player, "pregnantwith", "Goblin")
      set (player, "pregnant", True)

      CreateEvent (250, "pregnancy1") {
        if (player.pregnant) {
          msg ("You feel something small squirming in your chest.")
        }
        else {
          Quiet
        }
      }

      CreateEvent (500, "pregnancy2") {
        if (player.pregnant) {
          msg ("There's a painful spiking between your lungs.")
        }
        else {
          Quiet
        }
      }

      CreateEvent (750, "pregnancy3") {
        if (player.pregnant) {
          msg ("Breathing is getting difficult.")
        }
        else {
          Quiet
        }
      }

      CreateEvent (1000, "pregnancy4") {
        if (player.pregnant) {
          msg ("You've given birth to a {player.pregnantwith}.")
          msg("... and now you are dead.")
          finish
        }
        else {
          Quiet
        }
      }

    }
  }
}

Just looking at the last event to explain:

      CreateEvent (1000, "pregnancy") {
        if (player.pregnant) {
          msg ("You've given birth to a {player.pregnantwith}.")
          msg("... and now you are dead.")
          finish
        }
        else {
          Quiet
        }
      }

This create an event that will happen in 1000 turns (minutes). If the player is still pregnant, the messages are displayed, and the game ends. If the player is not pregnant, do nothing (Quiet means that if the player is waiting, the wait will not get interrupted by a non-event).


hegemonkhan
23 Jun 2017, 19:03

About:

there's only 3 ways of doing "constantly/automatically-repeatedly checking/activating/firing/running" (turnscripts and timers can be controlled for when you're doing the constantly checking and not doing it. The special 'changed' Script Attribute can only be "controlled" for when you're doing the constantly checking and not doing it, via NOT changing the specified Attribute's value vs doing so, thus it's not much of a "control", lol. Also, the 'changed' Script Attribute activates immediately upon the specfiied Attribute's value being changed, and thus again, no control and/or possible 'order of operation' conflicts/issues. But, using the 'changed' Script Attribute is often more simple/easy then trying to mess with using turnscripts/timers due to their good/many control/handling capabilities, which the 'changed' Script Attribute lacks)

  1. the 'turnscript' Element
  2. the 'timer' Element
  3. the special 'changedNAME_OF_ATTRIBUTE' Script Attribute

let me know if and/or which ones you need explained on how to use them, as I'm too lazy right now and also am busy right now (got to go somewhere soon).