Hungry Guy scripting demo

Community Forums/Showcase/Hungry Guy scripting demo

WendellM(Posted 2003) [#1]
The Military Essentials package from Binary People has given me a decent set of animated figures to work with. One sort of project I've been interested in for a while is creating scripted "movies" for in-game cutscenes.

To do a proper job of it, I plan to build a GUI editor (using Yappy's XLnt II), but first I threw together a proof-of-concept test to make sure that my proposed approach would work. This uses elapsed time to determine when events (such as character walking or camera zoom) should start and stop. The timing is based on passes through the main loop (limited by WaitTimer), rather than using Millisecs, so that it remains functional even if the PC experiences slowdown. A script looks like:

Select elapsed
Case 3:text1=True ;"I'm hungry"
Case 6:text1=False:Cam1=True ;zoom in
Case 7:Cam1=False
Case 8:text2=True ;"Haven't eaten all day"
Case 11:text2=False:Cam2=True ;zoom in on face
Case 12:Cam2=False
Case 13:text3=True ;"The vending machine"
Case 16:text3=False
Case 17:Cam3=True ;cut to side view
Case 18:cam3=False:walk1=True ;walk toward door
End Select

It currently uses whole seconds, but finer timing is possible. A separate set of If-Thens executes the actions that are turned on and off by the 'script.'

For the test, I put together a two-room 'set,' loading and positioning models (from Carrara) within Blitz. The 'actor' is a retextured soldier from the Military Essentials pack (I've removed all but four animations from the modified .b3d). The result is something that rivals the first silent movies for crudeness, but which shows promise:


There's still plenty of refinement to be done (using functions, allowing external script files to be saved and read, etc.), but the potential does seem to be there. So, I'm inflic... err... *sharing* it with the Blitz community in its current form (3.8 megs, with source, executable, and models): http://frontieruniverse.com/HungryGuy.ZIP

(For the incautiously curious: the reason the guy is trying to get food goes back to SSI's FRUA from 1993. The first test adventure I wrote for it was "Quest for the Jeno's Pizza Rolls" which was just my apartment with said pizza rolls located in the kitchen; since then, all my early tests of adventure-type systems involve someone seeking food, just for tradition.)


Beaker(Posted 2003) [#2]
That seems to work pretty well. The camera seemed a bit stepped tho, but that's adjustable I suppose and probably down to my gfx card more than anything.


darklordz(Posted 2003) [#3]
funny...


Red Ocktober(Posted 2003) [#4]
hey, how are ya finding working with those animatrons from the Military Essentials package...

--Mike


WendellM(Posted 2003) [#5]
@MasterBeaker, Thanks. As it is now, every user will see the exact same set of frames as every other user, even if that means slowdown. If the camera is jerky, then you're probably right that it's your video card (the full 'movie' should take 46 seconds; if it's taking longer, then it's running less than 30 FPS). I consider this better than forcing it to take only 46 seconds (which is possible, but then the camera and figure movements would have big jumps to keep up).

@Darklordz, yeah - that's my attempt at comedy <g>.

@Mike, a good experience so far. The frame ranges are clearly shown in the HTML documentation. There's a demo program included that lets you quickly look at whichever one you're interested in, using any of the available models, and it also shows how to use the appropriate weapon. I found it very easy to use them and to adjust the timing (the walk synchs with the movement speed, and the sped-up "climb ladder" gives the effect I was hoping for). In removing the unused keyframes with Character FX, it became clear how simple it would be to modify the animations. Since the models are boned, it's also possible to apply in-game, real-time "overrides" to any joint(s) during animation if needed, though I haven't yet played with that.


Tranz(Posted 2003) [#6]
Seeking food has a long and noble history...as such, it needs no futher explaination


googlemesilly(Posted 2003) [#7]
I thought the ending was sad ! should have
made it happier ! haha

I liked the part how he tries to open the machine
that was funny ! ha ... (both arms waving forward haha)


Red Ocktober(Posted 2003) [#8]
Thanks for the info Wendell...

... one more thing.

... would be relatively easy to mod one of the soldiers to change his appearance?

--Mike


dangerdave(Posted 2003) [#9]
Wow, someone else has used FRUA!

DL'ing hungry guy ...


WendellM(Posted 2003) [#10]
@Mike, redoing the texture is quite easy (you can try it yourself by repainting GuyTex.jpg). The mesh can also be modded pretty easily. Here's a changed version I did by converting from .b3d to .ms3d in UltimateUnwrap, spending less than 5 minutes moving some mesh vertices in MilkShape (I left the skeleton alone), then exporting back as .b3d: http://frontieruniverse.com/Guy.b3d (you can just overwrite the current Guy.b3d in the Data folder).

It's a horrible mutant with long nose, big skull, enlarged left arm, and breasts(!) but it still works fine with the original program (except for the collapsing animation, which is a little offset). A silly example, but it shows how easily the mesh can be modified without having to adjust the skeleton:


@dangerdave99, yeah, I never made anything "real" with FRUA, but it sure was fun to play around with. Truly a classic adventure game/RPG maker.


Red Ocktober(Posted 2003) [#11]
... cool

Thanks Wen...

--Mike


NTense(Posted 2003) [#12]
@Wendell
Since the models are boned, it's also possible to apply in-game, real-time "overrides" to any joint(s) during animation if needed, though I haven't yet played with that.


I'm doing the "overrides" right now in another game I'm working on, allowing me to point the body/arm/gun at a userdefined reticle. Here are a couple of shots:





This if my first bit of work with it. I'm working on writing a physics library to provide Havok style Ragdoll physics (this is a slow WIP, but none-the-less, coming along). The important thing you have to remember is to update the "overridden" bone rotation/position AFTER you've called UpdateWorld.. Here's the code I used in those shots:
For k = 1 To frames
		time = time + period
		If k = frames Then CaptureWorld
		
		If MainMenuflag	 = 1 Then	
			MainMenu()
		ElseIf MainMenuFlag = 0 And SinglePlayerFlag = 1 Then
			UpdateGame()
		EndIf
		
		UpdateWorld
		
		If InGameFlag = 1 Then
			Player.T_Player = FindPlayer_Local()
			; UPDATE RIDER ANIMATION OVERRIDES
			PointEntity Player\Rider\RightShoulder, Reticle\CounterBalance
			PointEntity Player\Rider\BodyHandle, Reticle\CounterBalance
			RotateEntity Player\Rider\BodyHandle, EntityPitch(Player\Rider\BodyHandle)*0.5, EntityYaw(Player\Rider\BodyHandle)*0.5, EntityRoll(Player\Rider\BodyHandle)*0.5
			PointEntity Player\Rider\CurrentWeapon\ObjectHandle, Reticle\CounterBalance
		EndIf
		
	Next
		
	; Render 3D stuff
	RenderWorld tween#
;etc........


@Mike:
would be relatively easy to mod one of the soldiers to change his appearance?


Not hard at all.. The models come in multiple formats including the original MS3D format. So you can edit away. I have also started posting some tutorials on my website for retexturing, and attaching accessory objects. I'll be posting more as I have time, and people have questions.


WendellM(Posted 2003) [#13]
Thanks for the sample code, NTense. What's he riding on, BTW, the Linux penguin?
Do you get to shoot at big boxes of Windows and Office that shoot bugs at you, with Bill Gates as the end boss? <g>
I'd like to see that in a game.... Maybe as a future project.


NTense(Posted 2003) [#14]
It's an Ostrich ;-) .. I'm going for a Joust3D/Combat/Online Tournament game. I haven't even really come up with a name for it yet, but it already 'feels' fun, and I haven't even gotten the gameplay fully implemented yet. Hmm.. I may have to add a Linux penguin somewhere in the mix just for fun!


Bot Builder(Posted 2003) [#15]
Hehehe. this hungry guy demo is funny. wierd ending though. it'd be better if the machine shot out a buch of sprites textured to look like bags of chips and candy bars, and have the guy run around in circles shouting "food! food! food!"

Anyway, I stole singularitie's footstep sounds, gave him a death sound, and used Metalman's speech dll to make the guy talk. It wasn't to hard, but It makes it much more enertaining.


Doggie(Posted 2003) [#16]
I thought it would be better if he rocked the machine till it fell over on him. Kersplat! Actually, I was surprised that's not what happened. Anyways, I've been wanting to make a "movie maker" thingamajig in Blitz for quite a while so maybe there's code here I can steal...I mean ideas I can learn from. hehe

Doggie


Tranz(Posted 2003) [#17]
The guy should have gotten the food at the end...and since he's dead there'll be no sequel!

Great stuff though, lol!


WendellM(Posted 2003) [#18]
Thanks, guys - I'm glad you found it amusing and helpful as a starting point for going further.
I've been exploring ways of making it easier to use via external text scripts, which currently look like:

0 Initial Setup
 Cam -30,15,0, 0,-120,0
 AmbientLight 120, 120, 120
2 Soldier 2 asks question
 disp 0,255,0, 500,500, "Did you hear something?", 2  
5 Soldier 1 replies
 disp 128,128,255, 300,500, "No, nothing.", 2
7 Start the bad guy creeping forward
 anim Bad1, 28, 1, 0.25, 10
 move Bad1, 0, 0, -.15, 6
8 Move camera to show bad guy
 cam 0,25,5, 20,180,0

The script lines are parsed into a type with parameters as fields.
For one-time actions (like a camera change), the command is executed once:
Case "cam";Cam X Y Z Pitch Yaw Roll
	PositionEntity Camera,temp\param1,temp\param2,temp\param3
	RotateEntity camera,temp\param4,temp\param5,temp\param6

For 'persistent' actions (executed each frame), the action is put in a Persistent typelist with an expiration time:
Function MakePersist(cmd$);calculates ending time of persistent action and puts it in type list
	Persist.PersistType=New PersistType
	Persist\cmd=cmd$
	Expire$=Right(cmd$,2);good for up to 99 seconds
	Persist\expire=Int(expire)+elapsed;when to remove it from list
End Function

And then the persistent actions are executed each frame (or deleted if expired):
For pers.PersistType=Each PersistType
If pers\expire=elapsed Then
	Delete pers
Else
	Select Temp\Command
	Case "move";Move Actor$ X Y Z Secs
		Activate(temp\param1)
		MoveEntity Model\ObjectHandle,temp\param2,temp\param3,temp\param4

My next planned step is writing a 3D GUI editor (with XLnt ii) to generate the scripts in an easy way.
However, Koriolis' Blitz Virtual Machine looks pretty interesting, so I've downloaded the demo and will be taking a look at it.
If it's possible to create scripts with Blitz syntax then there's no need to use this interpreted system,
and the editor could just create Blitz VM code to be 'compiled'... we'll see.

The updated version of this scripting system is here: Shootout 5 text scripting demo.