Saturday, December 28, 2013

CAOS snippets

Learning the CAOS language can be a painful experience.

When you look for command usage examples when debugging your very first CAOS console application, there's not much you can find :
  • The "inst,dde: getb cnam,endm" every single kit, app or example uses as a demo ( it shows current creature's name )
  • Some "cheat codes" to kill creatures, give them full life... always the same ones, and never any further documentation of how they work.
  • Raw CAOS documentation, with very few information on actual syntax, importance of spaces, commas or variables...
Putting it all together can be a tricky process, especially since the early Creatures games are very sensitive to the slightest CAOS script mistake and will mercilessly crash the whole game for a single missing space.

Just so you don't tear your hair out on your early CAOS experiments, here is a list of snippets that do some basic stuff, that you can just copy and paste in your CAOS console or custom app, without wondering if you should use lowercase, uppercase, commas, spaces brackets exactly as in the documentation or not.



This is neither a CAOS tutorial nor a complete documentation rewrite (those are coming in future articles though).Just a sample of readily usable code bits illustrating the use of some common commands you might need.

( Those are Creatures 1 CAOS snippets, though most of them should work the same on other games too. Things that could change include : chemical names, object classification, system menus ID's...)

 

Get current creature's name :

dde: getb cnam

Select the grendel:

enum 4 2 0,sys: camt,setv norn targ

Get quick stats on all norns:

dde: getb ovvd

This returns a list of parameters delimited by pipes "|' and is interpreted as such:
Name|Moniker|Sex|Age|Pregnancy|Life Force|Medical condition|Current Room|Xposition|Yposition

Count how many objects of any given classifier exist in the world:

dde: putv totl 4 1 0

4 1 0 is norns
4 2 0 is grendels
4 0 0 is norns and grendels ( and anything else if you imported ettins or other species in C1 )

Get the number of rooms in the game:

dde: putv rms#

Make the hand say something 

(Norns don't hear it nor act upon it when you use 'say$', useful for debugging messages.Brackets are mandatory )
enum 2 1 1 say$ [Hello there]


Get the hand's position ( given in absolute world coordinates ):

enum 2 1 1 dde: putv posl,dde: putv posr,dde: putv post,dde: putv posb

A sample of using sys: cmnd # for running existing menu options :

(The complete list of ID's for C1 and C2 can be found here )

Pause the game:
sys: cmnd 32838


Resume the game
sys: cmnd 32837

Toggle infinite scrolling :
sys: cmnd 32774


Show the level of a given chemical in current creature's bloodstream :

(59 is glycogen, which is the measure of the creature's life force shown in the bottom toolbar.
Remember you will get a value between 0 and 255, not a percentage )

dde: putv chem 59

Read the content of any script in the game from it's classification numbers:

Here the activate script for cheese :2=simple 6=food 1=cheese 1=activate

dde: scrp 2 6 1 1


Move the creatures game window to an arbitrary position and size on the desktop:

Parameters are  Xposition Yposition Width Height. 0 0 is top left screen corner

sys: wpos 0 0 1024 768


Get a given chemical's level for all norns:

Here again 59 is life force,  and 4 1 0 is "All Norns" :

enum 4 1 0 dde: putv chem 59 next,endm


Move current target relatively:

Parameters are Xdisplacement, and Ydisplacement. Expressed in world coordinates,starting top left

mvby 10 100

Move current target to a fixed position

Parameters are Xpos, and Ypos.Expressed in world coordinates,starting top left. 2200 500 is roughly the kitchen :

mvto 2200 500

Pick up current item :

Works to some extent on Norns too, but you can't get them past current room's boundaries that way:

edit 
 

Get a creature's age :

dde: getb ctim

Get back to the kitchen and make me a sandwich:

sys: cmra 2200 500


Randomly target a Norn and center cam on it ( doesn't make it current Norn ):

rtar 4 1 0,sys: camt 


Randomly target a Norn and center cam on it (does make it current Norn ):

rtar 4 1 0,setv norn targ,sys: camt

Open a new world file ( brackets are mandatory)

sys: wrld [burrows.sfc]

Take a picture and save it to a file:

dde: pict W|H
With W and H being raw values for the image Width and height.
See this article for an explanation of how to manipulate the file this command returns.


The "Show me one" command(Randomly target an object of corresponding classification, center cam on it, and circle it in pink) :
 

rtar X Y Z,sys: camt,sys: edit posl post posr posb 
With X,Y,Z being the required classifier.Use 0 for wildcard.


The "Show me one" command ran on herbs

 

Print all chemicals for a given creature:

setv var0 0,loop,dde: putv chem var0,addv var0 1,untl var0 eq 255


Create a piece of cheese in the hand:

inst,new: simp food 3 3 3500 0,setv clas 33947904,setv attr 67,bhvr 0 1,setv obv0 1,edit

Gift current Norn some cheese:

inst,setv var0 posb,setv var1 posl,new: simp food 3 3 3500 0,setv clas 33947904,setv attr 67,bhvr 0 1,pose 2,subv var0 32,mvto var1 var0,sys: camt

 

Perform cesarean (Extract the egg from any dead pregnant Norn):

enum 4 1 2,doif dead gt 0,doif baby gt 0,sys: camt,dde: putv baby,setv var0 baby,setv var1 posl,addv var1 16,setv var2 limb,rndv var3 0 5,mulv var3 8,new: simp eggs 8 var3 2000 0,pose 0,setv clas 33882624,setv attr 64,setv obv0 var0,setv obv1 0,subv var2 hght,mvto var1 var2,slim,evnt targ,tick 900,dde: negg,endi,endi,next

No comments:

Post a Comment