The Cove's shore life: crabs up the beach from dusk till dawn (keep to the sand, pinch if you get close, crab meat to cook), gulls after food on the sand and fish on a smoking rack; online too
This commit is contained in:
56
scripts/creatures/gull.gd
Normal file
56
scripts/creatures/gull.gd
Normal file
@@ -0,0 +1,56 @@
|
||||
extends "res://scripts/creatures/crow.gd"
|
||||
## A gull (0.6.0, the Cove only): the Cove's crow, sent by thieves.gd by
|
||||
## day. It comes for food left on the sand and for fish on a smoking rack
|
||||
## that nobody's watching. Bolder and quicker than a crow: it lands, snatches
|
||||
## one and is off with it, and another soon follows. Shoot it down while
|
||||
## it's carrying and it drops what it took. Feathers.
|
||||
|
||||
const SNATCH_AFTER := 1.2 ## seconds on the ground before it grabs one
|
||||
const GULL_SCARE := 6.0 ## (bolder than a crow)
|
||||
|
||||
var carry: Dictionary = {} ## {id, count, extra} once it has something
|
||||
|
||||
func display_name() -> String:
|
||||
return "Gull"
|
||||
|
||||
func interact_prompt(_p: Node) -> String:
|
||||
if is_dead():
|
||||
return "Gull [E] Pluck"
|
||||
if not carry.is_empty():
|
||||
return "Gull (off with your %s!)" % ItemDB.item_name(String(carry.id)).to_lower()
|
||||
return {"peck": "Gull (after your food!)", "fly": "Gull (circling your food)"}.get(state, "Gull")
|
||||
|
||||
func _think(dt: float) -> void:
|
||||
match state:
|
||||
"fly":
|
||||
if not thieves.gull_still_there(food) or thieves.watched(thieves.spot(food), GULL_SCARE):
|
||||
_leave()
|
||||
return
|
||||
_goal = thieves.spot(food)
|
||||
var ground: float = terrain.sample_height(global_position.x, global_position.z)
|
||||
if Vector2(_goal.x - global_position.x, _goal.z - global_position.z).length() < 0.35 and global_position.y - ground < 0.15:
|
||||
state = "peck"
|
||||
_state_t = SNATCH_AFTER
|
||||
thieves.gull_landed(self, food)
|
||||
"peck":
|
||||
if not thieves.gull_still_there(food) or thieves.watched(global_position, GULL_SCARE):
|
||||
_leave()
|
||||
return
|
||||
_state_t -= dt
|
||||
if _state_t <= 0.0:
|
||||
_peck_anim = 0.4
|
||||
carry = thieves.snatch(self, food)
|
||||
_leave()
|
||||
"fly_off":
|
||||
if thieves.out_of_sight(global_position):
|
||||
thieves.gone(self)
|
||||
_:
|
||||
_leave()
|
||||
|
||||
## Shot down with something in its beak: it drops it where it falls.
|
||||
func _die(from: Vector3) -> void:
|
||||
super._die(from)
|
||||
if not carry.is_empty() and not puppet:
|
||||
var at := global_position + Vector3(0, 0.3, 0)
|
||||
world.drop_item(String(carry.id), int(carry.count), Transform3D(Basis(), at), carry.get("extra", {}))
|
||||
carry = {}
|
||||
Reference in New Issue
Block a user