Trigger Logic
Introduction
Triggers offer a non-scripting solution to creating game logic. Triggers interact with each other using interface IDs. Think of it like walkie-talkies that communicate on a certain frequency.
Trigger Events
Events allow you to listen for game events and trigger specific actions accordingly:
| ID | Event | Description |
|---|---|---|
| 0 | onShoot | Fires when a player shoots the trigger object. |
| 1 | onMelee | Fires when a player melees the trigger object. |
| 2 | onDamage | Fires when the trigger object takes damage in any way. |
| 3 | onEnterObject | Fires when a player enters the trigger object. |
| 4 | onDestroy | Fires when the trigger object is destroyed. |
| 5 | onRespawn | Fires when the trigger object respawns. |
| 6 | onTimer | Fires when the trigger object's timer runs out. |
| 7 | onProjectile | Fires on the configured projectile event. |
| 8 | onThrowingMelee | Fires when a melee weapon is thrown. |
| 9 | onPunch | Fires when a player punches the trigger object. |
| 10 | onHoldMouse | Fires when a player holds the mouse button on the trigger object. |
| 11 | onCollision | Fires on collision with the trigger object. |
| 12 | onStorageEquals | Fires when interface storage equals a specific value. |
| 13 | onStorageGreater | Fires when interface storage is greater than a specific value. |
| 14 | onStorageLesser | Fires when interface storage is less than a specific value. |
| 15 | onAIDeath | Fires when an AI dies. |
| 16 | onInteractKey | Fires when a player presses the interact key. |
| 17 | onPlayerSpawn | Fires when a player spawns in the game. |
| 18 | onPlayerKill | Fires when a player gets a kill. |
| 19 | onPlayerDie | Fires when a player dies. |
| 20 | onAIDamage | Fires when an AI takes damage. |
| 21 | onNukeStart | Fires when a nuke starts. |
| 22 | onNukeEnd | Fires when a nuke ends. |
| 23 | onExitObject | Fires when a player exits the trigger object. |
| 24 | onCustomValEquals | Fires when a custom value equals a specific value. |
| 25 | onCustomValLesser | Fires when a custom value is less than a specific value. |
| 26 | onGameStart | Fires when the game starts. |
| 27 | onObjectiveSwitch | Fires when the objective switches (e.g. Hardpoint). |
| 28 | onPlayerDamage | Fires when a player takes damage. |
| 29 | onAIHalfHealth | Fires when an AI reaches half health. |
| 30 | onCustomValGreater | Fires when a custom value is greater than a specific value. |
| 31 | onAIKillPlayer | Fires when an AI kills a player. |
Trigger Conditions
Conditions allow you to execute an action only if a certain condition is met, similar to if statements in KrunkScript:
| ID | Condition | Description | Parameters |
|---|---|---|---|
| 0 | None | No condition required for the action to execute. | - |
| 1 | Player Value | Requires a specific player value for the action to execute. | Key (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Type (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Val |
| 2 | Current Class | Requires the player to be using a specific class. | Class |
| 3 | Trigger Value | Requires the trigger value to match a specific amount. | Key (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Type (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Val |
| 4 | Player Count | Requires a specific player count to be met. | Type (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Filter (Active, Spectating, Overall Connected); Amount |
| 5 | Global Value | Requires a specific global value to be met. | Key (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Type (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Val |
| 6 | Player has Account | Requires the player to have a registered Krunker account. | - |
| 7 | Player has Premium | Requires the player to be subscribed to Krunker Premium. | - |
| 8 | Player is Verified | Requires the player to have verification status. | - |
| 9 | Player is Partner | Requires the player to have partner status. | - |
| 10 | Player Level | Requires the player to be at a specific level. | Type (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Level |
| 11 | Player Inventory Value | Requires the player's inventory value to meet a condition. | Type (Equal, Not Equal, Greater than, Greater or Equal, Less than, Less or Equal); Val |
| 12 | Custom Action | Calls a custom KrunkScript function to check the condition. | Custom Param |
Trigger Actions
Execute actions to interact with the game and players:
| ID | Action | Description |
|---|---|---|
| 0 | Give Player Score | Gives the player a specified amount of score. |
| 1 | Kill Player | Kills the player. |
| 2 | Respawn Player | Respawns the player. |
| 3 | Change Player Health | Adjusts the player's health by a specified amount. |
| 4 | Destroy Interface | Destroys the target interface. |
| 5 | Toggle Interface Gate | Toggles the target interface gate open or closed. |
| 6 | Change Interface Health | Changes the health of the target interface. |
| 7 | Teleport Player To Interface | Teleports the player to the target interface. |
| 8 | Change Interface Deposit Box Amount | Changes the deposit box amount of the target interface. |
| 9 | Kill Opposing Team | Kills all players on the opposing team. |
| 10 | Respawn Opposing Team | Respawns all players on the opposing team. |
| 11 | Respawn Destructible Interface | Respawns the target destructible interface. |
| 12 | Toggle Destructible Interface | Toggles the target destructible interface between destroyed and active. |
| 13 | Set Player Score | Sets the player's score to a specific value. |
| 14 | Broadcast Sound | Plays a sound for all players in the game. |
| 15 | Clear Player Loadout | Clears the player's weapon loadout. |
| 16 | Broadcast Message | Sends a chat message to all players in the lobby. |
| 17 | Send Message | Sends a chat message to the triggering player only. |
| 18 | Swap Player Team | Swaps the player to the opposing team. |
| 19 | Set Player Team | Sets the player to a specific team. |
| 20 | Round Time | Adjusts the round timer by a specified amount. |
| 21 | Reset Interface | Completely resets the target interface to its original state. |
| 22 | End Round | Ends the current round. |
| 23 | Refill Player Knife | Refills the player's throwable knife. |
| 24 | Destroy Self | Destroys the trigger object itself. |
| 25 | Increase Interface Storage | Increases the target interface storage by a specified amount. |
| 26 | Decrease Interface Storage | Decreases the target interface storage by a specified amount. |
| 27 | Set Interface Storage | Sets the target interface storage to a specific value. |
| 28 | Reset Interface Storage | Resets the target interface storage to zero. |
| 29 | Broadcast Popup | Sends a popup message to all players in the lobby. |
| 30 | Send Popup | Sends a popup message to the triggering player only. |
| 31 | Jump Scare | Displays a jump scare effect to the player. |
| 32 | Reward KR | Rewards the player with a specified amount of KR. |
| 33 | Clear Player Checkpoints | Clears all of the player's checkpoints. |
| 34 | Send Sound | Plays a sound for the triggering player only. |
| 35 | Explosion | Creates an explosion at the trigger object's position. |
| 36 | Spawn AI | Spawns AI bots at their configured positions. |
| 37 | Set Player Value | Sets a custom player value to a specific number. |
| 38 | Inc/Dec Player Value | Increases or decreases a custom player value by a specified amount. |
| 39 | Play Animation | Plays a specified animation on AIs or interface objects. |
| 40 | Teleport Player to Path Node | Teleports the player to a specified path node. |
| 41 | Teleport Destructible Interface to Path Node | Teleports the target destructible interface to a specified path node. |
| 42 | Reset Destructible Interface Position | Resets the destructible interface to its original position. |
| 43 | Set Interface Trigger Value | Sets a custom value on the target interface trigger. |
| 44 | Inc/Dec Interface Trigger Value | Increases or decreases a custom value on the target interface trigger. |
| 45 | Set Trigger Value (Self) | Sets a custom value on the trigger object itself. |
| 46 | Inc/Dec Trigger Value (Self) | Increases or decreases a custom value on the trigger object itself. |
| 47 | Change Class | Changes the player's class. |
| 48 | Set Interface Deposit Box Amount | Sets the deposit box amount of the target interface. |
| 49 | Save Data | Saves player data to persistent storage. |
| 50 | Change Primary Weapon | Changes the player's primary weapon. |
| 51 | Change Secondary Weapon | Changes the player's secondary weapon. |
| 52 | Set Global Value | Sets a global value visible to the entire lobby. |
| 53 | Change Global Value | Changes a global value visible to the entire lobby. |
| 54 | Stop Sound | Stops a currently playing sound. |
| 55 | Show/Hide GUI Element (All) | Shows or hides a GUI element for all players. |
| 56 | Show/Hide GUI Element (Player) | Shows or hides a GUI element for the triggering player only. |
| 57 | Load Data | Loads the player's saved data from persistent storage. |
| 58 | Custom Action | Executes a custom KrunkScript action with optional parameters. |
| 61 | Change Ambient Sound | Changes the game's ambient sound. |
| 63 | Play Animation (Self) | Plays a custom animation on the trigger object itself. |
| 64 | Give Effect | Gives the player a selected status effect. |
| 66 | Give Random Effect | Gives the player a random status effect. |
| 67 | Play Video Ad | Plays a full-screen video ad for the player. |
| 69 | Force AI Target | Forces all AI to target the trigger object's position. |
| 70 | Mode Specific | Executes a game mode-specific trigger action. |
Triggers & Scripts
Triggers and scripts can interact with each other. You can call a KrunkScript action from a Trigger Event using Custom Action (58).
When this action executes, it automatically calls the onCustomTrigger hook in the server script:
# server-side hook called by Custom Action trigger
public action onCustomTrigger(str playerID, str customParam, num value) {
# playerID - automatically passed in
# customParam - custom string from the trigger
# value - custom number from the trigger
}