creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Development Forum
old
Using the Timer to Kill An Agent?   
Malkin

Malkin
Australia  
Manager


 visit Malkin's website: Malkin's page at CWiki
  11/30/2013

Say I have an agent.. I make it roughly like so:

********Lets make some Food
inst
*create some underneath the garden
new: simp 2 11 1000 "infinite_cheese_machine" 2 44 5000
attr 195
*bhvr 48
elas 30
fric 50
accg 3
tick 875
setv ov03 0

mvto 1950 950
cmrt 0


You'll notice I've given it a tick of 875 - roughly 44 seconds, and an OV.

What's the objective difference between running the timer off a predefined wait time, like this:

scrp 2 11 1000 9
wait 3000
kill targ
endm


and using an object variable to increment the time until destruction, like this?


scrp 2 11 1000 9

addv ov03 1

doif ov03 ge 10

kill targ

endi

endm


Which is the better practice for using the timer to get rid of the item? Are there any drawbacks with using either method that need to be accounted for?


My TCR Norns
 
Moe

Moe


 visit Moe's website: Creatures 2 to Docking Station
  11/30/2013  1

The WAIT method can be interrupted if a drop, pickup, or other script is called, thus ensuring an everlasting agent. You can encompass the wait portion with a LOCK and UNLK command to prevent this, but it stop scripts from being called like eat scripts. That's not so good for things like food or complex agents that otherwise need scripts to activate in the meantime.

You can actually use the TICK method 2 ways. The first is as you described, and it's the most common way for complex agents with lifespans who use the TICK script for other purposes (like a critter moving, eating, etc, and eventually dying [kill targ'ing] of old age). This method however causes the engine to run the script multiple times, thus eating up performance.

In your example, the script needs to run 10 times over roughly 7 minutes.

For an agent that needs to die pretty simply when it reaches old age, say like a fruit, you could just give it a long tick. You could set the TICK to 8750 and have it only run once and kill the agent at the appropriate time. The tomatoes in C2toDS have a long tick before they become detritus.

As I said however, if it's something more complex that needs to use the timer script for more than just death, a good variable for storage is preferable.

 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  4/20/2014

If I was just going the 'set the TICK long, let the timer script just be there to kill the agent' route, what would I need to do to make the agent kill itself safely? (e.g. if a norn was holding it.)

Would

scrp 2 3 10854 9
lock
kill targ
endm


be enough for the bare bones, or would more be needed? (Niceties like ALPH aside...)


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