Is There a Better Way?

I have an event (set to event touch) which chases the player down. If it touches the player I want it to randomly damage (remove HP) one, and only one, party member. My problem is that there are varying number of party members from one to seven. Is there a simple way to do this?


(I have come up with a complicated method I don't really want to use. My current method is to set a variable equal to the party size. Then have an if else branch which runs through every possible combination of party members for that party size performing a dice roll for each (through another variable) to decide if that member is hurt. This was fairly simple to do as a test with only three party members, but seems like a nightmare to do for seven.)  
If you want to do it with events only, you'll need several conditional branches, but no need to check every possible party combination.


You'll need three variables only, "party size", "selected member" and "selected ID"


1) use control variables : game data : party members to get the number of party members.


2) for each party size (this needs to be several conditional branches), make a different control variable command "selected member" set for random between 1 and "party size"


Because you need to set the random to a fixed number, you'll need one conditional branch for each possible party size


3) for each possible party position, make a conditional branch if "selected member" is that number and if yes, control variable "selected ID" as game data : party member #x's ID


4) change HP and use the variable "selected ID" to determine which actor gets hurt.
If you want to do it with events only, you'll need several conditional branches, but no need to check every possible party combination.


You'll need three variables only, "party size", "selected member" and "selected ID"


1) use control variables : game data : party members to get the number of party members.


2) for each party size (this needs to be several conditional branches), make a different control variable command "selected member" set for random between 1 and "party size"


Because you need to set the random to a fixed number, you'll need one conditional branch for each possible party size


3) for each possible party position, make a conditional branch if "selected member" is that number and if yes, control variable "selected ID" as game data : party member #x's ID


4) change HP and use the variable "selected ID" to determine which actor gets hurt.



That worked great. Thanks. It also taught me something about Actor ID number.


It leads me to a second question though. It was working perfectly. I tried to add a State as well as a HP Loss. Now, regardless of what the HP Loss is set to, it drops the actors HP to 0 and gives me a game over message if all actors in the party have zero HP. It doesn't seem to matter what State it is or if I've created it. I can even leave it blank. If I decrease States to 0 or remove the state effect, it works fine. Otherwise, it does not. I don't really understand how states work, but this doesn't make sense to me. 


Second Edit - Never mind. I figured out that State 1 is Death apparently no matter what? So as long as I use a State with a different ID number it works just fine. Thanks again.

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-better-way.62206/