 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Wed Jul 16, 2008 4:23 pm Post subject: Script freeze - possible wantimmediate problem...? |
|
|
Maybe I've just been away from scripting too long, but I can't find the problem here.
Basically, I have an NPC who calls a textbox, which itself calls a script instead if a certain tag is turned on. This script follows:
Code: | plotscript, ast forest guard, begin
swtextbox(555)
get NPC to Y(2,31)
set NPC direction (2,north)
end |
The first and second lines are simple scripts:
Code: | script,swtextbox,box=0,begin
show text box(box)
wait for text box
end
script,getNPCtoY,who=-1,y=0,begin
alternpc(who,npcstat:picture,readnpc(who,npcstat:picture)+1)
#the line above changes the graphic from the 'standing' to the 'walking' pose
while(npcy(who)<>y),do
begin
walk npc to y (who,y)
end
waitfornpc(who)
alternpc(who,npcstat:picture,readnpc(who,npcstat:picture)--1)
#this line puts the picture back to the 'standing' pose
end |
When I activate the NPC with tag turned off, everything is fine (no script called). When the tag is on, the game freezes. Textbox 555 never shows, the npc never changes picture or tries to walk or anything. What is all the more perplexing is that there is no suspension of player anywhere, and no waits in the one loop involved, so even if the script 'failed' I don't see how it could freeze the game. Before people ask, I will verify the following simple things:
*The NPC 2 does have a moving speed of 2, and is the only copy of NPC 2 on the map
*The text box numbers are correct (box 554 leads to the script, which itself calls 555; 554 does not 'also' try to call 555)
*The map is correct - the destination tile has y-coordinate 31, and there are no walls in the way
However, there is aonther issue that might be interfering. There is also an on-keypress script:
Code: | plotscript, gen keypress, begin
if( (key is pressed(key:alt),or,key is pressed(key:esc)) ,and, (topmenu==false)),then
begin
suspendnpcs
wait(1)
#more stuff dealing with menus that does involve waiting,
#but this should never have fun because no one pressed alt or esc
#besides, this script is on every map and has never caused
#problems anywhere else
end
if(NoBoatsOnMap),then
(UseKeyWallCheck)
end |
NoBoatsOnMap returns true on this map, so the script UseKeyWallCheck runs (again, this works fine everywhere else):
Code: | if(NoWallAhead==false),then
begin
#stuff that should not run, because there is no wall ahead, so
#NoWallAhead returned true; again, this is used everywhere else
#with no problems
end
end |
In gdebug, I have this:
WANTIMMEDIATE BUG
genkeypress terminated, setting wantimmediate on astforestguard
wantimmediate would have skipped wait on command 59 in swtextbox, state = 1
needf = 0 _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Wed Jul 16, 2008 10:05 pm Post subject: |
|
|
Your problem is this while loop:
Code: | while(npcy(who)<>y),do
begin
walk npc to y (who,y)
end |
Now take a look at the walk NPC to Y script:
Code: | script,walkNPCtoY,who,n,begin
if (n<<NPCY(who)) then(walk NPC(who,north,NPCY(who)--n))
if (n>>NPCY(who)) then(walk NPC(who,south,n--NPCY(who)))
end |
It doesn't wait for the NPC. Without a wait, the NPC never moves and the loop never exits. The while loop's not needed. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Thu Jul 17, 2008 4:44 am Post subject: |
|
|
D'oh!
Of course I would double and triple check all of my functions, but not Plotscr's. By the way, the while loop is needed. I'm not just rewriting walkNPCtoY, I'm making a function that keeps making the NPC try to walk to the given spot even when other wandering NPCs and/or heroes get in its way. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
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
|