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

Respawning Enemies

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




Joined: 18 Jul 2007
Posts: 2

PostPosted: Wed Jul 18, 2007 6:33 pm    Post subject: Respawning Enemies Reply with quote

My game has the monsters walking around and when the player approaches them, the battle starts. Of course, their NPC's are set to "use only once", but once their defeated (Or ran away from), how can I get them to repsawn once the player has left the area and then came back. "Cresent Dream" also uses this battle system for anyone who needs an expampe. PLEASE HELP! Crying
Back to top
View user's profile Send private message
AdrianX
..yeah.




Joined: 13 Feb 2003
Posts: 286
Location: Batangas City,Philippines

PostPosted: Wed Jul 18, 2007 7:02 pm    Post subject: Reply with quote

..no,in Crescent Dream,i did NOT set the NPCs to be used only once.
..i assigned specific tags to them,and once activated by the hero,the assigned tag will be turned on.i made it so that they will appear only if their tag is off,so there.
..in the map autorun script for maps where there are ememies,i made it so that all the enemy-assigned tags will be turned off again so that they will again appear for you to fight.
..oh,and you can re-use the "enemy tags" in all the enemy - infested maps you have.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Camdog




Joined: 08 Aug 2003
Posts: 606

PostPosted: Thu Jul 19, 2007 5:56 am    Post subject: Reply with quote

Setting NPCs to "use only once" actually associates them with a tag that, when turned on, causes them to no longer appear. You can see the tag number in Custom.exe next to their usability setting in the edit NPC screen. (It will look something like "Usable only once (tag 1002)".)

Though this tag is assigned automatically by Custom, you can still manipulate like any other tag in a plotscript. In other words, all you have to do is call a script that resets all the "use only once tags" whenever you want to respawn enemies on a map. The easiest way to do this (assuming you want enemies on a map to respawn whenever a player leaves that map) is to set that script as that map's autorun script (which can be found in Edit Map Data -> Edit General Map Data). The script would look something like this:

Code:
script, respawn enemies in first cave, begin
  set tag(1002, off)
  set tag(1003, off)
  set tag(1004, off)
  #etc
end


Where those numbers are the tag numbers shown after the "use only once option" in custom.
Back to top
View user's profile Send private message
NeoForce




Joined: 18 Jul 2007
Posts: 2

PostPosted: Thu Jul 19, 2007 2:40 pm    Post subject: Thanks Reply with quote

Wow, very cool

Thanks everyonKeep your eyes out for my soon-to-be-released (Hopefully)!
Back to top
View user's profile Send private message
DukeofDellot




Joined: 07 Feb 2003
Posts: 32

PostPosted: Thu Jul 19, 2007 3:53 pm    Post subject: Also something neat... Reply with quote

You know, it took me a while to figure this out, but you can also do this without tags. "Destroy NPC" only removes the NPC until the player uses a door, so I messed around with it a bit, and made a script that uses no tags, and keeps the NPC on the map if you run away from combat.

This is the exact script I'm using:
Code:

Script, Tikar Battle, Who, begin

alter NPC (who,NPCstat: activation, NPCactivation: use)
wait (2)

If ((fight formation (random (0,3)))==1)
     then  (destroy NPC (who))

     else  (wait (50)
             alter NPC (who,NPCstat: activation, NPCactivation: touch))

end


A few things to note:
The variable "Who" is set in Custom.exe in the NPC options and should be the same as the NPC number.
Edit (this sentence was a mess):Because the NPCs are no longer "destroyed" when you use a door, the same few NPCs can be used multiple times in a dungeon. You just must make sure that seeing extra copies of an NPC requires the use of a door.
I'm going to be "customizing" the script for different enemy sets so that certain NPCs get battle formations determined by the party's levels, and others may have that second wait command shortened so that they seem to pursue the player a little more aggressively (in which case I will also make them switch between "stand still" and "follow player" in movement types).

Also, I think I've gotten rid of it by including the first "alter NPC" command and that little wait (2) at the beginning, but there was this really nasty bug for a while that caused the NPC to trigger and send the player into an infinite number of battles from time to time, but I think I've got it.

And, Camdog, I'd like to say that I had never thought to use the tags above 1000 in my scripts... I might have to keep that in mind for later.


Last edited by DukeofDellot on Thu Jul 19, 2007 4:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Thu Jul 19, 2007 4:16 pm    Post subject: Reply with quote

This is essentially what I did for Scary Game 2, except it wasn't as clean since the fight screen was a different map. You can choose to remember NPC states now, though, which would've solved that problem.

Out of curiosity, is there a plotscripting command to reset NPC states? There should be.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
DukeofDellot




Joined: 07 Feb 2003
Posts: 32

PostPosted: Thu Jul 19, 2007 7:56 pm    Post subject: oops... Reply with quote

Now there's a new bug, and I realize what happened... which is pretty funny. The destroy NPC command only targets the first copy of it... so... heh... you know, I just thought of that as I was typing. Either way, it was kind of funny that it took winning two fights to get the opponents to disappear. (Switching back from GML is messing with my head...)

And since I don't know the real answer to my problem... I'm going with "brute force" and making it say "Destroy NPC (who)" a number of times adjusted for the dungeon. In this case, the opening dungeon only needs two...

I guess if I wasn't so stubborn, I would switch over to tags... but... I'm a jerk like that...

In short, the script shown in my previous post does not allow the use of the same NPCs in different rooms of the map. Though if you do not use duplicate NPCs, it should still work fine.

EDIT: I take it back...

SHAZAM!!!
Code:


Script, Tikar Battle, Who, begin

alter NPC (who,NPCstat: activation, NPCactivation: use)
wait (2)

If ((fight formation (random (0,3)))==1)
     then  (while (NPC copy count (who)>>0)
                      do (destroy NPC (who))

     else  (wait (50)
             alter NPC (who,NPCstat: activation, NPCactivation: touch))

end


I fixed it... heh... ... ... I really should wait and post at this point, shouldn't I?

Either way, the code I put here should produce the results I promised on my first post, including the ability to reuse NPCs under the conditions stated without it appearing to have them reused. ... ... ... I feel special now. Sorry about me being a little slow...
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: Fri Jul 20, 2007 4:17 am    Post subject: Re: Also something neat... Reply with quote

There's no reason to pass the NPC id number to your script: it is passed the npc reference automatically as the 2nd argument, so you can delete the right NPC. See 'Plotscripting Tutorial#Other Ways to Start a Script'


Code:

Script, Tikar Battle, Dummy, Who, begin

alter NPC (who,NPCstat: activation, NPCactivation: use)
wait (2)

If (fight formation (random (0,3))
     then  (destroy NPC (who))

     else  (wait (50)
             alter NPC (who,NPCstat: activation, NPCactivation: touch))

end


Also, realise that every time you fight a battle, the map is reloaded, so all deleted npcs come back. (Incidentally, this is because for the DOS versions there wasn't enough memory to keep the map loaded, but it could be changed now (according to an option))

If you're using a WIP, you can delete the NPCs as you are doing, set the map to remember NPCs, and reset the NPC data when you enter the map.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
DukeofDellot




Joined: 07 Feb 2003
Posts: 32

PostPosted: Fri Jul 20, 2007 3:32 pm    Post subject: Reply with quote

huh... I did not know that... I guess I've got more reading to do then.

Thanks, Cacti.
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: Sat Jul 21, 2007 4:23 am    Post subject: Reply with quote

Oh, my mistake. After battle, the map is reloaded, and though tile data is reloaded, npc data is not.

So there's no need to use the new mapstate remembering features.
_________________
"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