creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Development Forum
old
blue plum trouble    
mea
Chaotic Spriter

mea


 visit mea's website: Caos of the Creatures Realm
  11/5/2014

I had made several different colors of plum sprites, but only the red ones were turned into the Garden Box bouncing plums. So finally I asked Laura if I could use the code for bouncing plums to turn the other colors of plums into agents for the Garden Box as well. She gave permission, & I've made the Script Reservations so I can give it a unique classifier without overlapping anyone elses. This is my first attempt at an agent, so predictably it's giving me problems.

The only things I've changed from the original code are the classifier & the sprite file that it uses. If I inject the blue plums by itself, it seems to grow just fine, but if I inject the original red plums either before or after injecting the blue plums, this is the result -




Here's the code for the blue plums -

*install invisible flag agent:
new: simp 1 205 22929 "blnk" 0 0 9000
***This is the script that the patch core will trigger when it's time to spawn a fruit:
setv name "spawn_script" 1000

*sprite image file and frame when the plant is fully grown:
sets name "sprite_file" "bouncingplum-blue"
setv name "sprite_pose" 2

*classifiers:
setv name "prod_fmly" 2
setv name "prod_gnus" 8
setv name "prod_spcs" 21901

***set va00 to targ, enumerate all the instances of the patch core agent, send a message to that patch core agent that script 1000 is being targetted:
seta va00 targ
enum 1 1 22929
mesg wrt+ targ 1000 va00 0 0
next

*spawn:
scrp 1 205 22929 1000
inst

*create fruit:
***changed 7 to 9 in order to import all images
new: simp 2 8 21901 "bouncingplum-blue" 9 0 name "patch_plane"
mira rand 0 1

*fruit properties:
*** attr 80 = plum blossoms invisible to creatures so they won't be eaten, and don't want them to suffer physics just yet.
attr 80
bhvr 48
accg 3
perm 60
fric 100
elas 80
aero 1

*move to co-ords sent by the core patch agent:
mvto _p1_ _p2_

setv name "patch_id" mame "patch_id"
tick rand mame "tickfrom" mame "tickto"

*default tick:
doif tick eq 0
tick 300
endi
endm

*timer:
scrp 2 8 21901 9
***Age it every Tick
addv ov00 1
***if it's not fully grown, grow it to the next stage:
***(only on tick 2,4,6)
doif ov00 le 9
doif ov00 eq 1
elif ov00 eq 3
elif ov00 eq 5
elif ov00 eq 7
elif ov00 eq 9
else
setv va00 pose
addv va00 1
pose va00
endi
***if it's older then 22 ticks, let it rot
***more frames are used, fully rotten frames are now 6 and 8
elif ov00 gt 22
doif pose eq 6
kill targ
endi
doif pose eq 8
kill targ
endi
setv va00 pose
addv va00 1
pose va00
**if it's fully grown and has been sitting on the plant for 10 turns, it should fall off the patch:
elif ov00 eq 14
doif attr eq 67
setv name "patch_id" 0
attr 195
stop
endi
***if it is fully grown, make sure creatures can see/grab it:
elif ov00 eq 11
doif attr eq 80
attr 67
emit 6 0.01
endi
stop
endi
endm

*simplified collision:
scrp 2 8 21901 6
lock
***bouncing noise when the fruit collides.
sndc "smit"
endm

*pickup:
scrp 2 8 21901 4
inst
***if it's attr is still 67, you (or a creature) are picking it directly off the plant nd need to set it so it doesn't act attached to the patch anymore.
doif attr = 67
attr 195
stim writ from 18 1

*clear the patch_id variable so a new one can spawn:
setv name "patch_id" 0
endi
endm

*drop:
scrp 2 8 21901 5
doif pose lt 15
stim writ from 19 1
endi
endm

*eat:
scrp 2 8 21901 12
***pose 2 is the frame of the full plum sprite file in "bouncingplum-blue.c16" and I want the creature to take a bite.
***due to more frames being used upon creation, 4 is now the fully grown plum. changed
doif pose eq 4
sndc "chwp"
stim writ from 78 1
***pose 5 is the frame of the half-eaten plum sprite file in "bouncingplum-blue.c16" and I'm telling the engine that creature has taken a bite.
***same as above. more frames, 7 is now half-eaten. changed
pose 7
elif pose eq 7
sndc "chwp"
stim writ from 78 1
wait 10
**the plum has now been completely eaten = kill ownr.
kill ownr
endi
endm

*remove:
rscr
enum 1 205 22929
kill targ
next
enum 2 8 21901
kill targ
next
scrx 2 8 21901 4
scrx 2 8 21901 5
scrx 2 8 21901 6
scrx 2 8 21901 9
scrx 2 8 21901 12


Does anyone have an idea of why it's being so tricky & how to fix it?

 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  11/5/2014  2

Patch plants are made in two parts - the fruit itself, and a 'mother item' which talks to the main garden box. The classifier for the 'mother item' (the 'invisible flag agent') needs to be unique, and not overlap with anyone else's classifier.

Every time you've got '1 205 22929', you need to replace that with '1 205 oneofyourclassifiernumbers'. :)


My TCR Norns
 
Laura
Tea Queen

Laura


 visit Laura's website: CC Chat
  11/5/2014

If it helps, I can attest that that solution will work; I had the same issue with the original plums. :)
 
mea
Chaotic Spriter

mea


 visit mea's website: Caos of the Creatures Realm
  11/6/2014  1

Okay, made the changes & testing it now.

Edit: So far it's looking good! It's no longer trying to flood the world with plums. [ngrin]

Thanks!

 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  11/6/2014

Woo! :D Glad it's working now! :)

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