The Dink Network

Removing hardness forever

July 25th 2010, 12:24 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
I have a snippet of code I use in a helper script that I can call from wherever I like to delete a sprite from the game forever. Problem is, it doesn't work. The sprite does not lose hardness nor does it disappear forever.

void killforever (void)
{
  // Remove a sprite from the game forever so it no longer shows up on screenswap
  // Arg1 is the sprite

  sp_hard(&arg1, 1);
  draw_hard_sprite(&arg1);
  int &hold = sp_editor_num(&arg1);
  if (&hold != 0)
  {
  	editor_type(&hold, 1); 
  }
}  


I do the following to remove an invisible barrier after using an item:
sp_nodraw(&actor1, 0);
&substory = 4;
say("There we go, hope it holds.", 1);
kill_cur_item();
draw_status();
external("helper", "killforever", &actor2);
sp_kill(&actor2, 1);


&actor2 = &current_sprite is set for the barrier sprite.
July 25th 2010, 12:38 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Grabbed a piece of code from Historical Hero where I made a sprite disappear and lose hardness. Note, this piece of code only does that:

  //remove sprite's hardness and sprite
  sp_hard(&current_sprite, 1);
  draw_hard_map(&current_sprite);
  sp_active(&current_sprite, 0);
  playsound(43, 22050, 0,0,0);
int &hold = sp_editor_num(&current_sprite);
  if (&hold != 0)
    {
     //this was placed by the editor, lets make it not come back
     editor_type(&hold, 1); 
    }

July 25th 2010, 12:55 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
That's basically the same thing but changing sp_kill with sp_active. I'll see if it makes a difference. Though in one other case where I try the same thing, I don't use either sp_kill or sp_active, but set the brain and brain_parm to shrink and die and that also doesn't work.
July 25th 2010, 01:14 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
What I just wrote works for me.
July 25th 2010, 01:32 PM
spike.gif
Sounds like it hangs with the helper thing. I'm not too familiar with the fancy 108 stuff, but I know I've had problems with external before. I was trying to get the parent sprite to say something, IIRC, and it just wouldn't work, although stuff like sp_target(&current_sprite,1); works just fine.

I'd chalk it to either the bugginess of external, or the bugginess of 108. But keep trying, there's nothing wrong with the code itself as far as I can see. Perhaps using a temp global instead of passing an argument to external()?

EDIT: I mean using the helper script to to kill &actor2, instead of passing &actor2 to it with external().
July 25th 2010, 02:07 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
It must be some random buggy function, because in some cases it works, in some it doesn't, and I can't seem to figure out what exactly the difference is between my working and non working cases of the same script implementation. Gonna try with sp_active, then by not using a helper external, then with a temp global (but I don't like those because it becomes hard to track which one I use).
July 25th 2010, 07:24 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Mind that the external()-ed script is attached to the same sprite (or 1000, or 0) as the script that called it. Specifically, this means that once you somehow get rid of &current_sprite, the external() script will stop as well.

(idle rambling: I'm not sure what happens with the caller script if you put script_attach(1000) in an external() procedure.)

From looking at the source, sp_kill and sp_active do the same thing (by which I mean that sp_kill eventually sets sp_active to 0), but you can put in some delay with sp_kill. There may or may not be a one-frame delay by default, I don't know that, but if there's a difference in behaviour, that's where it is.