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

Health Script: NPC Overflow, or some other problem?

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Dan the Man Entertainment




Joined: 31 May 2003
Posts: 204

PostPosted: Sat May 29, 2004 9:51 pm    Post subject: Health Script: NPC Overflow, or some other problem? Reply with quote

I made a health script. It is as follows. It is a meter.

script, herohealth, begin
while (health>>0)do(
wait (1)
if (health<=0) then(
gameover
)
else (
if (health>=30,and, health==40)then(
destroy npc (32)
createnpc (32, 12, 0, up)
createnpc (32, 13, 0, right)
createnpc (32, 14, 0, right)
createnpc (32, 15, 0, left)
)
if (health>=20, and, health<<30)then(
destroy npc (32)
createnpc (32, 13, 0, right)
createnpc (32, 14, 0, right)
createnpc (32, 15, 0, left)
)
if (health>=10, and, health<<20) then(
destroy npc (32)
createnpc (32, 14, 0, right)
createnpc (32, 15, 0, left)
)
if (health>=1, and, health<<10) then(
destroynpc(32)
createnpc (32, 15, 0, left)
)
)
)
end

For some reason, when the script is used,
it works, but it slows down the
game after a certain period of time and makes
the sword not appear (but it still does damage).
It also prevents the enemy from
awaking (the enemy is started by a script that has
been implemented into the npc by custom
and is activated by a starting script). Does anyone
know why the game lags? Is it because of
npc overflow, or something else that I messed up on?
Back to top
View user's profile Send private message
Flamer
The last guy on earth...




Joined: 04 Feb 2003
Posts: 725
Location: New Zealand (newly discovered)

PostPosted: Sun May 30, 2004 4:03 am    Post subject: Reply with quote

i can see the reason behind this. it's quite simple, lets do a NPC count.

this portion of the script will repeat it self more or less the same. (bear with me, if i display the entire script, it can get messy)
Code:

destroy npc (32)           #NPCnumber --1
createnpc (32, 12, 0, up)   #NPCnumber --1 +1 ==NPCnumber
createnpc (32, 13, 0, right) #NPCnumber +1
createnpc (32, 14, 0, right) #NPCnumber +1 +1 == NPCnumber +2
createnpc (32, 15, 0, left)  #NPCnumber +2 +1 == NPCnumber +3

if you loop through that again, replacing the first NPCnumber with the one you got last, you'll keep creating more NPCs than you would destroy.

to solve it's pretty simple. And it can easily go something like this.
Code:

while(NPCcopycount(32) >>0) do(
 destroy npc(32)
)

which will keep checking if there is anymore copies of NPC(32) and destroy them if any exists
_________________
If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch Raspberry!
(no offense to anyone that was mentioned)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Dan the Man Entertainment




Joined: 31 May 2003
Posts: 204

PostPosted: Sun May 30, 2004 8:42 am    Post subject: Reply with quote

Doesn't "destroy npc" kill all copies of the given number? I used this exact
same script with the enemy and it didn't overflow (although it didn't really work correctly either). I think I'll try your method because it seems to
work pretty well.
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: Mon May 31, 2004 10:48 pm    Post subject: Reply with quote

Dan the Man Entertainment wrote:
Doesn't "destroy npc" kill all copies of the given number? I used this exact
same script with the enemy and it didn't overflow (although it didn't really work correctly either). I think I'll try your method because it seems to
work pretty well.


"destroy NPC" only destroys one NPC, not every copy on the map. I updated http://hamsterrepublic.com/ohrrpgce/plotdictionary.html#about-destroynpc to clarify that.
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