Melko wrote: ↑
Fri Mar 22, 2019 1:01 am
You're almost there! Just a little flaw in the logic.
OnNPCKill runs when any npc dies, so you need to perform further checks in order to get where you want to be.
OnNPCKill's arguments are very useful in this! Particularly killedNPC and killReason.
killedNPC contains the NPC object being killed, so you already know which NPC, or goomba, died! So the first check would be to see if the NPC that died actually is one of those big goombas, by checking "if killedNPC.id == BIG_GOOMBA_ID" before executing further code related to the goombas.
Another thing you could check for is killReason. You can find them on this page, all prefixed with HARM_TYPE
Maybe you want to exclude certain harm types like lava from causing a split in the first place. Checking stuff like "if killReason == HARM_TYPE_LAVA" would be the way to go about that.
After those checks it's time to spawn the little goombas! Remember that killedNPC contains the goomba that died! So you already have the NPC object you want to spawn stuff around and don't need to use a for loop to get it. You can use values like killedNPC.x and killedNPC.y for the position to spawn at, and stuff like that!
Hope this helps.