Function to modify Player Attributes

I'm trying to set up the character creation process in my game, and I'm having some MAJOR issues. I have all of my variables setting as expected. However, at the end the scene, I have the following in order:

Wait for Key Press, then:
Clear Screen
Call Function caluclateStats With Parameters (list of input)

Now, the "caluclateStats" function is a set of switches. Basically, it's supposed to take each parameter in turn, and modify a set of player attributes based on it (code below).

However, it seems to do LITERALLY nothing when I have it run. The status module on the right side of the screen doesn't change in any way whatsoever, and neither do the backend values.

Could anyone help me with this?

switch (job) {
case (job="None") {
player.strength = player.strength+1
player.dexterity = player.dexterity+1
player.constitution = player.constitution+2
player.intelligence = player.intelligence
player.wisdom = player.wisdom+2
player.charisma = player.charisma
}
case (job="Retail or Food Service") {
player.strength = player.strength
player.dexterity = player.dexterity+2
player.constitution = player.constitution+1
player.intelligence = player.intelligence
player.wisdom = player.wisdom+1
player.charisma = player.charisma+2
}
case (job="Laborer") {
player.strength = player.strength+3
player.dexterity = player.dexterity+1
player.constitution = player.constitution+2
player.intelligence = player.intelligence
player.wisdom = player.wisdom
player.charisma = player.charisma
}
case (job="Office Worker") {
player.strength = player.strength-1
player.dexterity = player.dexterity+1
player.constitution = player.constitution
player.intelligence = player.intelligence+3
player.wisdom = player.wisdom+2
player.charisma = player.charisma+1
}
case (job="Self Employed") {
player.strength = player.strength+1
player.dexterity = player.dexterity+1
player.constitution = player.constitution+1
player.intelligence = player.intelligence+1
player.wisdom = player.wisdom+1
player.charisma = player.charisma+1
}
case (job="Odd Jobs") {
player.strength = player.strength+1
player.dexterity = player.dexterity+1
player.constitution = player.constitution+1
player.intelligence = player.intelligence
player.wisdom = player.wisdom+3
player.charisma = player.charisma
}
}
switch (age) {
case (age > 50 and age <= 60) {
player.strength = player.strength-1
player.dexterity = player.dexterity-1
player.constitution = player.constitution-1
player.intelligence = player.intelligence+1
player.wisdom = player.wisdom+1
player.charisma = player.charisma+1
}
case (age > 60 and age <= 70) {
player.strength = player.strength-2
player.dexterity = player.dexterity-2
player.constitution = player.constitution-2
player.intelligence = player.intelligence+2
player.wisdom = player.wisdom+2
player.charisma = player.charisma+2
}
case (age > 70) {
player.strength = player.strength-3
player.dexterity = player.dexterity-3
player.constitution = player.constitution-3
player.intelligence = player.intelligence+3
player.wisdom = player.wisdom+3
player.charisma = player.charisma+3
}
}
calculateHobbyStats (hobby1)
calculateHobbyStats (hobby2)
calculateHobbyStats (hobby3)


That's not how a case statement works.

A case block executes if the switch expression and the case expression are equal. So in the lines:

switch (job) {
  case (job="None") {

that block will execute if the variable job is equal to the expression (job = "None"), which returns true or false.

For that case, you want case ("None") {.

For the switch (age) { block, you could either do case (51,52,53,54,55,56,57,58,59,60) { or make it a set of if/else statements instead.


Okay, awesome. That worked perfectly!


For age, you can do switch(true) and Quest will match the first one that is true, so then those case statements would work.


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

Support

Forums