 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Dan the Man Entertainment
Joined: 31 May 2003 Posts: 204
|
Posted: Sat May 29, 2004 9:51 pm Post subject: Health Script: NPC Overflow, or some other problem? |
|
|
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 |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Sun May 30, 2004 4:03 am Post subject: |
|
|
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
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
Dan the Man Entertainment
Joined: 31 May 2003 Posts: 204
|
Posted: Sun May 30, 2004 8:42 am Post subject: |
|
|
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 |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Mon May 31, 2004 10:48 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|