Fields of Mistria — Vanilla GML Reference FoM v1.0.8

obj_dungeon_whirlpool.gml

object_create(
    "obj_dungeon_whirlpool",
    object_reserve("par_interactable"),
    {
        sprite_index: spr_main_dungeon_prototype_instance_door_whirlpool,
        pool_id: 0,
        pool_sister: 1,
        create: function() {
            event_inherit(ObjectEvent.Create);

            register_interaction(
                InputId.Interact,
                "misc_local/enter_whirlpool",
                function() {
                    obj_ari.dive(self, DiveBehavior.Whirlpool);
                },
                function() {
                    return obj_ari.fsm.current_state_id() == PlayerState.Swim;
                }
            );

            function dungeon_init() {
                self.x += 8;
                self.y += 8;
                depth = get_instance_depth(y, 16);

                self.sprite_index = spr_fx_water_whirlpool_active;

                var found = undefined;
                with obj_dungeon_whirlpool {
                    if self.id == other.id {
                        continue;
                    }
                    if self.pool_id == other.pool_sister {
                        found = self.id;
                        break;
                    }
                }
                assert_neq(found, undefined, "Failed to find an obj_dungeon_whirpool with a pool_id of {}", self.pool_sister);
                self.pool_sister = found;

                self.inactive_renderable = self.create_renderable(spr_fx_water_whirlpool_inactive);
                self.inactive_renderable.depth += 1;
            }
        },
        step_end: function() {
            if self.highlighter.update() && MIST.running == false {
                self.image_alpha = approach(self.image_alpha, 1.0, 0.1);
            } else {
                self.image_alpha = approach(self.image_alpha, 0.0, 0.1);
            }
            self.inactive_renderable.animation_frame = self.image_index;
        },
    }
);