Trigger API Reference\DCEI Functions\Weapon
bool IsUnitWeaponEnabled(unit unit, string weaponName)
bool IsUnitWeaponEnabled(unit unit, string weaponName)
Description
Returns true if a weapon is enabled for a unit.
Parameters
- unit
unit
the unit with the weapon. - string
weaponName
the name of the weapon to check.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnitSync(team_id, player_id, unit_type, x, y)
local enabled
local weapons = DCEI.GetUnitWeaponList(unit)
local unit_name = DCEI.GetUnitType(unit)
for _, weapon in ipairs(weapons) do
enabled = DCEI.IsUnitWeaponEnabled(unit, weapon)
DCEI.LogMessage(unit_name .. "'s weapon " .. weapon .. (enabled and " is " or " is not ") .. "enabled for " .. unit_type)
end
Related
BehaviorModifier GetUnitWeaponDamageModifier(unit unit, string weaponName)
BehaviorModifier GetUnitWeaponDamageModifier(unit unit, string weaponName)
Description
Returns a BehaviorModifier for the damage modifiers on the given weapon.
Parameters
- unit
unit
the unit with the weapon. - string
weaponName
the name of the weapon to check.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnitSync(team_id, player_id, unit_type, x, y)
DCEI.ApplyBehavior(unit, DCEI.Behavior("Damage Dealt Double"), 2)
local damage_modifier
local weapons = DCEI.GetUnitWeaponList(unit)
local unit_name = DCEI.GetUnitType(unit)
for _, weapon in ipairs(weapons) do
damage_modifier = DCEI.GetUnitWeaponDamageModifier(unit, weapon)
DCEI.LogMessage(unit_name .. "'s weapon " .. weapon .. "has a damage multiplier of: " .. damage_modifier.multiplier_factor)
end
Related
BehaviorModifier GetUnitWeaponCriticalChanceModifier(unit unit, string weaponName)
BehaviorModifier GetUnitWeaponCriticalChanceModifier(unit unit, string weaponName)
Description
Returns a BehaviorModifier for the critical chance modifiers on the given weapon.
Parameters
- unit
unit
the unit with the weapon. - string
weaponName
the name of the weapon to check.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnitSync(team_id, player_id, unit_type, x, y)
DCEI.ApplyBehavior(unit, DCEI.Behavior("Damage Dealt Double"), 2)
local critical_modifier
local weapons = DCEI.GetUnitWeaponList(unit)
local unit_name = DCEI.GetUnitType(unit)
for _, weapon in ipairs(weapons) do
critical_modifier = DCEI.GetUnitWeaponCriticalChanceModifier(unit, weapon)
DCEI.LogMessage(unit_name .. "'s weapon " .. weapon .. " has a critical chance multiplier of: " .. critical_modifier.multiplier_factor)
end
Related
BehaviorModifier GetUnitWeaponAttackSpeedModifier(unit unit, string weaponName)
BehaviorModifier GetUnitWeaponAttackSpeedModifier(unit unit, string weaponName)
Description
Returns a BehaviorModifier for the attack speed modifiers on the given weapon.
Parameters
- unit
unit
the unit with the weapon. - string
weaponName
the name of the weapon to check.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnitSync(team_id, player_id, unit_type, x, y)
DCEI.ApplyBehavior(unit, DCEI.Behavior("Damage Dealt Double"), 2)
local speed_modifier
local weapons = DCEI.GetUnitWeaponList(unit)
local unit_name = DCEI.GetUnitType(unit)
for _, weapon in ipairs(weapons) do
speed_modifier = DCEI.GetUnitWeaponAttackSpeedModifier(unit, weapon)
DCEI.LogMessage(unit_name .. "'s weapon " .. weapon .. " has a attack speed multiplier of: " .. speed_modifier.multiplier_factor)
end
Related
float GetUnitWeaponCriticalChance(string weaponName)
float GetUnitWeaponCriticalChance(string weaponName)
Description
Returns the given weapon's critical chance.
Parameters
- string
weaponName
the name of the weapon to check.
Example Usage
local weapon_name = DCEI.Weapon("Standard MeleeUnit Weapon")
local critical_chance = DCEI.GetUnitWeaponCriticalChance(weapon_name)
DCEI.LogMessage(weapon_name .. " has an attack speed of: " .. critical_chance)
Related
float GetUnitWeaponAttackSpeed(string weaponName)
float GetUnitWeaponAttackSpeed(string weaponName)
Description
Returns the given weapon's attack speed.
Parameters
- string
weaponName
the name of the weapon to check.
Example Usage
local weapon_name = DCEI.Weapon("Standard MeleeUnit Weapon")
local attack_speed = DCEI.GetUnitWeaponAttackSpeed(weapon_name)
DCEI.LogMessage(weapon_name .. " has an attack speed of: " .. attack_speed)
Related
void AddUnitWeapon(string unitType, string weaponName)
void AddUnitWeapon(string unitType, string weaponName)
Description
Adds the given weapon to the unit type.
Parameters
- string
unitType
the name of the type of unit to add the weapon to. - string
weaponName
the name of the weapon to add.
Example Usage
local weapon = DCEI.Weapon("Standard MeleeUnit Weapon")
local unit_type = DCEI.Unit("Standard RangedUnit")
DCEI.AddUnitWeapon(unit_type, weapon)
void RemoveUnitWeapon(string unitType, string weaponName)
void RemoveUnitWeapon(string unitType, string weaponName)
Description
Removes the given weapon from the unit type.
Parameters
- string
unitType
the name of the type of unit to remove the weapon from. - string
weaponName
the name of the weapon to remove.
Example Usage
local weapon = DCEI.Weapon("Standard MeleeUnit Weapon")
local unit_type = DCEI.Unit("Standard RangedUnit")
DCEI.RemoveUnitWeapon(unit_type, weapon)