#[no_std, cache_output] constants = import "constants.spwn" extract constants.obj_props extract constants.comparisons extract constants.easing_types extract import "control_flow.spwn" return { shake: #[desc("Implementation of the shake trigger") example("shake()")] ( #[desc("Strength value")] strength: @number = 1, #[desc("Interval value")] interval: @number = 0, #[desc("Duration of shake")] duration: @number = 0.5 ){ $.add( trigger { OBJ_ID: 1520, STRENGTH: strength, INTERVAL: interval, DURATION: duration, }) wait(duration) }, disable_trail: #[desc("Disables the player's trail") example("disable_trail()")] (){ $.add( trigger{ OBJ_ID: 33, }) }, enable_trail: #[desc("Enables the player's trail") example("enable_trail()")] (){ $.add( trigger{ OBJ_ID: 32, }) }, show_player: #[desc("Shows the player") example("show_player()")] (){ $.add( trigger{ OBJ_ID: 1613, }) }, hide_player: #[desc("Hides the player") example("hide_player()")] (){ $.add( trigger{ OBJ_ID: 1612, }) }, toggle_bg_effect: #[desc("Implementation of the bg effect on/off triggers") example("toggle_bg_effect(false)")] ( #[desc("Weather to toggle bg effect on or off")] on: @bool = false ) { if on { $.add( trigger{ OBJ_ID: 1818, }) } else { $.add( trigger{ OBJ_ID: 1819, }) } }, move_trigger: #[desc("Returns a move trigger as an object") example("$.add( move_trigger(1g,10,0).with(X,600) ) // Creates a move trigger at X 600 that moves group 1 a block to the right")] ( #[desc("Group to move")] group: @group, #[desc("Units to move on the X axis")] x: @number, #[desc("Units to move on the Y axis")] y: @number, #[desc("Duration of movement")] duration: @number = 0, easing: @easing_type = NONE, easing_rate: @number = 2 ) { return obj{ OBJ_ID: 901, TARGET: group, MOVE_X: x * 3, MOVE_Y: y * 3, DURATION: duration, EASING: easing.id, EASING_RATE: easing_rate, } }, lock_to_player_trigger: #[desc("Returns a move trigger that locks the group's position as an object") example("$.add( lock_to_player_trigger(1g,lock_x = true,lock_y = false).with(X,600) ) // Creates a move trigger at X 600 that locks group 1 to the player's X")] ( #[desc("Group to lock")] group: @group, #[desc("Lock to player X")] lock_x: @bool = true, #[desc("Lock to player Y")] lock_y: @bool = true, #[desc("Duration of lock")] duration: @number = 999, ) { return obj{ OBJ_ID: 901, TARGET: group, DURATION: duration, LOCK_TO_PLAYER_X: lock_x, LOCK_TO_PLAYER_Y: lock_y, } }, stop_trigger: #[desc("Returns a stop trigger as an object") example("$.add( stop_trigger(10g).with(X,600) ) // Creates a stop trigger at X 600 that stops group 10")] ( #[desc("Group to stop")] group: @group, ) { return obj{ OBJ_ID: 1616, TARGET: group, } }, alpha_trigger: #[desc("Returns an alpha trigger as an object") example("$.add( alpha_trigger(1g,0.5,duration = 2).with(X,600) ) // Creates an alpha trigger at X 600 that fades group 1 to half opacity over 2 seconds")] (group: @group, opacity: @number = 1, duration: @number = 0){ return obj { OBJ_ID: 1007, TARGET: group, OPACITY: opacity, DURATION: duration, } }, toggle_on_trigger: #[desc("Returns a toggle on trigger as an object") example("$.add( toggle_on_trigger(5g).with(X,600) ) // Creates a toggle trigger at X 600 that turns on group 5")] (#[desc("Group to toggle")] group: @group){ return obj{ OBJ_ID: 1049, TARGET: group, ACTIVATE_GROUP: true, } }, toggle_off_trigger: #[desc("Returns a toggle off trigger as an object") example("$.add( toggle_off_trigger(5g).with(X,600) ) // Creates a toggle trigger at X 600 that turns off group 5")] (#[desc("Group to toggle")] group: @group){ return obj{ OBJ_ID: 1049, TARGET: group, ACTIVATE_GROUP: false, } }, rotate_trigger: #[desc("Returns a rotate trigger as an object") example("$.add( rotate_trigger(10g,3g,90,duration = 5).with(X,600) ) // Creates a rotate trigger at X 600 that rotates group 10 90 degrees around group 3 over 5 seconds")] ( #[desc("Group to rotate")] group: @group, #[desc("Group of object to rotate around")] center: @group, #[desc("Rotation in degrees")] degrees: @number, #[desc("Duration of rotation")] duration: @number = 0, #[desc("Easing type")] easing: @easing_type = NONE, #[desc("Easing rate")] easing_rate: @number = 2, #[desc("Only rotate positions of the objects, not the textures")] lock_object_rotation: @bool = false ){ return obj{ OBJ_ID: 1346, TARGET: group, CENTER: center, ROTATE_DEGREES: degrees, DURATION: duration, EASING: easing.id, EASING_RATE: easing_rate, LOCK_OBJECT_ROTATION: lock_object_rotation } }, follow_trigger: #[desc("Returns a follow trigger as an object") example("$.add( follow_trigger(10g,3g).with(X,600) ) // Creates a follow trigger at X 600 that makes group 10 follow group 3")] ( #[desc("Group that will follow")] group: @group, #[desc("Group of object to follow")] other: @group, #[desc("Multiplier for the movement on the X-axis")] x_mod: @number = 1, #[desc("Multiplier for the movement on the Y-axis")] y_mod: @number = 1, #[desc("Duration of following")] duration: @number = 999 ){ return obj{ OBJ_ID: 1347, X_MOD: x_mod, Y_MOD: y_mod, DURATION: duration, TARGET: group, FOLLOW: other, } }, follow_player_y_trigger: #[desc("Returns a follow player Y trigger as an object") example("$.add( follow_player_y_trigger(10g,delay = 0.5).with(X,600) )")] ( #[desc("Group that will follow")] group: @group, #[desc("Interpolation factor (?)")] speed: @number = 1, #[desc("Delay of movement")] delay: @number = 0, #[desc("Offset on the Y-axis")] offset: @number = 0, #[desc("Maximum speed")] max_speed: @number = 0, #[desc("Duration of following")] duration: @number = 999 ){ return obj{ OBJ_ID: 1814, SPEED : speed, DELAY : delay, Y_OFFSET : offset, MAX_SPEED : max_speed, TARGET: group, DURATION: duration, } }, move_to_trigger: #[desc("Returns a move trigger that uses \"move to\" as an object") example("$.add( move_to_trigger(10g,3g).with(X,600) ) // Creates a move trigger at X 600 that moves group 10 to group 3")] ( #[desc("Group to move")] group: @group, #[desc("Group of the object to move to")] target: @group, #[desc("Duration of movement")] duration: @number = 0, #[desc("Will move to the object only on the X-axis")] x_only: @bool = false, #[desc("Will move to the object only on the y-axis")] y_only: @bool = false, #[desc("Easing type")] easing: @easing_type = NONE, #[desc("Easing rate")] easing_rate: @number = 2 ) { return obj{ OBJ_ID: 901, TARGET: group, USE_TARGET: true, TARGET_POS_AXES: (){ if x_only && y_only { return 0 } else if x_only { return 1 } else if y_only { return 2 } else { return 0 } }(), TARGET_POS: target, DURATION: duration, EASING: easing.id, EASING_RATE: easing_rate, } }, pulse_trigger: #[desc("Returns a pulse trigger as an object") example(" $.add( pulse_trigger(10g,255,0,0,fade_out = 0.5).with(X,600) ) $.add( pulse_trigger(10c,255,0,0,fade_out = 0.5).with(X,600) ) ")] ( #[desc("Target to pulse (group or color)")] target: @group | @color, #[desc("Red value of pulse color (or hue if HSV is enabled)")] r: @number, #[desc("Green value of pulse color (or saturation if HSV is enabled)")] g: @number, #[desc("Blue value of pulse color (or brightness/value if HSV is enabled)")] b: @number, #[desc("Fade-in duration")] fade_in: @number = 0, #[desc("Duration to hold the color")] hold: @number = 0, #[desc("Fade-out duration")] fade_out: @number = 0, #[desc("Weather to prioritize this pulse over simultaneous pulses")] exclusive: @bool = false, #[desc("Toggle HSV mode")] hsv: @bool = false, #[desc("HSV specific: saturation checked")] s_checked: @bool = false, #[desc("HSV specific: brightness checked")] b_checked: @bool = false ) { if hsv { return obj{ OBJ_ID: 1006, COPIED_COLOR_HVS: r as @string + "a" + g as @string + "a" + b as @string + "a" + s_checked as @number as @string + "a" + b_checked as @number as @string, EXCLUSIVE: exclusive, FADE_IN: fade_in, HOLD: hold, FADE_OUT: fade_out, TARGET: target, PULSE_HSV: hsv, TARGET_TYPE: 1 if target.type == @group else 0 } } else { return obj{ OBJ_ID: 1006, TRIGGER_RED: r, TRIGGER_GREEN: g, TRIGGER_BLUE: b, EXCLUSIVE: exclusive, FADE_IN: fade_in, HOLD: hold, FADE_OUT: fade_out, TARGET: target, PULSE_HSV: hsv, TARGET_TYPE: 1 if target.type == @group else 0 } } }, color_trigger: #[desc("Returns a color trigger as an object") example("$.add( color_trigger(BG,0,0,0,0.5).with(X,600) )")] ( #[desc("Color channel to change")] channel: @color, #[desc("Red value of the target color")] r: @number, #[desc("Green value of the target color")] g: @number, #[desc("Blue value of the target color")] b: @number, #[desc("Duration of color change")] duration: @number = 0, #[desc("Opacity of target color")] opacity: @number = 1, #[desc("Toggle blending on target color")] blending: @bool = false ){ return obj{ OBJ_ID: 899, DURATION: duration, TRIGGER_RED: r, TRIGGER_GREEN: g, TRIGGER_BLUE: b, OPACITY: opacity, BLENDING: blending, TARGET_COLOR: channel, 36: 1, } }, pickup_trigger: #[desc("Returns a pickup trigger as an object") example("$.add( pickup_trigger(1i,3).with(X,600) )")] (#[desc("Item ID to modify")] item_id: @item, #[desc("Amount to add")] amount: @number) { return obj{ OBJ_ID: 1817, COUNT: amount, ITEM: item_id, } }, spawn_trigger: #[desc("Returns a spawn trigger as an object") example("$.add( spawn_trigger(5g,0.5).with(X,600) )")] (#[desc("Group to spawn")] group: @group, #[desc("Delay")] delay: @number) { return obj{ OBJ_ID: 1268, SPAWN_DURATION: delay, TARGET: group, } }, }