creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Development Forum
old
How to make a fruit that rots etc? C3/DS   
Mana

Mana
Finland  


  3/24/2013

Hello,
I hope I'm posting this in the right place.
(Also sorry in advance for the messy way I typed/organized this,
the main point of the topic is in the second paragraph)
First of all, I'm a complete newb to CAOS.
I just had my first attempts at making an agent today,
(I know I should've just followed some tutorial or something rather than just jumped in like that. I've looked at a few now afterwards but they didn't cover the issues here.)
I didn't intend to, I was messing around randomly with my graphics editor when I got the urge to try if I could make anything that'd make a decent sprite in Creatures (3/DS).
Turns out I did, so I wanted to see it in game so I just took a fitting agent and switched the sprites, sounds (I just wanted to test it).
Since it did work, I got inspired, wanted to make a proper version of it.
But. I ran into trouble with the things I wanted to add;
I wanted the fruit to take two bites to eat and then turn into detritus (like the apple cores). I wanted also for it to be able to rot.
But, I just ran into all kinds of errors, succeeded in a couple of things (managed to make it switch into another pose when dropped and back when picked up) but then lost that as I switched to trying to make the detritus part of the agent (because I originally just had those as fruit).

Unfortunately viewing the .cos files for agents like apples and carrots didn't really work out for me (error, another error, suddenly the fruit only takes one bite, more errors)...[ngrimace]

So, are there any tutorials that cover:
a) Apple-core like detritus
b) Rotting
c) Multiple bites to eat a fruit (as I originally just based the agent on another so I don't really have any real idea how it worked and I should to figure out how to connect this stuff together)
d) How scripts are supposed to be organized - in what order etc?
Any list of common errors to avoid?

How the fruit should behave in the end;
1) Untouched fruit
2) Creature takes a bite, fruit switches to second pose
3) Creature takes another bite, fruit switches to second agent (detritus)
4) Detritus OR untouched fruit rots


The item still wouldn't be of much use then I know, but I'd try to do more stuff to it if I had these parts figured out.

I know there might not be any good way to answer this without it being too much of a bother, but I'm posting this just in case.

 
Ghosthande
Prodigal Sock

Ghosthande
United States  

 visit Ghosthande's website: Breeders Beware
  3/24/2013  1

Welcome to the forum! :)

I would suggest you read AquaShee's CAOS Chaos tutorials, as--aside from giving you a good foundation for the basics--they also explain how to make a food that reacts to having multiple bites taken out of it. This will help you understand the basic mechanism by which a food can "count" how many times it's been eaten--you could try changing that to make the food generate detritus, instead of disappearing.

Making a fruit or food item rot on its own is generally best accomplished with a timer script. Offhand, I can think of a tutorial explaining timer scripts here--most of the tutorial doesn't really apply, because it's about growing plants, but information on timer scripts is included. Perhaps the best strategy is to set a timer script to "count down" a variable, and then when the variable hits zero, the food rots. (Interacting with an object tends to reset its timer, which is why I'd recommend counting down in increments specifically!)

As for actually making the detritus/core itself... the easiest method is to create a brand new detritus agent, place it where the food item was, and then delete the food item. (Functionally, it's very similar to how a simple vendor works, with the exception that the food item kills itself once it's finished.) Basically you "swap out" one object for another.



 
Malkin

Malkin
Australia  
Manager


 visit Malkin's website: Malkin's page at CWiki
  3/24/2013  1

Have you tried using the Creatures 3 Bootstrap V2? It's an annotated version of the C3 bootstrap, and might help make things more clear than just the raw scripts themselves.

Rotting would just be covered by the timer script (script 9). "If you're off the tree, and you've been lying about on the floor for a while, and not being carried, kill yourself."

You could make your food item multi-bite by following the tutorial at CAOS chaos.

I hope this helps start you off - best of luck!

This is from my Albian Apples (circa 2010), a C12DS addon. It might not be the most efficient way to accomplish what you're after, but it is a way. You can use Jagent to decompile any agent file and read the code for yourself.


*Eat me
scrp 2 8 10853 12
*get the position of the apple!
setv va98 posl

setv va99 post


*make some noise!
snde "chwp"
*if I'm a full apple
doif pose eq 10
*make me into a half-bitten apple
pose 11
*give the norn who ate me the 'I have eaten fruit' stimulus
stim writ from 78 1
*this helps you inject extra chemicals
seta va16 from

inst

targ va16

chem 5 .15

chem 3 .2

chem 13 .2
*If I was already a half-bitten apple
elif pose eq 11
*give the same stimulus
stim writ from 78 1
*and inject more chemicals
seta va16 from

inst

targ va16

chem 5 .15

chem 3 .2

chem 13 .2
*instantaneously make a new detritus item
inst
targ ownr

new: simp 2 10 10853 "applc3" 1 12 5000

attr 195

bhvr 48

elas 30
perm 51

accg 3

fric 100

tick 875
*move to the location that was chosen at the start
mvsf va98 va99
*detritus timer object variable
setv ov03 0
*get rid of the owner of the code - the apple
kill ownr

endi
endm


My TCR Norns
 
Mana

Mana
Finland  


  3/26/2013

Thank you for the replies! [nsmile]
Sorry I didn't reply/get to continuing my attempt to make this agent earlier. No decent reason, I felt like doing a couple of other things and soon as I knew a couple of days had passed...I'm just very bad at choosing what to do rather than just drifting along to my latest whim. [ngrimace]
Anyhow.
I now started from scratch again, read a couple of those things you linked! But not all, which might have helped me to understand things better...or, at least that C3 bootstrap commentary sounds like it could be very helpful to understand the various things that I don't. Yet it's one of the things I didn't yet try.
But, after this latest failure I just feel rather annoyed/frustrated over not having any idea what I did wrong. But then, there were a few things I didn't really know the meaning of in the scripts. So. But I suppose I'm just tired, I'll probably try again at a later time and have a look at the cheese tutorial and the C3 bootstrap commentary.

Here is the error I get trying to inject my latest attempt;
"Failed to close block at token " ... <= 6 kill ownr retn @ ]

Probably some really glaring errors here;
((the bits with the stars in front are some things that I thought disabling could fix the error but I was wrong))
*FRUIT
new: simp 2 8 24999 "chafruit" 4 0 rand 200 6000
bhvr 48
attr 199
perm 60
elas 5
accg 3
aero 10
fric 50
velo rand 10 25 rand 0 -10
emit 6 .5
setv ov10 rand 200 1000
mvsf game "CreatorX" game "CreatorY"
tick 60
endm

*FRUIT DROPPED
scrp 2 8 24999 6
snde "drom"
endm

*FRUIT PICKED UP
scrp 2 8 24999 4
snde "drod"
endm

*FRUIT ROTS
scrp 2 8 24999 9
tick 0
gsub rota
subr rota
loop
setv va00 pose
addv va00 1
pose va00
wait rand 20 60
untl pose = 5
*setv va20 256
*loop
*subv va20 50
*alph va20 1
wait 8
*untl va20 <= 6
kill ownr
retn
endm

*BITTEN FRUIT ROTS
scrp 2 8 24999 9
tick 0
gsub rotb
subr rotb
doif pose eq 6
loop
setv va00 pose
addv va00 1
pose va00
wait rand 20 60
untl pose = 11
setv va20 256
loop
subv va20 50
alph va20 1
wait 8
untl va20 <= 6
kill ownr
retn
endm

*FRUIT EATEN
scrp 2 8 24999 12
setv va98 posl
setv va99 post
snde "eatm"
doif pose eq 0
pose 11
stim writ from 78 rand 1 3
seta va16 from
inst
targ va16
chem 63 5
elif pose eq 6
stim writ from 78 rand 1 3
seta va16 from
inst
targ va16
chem 63 5
*LEAVES LEFT
inst targ ownr
new: simp 2 10 24998 "chafruit" 18 13 rand 200 6000
bhvr 48
attr 199
perm 60
elas 5
accg 3
aero 10
fric 50
velo rand 10 25 rand 0 -10
emit 6 .5
setv ov10 rand 200 1000
tick 60
mvsf va98 va99
kill ownr
endi
endm

*LEAVES DROPPED
scrp 2 10 24998 6
inst
doif pose eq 12
pose 13
endi
snde "drod"
endm

*LEAVES PICKED UP
scrp 2 10 24998 4
inst
doif pose eq 13
pose 12
endi
snde "drod"
endm

*LEAVES EATEN
scrp 2 10 24998 12
inst
snde "eatd"
stim writ from 81 1
stim writ from 77 1
kill ownr
endm

*LEAVES ROT
scrp 2 10 24998 9
tick 0
gsub rotc
subr rotc
doif pose eq 13
loop
setv va00 pose
addv va00 1
pose va00
wait rand 20 60
untl pose = 18
*setv va20 256
*loop
*subv va20 50
*alph va20 1
wait 7
*untl va20 <= 6
kill ownr
retn
endm

*REMOVE
rscr
enum 2 8 24999
kill targ
next

 
Malkin

Malkin
Australia  
Manager


 visit Malkin's website: Malkin's page at CWiki
  3/27/2013  1

From a cursory glance, the two rotting scripts clash with each other, as they both have the same number - "scrp 2 8 24999 9". As both of those scripts are trying to do different things, the game won't like it. Can you mash it into one timer script? (doif pose eq (whatever the full pose is), (rot in the full-fruit way) elif pose eq (whatever the half-eaten pose is), (rot in the half-fruit way), endi endm).

My TCR Norns
 
Mana

Mana
Finland  


  3/27/2013

Malkin wrote:
From a cursory glance, the two rotting scripts clash with each other, as they both have the same number - "scrp 2 8 24999 9". As both of those scripts are trying to do different things, the game won't like it. Can you mash it into one timer script? (doif pose eq (whatever the full pose is), (rot in the full-fruit way) elif pose eq (whatever the half-eaten pose is), (rot in the half-fruit way), endi endm).



Thanks, managed to get it to inject now (and also due to a couple of other edits)

Now I found three new problems - first, it starts rotting too quickly (I figure that could be fixed by changing some numbers. But which ones? 'setv ov10 rand <number> <number>'? 'tick <number>'? The 'wait rand <number> <number>'s?)

Second, creatures are still able to pick up and eat the rotting fruits.
Since I already have the eating scripts only apply if the fruit is fresh...is there some way (short of making a new agent) to make the rotting fruits unmovable or uneatable? And disable the fruit smell at that point? [nquestion]
(Perhaps not, since I can recall creatures trying to eat rotting tomatoes in C2...)

And third. The leaves/detritus are supposed to change pose when picked up and when dropped, but it doesn't seem to work, though as far as I can recall it worked in some earlier incarnation of this agent. But looking at those files nothing seems to have changed.
Here's what I have now;
*LEAVES DROPPED
scrp 2 10 24998 6
inst
doif pose eq 12
pose 13
endi
snde "drod"
endm

*LEAVES PICKED UP
scrp 2 10 24998 4
inst
doif pose eq 13
pose 12
endi
snde "drod"
endm


You can see the poses in the code should be correct;

 
Malkin

Malkin
Australia  
Manager


 visit Malkin's website: Malkin's page at CWiki
  3/27/2013  1

The 'wait rand 20 60' means 'wait for a random number of ticks (choose a number between 20 and 60). There are about 20 ticks per second, so the current setting is 'somewhere between 1 and 3 seconds. Try a lower limit of 600 for 30 seconds, and 1200 for an upper limit of 1 minute - wait rand 600 1200.

Second, creatures are still able to pick up and eat the rotting fruits.
Since I already have the eating scripts only apply if the fruit is fresh...is there some way (short of making a new agent) to make the rotting fruits unmovable or uneatable? And disable the fruit smell at that point?
(Perhaps not, since I can recall creatures trying to eat rotting tomatoes in C2...)



You could change the bhvr or attr when it rots so that it's invisible or not-interactive.

I'm not very strong on changing poses in an agent, but Sarako's Guide to Mac Agenteering suggests that you might not need those doifs in the pickup and drop scripts.


My TCR Norns
 
Ghosthande
Prodigal Sock

Ghosthande
United States  

 visit Ghosthande's website: Breeders Beware
  3/27/2013  1

Or you could use something like this when the apple becomes detritus:

CATO 10
SETV OV__ 1
EMIT 4 0.1

And then have a condition in the eat script which checks that variable; if it is 0, it is "fruit" and gives the creature an "eaten fruit" stim, but if it is 1, it is "detritus" and gives the creature an "eaten detritus" stim. That's what I do for most type-changing agents now... especially since some breeds like Toxics enjoy detritus, so it can be handy to create your own. :)



 
Mana

Mana
Finland  


  3/27/2013

You could change the bhvr or attr when it rots so that it's invisible or not-interactive.

I'm not very strong on changing poses in an agent, but Sarako's Guide to Mac Agenteering suggests that you might not need those doifs in the pickup and drop scripts.



Thanks, managed get both of those working. [nsmile]

Ghosthande wrote:
Or you could use something like this when the apple becomes detritus:

CATO 10
SETV OV__ 1
EMIT 4 0.1

And then have a condition in the eat script which checks that variable; if it is 0, it is "fruit" and gives the creature an "eaten fruit" stim, but if it is 1, it is "detritus" and gives the creature an "eaten detritus" stim. That's what I do for most type-changing agents now... especially since some breeds like Toxics enjoy detritus, so it can be handy to create your own. :)



'CATO' is a command I have been wishing would exist and apparently it does, after all! Thank you, that was really the best solution, works well. [ngrin]

Now though. I said before the fruits rot too fast. But changing the wait numbers makes the whole rotting process slower too, and I'd like to only have it begin later then proceed at its current speed.
Where and how could I insert something that makes the fruit stay fresh for a longer period withot affecting how fast it rots when it actually goes bad?

*FRUIT ROTS
scrp 2 8 24999 9
tick 0
gsub rota
subr rota
doif pose eq 0
loop
setv va00 pose
addv va00 1
pose va00
cato 10
setv ov06 1
emit 4 0.1
setv va04 room ownr
prop va04 6 0
wait rand 600 1200
untl pose = 5
setv va20 256
loop
subv va20 50
alph va20 1
wait 8
untl va20 <= 6
kill ownr
*BITTEN FRUIT ROTS
elif pose eq 6
loop
setv va00 pose
addv va00 1
pose va00
attr 16
cato 10
setv ov06 1
emit 4 0.1
setv va04 room ownr
prop va04 6 0
wait rand 600 1200
untl pose = 11
setv va20 256
loop
subv va20 50
alph va20 1
wait 8
untl va20 <= 6
kill ownr
retn
endi
endm

 
Malkin

Malkin
Australia  
Manager


 visit Malkin's website: Malkin's page at CWiki
  3/27/2013

The freshness-lifespan of your fruit is controlled by ov10 - try experimenting with the lower and upper limits of the ticks there. If 20 ticks is one second, then 200 ticks is 10 seconds and 1000 ticks is 50 seconds.

Choose a couple of reasonable times, convert them into seconds, then multiply each by 20, and those are the numbers that need to be there.

Just as a note, when you cato the item to become detritus, be wary of the extra chemicals you're injecting, too - as some cures can harm toxics quite badly.


My TCR Norns
 
Ghosthande
Prodigal Sock

Ghosthande
United States  

 visit Ghosthande's website: Breeders Beware
  3/27/2013

Please note, though, that other scripts can reset the timer. So if it's set to wait 5000 ticks, but a Creature picks it up/nibbles on it/etc. after just 300 ticks, it will reset the timer to 5000 and start all over. That's why I suggested using increments--you can be much surer about the exact amount of time. Not the problem you're experiencing now, but one that can potentially be just annoying. [ntongue]


 
Malkin

Malkin
Australia  
Manager


 visit Malkin's website: Malkin's page at CWiki
  3/27/2013

Though, for a fruit, that could be a feature, not a bug - in that a fruit that has been touched will hang around for longer?

My TCR Norns
 


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
0 online
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