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

Reload One-use NPCs?

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
emmychu
Guest






PostPosted: Fri Apr 12, 2013 5:58 pm    Post subject: Reload One-use NPCs? Reply with quote

Hihi! I was hoping someone could help me out with a question!

All the battles in my game are triggered after touching NPCs that wander the map, representing the monsters as opposed to random battles. The player can avoid the walkabouts and battles will not be triggered, and there are a set number of encounters on the map. Touching the NPCs runs a script that starts a battle formation. I have each NPC set to use only once so that they disappear after the encounter.

However, I'd like for all the enemies to respawn after leaving and re-entering the maps. Is this possible? The 'usable once' command seems to destroy them permanently, which makes sense. Is there another way I can destroy the NPC with plotscripting (how do I make it target whatever NPC the player has bumped into specifically?) and set the map to forget the NPC states when leaving, therefor having the NPCs respawn when the player comes back?

Thanks for any help or suggestions! I hope I was clear enough!
Back to top
emmychu
Guest






PostPosted: Fri Apr 12, 2013 6:32 pm    Post subject: Reply with quote

ACTUALLY, I think I've found something that may work.

Using 'npcref' as a name, I believe it makes a script refer to whichever NPC triggered the script (had to do some digging around to find that one!).

So, I have all my NPCs set to 'usable repeatedly' now, and my script reads:

Code:
plotscript, BattlesOne, npcref, begin
  fight formation (random formation (1))
  destroy NPC(npcref)
end


So far it seems to be working. I tested it by battling one walkabout, leaving the map and returning. The NPC had re-appeared. So, success, I believe!

I'm still very new to this, so sorry for the newbie question and double post!
Back to top
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Apr 12, 2013 7:54 pm    Post subject: Reply with quote

Hello!

Yes, that's the way to go. And yes, the arguments to NPC use scripts and other triggered scripts need to be much better documented.

NPCs on the current map will also be reloaded when you load a saved game.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
emmychu
I choose you!




Joined: 12 Apr 2013
Posts: 3

PostPosted: Mon Apr 22, 2013 4:15 pm    Post subject: Reply with quote

For some reason this isn't working for me anymore! I'm not sure what I must've changed, since I'm sure I did have it working...

Right now the enemies aren't disappearing after the battles, and they immediately trigger another battle formation. The only way they get destroyed properly is if I set them to useable only once, which isn't what I want!

Do I need to give them all different script arguments? Do they all need to have script argument 0? I'm really confused as to what the problem is, since I'm sure they were working properly not too long ago!

My script that all the enemy NPCs are set to trigger:
Code:
plotscript, OtherworldBattlesOne, npcref, begin
  fight formation (random formation (1))
  destroy NPC(npcref)
end
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Apr 23, 2013 1:18 am    Post subject: Reply with quote

I can think of a few possible things that have changed to cause the script to be repeatedly retriggered:

1) You turned on the "permit double triggering of scripts" general bitset

2) You added an after-battle script to the map

3) There is some other script being triggered or run, such as a script being called by a timer every tick.

All would have the same effect: "fight formation" causes a one tick wait before the NPC is deleted, during which time other scripts can be triggered, including OtherworldBattlesOne itself (either if the permit double-triggering bit is on, or if some other script is also triggered, so that OtherworldBattlesOne doesn't appear to be the active script anymore).

Anyway, the fix is easy: just move the delete NPC before the fightformation command. However that solution is specific to this script. More generally you would want the script to not allow being triggered twice, with an explicit test:

Code:
plotscript, on touch script, begin
  #if already in this script, don't restart it
  if (check tag(tag: in on-touch script)) then (exit script)
  set tag(tag: in on-touch script, on)
  # do whatever...

  set tag(tag: in on-touch script, off)
end


(It's likely that you'll need to do that if writing an on-keypress script that contains a wait command.)
_________________
"It is so great it is insanely great."


Last edited by TMC on Tue Apr 23, 2013 9:23 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
emmychu
I choose you!




Joined: 12 Apr 2013
Posts: 3

PostPosted: Tue Apr 23, 2013 10:50 am    Post subject: Reply with quote

I double checked, and the double-triggering of scripts wasn't turned on, so that wasn't the problem.

I did put in a 'run' script for the hero to speed up while holding Z, which is the only thing I can think of that would interfere. However, I just went and took that off of the map's on-keypress script, and the problem is still occurring.

It seems that the NPC is just simply not getting deleted. I tried moving them a few tiles as well, and they did not respond. Is the 'npcref' not working with them?

I even tried to include 'destroy NPC(npcref)' before the fight formation trigger. The NPC still was not destroyed, and triggered another battle after. I'm really confused. :C
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Tue Apr 23, 2013 11:13 am    Post subject: Reply with quote

emmychu wrote:

My script that all the enemy NPCs are set to trigger:
Code:
plotscript, OtherworldBattlesOne, npcref, begin
  fight formation (random formation (1))
  destroy NPC(npcref)
end


Ah! I think I see the problem. The first argument to an NPC script is the "Script Argument" number from the NPC editor. The second argument is the npc reference. So you can just change your script like this:

Code:
plotscript, OtherworldBattlesOne, arg, npcref, begin
  fight formation (random formation (1))
  destroy NPC(npcref)
end
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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