-
Notifications
You must be signed in to change notification settings - Fork 0
02_WAND_PROPERTIES
This chapter focuses on defining the properties and behavior of your custom wand. We'll dive into the Lua script that sets up these characteristics.
This script is crucial for determining how your wand behaves in the game. Here's a breakdown of the key components:
dofile_once("data/scripts/lib/utilities.lua")
dofile_once("data/scripts/gun/procedural/gun_action_utils.lua")
local entity_id = GetUpdatedEntityID()
local x, y = EntityGetTransform(entity_id)
local ability_comp = EntityGetFirstComponent(entity_id, "AbilityComponent")
-- Define wand properties
local wand = {}
wand.name = {"Custom Wand"} -- Can be a table for random selection
wand.deck_capacity = 8
wand.actions_per_round = 1
wand.reload_time = 20
wand.shuffle_deck_when_empty = 1 -- 1 for true, 0 for false
wand.fire_rate_wait = 10
wand.spread_degrees = 5
wand.speed_multiplier = 1
wand.mana_charge_speed = 50
wand.mana_max = 200
Use these functions to set the wand's properties:
ComponentSetValue2(ability_comp, "ui_name", wand.name[1])
ComponentObjectSetValue2(ability_comp, "gun_config", "deck_capacity", wand.deck_capacity)
ComponentObjectSetValue2(ability_comp, "gun_config", "actions_per_round", wand.actions_per_round)
ComponentObjectSetValue2(ability_comp, "gun_config", "reload_time", wand.reload_time)
ComponentObjectSetValue2(ability_comp, "gun_config", "shuffle_deck_when_empty", wand.shuffle_deck_when_empty)
ComponentObjectSetValue2(ability_comp, "gunaction_config", "fire_rate_wait", wand.fire_rate_wait)
ComponentObjectSetValue2(ability_comp, "gunaction_config", "spread_degrees", wand.spread_degrees)
ComponentObjectSetValue2(ability_comp, "gunaction_config", "speed_multiplier", wand.speed_multiplier)
ComponentSetValue2(ability_comp, "mana_charge_speed", wand.mana_charge_speed)
ComponentSetValue2(ability_comp, "mana_max", wand.mana_max)
You can add spells to your wand using the AddGunAction
function:
AddGunAction(entity_id, "LIGHT_BULLET")
AddGunAction(entity_id, "SPARK_BOLT")
AddGunAction(entity_id, "BOUNCING_BURST")
For a permanent spell that doesn't consume mana or get shuffled, use AddGunActionPermanent
:
AddGunActionPermanent(entity_id, "ENERGY_SHIELD")
For a comprehensive list of available spells and their IDs, refer to the following link : https://noita.fandom.com/wiki/Modding:Spell_and_Perk_IDs
If you want to randomize certain properties, you can use Lua's random functions:
local random_capacity = math.random(5, 10)
ComponentObjectSetValue2(ability_comp, "gun_config", "deck_capacity", random_capacity)
In the next chapter, we'll look at how to define the wand entity in XML, which ties together all these properties with the wand's physical representation in the game.