On This Page

  • Reference
  • LUA API
  • Classes
  • Unit

Unit

Unit is one of the basic elements in the project, skill and magic effect need to be attached to the unit to produce subsequent effects.

Functions

create_unit

Create unit.

Parameters

VariableTypeDescription
unit_idnumberUnit type ID.
pointtablePoint.
directionnubmerFacing angle.
unit: create_unit(unit_id, point, direction)

remove_unit

Delete unit.

unit:remove_unit()

Deleting a unit will trigger a Unit Destroyed Event.

Teleport_to_Point

Move unit to point instant.

Parameter

VariableTypeDescription
pointtableTarget point.
unit: Teleport_to_Point(point)

Units may get stuck in weird positions if the target point is not reachable.

set_unit_to_point

Force move unit to point.

Parameters

VariableTypeDescription
pointtableTarget point.
isSmoothboolWhether to move smoothly.
unit:set_unit_to_point(point, isSmooth)

After smooth movement is checked, the unit will translate to the target point, forcing the movement to ignore restrictions such as collisions.

resurrect_unit

Resurrection unit to target point.

Parameter

VariableTypeDescription
pointtableTarget point.
unit:resurrect_unit(point)

Only units that have not been destroyed can be revived.

heals

Heal the unit.

Parameters

VariableTypeDescription
valuenumberHealing amount.
isShowTxtboolWhether to display skip text.
skillabilityAssociated skill of this treatment.
from_unitunitSource unit for this healing.
txt_enumtableSkipping style of this skipping word.
unit:heals(value, isShowTxt, skill, from_unit, txt_enum)

add_tag

Label an organization.

Parameter

VariableTypeDescription
strstrLabel content.
unit:add_tag(tag)

remove_tag

Remove an organization's label.

Parameter

VariableTypeDescription
strstrLabel content.
unit:remove_tag(tag)

add_state

Add status to unit.

Parameter

VariableTypeDescription
state_enumnumberEnumeration corresponding to the state.
unit:add_state(state_enum)

The unit's status exists counted, that is, after being added twice, it needs to be removed twice before it can actually be removed.

remove_state

Remove the status of the unit.

Parameter

VariableTypeDescription
state_enumnumberEnumeration corresponding to the state.
unit:remove_state(state_enum)

The unit's status exists counted, that is, after being added twice, it needs to be removed twice before it can actually be removed.

learns_ability

Let units learn skills.

Parameter

VariableTypeDescription
ability_idnumberId of the corresponding skill.
unit:learns_ability(ability_id)

Learning requires skill points.

release_command

Issue orders to units.

Parameter

VariableTypeDescription
commandnumberPlayer operation command.
unit:release_command(command)

set_orientation

Set the orientation of the unit.

Parameters

VariableTypeDescription
directionnumberSteering angle of the unit.
turn_timenumberTurn time.
unit: set_orientation(direction, turn_time)

The unit will slowly turn its face towards it during the turn time.

set_name

Set the name of the unit.

Parameter

VariableTypeDescription
namestrUnit name.
unit:set_name(name)

set_description

Set the description of the unit.

Parameter

VariableTypeDescription
descriptionstrUnit description.
unit:set_description(description)

set_attributes

Set the properties of the unit

Parameters

VariableTypeDescription
attrNamestrAttribute name.
valuenumberAttribute value.
attrTypenumberAttribute type.
unit:set_attributes(attrName, value, attrType)

increase_attributes

Add unit properties.

Parameters

VariableTypeDescription
attrNamestrAttribute name.
valuenumberAttribute value.
attrTypenumberAttribute type.
unit:increase_attributes(attrName, value, attrType)

Negative values decrease.

set_level

Set the level of the unit.

Parameter

VariableTypeDescription
levelnumberCorresponding level.
unit:set_level(level)

Downgrading does not reclaim skill points.

increase_level

Increase the level of the unit.

Parameter

VariableTypeDescription
levelnumberCorresponding level.
unit:increase_level(level)

Downgrading does not reclaim skill points.

set_exp

Set the unit's current experience.

Parameter

VariableTypeDescription
expnumberExperience value.
unit:set_exp(exp)

increase_exp

Add experience to units.

Parameter

VariableTypeDescription
expnumberExperience value.
unit:increase_exp(exp)

set_current_hp

Set the unit's current health.

Parameter

VariableTypeDescription
hpnumberLife value.
unit:set_current_hp(hp)

increase_current_hp

Increase the unit's current health.

Parameter

VariableTypeDescription
hpnumberLife value.
unit:increase_current_hp(hp)

set_current_mp

Set the unit's current mana.

Parameter

VariableTypeDescription
mpnumberMagic value.
unit:set_current_mp(mp)

increase_current_mp

Increase the unit's current mana.

Parameter

VariableTypeDescription
mpnumberMagic value.
unit:increase_current_mp(mp)

set_hero_ability_point

Set the number of skill points for a unit.

Parameter

VariableTypeDescription
skill_pointnumberNumber of skill points.
unit:set_hero_ability_point(skill_point)

increase_hero_ability_point

Add skill points to units.

Parameter

VariableTypeDescription
skill_pointnumberNumber of skill points.
unit:increase_hero_ability_point(skill_point)

set_unit_height

Set the flying height of the unit.

Parameters

VariableTypeDescription
heightnumberHeight.
trans_timenumberChange time.
unit:set_unit_height(height, trans_time)

After changing the altitude, the unit will slowly move past within the changing time.

set_life_cycle

Set the lifecycle of the unit.

Parameter

VariableTypeDescription
timenumberLife cycle.
unit:set_life_cycle(time)

After the life cycle runs out, the unit will die naturally.

set_pause_state_of_life_cycle

Set a unit's lifecycle paused state.

Parameter

VariableTypeDescription
is_stopboolWhether to stop the life cycle lapse.
unit:set_pause_state_of_life_cycle(is_stop)

set_alert_range

Set the alert range of the unit.

Parameter

VariableTypeDescription
rangenumberWarning range.
unit:set_alert_range(range)

set_cancel_alert_range

Set the unit's disarm range.

Parameter

VariableTypeDescription
rangenumberCancel alert range.
unit:set_cancel_alert_range(range)

set_unit_pkg_cnt

Set the number of slots in the unit's inventory slot.

Parameter

VariableTypeDescription
numbernumberNumber of slots.
unit:set_unit_pkg_cnt(number)

set_unit_bar_cnt

Set the number of slots in the unit's inventory.

Parameter

VariableTypeDescription
numbernumberNumber of slots.
unit:set_unit_bar_cnt(number)

set_default_switch_behavior

Set the default behavior of units.

Parameter

VariableTypeDescription
behaviornumberUnit behavior.
unit:set_default_switch_behavior(behavior)

set_attr_growth

Set the property growth of the unit.

Parameters

VariableTypeDescription
unit_idnumberUnit ID.
attr_namestrAttribute name.
valuenumberReward value.
unit:set_attr_growth(unit_id, attr_name, value)

set_unit_reward_exp

Set the experience value reward for the unit being killed.

Parameter

VariableTypeDescription
expnumberNumber of experience.
unit:set_unit_reward_exp(exp)

set_unit_reward_res

Set the attribute reward of the killed player.

Parameters

VariableTypeDescription
player_attr_namestrPlayer attribute name.
valuenumberReward value.
unit:set_unit_reward_res(player_attr_name, value)

set_attack_type

Set the unit's attack type.

Parameter

VariableTypeDescription
attack_namestrAttack type name.
unit:set_attack_type(attack_name)

set_armor_type

Set the armor type of the unit.

Parameter

VariableTypeDescription
armor_type_namestrArmor type name.
unit:set_armor_type(armor_type_name)

enable_afterimage

Turn on afterimages of units.

Parameters

VariableTypeDescription
greennumberGreen.
bluenumberBlue.
alphanumberOpacity.
break_timenumberInterval time.
show_timenumberFull display time.
start_timenumberStart time.
end_timenumberEnd time.
is_origin_martialboolWhether to use the original material.
unit:enable_afterimage(green, blue, alpha, break_time, show_time, start_time, end_time, is_origin_martial)

disable_afterimage

Turn off the afterimage of the unit.

unit:disable_afterimage()

set_afterimage_color

Set the afterimage color for units.

Parameters

VariableTypeDescription
rednumberRed.
greennumberGreen.
bluenumberBlue.
alphanumberOpacity.
unit:set_afterimage_color(red, green, blue, alpha)

set_afterimage_time

Set the afterimage time for the unit.

Parameters

VariableTypeDescription
break_timenumberInterval time.
show_timenumberFull display time.
start_timenumberStart time.
end_timenumberEnd time.
unit:set_afterimage_time(break_time, show_time, start_time, end_time)

set_unit_avatar

Set unit avatar.

Parameter

VariableTypeDescription
img_idnumberImage ID.
unit:set_unit_avatar(img_id)

set_blood_bar_type

Set the unit's health bar style.

Parameter

VariableTypeDescription
bar_type_namestrBlood bar type name.
unit:set_blood_bar_type(bar_type_name)

set_health_bar_display

Set the health bar display mode of the unit.

Parameter

VariableTypeDescription
bar_show_type_namestrName of the blood bar display method.
unit:set_health_bar_display(bar_show_type_name)

set_minimap_avatar_for_unit

Set the unit minimap avatar.

Parameter

VariableTypeDescription
img_idnumberImage ID.
unit:set_minimap_avatar_for_unit(img_id)

set_minimap_avatar_for_enemy_unit

Set the minimap portrait of the enemy unit.

Parameter

VariableTypeDescription
img_idnumberImage ID.
unit:set_minimap_avatar_for_enemy_unit(img_id)

set_model_scale

Set model scaling in units.

Parameter

VariableTypeDescription
scalenumberZoom factor.
unit:set_model_scale(scale)

set_turning_speed

Set the unit's turn speed.

Parameter

VariableTypeDescription
speednumberTurn speed.
unit:set_turning_speed(speed)

replace_model

Replace model.

Parameter

VariableTypeDescription
model_idnumberModel ID.
unit:replace_model(model_id)

cancel_replace_model

Cancel model replacement.

Parameter

VariableTypeDescription
model_idnumberModel ID.
unit: cancel_replace_model(model_id)

Restore the unit's model to how it was originally.

set_semitransparency_when_hidden_unit_is_visible

Set whether to be translucent or not when invisible.

Parameter

VariableTypeDescription
is_visibleboolWhether translucent.
unit:set_semitransparency_when_hidden_unit_is_visible(is_visible)

set_corpse_recyclable_status_after_fading

Set whether to recycle or not after the corpse disappears.

Parameter

VariableTypeDescription
is_recycleboolWhether to recycle the corpse.
unit:set_corpse_recyclable_status_after_fading(is_recycle)

set_Xray_is_open

Set perspective state.

Parameter

VariableTypeDescription
is_openboolSwitch.
unit:set_Xray_is_open(is_open)

add_tech_to_unit

Units add technology.

Parameter

VariableTypeDescription
tech_idnumberTechnology ID.
unit:add_tech_to_unit(tech_id)

remove_tech_from_unit

Unit delete technology.

Parameter

VariableTypeDescription
tech_idnumberTechnology ID.
unit:remove_tech_from_unit(tech_id)

research_tech

Research technology.

Parameter

VariableTypeDescription
tech_idnumberTechnology ID.
unit:research_tech(tech_id)

play_animation

play animation.

Parameters

VariableTypeDescription
anim_namestrAnimation name.
speednumberPlayback speed.
start_timenumberStart time.
end_timenumberEnd time.
isloopboolWhether to loop.
is_back_normalboolWhether to return to the default state after playback is complete.
unit:play_animation(anim_name, speed, start_time, end_time, isloop, is_back_normal)

stop_animation

Stop animation.

Parameter

VariableTypeDescription
anim_namestrAnimation name.
unit:stop_animation(anim_name)

change_animation

Replace animation.

Parameters

VariableTypeDescription
replace_anim_namestrAnimation name.
bereplace_anim_namestrReplaced animation name.
unit:change_animation(replace_anim_name, bereplace_anim_name)

cancel_change_animation

Cancel animation replacement.

Parameters

VariableTypeDescription
replace_anim_namestrAnimation name.
bereplace_anim_namestrReplaced animation name.
unit:cancel_change_animation(replace_anim_name, bereplace_anim_name)

clear_change_animation

reset animation replacement

Parameter

VariableTypeDescription
replace_anim_namestrAnimation name.
unit:clear_change_animation(anim_name)

stop_cur_animation

Stop the currently playing animation.

unit:stop_cur_animation()

set_animation_speed

Set the animation playback rate.

Parameter

VariableTypeDescription
speednumberPlayback speed.
unit:set_animation_speed(speed)

add_item

Add items to the store.

Parameters

VariableTypeDescription
tag_namestrStore page name.
item_idnumberItem ID.
unit: add_item(tag_name, item_id)

remove_item

Remove item from store.

Parameters

VariableTypeDescription
item_namestrType of item.
item_idnumberID of the item.
unit: remove_item(item_name, item_id)

set_item_stock

Set the inventory of items in the store.

Parameters

VariableTypeDescription
tag_namestrStore page name.
item_idnumberItem ID.
numbernumberQuantity.
unit:set_item_stock(tag_name, item_id, number)

sell_item_to_shop

Sell items to shop.

Parameters

VariableTypeDescription
unitunitTarget shop to sell the item.
item_idnumberItem ID.
unit:sell_item_to_shop(unit, item_id)

purchase_item_from_shop

Purchase items from the store.

Parameters

VariableTypeDescription
unitunitTarget store to buy the item from.
tag_numnumberIndex of the tag page.
item_idnumberItem ID.
unit: purchase_item_from_shop(unit, tag_num, item_id)

remove_item_from_unit

Unit removes items.

Parameter

VariableTypeDescription
item_idnumberItem ID.
unit:remove_item_from_unit(item_id)

transfer_item_to_unit

Transfer items.

Parameters

VariableTypeDescription
itemitemItem.
typenumberBackpack slot type.
positionnumberSlot.
is_moveboolWhether to move if the target slot already has an item.
unit: transfer_item_to_unit(item, type, position, is_move)

add_item_to_unit

Unit add items.

Parameter

VariableTypeDescription
item_idnumberItem ID.
unit:add_item_to_unit(item_id)

add_modifier

Add magic effects to units.

Parameters

VariableTypeDescription
modifier_typenumberMagic effect type ID.
source_unitunitSource unit.
associated_abilityabilityAssociated skill.
secondsnumberDuration.
durationnumberCycle period.
stacksnumberNumber of magic effect layers.
unit:add_modifier(modifier_type, source_unit, associated_ability, seconds, duration, stacks)

remove_modifier_type

Unit removal magic effect type.

Parameter

VariableTypeDescription
modifier_typenumberMagic effect type ID.
unit:remove_modifier_type(modifier_type)

delete_all_modifiers_by_effect_type

Remove magic effects that affect the type.

Parameter

VariableTypeDescription
modifier_typenumberMagic effect type ID.
unit:delete_all_modifiers_by_effect_type(modifier_type)

get_specified_modifier_type

Get the magic effect of the specified type for the unit.

Parameter

VariableTypeDescription
modifier_typenumberMagic effect type ID.
unit:get_specified_modifier_type(modifier_type)

get_recovery_interval_of_shop_goods

Get the stock interval of store items.

Parameters

VariableTypeDescription
pagenumberPage index.
indexnumberCommodity index.

Return

TypeDescription
numberInventory interval.
unit: get_recovery_interval_of_shop_goods( page, index)

get_remaining_recovery_time_of_shop_goods

Get the remaining recovery time of a store item.

Parameters

VariableTypeDescription
pagenumberPage index.
indexnumberCommodity index.

Return

TypeDescription
numberRemaining recovery time of the item.
unit: get_remaining_recovery_time_of_shop_goods(page, index)

remove_abilities_in_type

Remove skills (specific types).

Parameters

VariableTypeDescription
typestrAbility type (AbilityType).
idnumberObject code ID.
unit:remove_abilities_in_type(type, ID)

get_abilities_by_type

Get a specific type of skill.

Parameter

VariableTypeDescription
typestrAbility type (AbilityType).

Return

Ability specifies the type of skill.

unit:get_abilities_by_type(type)

api_switch_ability

Exchange skill positions.

Parameters

VariableTypeDescription
ability_1abilityFirst ability.
ability_2abilitySecond ability.
unit:api_switch_ability(ability_1, ability_2)

add_ability

Add skills.

Parameters

VariableTypeDescription
typestrAbility type see AbilityType.
idnumberObject code ID.
slotnumberSkill slot.
levelnumberLevel.
unit:add_ability(type, ID, slot, level)

remove_ability

Remove skill.

Parameters

VariableTypeDescription
typenumberSkill position.
slotnumberLevel.
unit:remove_ability(type, slot)

get_ability_by_type

Find skills by skill name.

Parameters

VariableTypeDescription
typestrAbility type see AbilityType.
ability_typenumberSkill type ID (object code ID).
unit:get_ability_by_type(type, ability_type)

get_ability_by_slot

Acquiring the skill of a certain skill position.

Parameters

VariableTypeDescription
typestrAbility type see AbilityType.
slotnumberSkill slot.
unit: get_ability_by_slot(type, slot)

get_item_by_slot

Get the item in the unit's backpack slot.

Parameters

VariableTypeDescription
typenumberBackpack slot type enumeration.
slotnumberSlot.
unit:get_item_by_slot(type, slot)

get_all_items

All items in the unit.

unit:get_all_items()

kill_unit

Kill unit.

Parameter

VariableTypeDescription
killerunitKiller.
unit: kill_unit(killer)

create_illusion

Create illusion.

Parameters

VariableTypeDescription
illusion_unitunitUnit to be copied.
call_unitunitCaller.
playerplayerPlayer who belongs to.
pointtableGenerated position.
directionnumberDirection.
unit: create_illusion(illusion_unit, call_unit, player, point, direction)

unit_gains_tech

Units gain technology.

Parameter

VariableTypeDescription
TECH_KEYnumberTechnology ID.
unit:unit_gains_tech(TECH_KEY)

change_unit_role

Set owning player.

Parameter

VariableTypeDescription
playerplayerPlayer.
unit:change_unit_role(player)

get_tech_list

Traversing research and development technology to do actions.

Return

TypeDescription
tableTechnology list.
unit:get_tech_list()

get_affect_techs

Traversing applied technology doing actions.

Return

TypeDescription
tableTechnology list.
unit:get_affect_techs()

get_shop_item_list

Iterate through the items in the store to perform actions.

Parameter

VariableTypeDescription
tag_namestrTab name.

Return

TypeDescription
tableProduct list.
     unit:get_shop_item_list(tag_name)

get_current_unit_hp

Get the current health value.

Return

TypeDescription
numberLife value.
unit:get_current_unit_hp()

get_current_unit_mp

Get the current mana.

Return

TypeDescription
numberMagic value.
unit:get_current_unit_mp()

get_attr_other

Get the property of the unit's extra property type.

Parameter

VariableTypeDescription
attr_namestrAttribute name.

Return

TypeDescription
numberAttribute value.
unit:get_attr_other(attr_name)

get_attr_base

Get the property of the unit's base property type.

Parameter

VariableTypeDescription
attr_namestrAttribute name.

Return

TypeDescription
numberAttribute value.
unit:get_attr_base(attr_name)

get_attr_base_ratio

Get the attribute of the unit's basic attribute bonus type.

Parameter

VariableTypeDescription
attr_namestrAttribute name.

Return

TypeDescription
numberAttribute value.
unit:get_attr_base_ratio(attr_name)

get_attr_bonus

Get properties of unity gain property type.

Parameter

VariableTypeDescription
attr_namestrAttribute name.

Return

TypeDescription
numberAttribute value.
unit:get_attr_bonus(attr_name)

get_attr_all_ratio

Get the attribute of the unit's total attribute bonus type.

Parameter

VariableTypeDescription
attr_namestrAttribute name.

Return

TypeDescription
numberAttribute value.
unit:get_attr_all_ratio(attr_name)

get_attr_bonus_ratio

Get the attribute of the unit gain attribute bonus type.

Parameter

VariableTypeDescription
attr_namestrAttribute name.

Return

TypeDescription
numberAttribute value.
unit:get_attr_bonus_ratio(attr_name)

get_unit_attribute_growth

Get unit attribute growth.

Parameters

VariableTypeDescription
unit_idnumberUnit ID.
attr_namestrAttribute name.

Return

TypeDescription
numberAttribute value.
unit: get_unit_attribute_growth(unit_id, attr_name)

get_life_cycle_of_unit

Get unit lifecycle.

Return

TypeDescription
numberLifetime of the unit.
unit:get_life_cycle_of_unit()

get_height

Get unit flight altitude.

Return

TypeDescription
numberFlight altitude.
unit:get_height()

get_unit_turning_speed

Get unit turn speed.

Return

TypeDescription
numberTurn speed.
unit:get_unit_turning_speed()

get_unit_alert_range

Get unit alert range.

Return

TypeDescription
numberWarning range.
unit:get_unit_alert_range()

get_unit_cancel_alert_range

Get unit cancel alert range.

Return

TypeDescription
numberCancel the warning range.
unit:get_unit_cancel_alert_range()

get_unit_collision_radius

Get the unit collision radius.

Return

TypeDescription
numberCollision radius.
unit:get_unit_collision_radius()

get_unit_resource_cost

Get unit construction resource consumption property.

Parameters

VariableTypeDescription
unit_idnumberUnit ID.
player_attr_namestrPlayer resource name consumed.

Return

TypeDescription
numberResource consumption value.
unit:get_unit_resource_cost(unit_id, player_attr_name)

get_player_attribute_gained_from_killing_unit

Get the attribute of the player who was killed by the unit.

Parameter

VariableTypeDescription
player_attr_namestrPlayer resource name that can be obtained.

Return

TypeDescription
numberResource consumption value.
unit:get_player_attribute_gained_from_killing_unit(player_attr_name)

get_scale

Get the unit scale.

Return

TypeDescription
numberZoom factor.
unit:get_scale()

get_unit_selection_range_scale

Get unit selection circle zoom.

Return

TypeDescription
numberZoom factor.
unit:get_unit_selection_range_scale()

get_unit_xaxis_scale

Get the X-axis scaling of the unit.

Return

TypeDescription
numberZoom factor.
unit:get_unit_xaxis_scale()

get_unit_zaxis_scale

Get the Z-axis scaling of the unit.

Return

TypeDescription
numberZoom factor.
unit:get_unit_zaxis_scale()

get_unit_yaxis_scale

Get the Y-axis scaling of the unit.

Return

TypeDescription
numberZoom factor.
unit:get_unit_yaxis_scale()

get_shop_purchase_range

Get the purchase scope of the store.

Return

TypeDescription
numberPurchase range.
unit:get_shop_purchase_range()

get_unit_level

Get unit level.

Return

TypeDescription
numberRank of the unit.
unit:get_unit_level()

get_key

Get the unit type ID of the unit.

Return

TypeDescription
numberUnit type ID.
unit:get_key()

get_current_exp_of_unit

Get the current experience value of the unit.

Return

TypeDescription
numberUnit type ID.
unit:get_current_exp_of_unit()

get_exp_required_for_current_upgrade

Gain the experience needed for the unit's current upgrade.

Return

TypeDescription
numberUnit type ID.
unit:get_exp_required_for_current_upgrade()

get_hero_ability_point_number

Get the hero's skill points.

Return

TypeDescription
numberUnit type ID.
unit:get_hero_ability_point_number()

get_unit_bag_slot_number

Get the number of slots in the unit's inventory.

Return

TypeDescription
numberUnit type ID.
unit:get_unit_bag_slot_number()

get_unit_inventory_slot_number

Get the number of slots in the unit's inventory.

Return

TypeDescription
numberUnit type ID.
unit:get_unit_inventory_slot_number()

get_item_type_number_of_unit

Get the number of item types owned by the unit.

Parameters

VariableTypeDescription
item_iditem ID

Return

TypeDescription
numberUnit type ID.
unit:get_item_type_number_of_unit(item_id)

get_exp_gained_from_killing_unit

Get unit kill experience.

Return

TypeDescription
numberUnit type ID.
unit:get_exp_gained_from_killing_unit()

get_shield_value_of_specified_type_for_unit

Get the shield value of the specified shield type for the unit.

Parameter

VariableTypeDescription
shield_type_namestrShield type name.

Return

TypeDescription
numberShield value.
unit:get_shield_value_of_specified_type_for_unit(shield_type_name)

get_shop_tab_number

Get the number of store tabs.

Return

TypeDescription
numberNumber of tabs.
unit:get_shop_tab_number()

get_shop_item_stock

Get the store's item inventory.

Parameters

VariableTypeDescription
tag_indexnumberStore tag index.
item_idnumberItem ID.

Return

TypeDescription
numberInventory quantity.
unit: get_shop_item_stock(tag_index, item_id)

get_unit_name

Get unit name.

Return

TypeDescription
strUnit name.
unit:get_unit_name()

get_unit_description

Get the description of the unit.

Return

TypeDescription
strDescription of the unit.
unit:get_unit_description()

get_unit_type_name

Get unit type name.

Parameter

VariableTypeDescription
unit_idnumberUnit type ID.

Return

TypeDescription
strUnit type name.
unit:get_unit_type_name(unit_id)

get_unit_type_description

Get the description of the unit type.

Parameter

VariableTypeDescription
unit_idnumberUnit type ID.

Return

TypeDescription
strUnit type description.
unit:get_unit_type_description(unit_id)

get_shop_tab_name

Get the store's page signature.

Parameter

VariableTypeDescription
unit_idnumberUnit type ID.

Return

TypeDescription
strStore's page signature.
unit:get_shop_tab_name(tag_index)

get_unit_subtype

Get unit classification.

Return

TypeDescription
numberUnit classification.
unit:get_unit_subtype()

get_image_of_unit_type_icon

Get the avatar of the unit type.

Parameter

VariableTypeDescription
unit_idnumberUnit type ID.

Return

TypeDescription
numberPicture ID.
unit:get_image_of_unit_type_icon(unit_id)

get_unit_type

Get unit type.

Return

TypeDescription
numberUnit type ID.
unit:get_unit_type()

last_unit_created

Last created unit.

Return

TypeDescription
unitUnit to create.
unit:last_unit_created()

get_unit_owner

Get the owner of the unit unit.

Return

TypeDescription
unitOwner of the unit unit.
unit:get_unit_owner()

get_illusion_summoner

Get the summoner of visions.

Return

TypeDescription
unitCaller of the illusion.
unit:get_illusion_summoner()

get_unit_orientation

Get the orientation of the unit.

Return

TypeDescription
numberOrientation of the unit.
unit:get_unit_orientation()

get_armor_type

Get armor type.

Return

TypeDescription
numberArmor type ID.
unit:get_armor_type()

get_attack_type

Get attack type.

Return

TypeDescription
numberAttack type ID.
unit:get_attack_type()

get_shop_goods

Get items from the store.

Parameters

VariableTypeDescription
tag_indexnumberTag index.
item_indexnumberItem index.

Return

TypeDescription
itemItem.
unit: get_shop_goods(tag_index, item_index)

get_current_unit_model

Get the current model of the unit.

Return

TypeDescription
numberModel ID.
unit:get_current_unit_model()

get_original_unit_model

Get the original model of the unit.

Return

TypeDescription
numberModel ID.
unit:get_original_unit_model()

get_unit_location_point

Get the location of the unit.

Return

TypeDescription
pointPoint where the unit is located.
unit:get_unit_location_point()

get_nearest_reachable_point_to_unit

Get the nearest passable point of the unit.

Return

TypeDescription
pointPassable point.
unit:get_nearest_reachable_point_to_unit()

get_camp

Get unit's team.

Return

TypeDescription
numberTeam ID.
unit:get_camp()

has_tag

Whether to have a label or not.

Parameter

VariableTypeDescription
tag_namestrTag name.

Return

TypeDescription
boolWhether to have this tag.
unit:has_tag(tag_name)

is_unit_alive

Whether to survive or not.

Return

TypeDescription
boolWhether the unit is alive.
unit:is_unit_alive()

visibility_of_unit

Whether it is visible or not.

Parameter

VariableTypeDescription
target_unitunitTarget unit.

Return

TypeDescription
boolIs it visible.
unit:visibility_of_unit(target_unit)

is_unit_moving

Whether the unit is moving or not.

Return

TypeDescription
boolWhether the unit is moving.
unit:is_unit_moving()

is_in_radius

Whether it is near the unit or not.

Parameters

VariableTypeDescription
point_or_unitunit/pointTarget unit/point.
rangenumberRange.

Return

TypeDescription
boolWhether it is in the unit range.
unit:is_in_radius(point_or_unit, range)

unit_is_shop

Whether the unit is a store or not.

Return

TypeDescription
boolWhether it is a store.
unit:unit_is_shop()

is_unit_illusion

Whether the unit is an illusion or not.

Return

TypeDescription
boolWhether the unit is an illusion.
unit:is_unit_illusion()

unit_in_group

Whether the unit is in the unit group or not.

Parameter

VariableTypeDescription
groupunit_groupUnit group.

Return

TypeDescription
boolWhether the unit is in a unit group.
unit: unit_in_group(group)

is_in_battle

Whether the unit is in combat or not.

Return

TypeDescription
boolWhether the unit is in combat.
unit:is_in_battle()

has_buff_status

Whether the unit has a designated status or not.

Parameter

VariableTypeDescription
state_namestrState name.

Return

TypeDescription
boolWhether the unit has the assigned state.
unit:has_buff_status(state_name)

check_has_ability_type

Whether the unit has a specific type of skill or not.

Parameter

VariableTypeDescription
ability_idnumberSkill type ID.

Return

TypeDescription
boolWhether the unit has the specified type of skill.
unit:check_has_ability_type(ability_id)

unit_has_item

Whether there are items or not.

Parameter

VariableTypeDescription
itemitemItem.

Return

TypeDescription
boolWhether the unit has a corresponding item.
unit: unit_has_item(item)

unit_has_item_name

Whether there are items of the specified type or not.

Parameter

VariableTypeDescription
item_idnumberItem type ID.

Return

TypeDescription
boolWhether the unit has items of the specified type.
unit:unit_has_item_name(item_id)

unit_has_modifier

Whether the unit has magic effect or not.

Parameter

VariableTypeDescription
modifier_idnumberMagic effect type ID.

Return

TypeDescription
boolWhether the unit has the assigned state.
unit: unit_has_modifier(modifier_id)

unit_has_modifier_style

Whether the unit has magic effects of the specified affect type or not.

Parameter

VariableTypeDescription
state_namestrState name.

Return

TypeDescription
boolWhether the unit has magic effects of the specified affect type.
unit:unit_has_modifier_style(modifier_type_name)

unit_has_modifier_tag

Whether the unit has the magic effects with specified tags or not.

Parameter

VariableTypeDescription
tag_namestrTag name.

Return

TypeDescription
boolWhether the unit has the magic effect of the specified tag.
unit: unit_has_modifier_tag(tag_name)

check_unit_key_precondition

Whether the unit type precondition is passed or not.

Parameters

VariableTypeDescription
playerplayerCorresponding player.
unit_idnumberUnit type ID.

Return

TypeDescription
boolWhether the unit has the assigned state.
unit. check_unit_key_precondition(player, unit_id)

is_enemy_relation

Whether the unit is a hostile relationship or not.

Parameter

VariableTypeDescription
target_unitunitTarget unit.

Return

TypeDescription
boolWhether the unit is hostile to the target unit.
unit:is_enemy_relation(target_unit)

can_teleport_to

Whether the unit can be sent to the point or not.

Parameter

VariableTypeDescription
pointpointTarget point.

Return

TypeDescription
boolWhether the unit can teleport to the point.
unit:can_teleport_to(point)

unit_can_collide_with_point

Whether to collide with the point or not.

Parameters

VariableTypeDescription
pointpointTarget point.
rangenumberCollision range of the unit.

Return

TypeDescription
boolWhether the unit collides with the point.
unit:unit_can_collide_with_point(point, range)

unit_can_from_point_to_point

Whether pathfinding is reachable or not.

Return

TypeDescription
boolWhether pathfinding is reachable.
unit:unit_can_from_point_to_point(start_point, end_point)

get_unit_move_collision

Whether to have the specified collision type or not.

Return

TypeDescription
boolWhether to have the specified collision type.
unit:get_unit_move_collision(collision_type_name)

get_unit_player

Get the player the unit belongs to.

Return

VariableTypeDescription
playerplayerPlayer.
unit:get_unit_player()

Events

Unit triggers need to be included in a group to use group variables.

Before unit die

Dying.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Before unit die" , function ( data )
    print ( "Is about to die" )
end )

Unit Die

Die.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit Die" , function ( data )
    print ( "Death" )
end )

Kill unit

Kill event.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Kill unit" , function ( data )
    print ( "Kill event" )
end )

Unit born

Create.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit born" , function ( data )
    print ( "Create" )
end )

Revive unit

Rebirth.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Revive unit" , function ( data )
    print ( "Rebirth" )
end )

Upgrade unit

Upgrade.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Upgrade unit" , function ( data )
    print ( "Upgrade" )
end )

Unit pre add exp

About to gain experience.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit pre add exp" , function ( data )
    print ( "Experience is about to be gained" )
end )

Unit on add exp

Get experience.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit on add exp" , function ( data )
    print ( "Gain experience" )
end )

Unit be hurt

Hurt.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit be hurt" , function ( data )
    print ( "Taken damage" )
end )

Unit hurt other

Cause some damages.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit hurt other" , function ( data )
    print ( "Cause damage" )
end )

Unit hurt other finish

After inflicting damage.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit hurt other finish" , function ( data )
    print ( "After damage is done" )
end )

Unit be hurt complete

After being hurt.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit be hurt complete" , function ( data )
    print ( "After taking damage" )
end )

Unit get cure

Be treated.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit get cure" , function ( data )
    print ( "Healed" )
end )

Unit releaseability

Cast skills.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit release ability" , function ( data )
    print ( "Cast skill" )
end )

Unit start move

Start moving.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit start move" , function ( data )
    print ( "Start moving" )
end )

Unit enter battle

Enter combat state.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit enter battle" , function ( data )
    print ( "Enter combat state" )
end )

Unit exit battle

Out of combat.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit exit battle" , function ( data )
    print ( "Out of combat state" )
end )

Unit enter grass

Into the grass.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit enter grass" , function ( data )
    print ( "Enter the grass" )
end )

Unit leave grass

Leave the grass.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit leave grass" , function ( data )
    print ( "Leave the grass" )
end )

Unit on command

Request order.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit on command" , function ( data )
    print ( "Request command" )
end )

Ability plus point

Learning skills.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Ability plus point" , function ( data )
    print ( "Learning skills" )
end )

Unit remove

Delete.

local unit_group = cli.unit.create_unit_trigger_group ( 100001 )
unit_group . add_trigger ( "Unit remove" , function ( data )
    print ( "Delete" )
end )