Hey, I've been using VX Ace for years now, but only recently have I been forced to script with Ruby, and I'm at a standstill.
There is a boss fight in the game I'm making where it's supposed to check if a certain enemy is dead (enemy, not actor), and if it is, then increase the value of a variable by 1 and turn a certain switch on. It does that with every enemy, increases the number of the same variable, but the switch activated is different for each enemy. Yeah, I know I could just use the Conditional Branch for that, but let's say that, because of certain restrictions, I'm being forced to do this through Ruby.
Now the problem is that I don't know how to make it so that the game can detect whether a certain enemy is dead or not. I did an attempt that runs at the end of every turn, and it looks like this:
def enemy ; $game_troop.members[1]
if enemy == (enemy.state?(1))
$game_variables[989] += 1
$game_switches[969] = true
end
end
However, even if the enemy dies, nothing happens. I have a test text scripted to appear if the switch has been turned on. It doesn't appear, meaning the switch hasn't turned on, further meaning that the code doesn't work. If anyone could guide me on how I'm supposed to write the code, I'd really appreciate it.
There is a boss fight in the game I'm making where it's supposed to check if a certain enemy is dead (enemy, not actor), and if it is, then increase the value of a variable by 1 and turn a certain switch on. It does that with every enemy, increases the number of the same variable, but the switch activated is different for each enemy. Yeah, I know I could just use the Conditional Branch for that, but let's say that, because of certain restrictions, I'm being forced to do this through Ruby.
Now the problem is that I don't know how to make it so that the game can detect whether a certain enemy is dead or not. I did an attempt that runs at the end of every turn, and it looks like this:
def enemy ; $game_troop.members[1]
if enemy == (enemy.state?(1))
$game_variables[989] += 1
$game_switches[969] = true
end
end
However, even if the enemy dies, nothing happens. I have a test text scripted to appear if the switch has been turned on. It doesn't appear, meaning the switch hasn't turned on, further meaning that the code doesn't work. If anyone could guide me on how I'm supposed to write the code, I'd really appreciate it.