User Tools

Site Tools


grid:targeting

Grid Targetting

This section explains how targeting works in this grid system.

Terms

Before proceeding further, there're several terms (and function) you need to familiarize with to help you understand the whole docs. Here is the list.

  • User position

The user position represents the position of the user of the skill. User position usually matters to determine the attack range of the skill.

  • Targetable grid

The targetable grid is the possible grid to be targeted. These grids are meant for the player to select which grid they want to select to launch the skill. Or for the enemy to look for the target available in their range. This type of grid only happens in the selection layer, i.e, it does NOT have an effect on the actual area of effect which needs to be customized further.

  • Center grid

The center grid is the selected grid when the player (or enemies) done selecting which grid they want to launch the attack. The center grid is a single integer value that represents which index that grid is selected. Center grid matters to determine the area of effect handled by the target grid.

  • Target grid

The target grid represents an array of area effect that is configured manually using a combination of positioning and direction. By default, the target grid is only an array that has a single value which is the center grid value. (see below for clarification)

Illustration

To make it even clear, let's take a look at illustration below:

User position and targetable grid

i.imgur.com_ld1a5n6.jpg

0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23

The user has index position in 14, while the targetable grid is [8, 9, 10]. The targetable grid relative position may be changed when the user also change their position. For example, like this

i.imgur.com_nsc1bxm.jpg

0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23

Center grid

i.imgur.com_0mesvwe.jpg

0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23

The center grid is set when the choice is made. This is the epicenter of your skill. The target grid (area of effect or not) is usually determined by the center grid. i,e, when you select the index 10 before unleashing the skill, the center grid is set to 10. However, the center grid does not have a role to determine where the skill falls into. It is the job of the target grid, which is very possible that the target grid may be different than the center grid.

Target grid

i.imgur.com_bu6zln7.jpg

0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23

The target grid is the actual variable that determines the target. By default, it follows the value of the center grid. For example, if you select the index 10 so that the center grid is set to that value, the initial value of the target grid is [10] (in an array). However, you can expand it further based on either center grid, user position, or both. In this particular example, it spreads around based on the center grid.

Determining the skill target scope

This section explains how to set the skill target scope.

Targetable grid

By default, the skill is able to target all area, in other word, the scope is the whole grid. This is for the purpose that when you create a new skill and want to test the effect, you don't need to specify the grid. However, you probably don't want this, so here is the way how to change them. First, you have to put the note tag in the skill or item note box.

<grid target: method_name>

Example:

<grid target: dy_nuclearbomb_target>

The method name is a method you put inside the Grid::Area module. The name of the method must be the same as the one you put as the tag. To create the method, you could create an empty script slot (the script slot must be below my script). And write it like this

class << Grid::Area
  def method_name(user)
    # Write the code here
  end
end

The method accepts one parameter which is the user itself. For example, we're going to use the mini-nuke skill range. The method goes like this

def dy_nuclearbomb_target(user)
  return Grid.linear(Grid.neighbor(user.grid_pos, 4, 4), [4], 9)
end

The code user.grid_pos returns the position of the user. If the current position is in index 14 it will return the same value. Use this to dynamically set the target range. There is nothing that is stopping you if you want to create a strange targetable grid, like this…

Note: Be aware that the current selecting input only accepts the 4 directions which are up/left/right/down. If you went drunk and created a scrambled targetable grid that there is no way of selecting them using the fourth direction buttons, it will be useless.

Target scope

The grid system provide 3 kind of targetting. Which are

  • Target your ally
  • Target the enemy
  • Target everything (ally/enemy alike)

To determine the target scope, select the default skill scope from the database as follow

i.imgur.com_g6nh8dw.jpg

It does NOT matter whether it is one enemy, all enemies, random enemies, it basically tells the system that the skill/item is targeting the enemy. Because of this, any repeated attack or random attack to the enemies, you have to do it manually through the skill action sequence.

The same thing applies to ally selection. If you select the options provided that basically target the ally, it tells the system that the skill is targeting the ally. If you want a skill to target self, you have to do it through the targetable grid and do it this way (or look at self trigger skill section).

class << Grid::Area
  def self_target(user)
    return [user.grid_pos]
  end
end

Last, when you select the target scope equals none, it tells the system that the skill effect may fall for both allies and enemies alike. In essence, when the area effect is done through the target grid, if you select either of the target scope options, some battlers may not get affected even when they're within the area of effect.

Target battler & Target null

By default, all of the skill requires the selected grid to have a target on the targeted grid. This means, if the grid is null, the skill can not be launched. The target battler depends on the target scope you put. If you put the target as the enemy, you can not select the ally even if the ally is in the target range. This behavior can be changed by adding a hack using note tag <null target>. This tag allows the user to launch an attack on the empty grid.

Determine the target grid

As has been said, the target grid by default is equal to the center grid. And thus, you have to manually change them through Action Sequence for every skill sequence if you want an area of effect. To change the area of effect, use this command within the action sequence.

  [:grid_setup, {
    :method => value,
    :type => value,
    :scope => value,
    :null => value,
  }]

The command tells the system to change the current grid setup. It accepts four parameters in Ruby Hash format. However, you do not need to input all of them when you don't want to. It will simply use the default value.

Method parameter

Usage:

  :method => :method_name,
  :method => lambda {|a,b,c| puts "code here" },

Behavior if omitted: The target grid will simply not change

Using :method ⇒ :method_name will look for a method within the Grid::Area module. i.e, if you put it like :method ⇒ :change_grid it will look something that is defined as

  class << Grid::Area
    def change_grid(a,b,c)
      # Code here
    end
  end

Using :method ⇒ lambda object means you're using Ruby Lambda object. Lambda object is an anonymous method/function that returns something. So, you don't need to create a new method every time within the Grid::Area module. when you don't want to. To write a lambda object, you do it like this

  :method => lambda do |a,b,c|
    # Code here
  end

Both of method name reference a lambda object accepts 3 parameters which are

  • a = User of the skill
  • b = Any battler in the center grid, if there is no battler, it will be redirected to a target null
  • c = Center grid

Our mini-nuke explosion uses the lambda object to determine the target grid. It goes something like this on a moment before the projectile hits the target.

  :method => lambda do |a,b,c|
    return Grid.surrounding(c) | Grid.linear(c, [2,4,6,8], 2)
  end,

On a side note: The operand | is merging two arrays and remove the duplicated, i.e, when you have an array [1,2,3,4] and [3,4,5,6] it will be [1,2,3,4] instead of [1,2,3,4,3,4,5,6]

Type parameter

Usage:

  :type => :set,
  :type => :add,
  :type => :sub,

Behavior if omitted: Use :set as the default value

You have an option to select one of those three modes. Let's assume you have target grid array as [1,2,3,4] and the next target grid array is [3,4,5,6]

  • :set = target grid is replaced. It's now [3,4,5,6]
  • :add = target grid is merged. It's now [1,2,3,4,5,6]
  • :sub = target grid is substracted. It's now [1,2]

Scope parameter

Usage:

  :scope => :allies,
  :scope => :enemies,
  :scope => :collateral,

Behavior if omitted: No change on the scope

Change the current scope as explained in the target scope option in determining the targetable grid section.

Null parameter

Usage:

  :null => true,
  :null => false,

Behavior if omitted: Use the default value as true

This option is an option for you to allow a skill animation to play on the empty grid using the default [:show_anim] from the base TSBS script.

Self-Trigger skill

The self-trigger skill is a skill that does not require a selection through a targetable grid. The targetable grid is used as an Area of Effect indicator on where the skill may fall into. As has been said, the targetable grid only has its own role during the selection phase. It does not do anything during the action phase that you have to determine the target grid manually using [:grid_setup].

To determine if the skill is a self-trigger type, put this tag in the skill note box.

<self trigger>

When you're using the skill, it will look like this

i.imgur.com_t4oqjqq.jpg

Noticed that the cursor stays at the user position. You can not change the position of the cursor when you put this tag. You can only confirm or cancel the skill activation. During the action phase, the initial center grid will also be the same as user position. What you're going to decide with this mechanism is entirely up to you.

grid/targeting.txt · Last modified: 2019/12/29 17:16 (external edit)