Intro animation problem

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Intro animation problem

Post by Matokage »

I think I made a mistake while trying to make a slice be put on the screen while the camera focus on the other tip on the map

It's basically a bus rolling along a road while some text boxes pop on the screen.

Code: Select all

plotscript,busintro,begin
	variable (SLbus)
	SLbus := load large enemy sprite (0)
	suspend player
	teleport to map (3,109,0)
	focus camera (109,5,100)
	wait(1)
	put slice (SLbus,120,100)
	wait (1)
	show map
	focus camera (0,5,2)
	show textbox (19)
	wait (40)
	show textbox (20)
	wait (40)
	show textbox (21)
	wait (40)
	show textbox (22)
	wait (40)
	wait for camera
	fade screen out (0,0,0)
	wait (5)
	show backdrop (0)
	fade screen in
	teleport to map (2,0,0)
	focus camera (32,60,500)
	wait for camera
	show map
	put slice (SLbus,120,200)
	wait (10)
	move slice to(SLbus,120,100,2)
	wait for slice (SLbus)
	put hero
	teleport to map (2,32,60)
	resume player
Also, this script is activated by this other script before it ends

Code: Select all

plotscript, intro, begin
	suspend player
	show backdrop (0)
	show textbox (1)
	wait for textbox
	show map
	focus camera (17,14,100)
	wait (1)
	show textbox (2)
	wait for textbox
	show textbox (3)
	wait for textbox
	show textbox (4)
	wait for textbox
	show textbox (5)
	wait for textbox
	play song (2)
	wait (24)
	show textbox (6)
	wait for textbox
	show textbox (7)
	wait for textbox
	show textbox (8)
	wait for textbox
	show textbox (9)
	wait for textbox
	show textbox (10)
	wait for textbox
	show textbox (11)
	wait for textbox
	wait(10)
	set npc direction (npc reference (1,1),north)
	wait (5)
	show textbox (12)
	wait for textbox
	walk npc (npc reference(1,2),west,5)
	wait for npc (npc reference(1,2))
	walk npc (npc reference(1,2),north,1)
	wait for npc (npc reference(1,2))
	teleport to map (0,1,1)
	wait(1)
	focus camera (18,8,100)
	wait (1)
	fade screen out (23,00,23)
	wait (5)
	fade screen in
	wait (3)
	fade screen out (00,23,23)
	wait (5)
	fade screen in
	wait (3)
	fade screen out (23,23,00)
	wait (5)
	fade screen in
	wait (3)
	teleport to map (1,18,16)
	wait(1)
	focus camera (17,14,100)
	put npc (npc reference(1,2),18,12)
	wait for npc (npc reference(1,2))
	set npc direction (npc reference(1,1),east)
	show textbox (13)
	wait for textbox
	set npc direction (npc reference(1,2),west)
	show textbox (14)
	wait for textbox
	show textbox (15)
	walk npc (npc reference(1,1),west,7)
	wait for npc (npc reference(1,1))
	advance textbox
	show backdrop (0)
	wait (15)
	show textbox (16)
	wait (50)
	show textbox (17)
	wait (30)
	show textbox (18)
	wait (30)
	resume player
	busintro
end
I know it's too many lines but, can someone help with this... mess?
"I can't buy food with glory"
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

What is supposed to be happening and what's happening instead?
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

The bus slice (SLbus) should be centered in the screen (and it is) and the camera focussing from one place of the map (109, 5) to the other tip (0,5) while some textboxes are beign shown on the screen. But what is happening is tha the camera still on the screen while the textboxes show on the screen.

Hmm... i think i should take a look at VoM for some referrence
"I can't buy food with glory"
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

But what is happening is tha the camera still on the screen while the textboxes show on the screen.
This part didn't make sense.

I doubt that you want the bus to stay at a fixed position on the screen while the camera moves about. It's more logical to "place" the bus on the map, move it around, and then you can move the camera independently as you wish. To do that, just parent the bus slice to the map: "set parent(SLbus, lookupslice(sl:map layer 0))", and then position it (put slice) relative to the top left of the map in pixels.

VoM doesn't use slices at all, and I don't think the scripts are a great source to learn from. They're mostly long cutscenes.
Last edited by TMC on Mon Feb 09, 2015 5:00 am, edited 2 times in total.
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

Can i parent it to a NPC? This would make things a lot easier.
"I can't buy food with glory"
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, you can: "set parent(SLbus, get npc slice(npc))", where npc is an id or reference.

In fact you can just change the NPC's sprite to another one of your choice directly:

Code: Select all

variable (sprite)
# The slice returned by getnpcslice isn't the walkabout sprite, but a container slice.
# Get the walkabout sprite
sprite := lookup slice(sl:walkabout sprite component, get npc slice(npc))
# And change it to something else...
replace large enemy sprite (sprite, 0)  # bus sprite
The walkabout sprite is aligned so the bottom edge is centered on the bottom edge of the tile the npc is standing on. If you parent another slice to the npc slice using the first method then it'll be positioned differently (top left corners aligned) so you'd probably have to align it manually.
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

Thanks TMC! I going to try both methods and see witch one works batter for me.
"I can't buy food with glory"
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

I think plotscripting isn't my forte

Code: Select all

variable (SLbus)
	variable (BUSC)
	BUSC := NPC reference (0,0)
	SLbus := load large enemy sprite (0)
	set parent(SLbus, get npc slice(BUSC))
	put slice (SLbus,1,1)
	suspend player
	teleport to map (3,109,0)
	camera follows npc (BUSC)
	wait(1)
	show map
	walk npc (BUSC,left,100)
The NPC walks and the camera follows hims but the slice do not appear at all
"I can't buy food with glory"
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

I think the issue is that you're teleporting to a different map and maybe that's... erasing the NPC you've got it parented to or something. Try rearranging the script so that you parent the slice after the teleport command like..

Code: Select all

variable (SLbus)
	variable (BUSC)


	suspend player
	teleport to map (3,109,0)
	SLbus := load large enemy sprite (0)
	BUSC := NPC reference (0,0)
	set parent(SLbus, get npc slice(BUSC))
	put slice (SLbus,1,1)
	camera follows npc (BUSC)
	wait(1)
	show map
	walk npc (BUSC,left,100)
Last edited by Gizmog on Sat Feb 14, 2015 10:19 am, edited 1 time in total.
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

That Solved the problem, but now i'm loading another map continuing the same cutscene but the slice doesn't come again. do i need to look for everything again?

Code: Select all

variable (SLbus)
	variable (BUSC)
	BUSC := NPC reference (0,0)
	SLbus := load large enemy sprite (0)
	set vert anchor (SLbus, edge:middle)
	set horiz anchor (SLbus, edge:center)
	teleport to map (3,109,0)
	set parent(SLbus, get npc slice(BUSC))
	put slice (SLbus,0,1)
	suspend player
	camera follows npc (BUSC)
	wait(1)
	show map
	walk npc (BUSC,left,100)
	show textbox (19)
	wait (100)
	show textbox (20)
	wait (100)
	show textbox (21)
	wait (100)
	show textbox (22)
	wait (100)
	wait for npc (BUSC)
	fade screen out (0,0,0)
	wait (5)
	show backdrop (0)
	fade screen in
	teleport to map (2,0,0)
	free slice (SLbus)
	put slice (SLbus,0,1)
	camera follows NPC (BUSC)
	show map
	wait (1)
	walk NPC (BUSC,left, 10)
	wait for NPC
	teleport to map (2,32,60)
	resume player
"I can't buy food with glory"
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

Nevermind, I just fixed it right now

Code: Select all

	wait for npc (BUSC)
	fade screen out (0,0,0)
	wait (5)
	show backdrop (0)
	free slice (SLbus)
	BUSC := NPC reference (0,0)
	SLbus := load large enemy sprite (0)
	set vert anchor (SLbus, edge:middle)
	set horiz anchor (SLbus, edge:center)
	fade screen in
	teleport to map (2,0,0)
	set parent(SLbus, get npc slice(BUSC))
	put slice (SLbus,0,1)
	camera follows NPC (BUSC)
	show map
	wait (1)
	walk NPC (BUSC,left, 9)
	wait for NPC
	wait (10)
	set hero position (0,32,59)
	camera follows hero
	walk NPC (BUSC,left,10)
	wait for NPC
	resume player
Just had to free the slice and parent it again, but it makes the slice flicker 1 time. Now I just need to add some bus sounds and i'm done with the intro.
Now to the game it self!
"I can't buy food with glory"
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Wait, your script still has a mistake, it's only an unlucky coincidence that it works. (I say unlucky, because it makes you think the script is correct).

Here is the problem:

Code: Select all

 BUSC := NPC reference (0,0)
   ...
   teleport to map (2,0,0)
   set parent(SLbus, get npc slice(BUSC)) 
When you change map, all NPC references that refer to NPCs on the previous map shouldn't be used on the new map; they'll refer to random or nonexistent NPCs. Likewise, all slices that were attached to NPCs no longer exist, so it would also be an error to attempt to free them (as you did in the first script). So just move "NPC reference" later.

But it's OK to create the slice before changing the map as long as you don't parent it to an NPC slice until afterwards.

I'm actually not sure why there would be a flicker though. When does it happen and what exactly happens?
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

If I were to guess, it's because of TeleportToMap. The dictionary says it has an automatic wait (1), and so it's probably a single tick flicker at the point of teleportation?
User avatar
Matokage
Slime Knight
Posts: 275
Joined: Sat May 26, 2012 11:48 pm
Contact:

Post by Matokage »

Gizmog wrote:If I were to guess, it's because of TeleportToMap. The dictionary says it has an automatic wait (1), and so it's probably a single tick flicker at the point of teleportation?
Yeah, i think thats the problem.
TMC wrote:When you change map, all NPC references that refer to NPCs on the previous map shouldn't be used on the new map; they'll refer to random or nonexistent NPCs. Likewise, all slices that were attached to NPCs no longer exist, so it would also be an error to attempt to free them (as you did in the first script). So just move "NPC reference" later.
"I can't buy food with glory"
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

But at the point of the teleporttomap command the screen is covered by backdrop 0 (which I assume is black), so you shouldn't see anything.
Post Reply