*Inject the Gerana and set properties new: simp 2 15 21021 "b1-snett" 42 18 2000 attr 194 elas .1 accg 1 perm 100 base 0 frat 2 *Set basic variables all to 0 setv ov40 0 setv ov10 0 setv ov11 0 setv ov01 0 *This next variable sets the life of the critter *We want it to live for, say, 200 walks setv ov50 200 *Move into the Grendel Hideout (change these coordinates!) mvsf 1600 9200 tick 1 scrp 2 15 21021 9 *This is where any counters go. *Add to the age counter addv ov01 rand 3 5 *This is where any subroutines you want to happen go. *For now, we just have the movement subroutine and live gsub live gsub walk subr live *If the 'age' variable equals or is more than *the lifespan of the critter doif ov01 >= ov50 *Go to the dying subroutine! gsub die endi *You can also add a piece of code here which will *give lifestages to your critter, but that won't be *dealt with here. retn *The dying subroutine subr die *Go to the give birth subroutine *This ensures that there will always be a Gerana gsub givebirth *If the critter was previously going right doif ov10 = 1 *Slow down the animation, and show the *dying right animation anim [20 21 22 23] *Else if the critter was going left elif ov10 = 2 *Slow down the animation and show the *dying left animation anim [16 17 18 19] endi *This will add nutrients to the environment setv va12 grap posx posy altr va12 3 0.3 *Delete the dead Gerana kill ownr retn *The give birth subroutine subr givebirth setv va00 posl setv va01 post *Inject the Gerana and set properties new: simp 2 15 21021 "b1-snett" 42 18 2000 attr 194 elas .1 accg 1 perm 100 base 0 frat 2 *Set basic variables all to 0 setv ov40 0 setv ov10 0 setv ov11 0 setv ov01 0 *This next variable sets the life of the critter *We want it to live for, say, 200 walks setv ov50 200 *Move to the previously set variables mvsf va00 va01 tick 1 retn *The walking subroutine! Yay. subr walk *Set the amount of 'walks' to a random number between 3 and 9 *The more walks you want, the higher the last number setv ov40 rand 3 9 *Set the direction randomly right or left setv ov10 rand 1 2 wait rand 1 10 *If there is a wall to the right, set ov11 to 1 doif obst rght lt 5 setv ov11 1 *If there is a wall to the left, set ov11 to 2 elif obst left lt 5 setv ov11 2 *Otherwise, just set ov11 to zero (so it has no effect) else setv ov11 0 endi *If the critter is not being carried and is not falling doif carr eq null and fall = 0 *Checks for walls (using the variables we set earlier) *If there is a wall to the right, go left doif ov11 = 1 gsub left endi *If there is a wall to the left, go right doif ov11 = 2 gsub right endi *Checks if the critter is going right *If so, go to the 'right' subroutine doif ov10 = 1 gsub right endi *Checks if the critter is going left *If so, go to the 'left' subroutine doif ov10 = 2 gsub left endi *If none of these are set, stop. else stop endi retn *The going right subroutine subr right *Repeat for ov40 times (randomly between 1 & 6) *The animation and movement is split up, *Which hopefully makes it look more natural. reps ov40 anim [8 9] velo 1 -1 over anim [10 11] velo 1 -1 over anim [12 13] velo 1 -1 over anim [14 15] velo 1 -1 over repe retn *The going left subroutine subr left *Repeat for ov40 times (randomly between 1 & 6) reps ov40 anim [0 1] velo -1 -1 over anim [2 3] velo -1 -1 over anim [4 5] velo -1 -1 over anim [6 7] velo -1 -1 over repe retn endm *The remove script! rscr enum 2 15 21021 kill targ next scrx 2 15 21021 9