mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Proper lightning
This commit is contained in:
parent
edc2720416
commit
836fe2b1c6
@ -232,7 +232,7 @@ DirectionalLight get_moon_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*
|
||||
return DirectionalLight(/*dir, */shadow, block/*, get_moon_color(dir), get_moon_brightness(dir)*/);
|
||||
}
|
||||
|
||||
const float LIGHTNING_HEIGHT = 350.0;
|
||||
const float LIGHTNING_HEIGHT = 25.0;
|
||||
|
||||
float lightning_intensity() {
|
||||
float time_since_lightning = tick.x - last_lightning.w;
|
||||
|
@ -41,7 +41,6 @@ const int SMOKE = 0;
|
||||
const int FIRE = 1;
|
||||
const int GUN_POWDER_SPARK = 2;
|
||||
const int SHRAPNEL = 3;
|
||||
|
||||
const int FIREWORK_BLUE = 4;
|
||||
const int FIREWORK_GREEN = 5;
|
||||
const int FIREWORK_PURPLE = 6;
|
||||
@ -76,6 +75,7 @@ const int DEATH = 34;
|
||||
const int ENERGY_BUFFING = 35;
|
||||
const int WEB_STRAND = 36;
|
||||
const int BLACK_SMOKE = 37;
|
||||
const int LIGHTNING = 38;
|
||||
|
||||
// meters per second squared (acceleration)
|
||||
const float earth_gravity = 9.807;
|
||||
@ -602,6 +602,18 @@ void main() {
|
||||
spin_in_axis(perp_axis, asin(inst_dir.z / length(inst_dir)) + PI / 2.0)
|
||||
);
|
||||
break;
|
||||
case LIGHTNING:
|
||||
f_reflect = 0.0;
|
||||
perp_axis = normalize(cross(inst_dir, vec3(0.0, 0.0, 1.0)));
|
||||
float z = (start_pos + inst_dir * percent()).z;
|
||||
vec3 start_off = vec3(abs(fract(vec3(vec2(z) * vec2(0.015, 0.01), 0)) - 0.5) * z * 0.5);
|
||||
attr = Attr(
|
||||
inst_dir * percent() + start_off,
|
||||
vec3(16.0),
|
||||
vec4(10.0, 30.0, 50.0, 1.0),// * (1.0 - length(inst_dir) * 0.1),
|
||||
identity()//spin_in_axis(perp_axis, asin(inst_dir.z / length(inst_dir)) + PI / 2.0)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
attr = Attr(
|
||||
linear_motion(
|
||||
|
@ -305,6 +305,7 @@ pub enum ServerChatCommand {
|
||||
CreateLocation,
|
||||
DeleteLocation,
|
||||
WeatherZone,
|
||||
Lightning,
|
||||
}
|
||||
|
||||
impl ServerChatCommand {
|
||||
@ -703,6 +704,9 @@ impl ServerChatCommand {
|
||||
"Create a weather zone",
|
||||
Some(Admin),
|
||||
),
|
||||
ServerChatCommand::Lightning => {
|
||||
cmd(vec![], "Lightning strike at current position", Some(Admin))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -781,6 +785,7 @@ impl ServerChatCommand {
|
||||
ServerChatCommand::CreateLocation => "create_location",
|
||||
ServerChatCommand::DeleteLocation => "delete_location",
|
||||
ServerChatCommand::WeatherZone => "weather_zone",
|
||||
ServerChatCommand::Lightning => "lightning",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ use common::{
|
||||
link::Is,
|
||||
mounting::Rider,
|
||||
npc::{self, get_npc_name},
|
||||
outcome::Outcome,
|
||||
parse_cmd_args,
|
||||
resources::{BattleMode, PlayerPhysicsSettings, Time, TimeOfDay},
|
||||
terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize},
|
||||
@ -192,6 +193,7 @@ fn do_command(
|
||||
ServerChatCommand::CreateLocation => handle_create_location,
|
||||
ServerChatCommand::DeleteLocation => handle_delete_location,
|
||||
ServerChatCommand::WeatherZone => handle_weather_zone,
|
||||
ServerChatCommand::Lightning => handle_lightning,
|
||||
};
|
||||
|
||||
handler(server, client, target, args, cmd)
|
||||
@ -3666,3 +3668,19 @@ fn handle_weather_zone(
|
||||
Err(action.help_string())
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_lightning(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
_target: EcsEntity,
|
||||
args: Vec<String>,
|
||||
action: &ServerChatCommand,
|
||||
) -> CmdResult<()> {
|
||||
let pos = position(server, client, "player")?.0;
|
||||
server
|
||||
.state
|
||||
.ecs()
|
||||
.read_resource::<EventBus<Outcome>>()
|
||||
.emit_now(Outcome::Lightning { pos });
|
||||
Ok(())
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ pub enum ParticleMode {
|
||||
EnergyBuffing = 35,
|
||||
WebStrand = 36,
|
||||
BlackSmoke = 37,
|
||||
Lightning = 38,
|
||||
}
|
||||
|
||||
impl ParticleMode {
|
||||
|
@ -63,12 +63,12 @@ impl ParticleMgr {
|
||||
|
||||
match outcome {
|
||||
Outcome::Lightning { pos } => {
|
||||
self.particles.resize_with(self.particles.len() + 400, || {
|
||||
self.particles.resize_with(self.particles.len() + 500, || {
|
||||
Particle::new_directed(
|
||||
Duration::from_secs_f32(rng.gen_range(2.0..3.0)),
|
||||
Duration::from_secs_f32(rng.gen_range(0.5..1.0)),
|
||||
time,
|
||||
ParticleMode::GunPowderSpark,
|
||||
*pos + Vec3::new(0.0, 0.0, rng.gen_range(250.0..1500.0)),
|
||||
ParticleMode::Lightning,
|
||||
*pos + Vec3::new(0.0, 0.0, rng.gen_range(0.0..600.0)),
|
||||
*pos,
|
||||
)
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user