-
Notifications
You must be signed in to change notification settings - Fork 5
weaponPreview
-
weaponPreview
- AddAnimation
- AddColor
- AddDamage
- AddDelay
- AddDesc
- AddEmitter
- AddFlashing
- AddImage
- AddSimpleColor
- ClearMarks
- GetQueuedSkillEffectMarker
- GetSkillEffectMarker
- GetTargetAreaMarker
- IsQueuedSkillEffectMarker
- IsSkillEffectMarker
- IsTargetAreaMarker
- ResetQueuedSkillEffectTimer
- ResetSkillEffectTimer
- ResetTargetAreaTimer
- SetLooping
- events
A library with methods that can be used in non-queued skills' GetTargetArea and GetSkillEffect methods; and in queued skills' GetSkillEffect method.
The methods adds preview marks on the in-game board when activating the skills. Since they only adds to the preview, the effects they display will not alter the board state when the skill is used. This can be useful to for example add back lost information due to having coded parts of the skill within scripts, which won't display by default.
It can also be used to add animations, emitters or other cool effects to the attack preview.
When using several methods (like two animations) for the same skill, it is possible to run them on top of each other, or to run them in sequence, depending on how you set it up.
The library also comes with a set of functions and events that can be used to get information about the current state of which unit is marking the board and with what weapon.
The collection of all marks added during a GetTargetArea or GetSkillEffect
Calling any of the methods starting with Add- adds a mark to the preview
marks can have a length. Most marks has a length of zero (0). The total length of the preview will be the smallest length needed to contain all mark's lengths. If all marks starts at the same time, the total length will be the largest length of any mark.
Methods that can add length:
| method |
|---|
| AddDelay |
| AddAnimation |
marks can have a duration. If not specified, it is infinite. The duration is what specifies how long the mark will be displayed from when it starts playing. duration does not change length.
delay can be added to the preview to space out when the next mark added will begin playing. This will also space out marks so the total length of the preview will increase.
Methods that can add delay:
| method |
|---|
| AddDelay |
| AddAnimation |
By default the preview will be looping. This can be disabled with SetLooping(false). Animations with the animation field Loop set to true will loop for the entire preview regardless however.
-
voidweaponPreview:AddAnimation(point, animation, delay)
| Argument name | Type | Description |
|---|---|---|
point |
Point | The location on the board to add the animation |
animation |
string | The name of the animation in the ANIMS table |
delay |
number | (Optional) Pass ANIM_DELAY to add a delay equal to the duration of this animation |
Adds a mark to the preview, playing an animation on a point on the board. Most animations should work out of the box.
If the animation's field Loop is equal to true, the animation will play for the entire preview.
The duration and length of this mark is defined by the total length of the animation in the ANIMS table.
If ANIM_DELAY is passed as Argument #3, then a delay will be added before the next mark
Example:
local point = Point(0, 0)
local anim = "FireBack"
weaponPreview:AddAnimation(point, anim)
-
voidweaponPreview:AddColor(point, gl_color, duration)
| Argument name | Type | Description |
|---|---|---|
point |
Point | The location on the board to display the color |
gl_color |
GL_Color | The color to display |
duration |
number | (Optional) The duration to display the color. Defaults to infinite
|
Adds a mark to the preview, displaying a color on a point on the board.
Example:
local point = Point(0, 0)
local color = GL_Color(255, 255, 255, 255)
weaponPreview:AddColor(point, anim)
-
voidweaponPreview:AddDamage(spaceDamage, duration)
| Argument name | Type | Description |
|---|---|---|
spaceDamage |
SpaceDamage | The SpaceDamage object to display |
duration |
number | (Optional) The duration to display the SpaceDamage object. Defaults to infinite
|
Adds a mark to the preview, displaying a SpaceDamage object on the board.
Example:
local point = Point(0, 0)
local damage = 2
local spaceDamage = SpaceDamage(point, damage)
weaponPreview:AddDamage(spaceDamage)
-
voidweaponPreview:AddDelay(delay)
| Argument name | Type | Description |
|---|---|---|
delay |
number | The delay to wait before displaying the next mark |
Adds a mark to the preview, adding a delay before the next mark, and has a length of the same amount.
Example:
local delayInSeconds = 1
weaponPreview:AddDelay(delayInSeconds)
-
voidweaponPreview:AddDesc(point, desc, isDeadly, duration)
| Argument name | Type | Description |
|---|---|---|
point |
Point | The location on the board to display the tile description |
desc |
string | The description to display for the tile |
isDeadly |
boolean | (Optional) Whether to mark the tile as deadly or not. Defaults to true
|
duration |
number | (Optional) The duration to display the description object. Defaults to infinite
|
Adds a mark to the preview, displaying a description for the specified tile.
Example:
local point = Point(0, 0)
local description = "This is a dangerous tile"
weaponPreview:AddDesc(point, description)
-
voidweaponPreview:AddEmitter(point, emitter, duration)
| Argument name | Type | Description |
|---|---|---|
point |
Point | The location on the board to display the emitter |
emitter |
string | The internal name for the emitter |
duration |
number | (Optional) The duration to display the emitter. Defaults to infinite
|
Adds a mark to the preview, playing an emitter on a point on the board.
Example:
local point = Point(0, 0)
local emitter = "Emitter_tiles_grass"
weaponPreview:AddEmitter(point, emitter)
-
voidweaponPreview:AddFlashing(point, flash, duration)
| Argument name | Type | Description |
|---|---|---|
point |
Point | The location on the board to cause to flash |
flash |
boolean | (Optional) Whether to cause the grid icons on a tile to start flashing or not. Defaults to true
|
duration |
number | (Optional) The duration to play the flashing. Defaults to infinite
|
Adds a mark to the preview, causing grid icons of buildings to flash on a point on the board.
Example:
local point = Point(0, 0)
weaponPreview:AddFlashing(point)
-
voidweaponPreview:AddImage(point, path, gl_color, duration)
| Argument name | Type | Description |
|---|---|---|
point |
Point | The location on the board to display the image |
path |
string | The path to the image to display |
gl_color |
GL_Color | The color tint added to the image |
duration |
number | (Optional) The duration to display the image. Defaults to infinite
|
Adds a mark to the preview, displaying an image on a point on the board.
Example:
local point = Point(0, 0)
local path = "img/combat/tile_icon/tile_rock.png"
local gl_color = GL_Color(255, 255, 255, 255)
weaponPreview:AddImage(point, path, gl_color)
-
voidweaponPreview:AddSimpleColor(point, gl_color, duration)
| Argument name | Type | Description |
|---|---|---|
point |
Point | The location on the board to display the color |
gl_color |
GL_Color | The color to display |
duration |
number | (Optional) The duration to display the color. Defaults to infinite
|
Adds a mark to the preview, displaying a color on a point on the board. Simple colors can not stack.
Example:
local point = Point(0, 0)
local gl_color = GL_Color(255, 255, 255, 255)
weaponPreview:AddSimpleColor(point, gl_color)
-
voidweaponPreview:ClearMarks()
Clears all marks added to the preview. Added for brevity.
Example:
weaponPreview:ClearMarks()
-
number,string,numberweaponPreview:GetQueuedSkillEffectMarker()
Returns 3 variables describing the queued weapon currently marking the board. A queued weapon will mark the board when a unit that is queueing a weapon is highlighted, and there is no armed weapon marking the board with GetSkillEffect. If there's currently no queued weapon marking the board, this function will return -1, "", -1.
| Variable name | Type | Description |
|---|---|---|
| pawnId | number | The id of the pawn marking the board |
| weapon | string | The queued weapon marking the board |
| weaponIndex | number | The weapon index of the weapon marking the board |
| Weapon Index | Description |
|---|---|
| -1 | No Weapon |
| 0 | Move |
| 1 | Primary Weapon |
| 2 | Secondary Weapon |
| 50 | Repair Skill |
Example:
LOGF("Pawn with id %q, with weapon %s in weapon index %s is currently marking the board", weaponPreview:GetQueuedSkillEffectMarker())
-
number,string,numberweaponPreview:GetSkillEffectMarker()
Returns 3 variables describing the armed weapon currently marking the board with its GetSkillEffect. An armed weapon will mark the board with its GetSkillEffect when it's armed and highlighting a valid tile as defined by its GetTargetArea. If there's no armed weapon currently marking the board with its GetSkillEffect, this function will return -1, "", -1.
| Variable name | Type | Description |
|---|---|---|
| pawnId | number | The id of the pawn marking the board |
| weapon | string | The armed weapon marking the board |
| weaponIndex | number | The weapon index of the weapon marking the board |
| Weapon Index | Description |
|---|---|
| -1 | No Weapon |
| 0 | Move |
| 1 | Primary Weapon |
| 2 | Secondary Weapon |
| 50 | Repair Skill |
Example:
LOGF("Pawn with id %q, with weapon %s in weapon index %s is currently marking the board", weaponPreview:GetSkillEffectMarker())
-
number,string,numberweaponPreview:GetTargetAreaMarker()
Returns 3 variables describing the armed weapon currently marking the board with its GetTargetArea. An armed weapon will continuously mark the board with its GetTargetArea whenever it's armed. If there's no armed weapon currently marking the board, this function will return -1, "", -1.
| Variable name | Type | Description |
|---|---|---|
| pawnId | number | The id of the pawn marking the board |
| weapon | string | The armed weapon marking the board |
| weaponIndex | number | The weapon index of the weapon marking the board |
| Weapon Index | Description |
|---|---|
| -1 | No Weapon |
| 0 | Move |
| 1 | Primary Weapon |
| 2 | Secondary Weapon |
| 50 | Repair Skill |
Example:
LOGF("Pawn with id %q, with weapon %s in weapon index %s is currently marking the board", weaponPreview:GetTargetAreaMarker())
-
booleanweaponPreview:IsQueuedSkillEffectMarker()
Returns true if there is currently a queued weapon marking the board; otherwise false. A queued weapon will mark the board when a unit that is queueing a weapon is highlighted, and there is no armed weapon marking the board with GetSkillEffect.
Example:
LOGF("A queued weapon is currently marking the board: %s", weaponPreview:IsQueuedSkillEffectMarker())
-
booleanweaponPreview:IsSkillEffectMarker()
Returns true if there's currently an armed weapon marking the board with its GetSkillEffect; otherwise false. An armed weapon will mark the board with its GetSkillEffect when it's armed and highlighting a valid tile as defined by its GetTargetArea.
Example:
LOGF("An armed weapon is currently marking the board with 'GetSkillEffect': %s", weaponPreview:IsSkillEffectMarker())
-
booleanweaponPreview:IsTargetAreaMarker()
Returns true if there's currently an armed weapon marking the board with its GetTargetArea; otherwise false. An armed weapon will continuously mark the board with its GetTargetArea whenever it's armed.
Example:
LOGF("An armed weapon is currently marking the board with 'GetTargetArea': %s", weaponPreview:IsTargetAreaMarker())
-
voidweaponPreview:ResetQueuedSkillEffectTimer()
Resets the timer used to keep track of which mark to play during a preview of a queued weapon's GetSkillEffect.
Example:
weaponPreview:ResetQueuedSkillEffectTimer()
-
voidweaponPreview:ResetSkillEffectTimer()
Resets the timer used to keep track of which mark to play during a preview of an armed weapon's GetSkillEffect. Can for instance be used in the beginning of GetSkillEffect to force a preview to always start from the beginning when targetting a new tile.
Example:
weaponPreview:ResetSkillEffectTimer()
-
voidweaponPreview:ResetTargetAreaTimer()
Resets the timer used to keep track of which mark to play during a preview of an armed weapon's GetTargetArea.
Example:
weaponPreview:ResetTargetAreaTimer()
-
voidweaponPreview:SetLooping(loop)
| Argument name | Type | Description |
|---|---|---|
loop |
boolean | Whether to enable or disable looping. Defaults to true
|
Disables looping if false. Otherwise enables looping.
Example:
weaponPreview:SetLooping(false)
The following events can be subscribed to, in order to be informed when the current marker changes.
Documentation on how to use events: Event System
-
voidonQueuedSkillEffectHidden:subscribe(eventHandler)
| Argument name | Type | Description |
|---|---|---|
pawnId |
number | The id of the pawn queueing the weapon |
weapon |
string | The weapon being queued |
weaponIndex |
number | The weapon index of the weapon being queued |
Dispatched when a queued weapon stops marking the board. A queued weapon will mark the board when a unit that is queueing a weapon is highlighted, and there is no armed weapon marking the board with GetSkillEffect.
Example:
local handler = function(pawnId, weapon, weaponIndex)
LOGF(
"Pawn with pawnId %s stopped marking with "..
"its queued weapon %q with weapon index %s",
pawnId,
weapon,
weaponIndex
)
end
weaponPreview.events.onQueuedSkillEffectHidden:subscribe(handler)
-
voidonQueuedSkillEffectShown:subscribe(eventHandler)
| Argument name | Type | Description |
|---|---|---|
pawnId |
number | The id of the pawn queueing the weapon |
weapon |
string | The weapon being queued |
weaponIndex |
number | The weapon index of the weapon being queued |
Dispatched when a queued weapon begins marking the board. A queued weapon will mark the board when a unit that is queueing a weapon is highlighted, and there is no armed weapon marking the board with GetSkillEffect.
Example:
local handler = function(pawnId, weapon, weaponIndex)
LOGF(
"Pawn with pawnId %s started marking with "..
"its queued weapon %q with weapon index %s",
pawnId,
weapon,
weaponIndex
)
end
weaponPreview.events.onQueuedSkillEffectShown:subscribe(handler)
-
voidonSkillEffectHidden:subscribe(eventHandler)
| Argument name | Type | Description |
|---|---|---|
pawnId |
number | The id of the pawn arming the weapon |
weapon |
string | The weapon being armed |
weaponIndex |
number | The weapon index of the weapon being armed |
Dispatched when an armed weapon stops marking the board with its GetSkillEffect. An armed weapon will mark the board with its GetSkillEffect when it's armed and highlighting a valid tile as defined by its GetTargetArea.
Example:
local handler = function(pawnId, weapon, weaponIndex)
LOGF(
"Pawn with pawnId %s stopped marking with "..
"GetSkillEffect with its armed weapon %q "..
"with weapon index %s",
pawnId,
weapon,
weaponIndex
)
end
weaponPreview.events.onSkillEffectHidden:subscribe(handler)
-
voidonSkillEffectShown:subscribe(eventHandler)
| Argument name | Type | Description |
|---|---|---|
pawnId |
number | The id of the pawn arming the weapon |
weapon |
string | The weapon being armed |
weaponIndex |
number | The weapon index of the weapon being armed |
Dispatched when an armed weapon begins marking the board with its GetSkillEffect. An armed weapon will mark the board with its GetSkillEffect when it's armed and highlighting a valid tile as defined by its GetTargetArea.
Example:
local handler = function(pawnId, weapon, weaponIndex)
LOGF(
"Pawn with pawnId %s started marking with "..
"GetSkillEffect with its armed weapon %q "..
"with weapon index %s",
pawnId,
weapon,
weaponIndex
)
end
weaponPreview.events.onSkillEffectShown:subscribe(handler)
-
voidonTargetAreaHidden:subscribe(eventHandler)
| Argument name | Type | Description |
|---|---|---|
pawnId |
number | The id of the pawn arming the weapon |
weapon |
string | The weapon being armed |
weaponIndex |
number | The weapon index of the weapon being armed |
Dispatched when an armed weapon stops marking the board with its GetTargetArea. An armed weapon will continuously mark the board with its GetTargetArea whenever it's armed.
Example:
local handler = function(pawnId, weapon, weaponIndex)
LOGF(
"Pawn with pawnId %s stopped marking with "..
"GetTargetArea with its armed weapon %q "..
"with weapon index %s",
pawnId,
weapon,
weaponIndex
)
end
weaponPreview.events.onTargetAreaHidden:subscribe(handler)
-
voidonTargetAreaShown:subscribe(eventHandler)
| Argument name | Type | Description |
|---|---|---|
pawnId |
number | The id of the pawn arming the weapon |
weapon |
string | The weapon being armed |
weaponIndex |
number | The weapon index of the weapon being armed |
Dispatched when an armed weapon starts marking the board with its GetTargetArea. An armed weapon will continuously mark the board with its GetTargetArea whenever it's armed.
Example:
local handler = function(pawnId, weapon, weaponIndex)
LOGF(
"Pawn with pawnId %s started marking with "..
"GetTargetArea with its armed weapon %q "..
"with weapon index %s",
pawnId,
weapon,
weaponIndex
)
end
weaponPreview.events.onTargetAreaShown:subscribe(handler)