Author Topic: Triggers: Status & Random triggers not firing  (Read 4790 times)

0 Members and 1 Guest are viewing this topic.

Offline MaxVirile

  • Newbie
  • *
  • Posts: 9
Triggers: Status & Random triggers not firing
« on: June 01, 2015, 01:31:59 PM »
Hello all,

I'm trying to make both Status & Random triggers, but neither seems to be firing, even though the conditions should be met (for example, the random should fire 100% of the time). Do I need to manually do something to compile the triggers .scriptx files? I was assuming that they'd automatically generate the first time the .script got run by the game, but maybe that's not the case...

Thanks,
MaxVirile

Offline aevojoey

  • Hero Member
  • *****
  • Posts: 1413
  • Thats ok, I'm used to disappointment.
Re: Triggers: Status & Random triggers not firing
« Reply #1 on: June 01, 2015, 02:12:52 PM »
I'm trying to make both Status & Random triggers, but neither seems to be firing, even though the conditions should be met (for example, the random should fire 100% of the time). Do I need to manually do something to compile the triggers .scriptx files? I was assuming that they'd automatically generate the first time the .script got run by the game, but maybe that's not the case...
Not all triggers really work in the code at the moment.
If you attach your files I will see if I can add the code to make them work.
Fixing the game is a better game than actually playing it.
Get the Current Version <|> Discuss the Game <|> Report a bug

Offline MaxVirile

  • Newbie
  • *
  • Posts: 9
Re: Triggers: Status & Random triggers not firing
« Reply #2 on: June 01, 2015, 03:06:47 PM »
Thanks for the quick reply.  :)  Below is the GlobalTriggers.xml:

<Triggers>
   <Trigger File="CustNoPay.script" Flag="NoPay" Type="GlobalFlag" />
   <Trigger File="RivalLose.script" Flag="RivalLose" Type="GlobalFlag" />
   <Trigger File="CustGambCheat.script" Flag="GamblingCheat" Type="GlobalFlag" />
   <Trigger File="NoMoney.script" Type="Money" Comparison="LessThan" Threshold="-5000" Who="Player" />
   <Trigger File="Random.script" Type="Random" />
   <Trigger File="NotPregnantByPlayer.script" Type="Status" Threshold="PregnantByPlayer" Has="False" />
</Triggers>

So, a "fire every time" trigger, and an "If not pregnant by player" trigger.  I'm assuming that you don't need the actual scripts themselves (and I'm still messing with them, anyway), since the easiest thing is probably to reference a script that pops-up a test dialog, to make sure that the firing worked.

Thanks again,
MaxVirile

Offline aevojoey

  • Hero Member
  • *****
  • Posts: 1413
  • Thats ok, I'm used to disappointment.
Re: Triggers: Status & Random triggers not firing
« Reply #3 on: June 01, 2015, 06:42:21 PM »
   <Trigger File="Random.script" Type="Random" />
   <Trigger File="NotPregnantByPlayer.script" Type="Status" Threshold="PregnantByPlayer" Has="False" />
So, a "fire every time" trigger, and an "If not pregnant by player" trigger.
You are missing the Chance="100" for it to know how often for it to run and the rest is just knowing the correct syntax:
   <Trigger File="Random.script" Type="Random" Chance="100"/>
   <Trigger File="NotPregnantByPlayer.script" Type="Status" Status="Pregnant By Player" Has="False" />

Once the syntax is correct, the issue becomes how the game handles the GlobalTriggers.xml
Global Triggers are the last thing handled during the Next Turn stage.
Any script that has a girl as its target needs the girl to be chosen first, the m_GirlTarget must be set.
The script then runs using that girl.
Normally there is no girl set for m_GirlTarget at that point so first you would need a script that chooses a girl and makes her active.
Then you would need the next script to run on her.
If you wanted it to run multiple times each turn you would probably have to have it multiple times in the GlobalTriggers.xml

Basically GlobalTriggers.xml is only supposed to be for major game events.
Fixing the game is a better game than actually playing it.
Get the Current Version <|> Discuss the Game <|> Report a bug

Offline MaxVirile

  • Newbie
  • *
  • Posts: 9
Re: Triggers: Status & Random triggers not firing
« Reply #4 on: June 02, 2015, 08:15:24 AM »
Thanks for looking into it.

I'm a little confused by your answer, so please forgive me if I'm getting it wrong.  I'm interpreting it as meaning: only global flag triggers will currently work, and they can't target a girl.  In case that isn't what you meant:

1. I didn't include 'Chance' on the Random trigger, since the documentation said that it defaults to 100%. However, I've tried it with chance set to 100, and it still doesn't fire, even if the script doesn't target a girl.
2. I'm trying to write a script to target a girl and make her active, then launch another script, as you suggested. Having trouble finding the commands to do either of those things in the script editor. Which ones are they?

Thanks,
MaxVirile

Offline aevojoey

  • Hero Member
  • *****
  • Posts: 1413
  • Thats ok, I'm used to disappointment.
Re: Triggers: Status & Random triggers not firing
« Reply #5 on: June 02, 2015, 10:35:02 AM »
I'm a little confused by your answer, so please forgive me if I'm getting it wrong.  I'm interpreting it as meaning: only global flag triggers will currently work, and they can't target a girl.  In case that isn't what you meant:
This part of the scripts has had few updates since I started so it is rather outdated.
Most of what has been added were the new image types and updated kidnap girls part.
The way the global scripts get triggered has never been updated and I don't think I had even looked at it till you brought it up.

After doing some testing it seems that GlobalTriggers.xml is loaded when the game is first created and then never checked again, so any changes made to it will only affect new games.
It also looks like that is the case for girls as well.
I'll see if I can fix that.

1. I didn't include 'Chance' on the Random trigger, since the documentation said that it defaults to 100%. However, I've tried it with chance set to 100, and it still doesn't fire, even if the script doesn't target a girl.
You're right, I missed the missing chance defaulting to 100 but either way I usually include things just to make it easier to edit later.

2. I'm trying to write a script to target a girl and make her active, then launch another script, as you suggested. Having trouble finding the commands to do either of those things in the script editor. Which ones are they?
There currently is no command for scripts to choose a girl or set the m_GirlTarget, that is done before the script is called by the game.
I can try adding a command that will choose a random girl but I'm not sure how that will work.
Fixing the game is a better game than actually playing it.
Get the Current Version <|> Discuss the Game <|> Report a bug

Offline aevojoey

  • Hero Member
  • *****
  • Posts: 1413
  • Thats ok, I'm used to disappointment.
Re: Triggers: Status & Random triggers not firing
« Reply #6 on: June 02, 2015, 07:39:36 PM »
I did not try to make the game reload GlobalTriggers.xml for existing games because it may cause too many problems.

I did add a function for scripts to get a random girl and prepare her to be used in scripts.
This function will override an existing m_GirlTarget so use it with caution.
If you use this and it does not correctly get a girl, it will end the script.

In the script editor the function is "Get Random Girl" with 2 variables.
The first variable is what building type and the second is the building number if type is Brothel.
If the first variable is "Anywhere", the game will randomly choose a girl from any building you own.
If you set it to choose from a building that you don't own, no girl will be chosen and the script will end.

I am not entirely sure if this will work all the time but that is for the script makers to figure out.
I made a simple test script that randomly chose a girl and displayed her name in the turn summary popups so I know it does do something.

I will push .06.01.21 shortly with this and the fix for the shop bug in it.
Fixing the game is a better game than actually playing it.
Get the Current Version <|> Discuss the Game <|> Report a bug