[Code] Make an .agents file

You’ve probably read some tutorials here and there and tried to make a .cosfile on your own. Now the thing is, how do you actually get a neat .agents file that will show up in the agent injector?

I’ll teach you.

What do you need?

  • Monk (from the Jagent suite)
  • A folder containing your .cos script and any attachments you need (.c16, .catalogue, sound files, …)

What about EasyPray? And a prayfile?

Not needed. We’ll use Caos2Pray. There is an excellent explanation in this article on Naturing :: Nurturing.

The only thing it misses is an example of the *# LINK command, a very useful command I will explain further below.

For this case, we’ll go with making an easy script. You know, the tiny empathic vendor thing in the workshop? That little floating thing? It always annoyed me that I couldn’t separately inject it. But no more, I’ll teach you how to make it show up in the agent injector.

What are we going to do?

  • Create an instance of the empathic vendor ingame
  • Move it to the agent injector
  • Create the CAOS2Pray and compile the script into an agent.

For now, just open CAOS tool and create a new file.

Create an instance of the empathic vendor ingame

Since this is an existing object which gets loaded when the world gets loaded, the script is placed in the bootstrap/010 Docking Station/ folder. We need to know the classifier of the existing empathic vendor to be able to create a new one that uses the same script.

Feel free taking your time to browse in the bootstrap folder and learn what stuff you can find here. For now, we need the mini empathic vendor script. This script is called mini empathic vendor.cos. Open it and search for the bit where the vendor gets injected into the world.

** Create the Vendor
new: comp 2 23 9 “mini_vendor” 23 0 3000
attr 198
perm 60
accg 5
elas 0
bhvr 3
anim [0 1 2 3 4 5 6 7 8 9 10 11 255]
seta va00 targ

*** Move it to the workshop
*mvto 4800 9400

*move it into the chamber
rtar 1 1 154
doif targ ne null
seta va01 targ
spas va01 va00
else
targ va00
mvto 4800 9400
endi

Copy this into your cosfile.

We won’t need the part where the vendor gets moved into the workshop and the chamber, so you can entirely remove that part. Also, since va00 is being used to make the containment chember pick up the correct agent, that’s not needed either.

You can remove the bottom half of the script until you’re left with this:

** Create the Vendor
new: comp 2 23 9 “mini_vendor” 23 0 3000
attr 198
perm 60
accg 5
elas 0
bhvr 3
anim [0 1 2 3 4 5 6 7 8 9 10 11 255]

This creates an instance of the empathic vendor. Now we only have to move it to the agent injector.

Move to the agent injector

The ‘move something somewhere safely’ command is mvsf X Y.

The X and Y values of the agent injector are stored as game variables CreatorX and CreatorY, so the final piece of code would be this:

mvsf game “CreatorX” game “CreatorY”

Great!

You now made a cosfile that injects a mini empathic vendor in the agent injector space.

For completeness, you should now add a removal script on the end that removes every mini empathic vendor in the world.

** rscr indicates a removal script
rscr
** enumerate over all mini empathic vendors and target them
enum 2 23 9
** kill them
kill targ
** End the enumeration loop
next

If you manage to have CAOS tool working with your game, you could now inject the cos script by going through Inject – Inject install script (f9) or Inject install and event scripts (f11). If CAOS tool can’t communicate with your game, no worries, we’ll create a CAOS2PRAY chunk on top of this cosfile now, so we can compile it with Monk.

Create a CAOS2PRAY chunk

If you haven’t read the post on Naturing :: Nurturing yet, I urge you to do so now. It will help you understand the next part.

At the top of your .cosfile, add this chunk of text:

* CAOS2PRAY CHUNK
*# Pray-File “miniempathicvendor_YOURNAME.agents”
*# DS-Name “Mini Empathic Vendor (DS)”
*# depend mini_vendor.c16
*# desc = “This is a mini empathic vendor.”
*# Agent Animation File = “mini_vendor.c16”
*# Agent animation String = “0 1 2 3 4 5 6 7 8 9 10 11 255”
*# Agent Sprite First Image = 0
*# Agent Animation Gallery = “mini_vendor.c16”
*

This is pretty much all you need.

The total .cosfile should now look like this:

* CAOS2PRAY CHUNK
*# Pray-File “miniempathicvendor.agents”
*# DS-Name “Mini Empathic Vendor (DS)”
*# depend mini_vendor.c16
*# desc = “This is a mini empathic vendor.”
*# Agent Animation File = “mini_vendor.c16”
*# Agent animation String = “0 1 2 3 4 5 6 7 8 9 10 11 255”
*# Agent Sprite First Image = 0
*# Agent Animation Gallery = “mini_vendor.c16”
*
** Create the Vendor
new: comp 2 23 9 “mini_vendor” 23 0 3000
attr 198
perm 60
accg 5
elas 0
bhvr 3
anim [0 1 2 3 4 5 6 7 8 9 10 11 255]
mvsf game “CreatorX” game “CreatorY”
** rscr indicates a removal script
rscr
** enumerate over all mini empathic vendors and target them
enum 2 23 9
** kill them
kill targ
** End the enumeration loop
next

You can now save your cosfile, open Monk, drag & drop your cosfile on Monk, and… The magic happens! An agent called “miniempathicvendor.agents” is now in the folder where your .cos file originally happened to be.

miniemven.gif

Put the agent in your agents/ folder, make sure that you click on the ‘chat’ tab before reopening the agent injector window, and your agent should now show up under “Mini Empathic Vendor (DS)”.

That’s it!

 

Extra for advanced users: the “link” command

The *# link command syntax is like this:

*# link cosfile1.cos cosfile2.cos cosfile3.cos

This would be handy incase you’re making a metaroom project, for example, and have each toy, plant and animal coded in its separate .cos file, which you can then compile into one huge .agents file.

You don’t have to link the cosfile you run this command from.

 

I hope you found this post useful. 🙂

One thought on “[Code] Make an .agents file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s