force_shield_init = ( ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param, ":agent", 1),
(store_trigger_param, "$counter", 0),
(store_trigger_param, "$sh_pos", 0),
(agent_has_item_equipped,":agent", "itm_force_shield"),
(agent_set_slot, ":agent", slot_agent_shield_hitpoints, -250), # 250 HP, deactivated
(agent_get_position, "$sh_pos", ":agent"),
(position_move_z, "$sh_pos", -500),
(set_spawn_position, "$sh_pos"),
(spawn_scene_prop, "spr_belt_shield_on"),
(assign, "$shield_id", reg0), # spawn_scene_prop returns instance id in reg0
(prop_instance_enable_physics, "$shield_id", 0),
(agent_set_attached_scene_prop, ":agent", "$shield_id"),
(agent_set_attached_scene_prop_x, ":agent", 0),
(agent_set_attached_scene_prop_y, ":agent", 0),
(agent_set_attached_scene_prop_z, ":agent", -500),
(display_message, "@Force shield initialized."),
]
)
force_shield_toggle = ( 0, 0, 0, [],
[
(try_begin),
(eq,"$counter", 1),
(key_clicked, key_h), # Replace this as you see fit
(get_player_agent_no, ":agent"),
(agent_get_slot, ":shield_health", ":agent", slot_agent_shield_hitpoints),
(val_mul, ":shield_health", -1),
(agent_set_slot, ":agent", slot_agent_shield_hitpoints, ":shield_health"),
(prop_instance_enable_physics, "$shield_id", 0),
(position_move_z, "$sh_pos", -500),
(agent_set_attached_scene_prop_z, ":agent", "$sh_pos"),
(prop_instance_animate_to_position, "$shield_id", "$sh_pos", 0),
(display_message, "@Force shield inactive."),
(assign,"$counter", 0),
(else_try),
(eq,"$counter", 0),
(key_clicked, key_h), # Replace this as you see fit
(get_player_agent_no, ":agent"),
(agent_get_slot, ":shield_health", ":agent", slot_agent_shield_hitpoints),
(val_mul, ":shield_health", -1),
(agent_set_slot, ":agent", slot_agent_shield_hitpoints, ":shield_health"),
(prop_instance_enable_physics, "$shield_id", 1),
(position_move_z, "$sh_pos", 500),
(agent_set_attached_scene_prop_z, ":agent", 0),
(prop_instance_animate_to_position, "$shield_id", "$sh_pos", 0),
(display_message, "@Force shield active."),
(assign,"$counter", 1),
(try_end),
]
)