Post new topic    
Liquid Metal Slime
Send private message
Issue with Hero Swap In/Out 
 PostTue Aug 13, 2013 9:29 pm
Send private message Reply with quote
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:
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?
Cornbread Chemist
Liquid Metal King Slime
Send private message
 
 PostTue Aug 13, 2013 9:37 pm
Send private message Reply with quote
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:

swap out hero (hero:Fred)
swap out hero (hero:Gluep)
add hero (hero:Harvey)
swap out hero (hero:Alan)
Liquid Metal Slime
Send private message
 
 PostTue Aug 13, 2013 9:46 pm
Send private message Reply with quote
Makes sense! Thanks for pointing that out, James V
Cornbread Chemist
Super Slime
Send private message
 
 PostWed Aug 14, 2013 3:03 am
Send private message Reply with quote
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:

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.
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Liquid Metal King Slime
Send private message
 
 PostWed Aug 14, 2013 2:18 pm
Send private message Reply with quote
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:

# 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"!)
Metal King Slime
Send private message
 
 PostWed Aug 14, 2013 7:14 pm
Send private message Reply with quote
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:
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)
Display posts from previous: