Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Targetting the NPC that calls the script

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
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

PostPosted: Tue Jun 15, 2010 5:54 pm    Post subject: Targetting the NPC that calls the script Reply with quote

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
View user's profile Send private message Visit poster's website
Rimudora
Psychopath yandere
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 26 May 2005
Posts: 335

PostPosted: Tue Jun 15, 2010 6:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Bobert-Rob
The guy from years ago who made one good game




Joined: 13 Jun 2010
Posts: 17

PostPosted: Thu Jun 17, 2010 7:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Jun 18, 2010 8:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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