creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Development Forum
old
Firing an Eat Script   
RisenAngel
Sanely Insane

RisenAngel
United States  
Manager


 visit RisenAngel's website: The Realm
  4/19/2012

As part of my Metallophagus Grendels V2, I'm coding an agent that will literally let them eat gadgets, regardless of if the gadget has the scripts for it or not.

The script that actually handles the gadget nomming looks like this:
***************CREATURE eat [12]
scrp 4 0 0 28
appr
inst
doif _it_ eq null
* no stim disappointment cos chemical based learning cant be silenced
wait 10
stop
setv ov55 0
endi

targ _it_
setv va00 bhvr
setv va01 bhvr
setv va02 fmly
setv va03 gnus
targ ownr
andv va00 16
doif va00 ne 16
andv va01 32
*Is it a gadget?
doif va02 = 3 and va03 = 8
*Check to see that the creature can eat gadgets and the thing in question is portable
doif ov54 <> 10 or va01 <> 32
*If not, disappoint
doif rand 0 4 eq 1
pose 39
else
pose 45
endi
* disappointment:
stim writ targ 0 1
wait 20
stop
else
*Mark as "I'm eating a gadget"
setv ov55 1
endi
*Or is it a machine?
elif va02 = 3 and va03 = 3
*Check to see that the creature can eat gadgets and the thing in question is portable
doif ov54 <> 10 or va01 <> 32
*If not, disappoint
doif rand 0 4 eq 1
pose 39
else
pose 45
endi
* disappointment:
stim writ targ 0 1
wait 20
stop
else
*Mark as "I'm eating a machine"
setv ov55 1
endi
else
* if IT can't be eaten or cant reach:
doif rand 0 4 eq 1
pose 39
else
pose 45
endi
* disappointment:
stim writ targ 0 1
wait 20
stop
endi
endi
touc

inst
doif _it_ eq null
* no stim disappointment cos chemical based learning cant be silenced
wait 10
stop
*If you're trying to eat a gadget, stopped being marked as such
setv ov55 0
endi


doif byit ne 0
* drop whatever you were carrying before:
doif held ne null and held ne _it_
mesg writ held 5
endi
wait 1
* pick up:
inst
doif _it_ eq null
* no stim disappointment cos chemical based learning cant be silenced
wait 10
stop
*If you're trying to eat a gadget, stopped being marked as such
doif ov55 = 1
setv ov55 0
endi
endi
mesg writ _it_ 4
wait 1
pose 73
* tell _IT_ to eat:
inst
doif _it_ eq null
* no stim disappointment cos chemical based learning cant be silenced
wait 10
stop
*If you're trying to eat a gadget, stopped being marked as such
setv ov55 0
endi
mesg writ _it_ 12
* stim yourself with EAT
targ _it_
doif sorq fmly gnus spcs 12 eq 0
* learn from stim if no script is being called
setv va99 1
else
* dont learn fronm stim script will provide learning
setv va99 0
endi
targ ownr
stim writ targ 26 va99
*If you're eating a machine, do this (if the thing doesn't have its own eat script)
doif ov55 = 1 and va99 = 1
sndc "cs_1"
targ _it_
kill targ
targ ownr
setv ov55 0
endi
wait 30
pose 74
wait 10
pose 12
wait 20
else
* disappointment:
stim writ targ 0 1
doif rand 0 4 eq 1
pose 39
else
pose 45
endi
wait 30
*If you're trying to eat a gadget, stopped being marked as such
setv ov55 0
endi
endm


For gadgets that lack eat scripts (the C3 gadgets, for example) it works perfectly.

The problem lies with gadgets that have eat scripts. The other agent coming with the Metallophagus Grendels, the Techno-Organic Carrot, has seeds classified as gadget and have an inactive eat script (since I intentionally set their behavior so that normal creatures cannot eat them). However, with the code mentioned above, the eat script seems to be outright refusing to fire - no sound is played and the gadget doesn't disappear.

So my question is, do I have to make the seeds (and other gadgets with eat scripts and inedible behavior) able to be eaten by normal creatures in order to fire their eat scripts, or am I doing something wrong here?


~ The Realm ~
Risen Angel's Creatures Blog


 
Ghosthande
Prodigal Sock

Ghosthande


 visit Ghosthande's website: Breeders Beware
  4/19/2012

I think "wildcard" scripts covering multiple species only work on agents that don't have their own scripts--because basically the game "defaults" back to it if there is nothing more specific available. The Sabertooth Norn eggs, for instance, use their own scripts.


 
Ettina

Ettina



  4/19/2012

Maybe make them eatable but non-nutritious, then change which chemicals act as starch, fat & fruit for your metal-eaters.

By the way, I don't care if anyone steals my ideas for their own work, as long as you don't try to stop me from making my own stuff. Many ideas I mention are things I don't have the time or skill to actually do.
 
Amaikokonut

Amaikokonut


 visit Amaikokonut's website: Naturing :: Nurturing
  4/19/2012

This might be a long shot, but would adding a "wait 1" after your "mesg writ _it_ 12" make a difference? I seem to remember mesg writ being fussy when run in an inst.

[Naturing :: Nurturing]
 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  4/19/2012

I managed to fix the problem by changing the if statement at the end to this:
*If you're eating a machine...
doif ov55 = 1
*If it doesn't have an eat script, kill it this way
doif va99 = 1
sndc "cs_1"
targ _it_
kill targ
*If it does, alter its behavior if it's not already edible
else
targ _it_
setv va90 bhvr
andv va90 16
doif va90 <> 16
setv va91 bhvr
addv va91 16
bhvr va91
endi
mesg writ targ 12
wait 1
doif targ <> null
doif va90 <> 16
subv va91 16
bhvr va91
endi
endi
endi
targ ownr
setv ov55 0
endi


Basically, if the gadget has an eat script it gets its behavior altered to accommodate it (if it isn't already, although this bit should only fire if the gadget couldn't be eaten in the first place), and then has its eat script fired. It seems to work so far, although I'm uncertain if the gadget's eat script is actually stimming the eater at all.

However, it's probably not the best way to get around the issue, and I'm still wondering why it didn't work initially.

Edit: And I found another problem - I was looking at the seed's eat script through the CAOS Debugger, and it turns out that apparently the script didn't recognize that it was being eaten by a creature (I have the line "doif crea from = 1" in the code). Which means I'm still doing something wrong.

Ghosthande: While that makes sense, the problem here is that the script isn't being run on the gadget - it's being run on the creature trying to eat the gadget. Since the default version of this script runs regardless of the presence of the eat script of the agent being acted upon, I don't think that's the issue here.


~ The Realm ~
Risen Angel's Creatures Blog


 


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