Welcome to the Creatures Wiki! Log in and join the community.

Blackbird (teardown)

From Creatures Wiki
Revision as of 02:03, 21 May 2023 by Verm (talk | contribs) (→‎Scripts: Script 0 is deactivate, a creature can basically never call this but it is a valid action)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Blackbird
This article is a teardown of an existing CAOS script.
Game Version Docking Station
Filename(s) Blackbird.agents
Classifier 2 15 4650
Dependencies
Images blackbird.c16
Sounds chwp.wav
Catalogue Tags blackbird.catalogue
Agents Blackbird.agents
Other none

This is a teardown page explaining the details and inner workings of this agent. For general information, see Blackbird

Blackbird is a simple critter agent made for Docking Station by AquaShee and Ghosthande. OV00 is to indicate the blackbird is hopping or flying, and OV01 indicates that it is moving to the left or right. The timer script for the blackbird does not use subroutines, and instead relies on valid logic statements (with a healthy dose of random chance) to function.

Scripts[edit]

Inject[edit]

  • A new simple critter agent, using 22 images.
  • Uses a TICK of 1
  • Injects inside the inventory.

Push[edit]

  • Stimulates the creature with a low strength that they have played with a critter.
  • Forces the creature to drop the blackbird
  • Makes the blackbird try to escape.

Pull[edit]

  • Stimulates the creature with a low strength that they have played with a critter.
  • Forces the creature to drop the blackbird
  • Makes the blackbird try to escape.

Hit[edit]

  • Stimulates the creature with a low strength that they have hit a critter.
  • Forces the creature to drop the blackbird
  • Makes the blackbird try to escape.

Deactivate[edit]

  • Stimulates the creature with a low strength that they have hit a critter.
  • Forces the creature to drop the blackbird
  • Makes the blackbird try to escape.

Eat script[edit]

  • Stimulates the creature with a low strength that they have eaten a critter.
  • Forces the creature to drop the blackbird
  • Makes the blackbird try to escape.

Collision script[edit]

  • If there is a wall to the right, set ov01 to 0.
  • Else, if there is a wall to the left, set ov01 to 1.
  • Else if there is a wall below the blackbird and the blackbird is flying, change to hopping.


Timer script[edit]

  • If the blackbird is hopping and not falling and if a random choice comes out as 1, and if the blackbird is hopping left, use a certain set of images to make it look that way. If the blackbird is not hopping left, it must be hopping right, so then make it look that way, then set the direction the blackbird is going in randomly between left and right.
  • If the hopping blackbird's random choice comes out as any number other than 1, and if their direction is left, set their VELY to -5 (they are going up) and their VELX to -5 (they are going left) and animate them accordingly.
  • If the hopping blackbird's random choice comes out as any number other than 1, and if their direction is right, set their VELY to -5 (they are going up) and their VELX to 5 (they are going right) and animate them accordingly.
  • If the blackbird is in fresh or salt water
    • Take flight
  • If the blackbird is hopping and falling
    • and the ground is very far away
  • Take flight
  • Else, if the blackbird is flying
    • And going left
      • Animate accordingly and set the VELX to going left.
    • If the blackbird is flying right
      • Animate accordingly and set the VELX to going right.
  • If there's a nearby obstacle below the blackbird or the blackbird is in fresh or salt water, try to fly up.
  • If a random choice comes out as 1, try to change direction.
  • If a random choice comes out as 1, and if there's an obstacle close beneath the blackbird, choose between hopping and flying.

Remove script[edit]

  • Count all Blackbirds in the world and KILL them.
  • Remove the scripts: push, pull, hit, script 0, collision, timer and eat.

Source code[edit]

inst
new: simp 2 15 4650 "blackbird" 22 0 rand 500 1000
attr 199
bhvr 63
elas 10
accg 2
perm 100
rnge 320
tick 1
**ov00: 0 = hopping, 1 = flying
**ov01: 0 = left, 1 = right
setv ov00 rand 0 1
setv ov01 rand 0 1
seta va00 targ
enum 1 2 11
	spas targ va00
	doif ov00 = 0 and clac = 0
		mesg writ targ 0
	endi
next

scrp 2 15 4650 1
	stim writ from 86 0.2
	targ from
	drop
	targ ownr
	setv ov00 1
	setv vely -30
endm

scrp 2 15 4650 2
	stim writ from 86 0.2
	targ from
	drop
	targ ownr
	setv ov00 1
	setv vely -30
endm

scrp 2 15 4650 0
	stim writ from 87 0.2
	targ from
	drop
	targ ownr
	setv ov00 1
	setv vely -30
endm

scrp 2 15 4650 12
	snde "chwp"
	stim writ from 80 0.2
	targ from
	drop
	targ ownr
	setv ov00 1
	setv vely -30
endm

scrp 2 15 4650 6
	doif wall eq rght
		setv ov01 0
	elif wall eq left
		setv ov01 1
	elif wall eq down and ov00 eq 1
		setv ov00 0
	endi
endm

scrp 2 15 4650 9
	doif ov00 eq 0 and fall eq 0
		doif rand 0 5 eq 1
			doif ov01 eq 0
				anim [13 13 20 13 13 20 13 13 20]
			else
				anim [17 17 21 17 17 21 17 17 21]
			endi
			over
			setv ov01 rand 0 1
		else
			doif ov01 eq 0
				setv vely -5
				setv velx -5
				anim [12 13 14 15 14 13]
				over
			elif ov01 eq 1
				setv vely -5
				setv velx 5
				anim [16 17 18 19 18 17]
				over
			endi
		endi
		doif rtyp room ownr eq 8 or rtyp room ownr eq 9
			setv ov00 1
		endi
	elif ov00 eq 0 and fall eq 1
		doif obst DOWN gt 50
			setv ov00 1
		endi
	elif ov00 eq 1
		doif ov01 eq 0
			anim [0 1 2 3 4 5]
			over
			setv velx -5
		elif ov01 eq 1
			anim [6 7 8 9 10 11]
			over
			setv velx 5
		endi
		doif obst DOWN lt 30 or rtyp room ownr eq 8 or rtyp room ownr eq 9
			setv vely rand -10 -12
		else
			setv vely rand -6 -12
		endi
		doif rand 0 20 eq 1
			setv ov01 rand 0 1
		endi
	endi
	doif rand 0 10 eq 1
		doif obst DOWN lt 50
			setv ov00 rand 0 1
		endi
	endi
endm

rscr
enum 2 15 4650
	kill targ
next
scrx 2 15 4650 1
scrx 2 15 4650 2
scrx 2 15 4650 3
scrx 2 15 4650 0
scrx 2 15 4650 6
scrx 2 15 4650 9
scrx 2 15 4650 12