Hi Klonan, thank you for your answer! I played around with the attack parameters and actions and managed to get half-way there:
Currently (see 1) I am able to spawn a target indicator at the predicted target position. The predicted target position is computed the usual way - taking in account the projectile speed and the target movement. What currently does not work:
- The indicator spawns at the same time that the projectile is shot. I tried setting a warmup time, but the indicator does not spawn before that is completed.
- The projectile speed is currently slow, but eventually I want to have it fast. With the current implementation this would make it impossible to evade.
- The indicator should spawn exactly 1 second before the projectile arrives at the predicted target location (currently it spawns too fast to evade if you are close to the tower and too easy to evade if you are far away).
So now I think I have to do some scripting to get to the desired result. I looked into script-triggers and here is what I'm thinking to do:
- Instead of firing a projectile, the tower just fires a script trigger. I get the source_entity and target_entity in on_script_trigger_effect.
- I can not use the target prediction of the tower since there is no way of telling it that I want the target at exactly 1s from now, so I'll have to compute it myself, which is easier since I assume the projectile speed is infinite.
- I spawn an indicator right away and then wait for 1s to spawn the projectile. (How do I wait for 1s?)
- There is no way with this method to animate the tower shooting (I want to add a powering-up animation for each shot).
Do you know if there is an easier solution for this, or one that allows me to animate the tower shooting?
Thank you for your help - Aphlax
(1)
Code: Select all
local tower = {
type = "turret",
name = "tower",
...,
attack_parameters = {
type = "projectile",
range = 16,
cooldown = 120,
lead_target_for_projectile_speed = 0.5,
ammo_type = {
category = "laser",
target_type = "position",
clamp_position = true,
action = {
type = "direct",
action_delivery = {
type = "projectile",
projectile = "tower-projectile",
starting_speed = 0.5,
target_effects = {
type = "create-entity",
entity_name = "tower-target-indicator"
}
},
}
}
}
}
local projectile = {
type = "projectile",
name = "tower-projectile",
...,
action = {
{
type = "direct",
action_delivery = {
type = "instant",
target_effects = {
{
type = "create-entity",
entity_name = "explosion"
}
}
}
},
{
type = "area",
radius = 2,
perimeter = 2,
action_delivery = {
type = "instant",
target_effects = {
{
type = "damage",
damage = {amount = 1, type = "explosion"}
}
}
}
}
}
}
local indicator = {
type = "corpse",
name = "tower-target-indicator",
time_before_removed = 120,
time_before_shading_off = 60,
...
}
data:extend({tower, projectile, indicator})