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

RisenAngel
United States  
Manager


 visit RisenAngel's website: The Realm
  7/16/2010  1

At the moment, I'm working on coding the Zanderfish for the Past Seas metaroom. For the most part, they work right.

Their timer script:
scrp 2 15 18870 9
doif carr = null

*Room Checker
doif rtyp room ownr <> 8 and rtyp room ownr <> 9
accg 3
loop
doif obst down <= 1
setv velx rand -2 2
setv vely -2
doif velx < 0
anim [0 1 2 3 4 5 6 7 255]
else
anim [8 9 10 11 12 13 14 15 255]
endi
endi
addv ov99 1
untl rtyp room ownr = 8 or rtyp room ownr = 9 or ov99 >= 50
doif ov99 >= 50
gsub dead
else
accg 0
setv ov99 0
endi
else
*Age a bit
addv ov01 1

*Grow up if old enough
doif ov01 >= 50 and ov00 = 0
gsub grow
elif ov01 >= 150 and ov00 = 1
*Kick the bucket due to old age
gsub dead
endi

*Check for overpopulation
doif rand 0 2 = 1
setv va00 0
esee 2 15 18870
addv va00 1
next
esee 2 18 18870
addv va00 1
next
*If over 20, kick the bucket
doif va00 > 20
gsub dead
endi
endi

*Time for reproduction
doif ov00 = 1 and rand 0 1 = 1
gsub repr
endi

*Random movement
gsub rndm
endi
endi

*Subroutines start here

*Dying
subr dead
lock
velo 0 0
*First, stop moving
doif ov10 = 0
pose 0
else
pose 8
endi
*Then, sink to the bottom
accg 0.5
loop
wait 5
untl obst down < 5
*Wait some more, then rot
wait 100
*If an adult, produce fishbones
doif ov00 = 1
doif ov10 = 0
setv va03 32
else
setv va03 33
endi
setv va00 posl
setv va01 post
setv va02 plne
inst
new: simp 2 10 18870 "ps_zander" 1 va03 va02
attr 194
bhvr 48
accg 3
aero 0
perm 30
elas 0
fric 70
tick rand 200 400
targ ownr
kill ownr
*If not an adult, then just rot here
else
doif room ownr <> -1
altr room ownr 4 0.01
endi
kill ownr
endi
retn

*Growing
subr grow
*First, stop moving
velo 0 0
*First, make sure you're not too close to a wall
doif obst left > 50 and obst rght > 50 and obst down > 50 and obst _up_ > 50
*Then, change bases and change lifestage. That's it.
doif ov10 < 0
pose 0
else
pose 8
endi
base 16
setv ov00 1
else
*Otherwise, do this fancy shmancy routine that should help prevent invalid position errors
setv va00 posl
setv va01 post
setv va02 attr
attr 0
doif ov10 < 0
pose 0
else
pose 8
endi
base 16
mvsf va00 va01
attr va02
setv ov00 1
endi
retn

*Reproduction
subr repr
setv va00 0
*Count surrounding fish/eggs
esee 2 15 18870
addv va00 1
next
esee 2 15 18870
addv va00 1
next
*If too few, lay eggs
doif va00 <= 6
setv va01 posx
setv va02 posy
inst
reps 3
new: simp 2 18 18870 "ps_zander" 1 34 500
attr 194
bhvr 48
accg 0
aero 10
perm 30
elas 0
fric 50
tick 1
*ov01 = grow counter
setv ov01 0
mvsf va01 va02
addv va01 4
repe
endi
retn

*Random Movement
subr rndm
*First, an obstacle checker
doif obst left < 50
setv ov10 rand 2 3
elif obst rght < 50
setv ov10 rand -2 -3
else
*If not close to a wall, then loop until ov10 <> 0
loop
setv ov10 rand 3 -3
untl ov10 <> 0
endi
doif obst down < 50
setv ov11 rand -1 -2
elif obst _up_ < 50
setv ov11 rand 1 2
else
setv ov11 rand 2 -2
endi
*If ov10 < 0, animate left, otherwise animate right
doif ov10 < 0
anim [0 1 2 3 4 5 6 7 255]
else
anim [8 9 10 11 12 13 14 15 255]
endi
velo ov10 ov11
retn
endm


For some strange reason, however, when they try to reproduce they throw this error:

Error Message wrote:
Runtime error in agent 2 15 18870 script 2 15 18870 9 unique id 1029547
Anim change failed - on part 0 which has base 0
... endi doif ov10 < 0 {@}anim [0 1 2 3 4 5 6 7 255] els ...



When the bit that tells them to reproduce is commented out, this error does not occur - however, this also leads to another bug: The adults, when they die, don't leave a skeleton behind like they should.

I cannot figure out solutions to either of these problems - the script looks like it should work, but it doesn't. At least not correctly. Can anyone else find out why?


~ The Realm ~
Risen Angel's Creatures Blog


 
sam999

sam999


 visit sam999's website: Speculative Evolution
  7/16/2010

Um grendel man? Look:
http://www.edash.screaming.net/creatures/

 
Ghosthande
Prodigal Sock

Ghosthande


 visit Ghosthande's website: Breeders Beware
  7/16/2010

You don't seem to have a TARG OWNR in the reproduction script.


 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  7/16/2010

Sam: Yes, I was aware of Edash's Zanders. However, Zanderfish were meant to be part of Past Seas at the start, and I'm not about to let the fact that someone else converted them first stop me. Besides, these zanders are completely different from Edash's.

Ghosthande: That might have something to do with it. I'll try that.

Edit: And now I get this.

Error Message wrote:
Runtime error in agent 2 15 18870 script 2 15 18870 9 unique id 1047314
Anim change failed - on part 0 which has base 16
... 3 4 5 6 7 255] else {@}anim [8 9 10 11 12 13 14 15 25 ...



Weirdly, this only occurs with the second-gen Zanders - the ones that are initially injected via the Installation Script perform without any errors.


~ The Realm ~
Risen Angel's Creatures Blog


 
Moe

Moe


 visit Moe's website: Creatures 2 to Docking Station
  7/16/2010

Without having the full script, it's hard to know what's going wrong. It's probably a setting on the baby fish themselves, in the Egg scripts.

The reason I say that is because I tried making "second generation" fish with my own injection and it was fine...so it must be something not in the fish scripts, but in their creation (hatching).

 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  7/16/2010

When you brought that up, I took a second look at the creation script in the eggs. Sure enough, the new: simp command still displayed the wrong number of sprite files (31 as opposed to 32), which was fixed in the actual installation script. When both were patched, the autokill errors stopped.

However, the fish still aren't producing skeletons when they should (both by natural death and by being eaten).

Natural Death Bit (Updated):
subr dead
lock
velo 0 0
*First, stop moving
doif ov10 = 0
pose 0
else
pose 8
endi
*Then, sink to the bottom
accg 0.5
loop
wait 5
untl obst down < 5
*Wait some more, then rot
wait 100
*If an adult, produce fishbones
doif ov00 = 1
doif ov10 = 0
setv va03 32
else
setv va03 33
endi
setv va00 posl
setv va01 post
setv va02 plne
inst
new: simp 2 10 18870 "ps_zander" 1 va03 va02
attr 194
bhvr 48
accg 3
aero 0
perm 30
elas 0
fric 70
*If not an adult, then just rot here
else
doif room ownr <> -1
altr room ownr 4 0.01
endi
endi
targ ownr


Eat Script:
*Zander Eat Script
scrp 2 15 18870 12
snde "chwp"
stim writ from 80 1
*If an adult, create fishbone
doif ov00 = 1
setv va00 posl
setv va01 post
setv va02 plne
doif ov10 < 0
setv va03 32
else
setv va03 33
endi
inst
new: simp 2 10 18870 "ps_zander" 1 va03 va02
attr 194
bhvr 48
accg 3
aero 0
perm 30
elas 0
fric 70
tick rand 200 400
endi
targ ownr
kill ownr
endm


Neither of these produces a fishbone like they should. I tried changing the reference to ov10 to just plain pose, but that didn't work.


~ The Realm ~
Risen Angel's Creatures Blog


 
Ghosthande
Prodigal Sock

Ghosthande


 visit Ghosthande's website: Breeders Beware
  7/16/2010

I don't see any commands telling the fishbones where to appear. Perhaps they just aren't being moved to the appropriate place?


 
Moe

Moe


 visit Moe's website: Creatures 2 to Docking Station
  7/16/2010

Yes I see no mvsf va00 va01...
 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  7/16/2010

For greater C3/DS compatibility, you could try:

doif tmvt va00 va01 eq 1

mvto va00 va01

else

mvsf va00 va01

endi


I'm pretty sure Vampess taught me that one.

It first tests that a move will end up inside a room, then moves an item there with C3 code, then if it doesn't, it moves an item somewhere safe with a DS code. :)


My TCR Norns
 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  7/16/2010

...

Okay, I thought that script looked a little short when I copy-pasted it, and had a gut feeling that I was missing something obvious.

With that, I think that's everything I had a problem with for the Zanders.


~ The Realm ~
Risen Angel's Creatures Blog


 
Moe

Moe


 visit Moe's website: Creatures 2 to Docking Station
  7/16/2010

A more versatile code block, which mimics the mvsf command of DS in it's persistence to find a safe place, would be something like this:

setv va00 *the x position you want to start with*

setv va01 *the y position you want to start with*

*Keep testing positions-*
loop
doif tmvt va00 va01 eq 0

*change the position if it's invalid, in this case, randomly*

subv va00 rand -10 10
subv va01 rand -10 10
endi

*-until it works

untl tmvt va00 va01 eq 1

*move

mvto va00 va01


:)

As suggested, it should be noted that the TMVT method Malkin shared is a good means of getting pixel-perfect placement for agents, if you know that the position you've chosen should be valid.

DS's MVSF command often calls an invalid position on a perfectly safe one (it's paranoid), and so when say, a plant grows, sometimes they'll "pop" from where they should be and have to "settle" back onto the floor. You've probably seen this.

If you code the plant properly however (as an example), you can often judge with great accuracy exactly where the plant should safely come out of the seed, and it shouldn't need to pop like it does, so trying the TMVT and MVTO method first saves some unsightly jumping.

 


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