A way to get the ref of the NPC who triggered a plotscript?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

A way to get the ref of the NPC who triggered a plotscript?

Post by Foxley »

I'm running a plotscript for NPCs for things like health pickups and other powerups. But to have them spawn from dead enemies, I don't believe using onetime tags would be a suitable way to make them disappear since the onetimes are tied to the NPC ID, not the reference. So I was hoping there would be a way to get the NPC reference of whatever NPC triggered the pickup/powerup plotscript, so I could destroy that NPC reference after the powerup effect occurs. But I'm not finding anything like that in plotdict.xml. Any info would be appreciated.
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

This is one of the most weirdly-documented features and it feels like the third time this week someone's needed it. Basically, a script run by an NPC will automatically send the NPC Reference to the second argument of that script.
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Sweet, thanks! And yeah, that definitely needs to be documented better. Even a blurb in plotdict.xml under the #about-plotscript section would be great.

Honestly I almost never read the help files on the wiki, should probably make an effort to read through it more though to avoid asking dumb questions like this.
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

Foxley wrote:Sweet, thanks! And yeah, that definitely needs to be documented better. Even a blurb in plotdict.xml under the #about-plotscript section would be great.

Honestly I almost never read the help files on the wiki, should probably make an effort to read through it more though to avoid asking dumb questions like this.
It's not a dumb question, it's a great question. The wiki is really scary and I wouldn't recommend trying to read through it unless it was some kinda around the world in 80 days style bet. Even the List of Frequently Asked Questions makes me cross-eyed.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

This might be the most commonly asked question of all. For a long time I've been meaning to make Custom itself preview what arguments will be passed to all triggered scripts.

And of course, the Plotscripting Tutorial is a terrible place to document it; a dedicated plotdict section would be a good idea.
Last edited by TMC on Sun Jan 01, 2017 6:29 am, edited 1 time in total.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1243
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Woah, I was not aware of that, that sounds super helpful.
My pronouns are they/them
Ps. I love my wife
Post Reply