Help with issue with *if coding


#1
*label casezero2
*if ((werewolfone) and (gargoyleone))
  *goto epilogue

*elseif ((werewolfone) and (vampireone))
  *goto epilogue

*elseif ((gargoyleone) and (vampireone))
  *goto epilogue

*else
  *goto caseone
  
*label caseone
Looking at the files you decide which case you want to do...
*choice
  *if (werewolfone = false)
    *hide_reuse  #"By Tooth and Claw"
                   *goto casea
                 
  *if (gargoyleone = false)
    *hide_reuse  #"Creepy Statues"
                   *goto caseb

  *if (((werewolfone) or (gargoyleone)) and (vampireone = false))
    *hide_reuse  #"SOS"
                   *goto casec

I’ve set up the code so that if you complete “By Tooth and Claw” the game sets [werewolfone] true, “Creepy Statues” sets [gargoyleone] true and “SOS” sets [vampireone] true. So the code above should make the player *goto epilogue if they have completed two missions. but apparently players can do all missions if they do the first two cases first they still get to do the third case. Can anyone see where the ‘issue’ is because I can’t spot it?


#2

I don’t use elseifs - - Not sure if they work quite as intended.
Gimme 10mins and I’ll hop on a pc and take a closer look!


*label casezero2
*temp n
*set n 0
*if (werewolfone)
  *set n + 1
*if (gargoyleone)
  *set n + 1
*if (vampireone)
  *set n + 1
*if (n > 1)
 *goto epilogue
*goto caseone

*label caseone
Looking at the files you decide which case you want to do...

*choice
    *hide_reuse *if (werewolfone = false) #"By Tooth and Claw"
                   *goto casea

    *hide_reuse *if (gargoyleone = false) #"Creepy Statues"
                   *goto caseb

    *hide_reuse *if ((werewolfone) or (gargoyleone)) and (vampireone = false)  #"SOS"
                   *goto casec

Thinking that will work, not tested it though.
Try to use lots of little *ifs, loads of complex ones are hard to read and debug.


#3

@CJW thanks!


#4
*if (((werewolfone) or (gargoyleone)) and (vampireone = false))

If werewolfone and gargoyleone are both true (which means the first two missions are done) and the third mission isn’t done (vampireone), that means you can do the third mission. That’s what I think does it. The problem I spotted is you need to use a strictly-or (XOR in some programming languages) there, I think. Because that *if goes true even if both of the werewolf and gargoyle missions are true (done), and the vampire mission isn’t.


#5

@AlexCosarca

Thanks I think @CJW 's suggestion will be easier for my coding ability it seems my using and/ors are playing up.


#6

You can simulate an exclusive or by separating them:

*if ((werewolfone) and (vampireone = false)) or ((gargoyleone) and (vampireone = false))

But, yes Alex is right in that it doesn’t currently care if they’re both true.

EDIT: That’s a lie. Sorry.

You’d need to add the false var in too:

*if (((werewolfone) and (vampireone = false)) and (gargoyleone =false)) or (((gargoyleone) and (vampireone = false)) and (werewolfone=false))

But as you can see the syntax gets silly.

In that regard, the method I provided won’t work either (if the player is not allowed to have done both the gargoyle and werewolf missions).

<-- Is actually confused as to what you’re trying to do now xD


#7

Thanks to the both of you :slight_smile:


#8

Or, you can set a counter that adds one to it when a mission is done and is set to 0 by default, so that if the counter is 2 or above, you can’t do any more missions.


#9

@CJW

the intention is when you do your first case either “By Tooth and Claw” or “Creepy Statues” the “SOS” case appears (for a limited time the player either does it or does the other case and loses the chance to do ths case)


#10

*if (werewolfone)
 *set (n+1)
*if (gargoyleone)
 *set (n+1)

Etc…

*hide_reuse *if (n=1) and (vampireone=false) #SOS Case

So if both wolf and gargoyle are done, n = 2 and the case won’t show?