Search This Blog

Grand Botanical Overhaul I: Cacti

I've recently begun my most ambitious project yet: the Grand Botanical Overhaul for Creatures 2. The plan here is to do something similar to my Creatures 1 Herb Update, to improve consistency in plant behaviors and streamline their use for creatures, while also including some quality of life improvements for the player. This includes:

  • Including launchers for the plants that don't have them
  • Making sure the main plants (pear, triffid, trumpet, aubergine, tomato, and acorn) have proper life cycles including plants, fruits, seeds, and detritus. This includes fixing any bugs in their life cycle.
  • Ensuring that anything inedible is invisible - both plants that are naturally inedible and plants that simply aren't ready to eat yet.
  • Implementing behavior similar to my updated C1 Herbs: creatures eat directly off the plant, hand pushes plant to pluck the fruit.
  • Reclassifying harmful members of edible classes into badplants.

As I go through this process, I'm thoroughly analyzing the code for each plant, so this will be a series of in-depth looks at the CAOS involved. I will be going into the changes I've made, but won't put anything up for download until the project is finished. I'm beginning with the cacti - technically badplants, but still in need of some fixes.

  • The launchers for the two kinds of cacti are switched.
  • The seeds of the cacti are harmful but classified as "seeds" along with beneficial seeds.

Since the cacti are badplants, I won't be overhauling their behavior in the same way as the other plants. It's a fairly simple place to start: reclassify the seeds, and fix the launchers.

Cactus 1 (Spinnomosa)

Spinnomosa Plant

This is the rounded cactus with the floating helicopter seeds.

For reference, sprites 0-9 show the plant growing. 10-13 show spikes emerging.13 shows the plant flowering. 14 shows the plant flowering with some seeds popped out. Sprites 15-21 are the seeds. Sprites 22 onward show the plant dying.

The object variables for the plant are as follows:

  • ov00: Growth State. 0 = new, 1 = fully grown, 2 = flowering, 3 = popped, 4 = dying.
  • ov02: How long the seed floats for.
  • ov03: Seed limiter. Once it produces this many seeds, it dies.

The plant has two scripts: push and timer.

Spinnomosa Push Script
scrp 2 15 1 1
  doif ov00 eq 1
    setv thrt 200
    base 9
    pose 3
    over
    stim writ from 50 255 0 0
     …18 100 235 50 0 0 0 0
    anim [3210]
    over
    base 0
  endi
  setv actv 0
endm
CACTUS 1 PUSH SCRIPT
If plant is grown
{ Ominous level 200
  Base sprite is full grown
  Set spikes out
  Wait til animation is over
  Pusher gets no neural input
   … 100 pain++, 50 fever toxin.
  Spikes sinking in
  Wait til animation is over
  Return to normal base frame
}
Set inactive.
End script.

The thrt command indicates how dangerous something is for the purpose of adjusting the ambient music. Otherwise, this is a pretty standard "touch it and get hurt" script, typical of badplants.

Spinnomosa Timer Script
scrp 2 15 1 9
  setv thrt 100
  doif ov03 le 0
    setv ov00 4
  endi
  doif ov00 eq 4
    doif pose eq 9
      pose 22
    else
      doif pose ge 22
        doif pose lt 30
          setv var0 pose
          addv var0 1
          pose var0
        else
          kill ownr
        endi
      else
        pose 22
      endi
    endi
  endi
  doif ov00 eq 0
    doif sean ne 3
      doif tmod eq 0
        doif pose lt 9
          setv var0 pose
          addv var0 1
          pose var0
        else
          setv ov00 1
        endi
      endi
    endi
  endi
  doif ov00 eq 1
    doif tmod eq 4
      rndv var0 100 300
      tick var0
      setv ov00 2
    endi
  endi
  doif ov00 eq 2
    tick 100
    doif pose lt 13
      setv var0 pose
      addv var0 1
      pose var0
    else
      inst
      pose 14
      setv var0 posl
      setv var1 post
      addv var0 20
      addv var1 10
      setv var3 ov02
      new: simp cact 17 15 3100 0
      setv cls2 2 21 2
      setv cls2 2 15 15
      setv attr 195
      bhvr 0 67
      bhvr 0 65
      setv aero 1
      setv rest 100
      setv accg 2
      setv size 30
      rndv var2 1 4
      tick var2
      setv ov09 var3
      rndv var2 -1 1
      doif ov09 gt 1
        addv ov09 var2
      endi
      setv ov10 ov09
      loop
        rndv ov11 -1 1
      untl ov11 ne 0
      mvto var0 var1
      rndv var9 0 1
      slow
      doif var9 eq 0
        snde pop3
      else
        snde pop4
      endi
      slim
      anim [0123456R]
      targ ownr
      setv ov00 3
      subv ov03 1
    endi
  endi
  doif ov00 eq 3
    wait 100
    doif pose ne 9
      pose 9
    else
      setv ov00 1
      rndv var0 500 1500
      tick var0
    endi
  endi
endm
CACTUS 1 TIMER SCRIPT
Ominous level 100
If seed limiter ran out
{ set plant state to dying
}
If plant is dying
{ If fully grown
  { Set to first dying pose
  } else
  { If in dying…
    { …pose range
      { save pose
        Increment
        Set incremented pose
      } else
      { delete cactus
      }
    } else
    { set to first dying pose
    }
  }
}
If plant is new
{ if not winter
  { if dawn
    { if not fully grown
      { save pose
        Increment
        Set incremented pose
      } else (if fully grown)
      { set plant state grown
      }
    }
  }
}
If plant is grown
{ if night
  { random time
    Set tick to it
    Set plant state flowering
  }
}
If plant is flowering
{ set tick 100
  If not flowered
  { save pose
    Increment pose
    Set incremented pose
  } else (visible flowers)
  { instantly
    Set popped flower pose
    Save position

    Adjust position for seed

    Save ov02
    New seed
    It’s cactus 1 seed
    It’s cactus 1 seed (badplant)
    Creature/hand carryable, boundaries, gravity.
    No click, eat/push/pull.
    No click, eat/push.
    1% vel lost to air resist
    100% vel lost after collision
    2 px/tick accel to gravity
    Permeability for doors
    Tick is random between…
    …1 and 4
    Inherit genetic floatiness
    Random -1 to 1
    If floatiness > 1
    { add the random value
    }
    Set ov10 as copy of float
    Do
    { float direction is random -1 to 1
    } until it isn’t 0
    Move to calculated location
    Random 0 or 1
    Normal script speed
    If random value is 0
    { pop3 sound
    } else (random is 1)
    { pop4 sound
    }
    Set object limits
    Spinning seed animation
    Target plant
    Set state to popped
    Decrement seed limiter
  }
}
If plant is popped
{ wait a while
  If pose isn’t full grown
  { make it so
  } else
  { set plant to grown
    Pick random number
    For timer
  }
}
End script

The only alteration here is to change the properties and classification of seeds produced by the plant.

Spinnomosa Seeds

The object variables for the seeds are as follows:

  • ov00: Seed life status. 0 = alive, 1 = dead.
  • ov01: Death timer.
  • ov09: Genetic floatiness. How long the seed will stay in the air.
  • ov10: Float limiter. Starts out equal to ov09, but counts down over time. The seed stops floating when it runs out.
  • ov11: Float direction. -1 = left, 1 = right.

In hindsight, it might have been easier to just remove the fever toxin and leave this seed as, well, a seed. Instead, I changed it to a badplant and reinforced the badness of eating it. But hey, it's not like this plant produces seeds very often anyway.

Spinnomosa Seed Scripts
scrp 2 21 2 12
scrp 2 15 15 12
  snde chwp
  stim writ from 30 255 0 0
   …73 50 235 5 37 50 0 0
   …18 25 235 20 232 10 0 0
  kill ownr
endm
CACTUS 1 SEED (SEED) EAT SCRIPT
CACTUS 1 SEED (BADPLANT) EAT SCRIPT
Chew sound
No neural input,
… 50 starch, 5 fever toxin, 50 hunger--.
… 25 pain++, 20 fever toxin, 10 Histamine A.
Delete seed
End script
scrp 2 21 2 5
scrp 2 15 15 5
  anim [0123456R]
endm
CACTUS SEED 1 (SEED) DROP SCRIPT
CACTUS SEED 1 (BADPLANT) DROP SCRIPT
Spinning animation.
End script.
scrp 2 21 2 6
scrp 2 15 15 6
  doif wall eq 3
    rndv var0 0 6
    pose var0
    doif ov10 ne 0
      setv ov10 0
    endi
  endi
  doif wall eq 2
    tick 5
  endi
  doif wall eq 0
    negv ov11
  endi
  doif wall eq 1
    negv ov11
  endi
endm
CACTUS 1 SEED (SEED) COLLISION SCRIPT
CACTUS 1 SEED (BADPLANT) COLLISION SCRIPT
If hit bottom
{ Get random value 0 to 6
  Set pose to that value
  If float limit isn’t 0
  { set float limit to 0
  }
}
If hit top
{ tick 5
}
If hit left
{ invert direction
}
If hit right
{ invert direction
}
End script

Of course, most of the magic happens in the timer script.

Spinnomosa Seed Timer Script
scrp 2 21 2 9
scrp 2 15 15 9
  doif ov00 eq 0
    doif ov10 eq 0
      doif grav eq 0
        doif lite ge 100
          doif intr ge 20
            rndv var0 30 80
            doif intr le var0
              setv rnge 1000
              setv var9 0
              esee 2 15 1
                addv var9 1
              next
              targ ownr
              doif var9 gt 12
                setv ov00 1
                pose 16
                tick 2000
                stop
              endi
              pose 0
              setv var0 posl
              setv var1 post
              subv var0 32
              subv var1 56
              setv var2 ov09
              inst
              new: simp cact 31 0
               …900 0
              setv cls2 2 15 1
              setv attr 196
              bhvr 1 9
              bhvr 1 1
              mvto var0 var1
              slim
              rndv var0 500 1500
              tick var0
              rndv ov03 2 4
              setv ov00 0
              setv ov02 var2
            endi
          endi
        endi
      endi
      addv ontr 10
      targ ownr
      kill ownr
    endi
    doif ov10 ne 0
      rndv var0 1 5
      mulv var0 ov11
      setv velx var0
      rndv var1 -7 -2
      setv vely var1
      subv ov10 1
      doif ov10 eq 0
        tick 100
      endi
    endi
  endi
  doif ov00 eq 1
    pose 16
    addv ov01 1
    doif ov01 ge 20
      addv ontr 10
      kill ownr
    endi
    setv rnge 1000
    setv var0 0
    esee 2 21 2
      addv var0 1
    next
    targ ownr
    doif var0 ge 20
      kill ownr
    endi
    setv var0 0
    esee 2 15 1
      addv var0 1
    next
    targ ownr
    doif var0 lt 12
      setv ov00 0
      rndv var1 50 200
      tick var1
    endi
  endi
endm
CACTUS 1 SEED (SEED) TIMER SCRIPT
CACTUS 1 SEED (BADPLANT) TIMER SCRIPT
If seed is alive
{ if float limit ran out
  { if seed not still falling
    { if light at least 100
      { if inorganic nutrients at least 20
        { random 30 to 80
          If inorganic nutrients <= random
          { range 1000
            Zero counter
            For cacti in range
            { increment counter
            }
            Target seed
            If counter > 12
            { set seed dead
              Pose invisible
              Tick 2000
              Exit script
            }
            Pose to default seed
            Save position

            Adjust position

            Save floatiness
            Instantly
            Make new cactus

            It’s cactus 1
            Activateable, boundaries, gravity
            Clickable, hittable, pushable.
            Clickable, pushable.
            Move to calc. location
            Set limits
            Random value
            Timer to random val
            Seed lim. 2 to 4
            Growth state is new
            Inherit floatiness
          }
        }
      }
    }
    Add 10 to organic nutrients
    targ seed
    kill seed
  }
  If float limit is not 0
  { random speed 1 to 5
    In appropriate direction
    Set horizontal velocity
    Random vertical speed
    Set vertical velocity
    Decrement float limit
    If float limit is 0
    { tick 100
    }
  }
}
If seed dead
{ pose is blank
  Increment death timer
  If death timer >= 20
  { Add 10 organic nutrients
    delete seed
  }
  Range 1000
  Zero counter
  For each other seed in range
  { increment counter
  }
  Target seed
  If counter >= 20
  { delete seed
  }
  Zero counter
  For each cactus in range
  { increment counter
  }
  Target seed
  If counter < 12
  { Set seed alive
    Random value
    Tick to random value
  }
}
End script

That large chunk at the end I removed entirely was dedicated to ensuring the cacti didn't die out - if there weren't enough cacti in range, the dead seed would be forcibly re-flagged as alive. I decided this was unnecessary; if the cacti die out, you can re-seed them with the launcher. This logic also deleted the seed if there were too many other seeds around, but this was mainly to kill excess seeds before they could reach the cactus counting logic. Without the re-flagging, dead seeds stay dead and will eventually be deleted.

Spinnomosa Launcher

The launcher needed minimal changes to its standard scripts.

Spinnomosa Launcher Scripts
scrp 2 9 1 6
  doif wall eq 3
    snde drp3
  endi
endm
CACTUS 1 LAUNCHER COLLISION SCRIPT
If hits floor
{ drop3 sound
}
End script
scrp 2 9 1 1
  doif carr eq 0
    doif grav eq 0
      stim writ from 0 255 0 0
       …36 30 45 30 0 0 0 0
      setv attr 192
      setv var0 posl
      setv var1 posb
      addv var0 20
      subv var1 20
      reps 5
        inst
        anim [01234567]
        new: simp cact 17 15
         …3100 0
        setv cls2 2 21 2
        setv cls2 2 15 15
        setv attr 195
        bhvr 0 67
        bhvr 0 65
        setv aero 1
        setv size 30
        setv rest 100
        setv accg 2
        tick 3
        rndv ov09 10 100
        loop
          rndv ov11 -1 1
        untl ov11 ne 0
        setv ov10 ov09
        mvto var0 var1
        slim
        setv grav 1
        rndv var9 -70 -20
        setv vely var9
        anim [0123456R]
        slow
        targ ownr
        anim [6543210]
        rndv var9 0 1
        doif var9 eq 0
          snde pop3
        else
          snde pop4
        endi
        over
      repe
      setv attr 199
    endi
  endi
  setv actv 0
endm
CACTUS 1 LAUNCHER PUSH SCRIPT
If not being carried
{ if not falling
  { no neural stimulus,
    …30 boredom--, 30 NFP--
    Boundaries, gravity.
    Save position

    Adjust position for seed

    For 5 repetitions
    { instantly
      animation
      New seed

      It’s Cactus 1 Seed (Seed)
      It’s Cactus 1 Seed (Badplant)
      H/C carry, bounds, gravity.
      No click, eat/push/pull.
      No click, eat/push.
      1% vel lost to air resist
      Permeability for doors
      100% vel lost after coll.
      2 px/tick accel to gravity
      Tick 3
      Genetic float 10 to 100
      Do
      { direction is -1 to 1
      } until it’s not 0
      Float lim is copy of floatiness
      Move to calc location
      Set limits
      It’s falling
      Random vertical speed
      Set vertical velocity
      Spinny seed animation
      Normal script speed
      Target launcher
      Animation
      Random 0 or 1
      If 0
      { pop3 sound
      } else
      { pop4 sound
      }
      Wait til animation over
    }
    H/C carry, activateable, bounds, gravity.
  }
}
Set inactive
End script

However, due to the sprites being swapped between the two launchers, I had to backwards engineer both of them so I could recreate them with the correct sprite. What I wouldn't give for a "change sprite file of existing object" command!

Installation Script
enum 2 15 1
  kill targ
next
enum 2 21 2
  kill targ
next
enum 2 9 1
  kill targ
next
enum 2 15 4
  kill targ
next
enum 2 21 6
  kill targ
next
enum 2 9 23
  kill targ
next
Delete existing cacti, seeds, and launchers.
new: simp clau 8 0 9000 0
setv cls2 2 9 23
setv aero 20
setv accg 10
setv rest 50
setv size 127
setv attr 199
bhvr 1 1
slim
mvto 5200 540
setv grav 1
Create Cactus 2 launcher.
new: simp slau 8 0 9000 0
setv cls2 2 9 1
setv aero 20
setv accg 10
setv rest 50
setv size 127
setv attr 199
bhvr 1 1
slim
mvto 5100 540
setv grav 1
sys: camt
Create Cactus 1 launcher.

Cactus 2 (Spikeocausius)

Spikeocausius Plant

The second type of cactus is the spiny, dark green one.

For reference, sprites 0-6 show the plant growing, while 7-12 show it withering and dying. Sprites 13-20 show the seed tilting from upwards to downwards counterclockwise. Sprites 21 through 28 are the same thing but going clockwise. Sprites 29-36 show the seed spinning as it falls downward. Sprites 37-39 show it sinking into the ground.

The object variables for the plant are as follows:

  • ov00: Growth state. 0 = new, 1 = grown, 2 = seeding, 3 = dying.
  • ov01: Seed limit. After seeding this many times, the plant dies.

I've omitted the pull and hit scripts, because they are identical to the push script.

Spikeocausius Scripts
scrp 2 15 4 1
  doif ov00 ne 0
    stim writ from 50 255 0 0
     …18 100 0 0 0 0 0 0
  endi
  setv actv 0
endm
CACTUS 2 PUSH SCRIPT
if plant isn't new
{ no neural input,
  100 pain++
}
Set inactive
End script
scrp 2 15 4 9
  doif ov00 eq 0
    doif pose lt 6
      setv var0 pose
      addv var0 1
      pose var0
    else
      setv ov00 1
      rndv var0 800 1500
      tick var0
    endi
  endi
  doif ov00 eq 1
    doif ov01 le 0
      setv ov00 3
      stop
    endi
    doif sean eq 0
      doif tmod eq 4
        setv ov00 2
      endi
    endi
  endi
  doif ov00 eq 2
    setv var0 posx
    setv var1 posy
    inst
    rndv var9 2 5
    reps var9
      new: simp cac2 27 13 4100 0
      setv cls2 2 21 6
      setv cls2 2 15 16
      setv attr 195
      setv aero 1
      setv accg 2
      setv rest 100
      setv size 30
      mvto var0 var1
      slim
      rndv vely -40 -20
      loop
        rndv velx -7 7
      untl velx ne 0
      mulv velx 4
      doif velx lt 0
        pose 1
      else
        pose 9
      endi
      tick 5
    repe
    slow
    targ ownr
    subv ov01 1
    setv ov00 1
  endi
  doif ov00 eq 3
    doif pose lt 12
      setv var0 pose
      addv var0 1
      pose var0
    else
      kill targ
    endi
  endi
endm
CACTUS 2 TIMER SCRIPT
If plant is new
{ if not fully grown
  { record pose
    Increment
    Set incremented pose
  } else (fully grown)
  { set plant grown
    Random value
    Tick set to random value
  }
}
If plant is grown
{ if seed limit ran out
  { set plant dying
    Exit script
  }
  If springtime
  { if nighttime
    { set plant seeding
    }
  }
}
If plant is seeding
{ record position

  Instantly
  Random value 2 to 5
  For that number of repetitions
  { new seed
    It’s cactus 2 seed (seed)
    It’s cactus 2 seed (badplant)
    H/C Carry, Bounds, Gravity
    1% vel lost to air resist
    2 px/tick accel to gravity
    100% vel lost after collision
    Permeability for doors
    Move to saved location
    Set limits
    Random upward velocity
    Do
    { random sideways velocity
    } until it’s not 0
    Multiply by 4
    If velocity negative (left)
    { set seed pose 1
    } else (right)
    { set seed pose 9
    }
    Tick 5
  }
  Normal script speed
  Target cactus
  Decrement seed limiter
  Plant state goes to grown
}
If plant state dying
{ if pose less than final death
  { get pose
    Increment
    Set incremented pose
  } else (pose is final death)
  { delete cactus
  }
}
End script

Spikeocausius Seeds

The only object variable of note is ov00: the seed state. 0 = in flight, 1 = landed, and 2 = dead.

Spikeocausius Seed Scripts
scrp 2 21 6 4
scrp 2 15 16 4
  base 16
  pose 0
  tick 0
endm
CACTUS 2 SEED (SEED) PICK UP SCRIPT
CACTUS 2 SEED (BADPLANT) PICK UP SCRIPT
Pointing down pose as base
Pose 0
No timer
End script
scrp 2 21 6 5
scrp 2 15 16 5
  base 16
  anim [01234567R]
endm
CACTUS 2 SEED (SEED) DROP SCRIPT
CACTUS 2 SEED (BADPLANT) DROP SCRIPT
Pointing down pose as base
Spinning animation
End script
scrp 2 21 6 6
scrp 2 15 16 6
  doif wall eq 3
    base 24
    anim [012]
    setv ov00 1
    rndv var0 100 200
    tick var0
  endi
endm
CACTUS 2 SEED (SEED) COLLISION SCRIPT
CACTUS 2 SEED (BADPLANT) COLLISION SCRIPT
If hit floor
{ base is first sinking in pose
  Sinking in animation
  Set state to landed
  Get random value 100 to 200
  Set timer to that value
}
End script

The timer script contains, if I understand how the targeting system works correctly, an interesting little bug. Because actions apply to the current target, the meaning of a line can be changed completely without any alterations to the line itself, by simply inserting a targeting command before the line in question. It's also remarkably easy to lose track of what the current target is, since several commands other than targ change it.

Spikeocausius Seed Timer Script
scrp 2 21 6 9
scrp 2 15 16 9
  doif ov00 eq 0
    inst
    doif velx lt 0
      doif vely lt 0
        doif pose lt 4
          setv var0 pose
          addv var0 1
          pose var0
        endi
      else
        doif vely gt 0
          doif pose lt 4
            pose 4
          endi
          doif pose lt 8
            setv var0 pose
            addv var0 1
            pose var0
          endi
        endi
      endi
    endi
    doif velx gt 0
      doif vely lt 0
        doif pose lt 12
          setv var0 pose
          addv var0 1
          pose var0
        endi
      else
        doif vely gt 0
          doif pose lt 12
            pose 12
          endi
          doif pose lt 15
            setv var0 pose
            addv var0 1
            pose var0
          endi
        endi
      endi
    endi
    doif velx eq 0
      base 16
      anim [01234567R]
    endi
  endi
  doif ov00 eq 1
    doif carr eq 0
      doif lite ge 100
        doif intr gt 0
          doif intr lt 50
            inst
            setv rnge 500
            setv var9 0
            esee 2 15 4
              addv var9 1
            next
            doif var9 ge 10
              targ ownr
              setv ov00 2
              tick 2000
              tick 600
              stop
            endi
            targ ownr
            setv var0 posl
            setv var1 post
            subv var0 27
            subv var1 43
            new: simp cac2 13 0
             …900 0
            setv cls2 2 15 4
            setv attr 196
            bhvr 1 15
            bhvr 1 1
            setv ov00 0
            rndv ov01 1 3
            mvto var0 var1
            tick 100
            slim
            slow
          endi
        endi
      endi
      addv ontr 5
      targ ownr
      kill targ
    endi
  endi
  doif ov00 eq 2
    doif carr eq 0
      addv ontr 5
      kill ownr
      setv rnge 500
      setv var9 0
      esee 2 21 6
        addv var9 1
      next
      doif var9 ge 10
        kill ownr
      endi
      setv var9 0
      esee 2 15 4
        addv var9 1
      next
      doif var9 lt 10
        inst
        targ ownr
        setv var0 posl
        setv var1 post
        subv var0 27
        subv var1 43
        new: simp cac2 13 0 900 0
        setv cls2 2 15 4
        setv attr 196
        bhvr 1 15
        setv ov00 0
        rndv ov01 1 3
        mvto var0 var1
        tick 100
        slim
        slow
        targ ownr
        kill targ
      endi
    endi
  endi
endm
CACTUS 2 SEED (SEED) TIMER SCRIPT
CACTUS 2 SEED (BADPLANT) TIMER SCRIPT
If state is flying
{ instantly
  If velx is leftward
  { if vely is upward
    { if pose is pointing NW
      { save pose
        Increment
        Set incremented pose
      }
    } else
    { if vely is downward
      { if pose pointing NW
        { set pose W
        }
        If pose pointing W to SW
        { save pose
          Increment
          Set incremented pose
        }
      }
    }
  }
  If velx is rightward
  { if vely is upward
    { if pose pointing N to NE
      { save pose
        Increment
        Set incremented pose
      }
    } else
    { if vely is downward
      { if pose pointing N to NE
        { set pointing E
        }
        If pose pointing E to SE
        { save pose
          Increment
          Set incremented pose
        }
      }
    }
  }
  If velx is center
  { pose pointing S
    Spinning fall animation
  }
}
If state is grounded
{ if not being carried
  { if light >= 100
    { if inorganic nutrients > 0
      { and < 50
        { instantly
          Range 500
          Zero counter
          For nearby cacti
          { increment counter
          }
          If counter >= 10
          { Target seed
            set plant to seeding set seed to dead
            Tick 2000
            Tick 600
            Exit script
          }
          Target seed
          Set location

          Adjust location

          New cactus

          It’s cactus 2
          H carryable, boundaries, gravity.
          Clickable, all actions
          Clickable, pushable
          Plant state new
          Random seed limit
          Move to calc location
          Tick 100
          Set limits
          Normal script speed
        }
      }
    }
    Add 5 to organic nutrients
    Target seed
    Delete seed
  }
}
If seed is dead
{ if not being carried
  { add 5 organic nutrients
    delete seed
    range 500
    Zero counter
    For each seed
    { increment counter
    }
    If counter >= 10
    { delete seed
    }
    Zero counter
    For each cactus
    { increment counter
    }
    If counter < 10
    { instantly
      Target seed
      Record location

      Adjust location

      New cactus
      It’s cactus 2
      H carryable, boundaries, gravity
      Clickable, all actions
      Plant state is new
      Seed limiter random
      Move to calc location
      Tick 100
      Set limits
      Normal script speed
      Target seed
      Delete seed
    }
  }
}
End script

The bit I highlighted in yellow is the part I was referring to when I said that the target changes the meaning of the line. As I understand it, when you etch, your target changes to "the thing touching the original object" and so that setv line is in fact targeting the cactus, not the seed. Which doesn't seem to be the intent! Adding a line to retarget the seed changes that yellow line's meaning to be more in line with what it was originally supposed to do: flag the seed as dead, rather than bizarrely marking the plant as seeding.

And once again, I deleted a section that revives dead seeds to prevent plants from dying out. That's what the launcher's for! 

Spikeocausius Launcher

The collision script for this launcher is identical to the other one, and I already showed the creation script, so that just leaves the push script, which is very similar to the other launcher, but not identical.

Spikeocausius Launcher Push Script
scrp 2 9 23 1
  doif carr eq 0
    doif grav eq 0
      stim writ from 0 255 0 0
       …45 20 36 20 0 0 0 0
      setv attr 192
      setv var0 posl
      setv var1 posb
      addv var0 20
      subv var1 35
      reps 5
        anim [01234567]
        inst
        new: simp cac2 27 13 4100 0
        setv cls2 2 21 6
        setv cls2 2 15 16
        setv attr 195
        setv aero 1
        setv accg 2
        setv rest 100
        setv size 30
        mvto var0 var1
        slim
        slow
        rndv vely -40 -20
        loop
          rndv velx -7 7
        untl velx ne 0
        mulv velx 4
        doif velx lt 0
          pose 1
        else
          pose 9
        endi
        tick 5
        targ ownr
        anim [6543210]
        snde laun
        over
      repe
      targ ownr
      setv attr 199
    endi
  endi
  setv actv 0
endm
CACTUS 2 LAUNCHER PUSH SCRIPT
If not being carried
{ if not falling
  { no neural stimulus,
    …20 boredom--, 20 NFP--
    boundaries, gravity
    Save position

    Adjust position for seed

    For 5 repetitions
    { animation
      Instantly
      New seed
      It’s Cactus 2 Seed (Seed)
      It’s Cactus 2 Seed (Badplant)
      H/C carryable, boundaries, gravity
      1% vel lost to air resist
      2 px/tick accel to gravity
      100% vel lost after coll.
      Permeability for doors
      Move to calc location
      Set limits
      Normal script speed
      Random vertical speed
      Do
      { direction is -7 to 7
      } until it’s not 0
      Multiply direction
      If going left
      { pose 1
      } else (going right)
      { pose 9
      }
      Tick 5
      Target launcher
      Finish animation
      Play sound
      Wait until animation done
    }
    Target launcher
    H/C carry, activateable, bounds, grav.
  }
}
Set inactive
End script

Albian Cactus Beetle

Of course, there's still one "problem" left to deal with. It's not a bug, more of an unwanted feature. The seeds of the cacti tend to fall down the elevator shaft and grow in the basement, much to the annoyance of pretty much every Creatures 2 player out there. I've decided to solve this problem with a literal bug! 

The Albian Cactus Beetle wanders around in the basement, and is pretty much not interactable for the hand or creatures, but if it somehow manages to get out of the basement, it'll teleport back. It gnaws at the cacti, killing them, and eats their seeds (both the originals and the updated badplant versions). No more basement cacti!


Albian Cactus Beetle Scripts
new: simp cbtl 18 0 5000 0
setv cls2 2 18 15
setv aero 20
setv accg 10
setv rest 50
setv size 127
setv attr 208
bhvr 0 0
slim
mvto 4900 1120
sys: camt
setv grav 1
tick 5
setv ov00 1
endm
New cactus beetle
it's the cactus beetle
20% vel lost to air resist
10 px/tick accel to gravity
50% vel lost after coll.
Permeability for doors
invisible, bounds, gravity
not interactable
set limits
move to basement
center camera
gravity on
timer to 5
set direction of travel: left
end script
scrp 2 18 15 6
doif wall eq 0
  setv ov00 0
  base 12
  anim [01234]
  over
endi
doif wall eq 1
  setv ov00 1
  base 12
  anim [43210]
  over
endi
endm
CACTUS BEETLE COLLISION SCRIPT
If hit left wall
{ set direction of travel: right
  animation base: face left
  turn from left to right
  wait til animation over
}
If hit right wall
{ set direction of travel: left
  animation base: face left
  turn from right to left
  wait til animation over
}
end script
scrp 2 18 15 9
doif posx lt 3871
  mvto 4900 1120
endi
doif posx gt 5931
  mvto 4900 1120
endi
doif posy lt 1057
  mvto 4900 1120
endi
doif posy gt 1193
  mvto 4900 1120
endi
rndv va00 0 39
doif va00 eq 0
  base 12
  doif ov00 eq 1
    setv ov00 0
    anim [01234]
    over
  else
    setv ov00 1
    anim [43210]
    over
  endi
endi
doif ov00 eq 1
  base 0
  anim [012345]
  setv vely -12
  setv velx -14
else
  base 6
  anim [012345]
  setv vely -12
  setv velx 14
endi
etch 2 0 0
  doif gnus eq 15
    doif spcs eq 1
      doif ov00 ne 4
        setv ov00 4
        doif pose ge 8
          pose 22
        endi
        doif pose eq 7
          pose 23
        endi
        doif pose eq 6
          pose 25
        endi
        doif pose eq 5
         pose 26
        endi
        doif pose eq 4
          pose 28
        endi
        doif pose lt 4
          pose 30
        endi
      endi
    endi
    doif spcs eq 4
      doif ov00 ne 3
        setv ov00 3
        setv va02 12
        subv va02 pose
        pose va02
        doif pose eq 6
          pose 7
        endi
      endi
    endi
    doif spcs eq 15
      kill targ
    endi
    doif spcs eq 16
      kill targ
    endi
  endi
  doif gnus eq 21
    doif spcs eq 2
      kill targ
    endi
    doif spcs eq 6
      kill targ
    endi
  endi
next
endm
CACTUS BEETLE TIMER SCRIPT
This whole chunk detects if the
  …beetle has left the basement
  …and moves it back if needed.









Generate random number 0 to 39
If that number is 0
{ animation base: facing left
  if direction is left
  { set direction right
    animate turning around
    wait for animation
  } else (direction is right)
  { set direction left
    animate turning around
    wait for animation
  }
}
If direction is left
{ set animation base
  walking animation
  movement

} else (direction is right)
{ set animation base
  walking animation
  movement

}
For each simple object touching beetle
{ if it's a badplant
  { if it's cactus 1
    { set it dying
      and select the appropriate dying pose



















    }
    if it's cactus 2
    { if not already dying
      { set it to dying
        calculate appropriate pose





      }
    }
    if it's new cactus 1 seed
    { delete it
    }
    if it's new cactus 2 seed
    { delete it
    }
  }
  if it's a seed
  { if it's old cactus 1 seed
    { delete it
    }
    if it's old cactus 2 seed
    { delete it
    }
  }
}
end script

Of course, with Pathfinder: Wrath of the Righteous out now, I likely won't be coming back to Creatures for a while. The Crusade calls!

No comments:

Post a Comment