 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Bobert-Rob The guy from years ago who made one good game

Joined: 13 Jun 2010 Posts: 17
|
Posted: Tue Jun 15, 2010 5:54 pm Post subject: Targetting the NPC that calls the script |
|
|
Okay, a new question. Lets say I have enemies (NPCs) on the map and they cause a fight to happen when you talk to them. They're in the way, you have to fight them. Well, once the battle is won, a script is called and the NPC is teleported to a position on the map where they can't be accessed by the hero anymore (1,1), effectively making them 'vanish'.
My problem is I'm not sure of how to target the enemy NPC. One way of doing it is to use NPC at spot and, depending on what way the hero is facing, the NPC right in front of the hero will be the one that vanishes. In fact, that's what I'm doing now, and it SORT OF works. But what if the enemy NPC is moving? If they're moving and you trigger the script, they're suddenly out of range. Or if the enemy NPC is pushable, they're now one space ahead.
So I was wondering if there was a way to target the NPC that calls the script from inside the script? That way, all I would have to do is reference whoever called the script and make that NPC disappear. Would this be possible, or am I just going to have to figure out some other method of doing this? The 'only once' setting on NPCs effect each one, not just the individual copy. Individual copy targeting would be key.
...almost makes one wish the 'only once' setting were an array so it could effect the individual copy. |
|
Back to top |
|
 |
Rimudora Psychopath yandere Halloween 2006 Creativity Winner


Joined: 26 May 2005 Posts: 335
|
Posted: Tue Jun 15, 2010 6:37 pm Post subject: |
|
|
Whenever you have an npc run a script, it returns two variables. The first is something you can set inside custom through 'edit npcs...'. The second one is a reference to the npc that called the script. So you could do something like this:
Code: | plotscript, battle, var1, npcref, begin
battle(var1)
setnpcposition(npcref,1,1)
end |
|
|
Back to top |
|
 |
Bobert-Rob The guy from years ago who made one good game

Joined: 13 Jun 2010 Posts: 17
|
Posted: Thu Jun 17, 2010 7:19 pm Post subject: |
|
|
Hey, that actually works! Glad it actually turned out to be pretty simple. I'll have to keep this in mind, thanks! |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Jun 18, 2010 8:24 pm Post subject: |
|
|
There is also a "delete NPC" command that sounds like it would be identical to moving the NPC off the screen, for your purposes.
And, I've come to realise that we really need to mention the script arguments inside Custom. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|