Thinking out loud on a pattern.
The thing I am working on supports removing (and optionally saving to disk) a character.
If there's just one character in the party then that's easy, decrement the number of characters in the party. No characters will show up as I am using a global for the number of characters in a party.
If the sixth character is removed that is also easy. Decrement number of characters in the party, the sixth one does not show up. (I should blank out the objects and arrays that make up the definition of that character, of course.)
If there are between two and five members... I want the effect of the characters that were "later" in the party "moving up."
So after the character gets removed, if there are two or more characters or four or fewer characters, I'll do things.
Wait, no, that's wrong - the third character could be removed, which means that we have 5 characters. Still gotta move characters around.
[RPG] Removing a character from a party
Moderator: Ice Cream Jonsey
- Ice Cream Jonsey
- Posts: 30065
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
[RPG] Removing a character from a party
the dark and gritty...Ice Cream Jonsey!
- Ice Cream Jonsey
- Posts: 30065
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
Re: [RPG] Removing a character from a party
I think I have it.
the dark and gritty...Ice Cream Jonsey!
- Flack
- Posts: 9057
- Joined: Tue Nov 18, 2008 3:02 pm
- Location: Oklahoma
- Contact:
Re: [RPG] Removing a character from a party
I'm probably making this either too easy or too hard, but maybe every turn something could check for an empty character slot, and if it finds one, run through the rest of the character array and subtract one from each position?
"I failed a savings throw and now I am back."
- The Happiness Engine
- Posts: 868
- Joined: Thu Aug 02, 2012 4:16 pm
Re: [RPG] Removing a character from a party
Since execution time cannot POSSIBLY matter can you just write out a new array of characters, skipping the one you are removing? For architectural limitations just have 2 arrays with one being used as a scratch space and then write the array back to where it normally lives.
- Tdarcos
- Posts: 9529
- Joined: Fri May 16, 2008 9:25 am
- Location: Arlington, Virginia
- Contact:
Re: [RPG] Removing a character from a party
Here is a general sample where "deadman" is the particular character being deleted, "group" is the array of members, "maxmembers" is the number of characters currently in the group.
Since I don't know what language you're using I've been generic, C/C++ has special operators such that the last line above could be
maxmembers -- ;
The small amount of time cleaning each entry after every move means the last entry is automatically cleared. Also, if you're doing this visually, each person in the party moves up and there is a vacancy after each one steps forward, before the next moves in.
Hope this helps.
Code: Select all
for i = deadman to maxmembers
{
group[i] = group[i+1]
group[i+1] = nothing
}
maxmembers = maxmembers - 1
maxmembers -- ;
The small amount of time cleaning each entry after every move means the last entry is automatically cleared. Also, if you're doing this visually, each person in the party moves up and there is a vacancy after each one steps forward, before the next moves in.
Hope this helps.
"Baby, I was afraid before
I'm not afraid, any more."
- Belinda Carlisle, Heaven Is A Place On Earth
I'm not afraid, any more."
- Belinda Carlisle, Heaven Is A Place On Earth
- Ice Cream Jonsey
- Posts: 30065
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
Re: [RPG] Removing a character from a party
I think it works. Onto burst mode for automatic weapons!
the dark and gritty...Ice Cream Jonsey!