creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
hack shack | script reservations | dev resources | dev forum

  

How a Hungry Critter Eats  on 5/23/2013 | 1 like

Hello,
     When making a critter agent that eats other foodstuff agents, what's the benefits and drawbacks of using "kill targ" on the foodstuff or using "mesg writ" to trigger the "I have been eaten" script for the foodstuff itself?
- Malkin


Dear Malkin,
     I used to use "kill targ" exclusively whenever a critter ate another agent, until AquaShee pointed out the advantages of the "mesg writ" method; since then I've been sold on the idea, and am biased against using "kill targ" except when necessary. Most of the reasons for triggering the foodstuff's eat script instead of killing it relate to flexibility and compatibility, such as:

1. Sometimes edible agents have relationships with other agents, which can go awry if the edible agent suddenly disappears. This is more likely to be true of other agent types (eg. flowers) than standard foods, but is good to keep in mind in general. Agents' own scripts usually have failsafes to keep them from being eaten when they shouldn't be, but killing the agent forces the critter to essentially cross its fingers and hope it didn't just cause a disaster for the other agent or its "friends".

2. Sometimes the edible agent might be "inedible" temporarily. For instance, if a carrot is not yet fully grown, it might be invisible and inedible for Creatures. In that case, you might not want your critter to indiscriminately eat the baby carrots. You might be able to have the critter check the food object's code to see what growth stage it's at, and this may not be too impractical if your critter only eats one or a few specific food types. But it's still a lot simpler to just trigger the eat script instead, and let the food agent handle the attempt the same way it would handle a Creature trying to eat it.

3. Sometimes we might run into the opposite scenario: a food agent that is meant to be eaten, but isn't supposed to get used up in the process--such as the fish food agents designed to keep the stickeltrout from dying out. In such cases, forcing the agent to disappear after it's eaten could have very annoying consequences. I might feel safe if my critter eats food instead of bugs, but you never know when someone will invent an "infinite block of cheese" that my critter will perceive as less than infinite; at least if I use "mesg writ", that other person's agent can still function the way they wanted it to, without my critter making a pest of itself. (No pun intended) [ntongue]

4. Using the food's eat script also enables the critter to take advantage of any other special features the food might have. If I use the "kill targ" method for my critter, it has to determine the sound effect used when it eats food, and the food is gone after the first bite, unless I hard-code it to check the food type. But if I use the "mesg writ" method, the food itself will determine all the specifics. The sound effect will always be consistent for that kind of food, and if it has multiple bites, the critter will be able to take a single bite out of it instead of eating the whole thing in one go.

5. The critter will always eat food agents appropriately, even ones that will be developed after the critter itself is released; if a new food behaves differently than the critter's coding anticipated, all will still run smoothly, without the need for an update.


There are still other situations in which "kill targ" is a more appropriate choice. Perhaps I made an agent a year ago that isn't edible, and now I want to make a critter that can eat it. To use "mesg writ" I would need to patch the old agent to make it edible. Or I can just make things easy on myself and use "kill targ". I'm already familiar with how the old agent works, so it's relatively safe for me to do it that way.

Or as another example, Norns aren't edible, but I wouldn't want to make them edible just so that Rexes could eat them using "mesg writ"... that would open the door for things I might not want my Norns to do to one another, or it might conflict with other scripts I had planned. [nwink]

But hopefully this has given you some idea of why "mesg writ" can be useful for a hungry critter... and why sometimes it is not so useful!
- Ghosthande
 
 
Malkin | 11/13/2013  log in to like post  1

If you get the critter or bug to target flowers instead of food, and get it to mesg writ targ script 303, instead of the eat script, then it will pollinate the flowers. :) (If the flowers are set up for it.) This is how pollination is handled in the norn and ettin terrariums. :)


downloads
cobs
adoptions
creaturelink
metarooms
breeds
 
gallery
art
wallpaper
screenshots
graphics
promos
sprites
dev
hack shack
script reservations
dev resources
active projects
dev forum
 
community
links
advice
chat
polls
resources
creatchi
 
forum
bookmarks
general
news
help
development
strangeo
survivor
mycaves
log in
register
lost pw
2 online
Dark_Author
Papriko
creatures caves is your #1 resource for the creatures artificial life game series: creatures, creatures 2, creatures 3, docking station, and the upcoming creatures family.

contact    help    privacy policy    terms & conditions    rules    donate    wiki