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

Need help with plotscripting NPCs movements for a "movi

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






PostPosted: Sat May 23, 2009 2:57 am    Post subject: Need help with plotscripting NPCs movements for a "movi Reply with quote

plotscript,chest,begin
show text box (1)
wait for key
suspend player
fade screen out
show backdrop(4)
wait (10)
fade screen in
wait(10)
resume player
wait for key
suspend player
fade screen out
show map
wait (10)
fade screen in
write map block (10,4,42,3)
write map block (10,5,43,3)
show text box (2)
wait(10)
resume player
wait for key
suspend player
walk hero (me,left,2)
wait for hero (me)
set hero direction (me,up)
wait for hero (me)
set hero direction (me,right)
wait for hero (me)
write map block (10,4,55,3)
write map block (10,5,40,3)
suspend NPCs
suspend obstruction
variable (Siil)
Siil := NPC reference (3,0)
set tag (3,on)
set NPC direction (Siil,south)
wait (3)
walk NPC (Siil,south,1)
wait (3)
walk NPC (Siil,south,1)
wait (3)
walk NPC (Siil,south,1)
wait (3)
walk NPC (Siil,south,1)
wait (3)
destroy NPC (Siil)
resume NPCs
resume obstruction
resume player
save map state (mapstate:tilemap)
end

Everything works like a charm until I use the command "set NPC direction" and the script doesn't do anything until the command "resume NPC" (so basically lines 39-49 are corrupt). The compiler says everything is OK but i don't get the effect that i want

Here are some pictures with comments (hope you understand the situation a bit more)






Back to top
Newbie_Power




Joined: 04 Sep 2006
Posts: 1762

PostPosted: Sat May 23, 2009 3:07 am    Post subject: Reply with quote

Reading your screenshots you can actually layer multiple NPCs on top of each other if you use Ctrl + Direction to place them instead.

With that aside, to make NPCs respond to move commands, you need to make sure they have a movement speed in the editor. This is something I noticed being an issue with scripts at times.

You'll also want to have "wait for NPC" after some of your move NPC commands, so that it doesn't use other commands pre-maturely (it doesn't wait to do wait (3), and then walk NPC, etc). I'm not sure if that'll fix the problem, but it's definitely something I suggest.
_________________

TheGiz> Am I the only one who likes to imagine that Elijah Wood's character in Back to the Future 2, the kid at the Wild Gunman machine in the Cafe 80's, is some future descendant of the AVGN?
Back to top
View user's profile Send private message
Gizmog1
Don't Lurk In The Bushes!




Joined: 05 Mar 2003
Posts: 2257
Location: Lurking In The Bushes!

PostPosted: Sat May 23, 2009 3:34 am    Post subject: Reply with quote

I'm curious about the wait commands too, because other than that the script looks fine. Did you remember to set the NPC's speed to something other than 0 in the editor?
Back to top
View user's profile Send private message Send e-mail AIM Address
Calehay
...yeah.
Class B Minstrel



Joined: 07 Jul 2004
Posts: 549

PostPosted: Sat May 23, 2009 5:13 am    Post subject: Reply with quote

Quote:
Code:
Siil := NPC reference (3,0)


It is early in the morning, so maybe my brain hasn't woken up with the rest of me, but isn't Siil NPC 2 based on your screenshot?

EDIT:

Also, what are you trying to get out of these lines of script:

Quote:
Code:
set NPC direction (Siil,south)
wait (3)
walk NPC (Siil,south,1)
wait (3)
walk NPC (Siil,south,1)
wait (3)
walk NPC (Siil,south,1)
wait (3)
walk NPC (Siil,south,1)
wait (3)


What this script will do as written is; once Siil begins moving, the game will wait 3 ticks, and whether Siil is still moving or not, Siil will be told to move south another tile. If you'd like for Siil to walk down one tile and then wait 3 ticks before moving again, then you need to add:
Code:
Wait for NPC (Siil)

After each WalkNPC command.
_________________
Calehay


Last edited by Calehay on Sat May 23, 2009 5:21 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
Guest







PostPosted: Sat May 23, 2009 5:15 am    Post subject: Reply with quote

Speed is 0 in editor, changed the code to:
plotscript,chest,begin
show text box (1)
wait for key
suspend player
fade screen out
show backdrop(4)
wait (10)
fade screen in
wait(10)
resume player
wait for key
suspend player
fade screen out
show map
wait (10)
fade screen in
write map block (10,4,42,3)
write map block (10,5,43,3)
show text box (2)
wait(10)
resume player
wait for key
suspend player
walk hero (me,left,2)
wait for hero (me)
set hero direction (me,up)
wait for hero (me)
set hero direction (me,right)
wait for hero (me)
write map block (10,4,55,3)
write map block (10,5,40,3)
suspend NPCs
suspend obstruction
variable (Siil)
Siil := NPC reference (3,0)
set tag (3,on)
set NPC direction (Siil,south)
wait for NPC (Siil)
walk NPC (Siil,south,4)
wait for NPC (Siil)
destroy NPC (Siil)
resume NPCs
resume obstruction
resume player
save map state (mapstate:tilemap)
end
Back to top
Guest







PostPosted: Sat May 23, 2009 5:16 am    Post subject: Reply with quote

Calehay wrote:
Quote:
Code:
Siil := NPC reference (3,0)


It is early in the morning, so maybe my brain hasn't woken up with the rest of me, but isn't Siil NPC 2 based on your screenshot?


o.O just noticed that. Ill try straight away
Back to top
Guest







PostPosted: Sat May 23, 2009 5:18 am    Post subject: Reply with quote

still nothing , any other suggestions?
......
suspend NPCs
suspend obstruction
variable (Siil)
Siil := NPC reference (2,0)
set tag (3,on)
set NPC direction (Siil,south)
wait for NPC (Siil)
walk NPC (Siil,south,3)
wait for NPC (Siil)
destroy NPC (Siil)
resume NPCs
resume obstruction
resume player
save map state (mapstate:tilemap)
end
Back to top
Calehay
...yeah.
Class B Minstrel



Joined: 07 Jul 2004
Posts: 549

PostPosted: Sat May 23, 2009 5:25 am    Post subject: Reply with quote

Anonymous wrote:
Speed is 0 in editor


It has to be more than 0 for an NPC to move.
_________________
Calehay
Back to top
View user's profile Send private message AIM Address
Guest







PostPosted: Sat May 23, 2009 5:55 am    Post subject: Reply with quote

Its 1 now but it still doesn't work
Back to top
Lynx
Guest






PostPosted: Sat May 23, 2009 5:59 am    Post subject: Reply with quote

This is what i have now - thanks to you guys I found out that I can place more than 1 NPC on 1 tile, therefore I went back to my original idea of the NPC "Siil" being on the chest (invisible) and moving in a zigzag down to the doorway.

plotscript,chest,begin
show text box (1)
wait for key
suspend player
fade screen out
show backdrop(4)
wait (10)
fade screen in
wait(10)
resume player
wait for key
suspend player
fade screen out
show map
wait (10)
fade screen in
write map block (10,4,42,3)
write map block (10,5,43,3)
show text box (2)
wait(10)
resume player
wait for key
suspend player
walk hero (me,left,2)
wait for hero (me)
set hero direction (me,up)
wait for hero (me)
set hero direction (me,right)
wait for hero (me)
write map block (10,4,55,3)
write map block (10,5,40,3)
suspend NPCs
suspend obstruction
variable (Siil)
Siil := NPC reference (2,0)
set tag (3,on)
set NPC direction (Siil,south)
wait for NPC (Siil)
walk NPC (Siil,south,1)
wait for NPC (Siil)
set NPC direction (Siil,west)
wait for NPC (Siil)
walk NPC (Siil,west,1)
wait for NPC (Siil)
set NPC direction (Siil,south)
wait for NPC (Siil)
walk NPC (Siil,south,2)
wait for NPC (Siil)
destroy NPC (Siil)
resume NPCs
resume obstruction
resume player
save map state (mapstate:tilemap)
end
Back to top
Calehay
...yeah.
Class B Minstrel



Joined: 07 Jul 2004
Posts: 549

PostPosted: Sat May 23, 2009 7:01 am    Post subject: Reply with quote

I've tried it as you've described, and it seems to work. However, I did learn that if tag 3 is not on before this script starts, you will not be able to control NPC 2. Can you confirm tag 3 is on by hitting F4 before using NPC 0?
_________________
Calehay
Back to top
View user's profile Send private message AIM Address
Guest







PostPosted: Sat May 23, 2009 9:08 am    Post subject: Reply with quote

Okedoke - after many hours of experimentation Pissed off! I came to the conclusion that the "write map block" command that i used on the chest and the tiny invisible NPC's that surround it WILL MAKE IT IMPOSSIBLE to put a npc on them (via plotscript) and also move on them.

To be sure i also removed the tag that makes the npc appear and now the npc is hidden on the map in a wall surrounded box (covered by a overtile).

So now i destroyed the invisible npc's which surrounded the chest and used the "set NPC position" command to place the important Hedgehog NPC 1 tile below the chest. It doesn't look very nice, but it works.

(It would be nice if there would soon be an option to place npc's on pieces of tilemap which have been changed via the "write map block" command)

plotscript,chest,begin
variable (Hedgehog)
variable (Therealchest)
variable (Theonbutton)
variable (Theoffbutton)
Hedgehog := NPC reference (2,0)
Therealchest := NPC reference (0,0)
Theonbutton := NPC reference (1,0)
Theoffbutton := NPC reference (3,0)
show text box (1)
wait for key
suspend player
fade screen out
show backdrop(4)
show text box (3)
wait (10)
fade screen in
wait(10)
resume player
wait for key
suspend player
fade screen out
show map
wait (10)
write map block (10,4,42,3)
write map block (10,5,43,3)
fade screen in
show text box (2)
wait(10)
resume player
wait for key
suspend player
set tag (3,on)
walk hero (me,left,2)
wait for hero (me)
set hero direction (me,up)
wait for hero (me)
set hero direction (me,right)
wait for hero (me)
write map block (10,4,55,3)
write map block (10,5,40,3)
suspend NPCs
suspend obstruction
destroy NPC (Therealchest)
destroy NPC (Theonbutton)
destroy NPC (Theoffbutton)
wait for all
set NPC position (Hedgehog, 10, 6)
wait for NPC (Hedgehog)
set NPC direction (Hedgehog,south)
wait for NPC (Hedgehog)
wait (5)
set NPC direction (Hedgehog,east)
wait for NPC (Hedgehog)
wait (5)
set NPC direction (Hedgehog,south)
wait for NPC (Hedgehog)
wait (5)
set NPC direction (Hedgehog,west)
wait for NPC (Hedgehog)
wait (5)
set NPC direction (Hedgehog,south)
wait for NPC (Hedgehog)
wait (5)
set NPC direction (Hedgehog,west)
wait for NPC (Hedgehog)
wait (5)
walk NPC (Hedgehog,west,1)
wait for NPC (Hedgehog)
wait (5)
set NPC direction (Hedgehog,south)
wait for NPC (Hedgehog)
wait (5)
walk NPC (Hedgehog,south,2)
wait for NPC (Hedgehog)
destroy NPC (Hedgehog)
resume NPCs
resume obstruction
resume player
save map state (mapstate:all)
end

(FINAL VERSION - WORKS) Razz
Back to top
Calehay
...yeah.
Class B Minstrel



Joined: 07 Jul 2004
Posts: 549

PostPosted: Sat May 23, 2009 9:35 am    Post subject: Reply with quote

When I tested the way you had it, it worked the way you described it as long as tag 3 was set before the NPC 0 script commenced (which I assumed it was set by stepping on NPC 1, and not mid-script.) so I don't think it's a problem with writemapblock. I did test what would happen if tag 3 was not set before starting that script and tag 3 was turned on during the scene, and the NPC appeared, but did not move.

Honestly, though, I think it would be easier to use create NPC. Just change NPC 2 to appear all of the time, remove it from the map and from your last iteration of the previous script, change:

Code:
Siil := NPC reference (2,0)
set tag (3,on)


to

Code:
Siil := Create NPC (2, X, Y, dir) #Changing "X" and "Y" to the x and
#y coordinates you want the NPC to stand at, and
#"dir" with the direction you need the
#NPC to face.


I also tried this, and it worked. I wouldn't settle for something you don't like quite yet.
_________________
Calehay
Back to top
View user's profile Send private message AIM Address
Lynx
Guest






PostPosted: Sat May 23, 2009 9:50 am    Post subject: Reply with quote

I changed it all around - just to be sure

Sorry - it isnt possible to create a NPC on a tile that has been altered with "write map block" command.

I am sure of this.
Back to top
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat May 23, 2009 11:36 am    Post subject: Reply with quote

First off, some comments about your script not related to the bug:

Code:
resume player
wait for key
suspend player

You don't need to resume the player in order to check for keypresses. suspend/resume player just stops keypresses from causing builtin effects like moving the hero, opening the menu, etc.

Code:
write map block (10,4,42,3)
write map block (10,5,43,3)

Bad. You are writing to map layer 3 but there is no map layer 3, only 0, 1 and 2. Due to wonky code in the engine, this will affect layer 2 instead, which is probably what you wanted. But you should fix your script anyway, or it will do the wrong thing when a 4th map layer is added.

Code:
set hero direction (me,up)
wait for hero (me)
set hero direction (me,right)
wait for hero (me)

You don't have to waitforhero when changing direction. This does nothing, except that waitforhero (and waitfornpc and waitforcamera) always wait for at least 1 tick, so this is equivalent to:
Code:
set hero direction (me,up)
wait (1)
set hero direction (me,right)
wait (1)


Code:
set NPC direction (Siil,south)
wait for NPC (Siil)
walk NPC (Siil,south,2)
wait for NPC (Siil)

This makes the NPC pause for 1 tick before moving. "walk NPC" automatically changed the NPC's direction. Maybe you didn't want this extra wait.

Code:
destroy NPC (Theoffbutton)
wait for all

Again, destroyNPC is instant, no need to wait.


Also, "create NPC" lets you create NPCs on top of each other, on top of the hero or anywhere on the map.

Quote:
Sorry - it isnt possible to create a NPC on a tile that has been altered with "write map block" command.

This is not true; it didn't work because of some other problem, but I can't tell you which one because you didn't post the script.


Now, your problem was that Siil only appears when tag 3 is on, but when you walk the hero two spaces to the left, they step on npc 3 which turns tag 3 off. You turn it back on in your script:
Code:
Siil := NPC reference (3,0)
set tag (3,on)

BUT, you don't do this until AFTER grabbing the NPC reference. Siil won't appear on the map until the second line. You need to swap these two lines around, and the script should work.


But, I agree, using createnpc is MUCH easier and bug-avoiding than using tags.
_________________
"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