Who can - please tell me!
1. How to make deepwater-explosive capsules damage the player and enemies?
2. How to make effect_id = "explosive-deepwater-explosion" only work on land?
3. How to make effect_id = "explosive-water-explosion" work with a slowdown of about 0.5 seconds?
Here is the full code of the main file:
Code: Select all
local explosion_animations = require("prototypes.deepwater-explosive.explosion-animations")
local sounds = require("__base__.prototypes.entity.sounds")
data:extend(
{
{
type = "projectile",
name = "deepwater-explosive",
flags = { "not-on-map" },
acceleration = 0.005,
hidden = true,
action =
{
{
type = "direct",
action_delivery =
{
type = "instant",
target_effects =
{
{
type = "set-tile",
tile_name = "nuclear-ground",
-- radius = 12,
radius = 3,
apply_projection = true,
tile_collision_mask = { layers={water_tile=true} }
},
{
type = "destroy-cliffs",
-- radius = 9,
radius = 1,
explosion_at_trigger = "explosion"
},
{
type = "create-entity",
entity_name = "mini-nuke-explosion"
},
{
type = "camera-effect",
duration = 60,
ease_in_duration = 5,
ease_out_duration = 60,
delay = 0,
strength = 6,
full_strength_max_distance = 200,
max_distance = 800
},
{
type = "script",
effect_id = "explosive-deepwater-explosion",
delay = 1000,
},
{
type = "invoke-tile-trigger",
repeat_count = 1
},
{
type = "destroy-decoratives",
decoratives_with_trigger_only = false,
from_render_layer = "decorative",
include_decals = false,
include_soft_decoratives = true,
invoke_decorative_trigger = true,
radius = 0.001,
to_render_layer = "object"
}
}
}
},
{
type = "area",
radius = 2.0,
-- radius = 4,
action_delivery =
{
type = "instant",
target_effects =
{
{
type = "damage",
damage =
{
type = "explosion",
amount = 100
}
},
{
type = "create-entity",
entity_name = "explosion"
}
}
}
}
},
animation =
{
animation_speed = 0.25,
draw_as_glow = true,
filename = "__modmashsplinterexplosivewater__/graphics/entity/explosive/explosives.png",
frame_count = 16,
height = 54,
line_length = 8,
priority = "high",
scale = 0.5,
shift = { 0.015625, 0.015625 },
width = 48
},
light =
{
intensity = 0.5,
size = 4
},
shadow =
{
animation_speed = 0.25,
draw_as_shadow = true,
filename = "__modmashsplinterexplosivewater__/graphics/entity/explosive/explosives-shadow.png",
frame_count = 16,
height = 40,
line_length = 8,
priority = "high",
scale = 0.5,
shift = { 0.0625, 0.1875 },
width = 50
}
},
{
type = "capsule",
name = "deepwater-explosive",
icon = "__modmashsplinterexplosivewater__/graphics/icons/deep-water-explosives.png",
icon_size = 64,
order = "d[acliff-explosive]",
stack_size = 20,
subgroup = "terrain",
capsule_action =
{
type = "throw",
attack_parameters =
{
type = "projectile",
ammo_category = "grenade",
activation_type = "throw",
cooldown = 30,
projectile_creation_distance = 0.6,
range = 15,
ammo_type =
{
category = "grenade",
target_type = "position",
action =
{
{
type = "direct",
action_delivery =
{
type = "projectile",
projectile = "deepwater-explosive",
starting_speed = 0.3
}
},
{
type = "direct",
action_delivery =
{
type = "instant",
target_effects =
{
{
type = "play-sound",
sound = sounds.nuclear_explosion(0.9),
play_on_target_position = false,
-- min_distance = 200,
max_distance = 100,
-- volume_modifier = 1,
audible_distance_modifier = 3
},
{
type = "play-sound",
sound = sounds.nuclear_explosion_aftershock(0.4),
play_on_target_position = false,
-- min_distance = 200,
max_distance = 100,
-- volume_modifier = 1,
audible_distance_modifier = 3
}
}
}
}
}
}
}
}
}
})
Code: Select all
require("prototypes.scripts.defines")
local is_valid = modmashsplinterexplosivemining.util.is_valid
local starts_with = modmashsplinterexplosivemining.util.starts_with
local print = modmashsplinterexplosivemining.util.print
local local_on_script_trigger_effect = function(event)
if event.effect_id == "explosive-deepwater-explosion" and event.target_position ~= nil then
local surface = game.surfaces[event.surface_index]
local entities = surface.find_entities_filtered{type={"resource"}, area = {{event.target_position.x-0.5, event.target_position.y-0.5}, {event.target_position.x+0.5, event.target_position.y+0.5}}}
local entities = surface.find_entities_filtered{area = {{event.target_position.x-0.5, event.target_position.y-0.5}, {event.target_position.x+0.5, event.target_position.y+0.5}}}
for k = 1, #entities do local ent = entities[k]
if is_valid(ent) then
ent.die()
end
end
surface.set_tiles(
{
{name="deepwater",position={x=event.target_position.x-0.5,y=event.target_position.y-0.5}},
{name="deepwater",position={x=event.target_position.x-0.5,y=event.target_position.y}},
{name="deepwater",position={x=event.target_position.x-0.5,y=event.target_position.y+0.5}},
{name="deepwater",position={x=event.target_position.x,y=event.target_position.y-0.5}},
{name="deepwater",position={x=event.target_position.x,y=event.target_position.y}},
{name="deepwater",position={x=event.target_position.x,y=event.target_position.y+0.5}},
{name="deepwater",position={x=event.target_position.x+0.5,y=event.target_position.y-0.5}},
{name="deepwater",position={x=event.target_position.x+0.5,y=event.target_position.y}},
{name="deepwater",position={x=event.target_position.x+0.5,y=event.target_position.y+0.5}}
}
)
end
end
script.on_event(defines.events.on_script_trigger_effect, local_on_script_trigger_effect)