Issue with Hero Swap In/Out

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Issue with Hero Swap In/Out

Post by Meatballsub »

Hey guys,

Having a little issue with one hero not wanting to swap in our out of the party via scripting. Here is the code:

Code: Select all

set tag(tag:deathscript,on)
swap out hero (hero:Fred)
swap out hero (hero:Gluep)
swap out hero (hero:Alan)
add hero (hero:Harvey)
destroy npc (3)
create npc (6,8,2)
fight formation (162)
swap out hero (hero:Harvey)
swap in hero (hero:Fred)
swap in hero (hero:Gluep)
swap in hero (hero:Alan)
set tag (tag:deathscript,off)
Everything works exactly as needed, with the exception of the swap in/out with Alan. He remains in the party regardless of everything I've tried. I thought a "wait for all" before the "fight formation" might help, but it didn't. I also tried calling him by using find hero, but that doesn't work either.

I double checked the HSI file and it shows his name as hero:Alan, so I think I'm good there...any suggestions?
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

It is impossible to ever have zero heroes in the party, so if you try to swap out the last hero in the party, the swap out will just be ignored.

You can work around this problem just by changing the order of your swapping

Code: Select all

swap out hero (hero:Fred)
swap out hero (hero:Gluep)
add hero (hero:Harvey)
swap out hero (hero:Alan)
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Post by Meatballsub »

Makes sense! Thanks for pointing that out, James :v:
User avatar
Mogri
Super Slime
Posts: 4598
Joined: Mon Oct 15, 2007 6:38 pm
Location: Austin, TX
Contact:

Post by Mogri »

Bob the Hamster wrote:It is impossible to ever have zero heroes in the party, so if you try to swap out the last hero in the party, the swap out will just be ignored.

You can work around this problem just by changing the order of your swapping

Code: Select all

swap out hero (hero:Fred)
swap out hero (hero:Gluep)
add hero (hero:Harvey)
swap out hero (hero:Alan)
FWIW, this is pretty unintuitive, and it's not hard to think of cases where the author will want to swap the entire party. It'd be nice if removing the last hero in the party put it into a "limbo" state, where the hero would be discarded if another hero gets added before the next tick and reinserted otherwise.
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

One way that I like to handle swapping is to manage specific slots, rather than just swapping out and in.

For example, suppose my part consists of 6 heroes, and I don't know which ones the player has swapped in via the Team menu.

I have a special battle that should be fought by three specific heroes with the fourth slot empty, so how do I handle the swapping before the special battle?

Code: Select all

# Force specific heroes into the first three slots
swap by position(0, find hero(hero:Blossom))
swap by position(1, find hero(hero:Bubbles))
swap by position(2, find hero(hero:Buttercup))
# Swap out whoever is in the fourth slot
if(hero by slot(3) >= 0) then(swap out hero(hero by slot(3)))
But I do like your suggestion, Mogri. Allowing an empty party briefly would be more intuitive.

(also, yay "Disable html in this post"!)
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

I like that suggestion too. I think it would be safe.

Recently I suggested that we should add a "set party" command which sets all party slots at once

Code: Select all

set party(find hero(hero:Blossom), find hero(hero:Bubbles), find hero(hero:Buttercup))
#or
set party by name(hero:Blossom, hero:Bubbles, hero:Buttercup)
Post Reply