Skip to content

DroppedItem ​

Inherits: RigidBody3D

An item (or a pile of a currency) that lies in the world, where a character can pick it up.

Description ​

It is a rigid body, so what physics does to it is a setting (Gameplay Config > Dropped Items > Physics): it can be put on the ground and kept still, thrown and frozen once it rests, or simulated for as long as it lies there. It looks like the model of its item or a flat picture of its icon, can carry visual effects (its own and the one of its quality), shows its name above it, and is picked up in the ways the Gameplay Config switches on: by walking over it, with the interact key when near, by clicking it, or by looking at it. The class does everything; the settings choose.

A dropped item comes from the player (dragging an item out of the bag), from loot rules that deliver to the ground, from the Drop Item event action and behavior task, and from you: place a dropped_item.tscn in the world scene and set its item (a placed item has a placement_id, so a taken item stays taken). The Object Registry keeps them and saves them. See DroppedItem.drop to make one from code.

Properties ​

intitem_id0:
intquantity1
intitem_level0
intcurrency_id0
intcurrency_amount0
intplacement_id0
PhysicsOverridephysics_overridePhysicsOverride.PROJECT
floatrespawn_time0.0
floatlifetime_override-1.0

Variables ​

ItemInstanceitem_instancenull
GameHost.SystemHubsystem_hubnull
floatage0.0
boolhas_landedfalse
boolis_gonefalse
boolis_activefalse

Methods ​

DroppedItemdrop( hub: GameHost.SystemHub, instance: ItemInstance, position: Vector3, launch: bool = true, velocity: Vector3 = Vector3.ZERO ) static
DroppedItemdrop_currency( hub: GameHost.SystemHub, p_currency_id: int, amount: int, position: Vector3, launch: bool = true ) static
intnew_placement_id( container: Node ) static
DroppedItemmake_node() static
Vector3scatter_position( origin: Vector3, index: int, count: int, radius: float, rng: RandomNumberGenerator = null ) static
voidactivate( hub: GameHost.SystemHub, launch: bool = false, velocity: Vector3 = Vector3.ZERO, restoring: bool = false )
voidset_item_instance( instance: ItemInstance )
voidset_currency( p_currency_id: int, amount: int )
Stringget_display_name()
intquantity_held()
intget_physics_mode()
boolis_interactable()
boolcan_be_taken_now()
booltry_pickup( taker: Entity, warn: bool = true )
voidprocess_interaction( taker: Entity )
voidshow_interact_prompt()
voidhide_interact_prompt()
voidset_current_target_on()
voidset_current_target_off()
voidset_current_target_hover()
voidset_hover( on: bool )
voidset_highlight( on: bool )
Vector3get_aim_position()
voidexpire()
voiddisable_as_taken()
voidrespawn()
voidapply_saved_state( saved: Dictionary )
Dictionaryto_save_data()
voidfrom_save_data( data: Dictionary )

Signals ​

picked_up( dropped: DroppedItem, taker: Entity, quantity: int ) ​

Emitted when a character takes the item (all of it, or part of the stack): who and how many

removed( dropped: DroppedItem ) ​

Emitted when the item is gone: taken, expired or removed

landed( dropped: DroppedItem ) ​

Emitted when the item has come to rest (or was put on the ground)

Enumerations ​

enum PhysicsOverride ​

Where the physics of the item comes from: the project setting, or one of the modes for this item only

  • PROJECT = 0
  • PLACE_ON_GROUND = 1
  • SETTLE_THEN_FREEZE = 2
  • ALWAYS_SIMULATED = 3

Constants ​

  • String DEFAULT_SCENE = "res://addons/chroniclenode/runtime_classes/entity/components/inventory/dropp... - The scene a dropped item is made from when the Gameplay Config names none
  • float SETTLE_TIMEOUT = 6.0 - The most seconds a thrown item may move before it is frozen where it is
  • float FALL_LIMIT = 60.0 - An item that falls this far below where it started is put back there (it went through the ground)
  • float RETRY_DELAY = 1.5 - How long a character who cannot take the item waits before trying again (seconds)

Property descriptions ​

Item

int item_id = 0: ​

The item that lies here (an item of the project). Leave empty for a pile of currency

int quantity = 1 ​

How many of the item (a stack)

int item_level = 0 ​

The item level a generated item is made at (0 = the level of its definition)

int currency_id = 0 ​

A pile of this currency lies here instead of an item (the id of a currency)

int currency_amount = 0 ​

How much of the currency is in the pile

Placement

int placement_id = 0 ​

The number that tells this item apart from the others of the world, so the game remembers it was taken. The Add Object tool sets it; leave 0 for an item that is made while the game runs

PhysicsOverride physics_override = PhysicsOverride.PROJECT ​

What physics does to this item: the project setting, or a mode for this item only (a placed item that must stay on a table: Place on ground)

float respawn_time = 0.0 ​

Seconds after it is taken until a placed item lies there again (0 = never)

float lifetime_override = -1.0 ​

Seconds before the item disappears (-1 = the project setting, 0 = never)

Variable descriptions ​

ItemInstance item_instance = null ​

The item that lies here (null for a pile of currency)

GameHost.SystemHub system_hub = null ​

The hub of the game systems

float age = 0.0 ​

How many seconds the item has lain in the world

bool has_landed = false ​

True once the item has come to rest

bool is_gone = false ​

True once the item is gone (taken, expired or removed)

bool is_active = false ​

Is the item in a world (made by the registry), and not only a node in the editor?

Method descriptions ​

DroppedItem drop( hub: GameHost.SystemHub, instance: ItemInstance, position: Vector3, launch: bool = true, velocity: Vector3 = Vector3.ZERO ) ​

Makes a dropped item of the item instance at a position and puts it in the world (the registry of the current world). launch throws it; without it the item is put where it is (and on the ground under it, by the physics mode). Gives the dropped item, or null when the world has no room for it or dropped items are off

DroppedItem drop_currency( hub: GameHost.SystemHub, p_currency_id: int, amount: int, position: Vector3, launch: bool = true ) ​

Makes a pile of a currency at a position, like drop

int new_placement_id( container: Node ) ​

A placement id that no other dropped item in the container has (a random positive whole number)

DroppedItem make_node() ​

The scene a dropped item is made from: the one of the Gameplay Config, else the one of the toolkit

Vector3 scatter_position( origin: Vector3, index: int, count: int, radius: float, rng: RandomNumberGenerator = null ) ​

A spot around an origin for the item number index of count that drop together: the first stays at the origin, the others are scattered in a ring

void activate( hub: GameHost.SystemHub, launch: bool = false, velocity: Vector3 = Vector3.ZERO, restoring: bool = false ) ​

The item the node holds: a made instance, a currency pile, or what its placement says. Called by the registry once the node is in the world

void set_item_instance( instance: ItemInstance ) ​

Gives the dropped item the item it holds (instead of the item_id of a placement)

void set_currency( p_currency_id: int, amount: int ) ​

Gives the dropped item a pile of currency

String get_display_name() ​

The name of what lies here

int quantity_held() ​

How many of the item (or how much of the currency) lie here

int get_physics_mode() ​

The mode that applies to this item: its own override, else the project setting

bool is_interactable() ​

Is the item an interact target (the interact key picks it up)? Only when that way of picking up is on

bool can_be_taken_now() ​

May the item be taken now? It has landed, its delay is over and it has something in it

bool try_pickup( taker: Entity, warn: bool = true ) ​

A character takes the item (or as much of it as fits). warn tells the player when the bag is full. Gives true when something was taken

void process_interaction( taker: Entity ) ​

The interact key was pressed near the item

void show_interact_prompt() ​

No description yet.

void hide_interact_prompt() ​

No description yet.

void set_current_target_on() ​

No description yet.

void set_current_target_off() ​

No description yet.

void set_current_target_hover() ​

No description yet.

void set_hover( on: bool ) ​

The mouse or the crosshair is on the item (or has left it)

void set_highlight( on: bool ) ​

Lights the item up (the overlay of the project), or not

Vector3 get_aim_position() ​

The position of the item for the mouse and the camera to aim at

void expire() ​

The lifetime is over: the item disappears

void disable_as_taken() ​

A placed item that the save says was taken: it is hidden and stays so

void respawn() ​

A placed item lies there again (its respawn time is over): a new roll of the item, at its place

void apply_saved_state( saved: Dictionary ) ​

Gives a placed item the state it was saved in: where it lies, what it holds, how long it has lain

Dictionary to_save_data() ​

The state of the item for a save: where it lies, what it holds and how long it has been there

void from_save_data( data: Dictionary ) ​

Puts the state of a save back (the node is made and in the world already). A frozen item stays where it was