sprite spawning rules

This commit is contained in:
Monty Marz 2020-08-14 03:22:25 +02:00
parent 0512c7a764
commit 7ab80ef367
7 changed files with 222 additions and 75 deletions

10
Cargo.lock generated
View File

@ -1309,6 +1309,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "format_num"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14ac05eb8d2eb4ed1eeff847911deae077b0b53332465de9d6a26b0ea9961bc8"
dependencies = [
"regex",
]
[[package]]
name = "fsevent"
version = "2.0.2"
@ -4766,6 +4775,7 @@ dependencies = [
"dot_vox",
"euc",
"failure",
"format_num",
"gfx",
"gfx_device_gl",
"gfx_gl",

View File

@ -65,14 +65,11 @@ VoxygenLocalization(
"common.create": "Oluştur",
"common.okay": "Tamam",
"common.accept": "Kabul Et",
"common.decline": "Reddet",
"common.disclaimer": "Uyarı",
"common.cancel": "İptal Et",
"common.none": "Yok",
"common.error": "Hata",
"common.fatal_error": "Ölümcül hata",
"common.you": "Sen",
"common.automatic": "Otomatik",
// Message when connection to the server is lost
"common.connection_lost": r#"Bağlantı koptu!
@ -305,30 +302,23 @@ edince kapat"#,
"hud.settings.fluid_rendering_mode.cheap": "Basit",
"hud.settings.fluid_rendering_mode.shiny": "Güzel",
"hud.settings.cloud_rendering_mode.regular": "Normal",
"hud.settings.particles": "Partiküller",
"hud.settings.resolution": "Çözünürlük",
"hud.settings.bit_depth": "Bit Derinliği",
"hud.settings.refresh_rate": "Yenileme Hızı",
"hud.settings.fullscreen": "Tam ekran",
"hud.settings.save_window_size": "Pencere boyutunu kaydet",
"hud.settings.music_volume": "Müzik Sesi",
"hud.settings.sound_effect_volume": "Efekt Sesi",
"hud.settings.audio_device": "Ses Aygıtı",
"hud.settings.awaitingkey": "Bir tuşa bas...",
"hud.settings.unbound": "Atanmamış",
"hud.settings.reset_keybinds": "Varsayılana döndür",
"hud.social": "Diğer Oyuncular",
"hud.social.online": "Çevrimiçi:",
"hud.settings.music_volume": "Müzik Sesi",
"hud.settings.sound_effect_volume": "Efekt Sesi",
"hud.settings.audio_device": "Ses Aygıtı",
"hud.social": "Sosyal",
"hud.social.online": "Çevrimiçi",
"hud.social.friends": "Arkadaşlar",
"hud.social.not_yet_available": "Şu anda kullanılabilir değil",
"hud.social.faction": "Klan",
"hud.social.play_online_fmt": "{nb_player} oyuncu çevrimiçi",
"hud.social.name": "İsim",
"hud.social.level": "Seviye",
"hud.social.zone": "Bölge",
"hud.crafting": "Üretim",
"hud.crafting.recipes": "Tarifler",
@ -336,19 +326,6 @@ edince kapat"#,
"hud.crafting.craft": "Üret",
"hud.crafting.tool_cata": "Gerektiriyor:",
"hud.group": "Grup",
"hud.group.invite_to_join": "{name} seni grubuna davet etti!",
"hud.group.invite": "Davet Et",
"hud.group.kick": "Gruptan At",
"hud.group.assign_leader": "Lider Seç",
"hud.group.leave": "Gruptan Ayrıl",
"hud.group.dead" : "Ölü",
"hud.group.out_of_range": "Erişim dışı",
"hud.group.add_friend": "Arkadaşlara Ekle",
"hud.group.link_group": "Grupları Bağla",
"hud.group.in_menu": "Menüde",
"hud.group.members": "Grup Üyeleri",
"hud.spell": "Büyü",
"hud.free_look_indicator": "Serbest bakış açık",
@ -391,7 +368,7 @@ edince kapat"#,
"gameinput.wallleap": "Duvar Sıçrayışı",
"gameinput.togglelantern": "Feneri yak/söndür",
"gameinput.mount": "Bin",
"gameinput.chat": "Sohbet",
"gameinput.enter": "Sohbet",
"gameinput.command": "Komut",
"gameinput.escape": "Oyunu Duraklat",
"gameinput.map": "Harita",
@ -407,13 +384,6 @@ edince kapat"#,
"gameinput.freelook": "Serbest Bakış",
"gameinput.autowalk": "Otomatik Yürüyüş",
"gameinput.dance": "Dans et",
"gameinput.select": "Varlık Seç",
"gameinput.acceptgroupinvite": "Grup Davetini Kabul Et",
"gameinput.declinegroupinvite": "Grup Davetini Reddet",
"gameinput.crafting": "Üretim",
"gameinput.sneak": "Eğil",
"gameinput.swimdown": "Aşağı Dal",
"gameinput.swimup": "Yüzeye çık",
/// End GameInput section
@ -486,8 +456,6 @@ Koruma
"'L-Shift'e basarak Planörünü aç ve gökyüzünü fethet.",
"Veloren hala Pre-Alpha'da. Onu geliştirmek için her gün elimizden geleni yapıyoruz!",
"Geliştirme Takımına katılmak istiyorsan veya sadece sohbet etmek istiyorsan Discord sunucumuza katıl.",
"Can barında canı sayı olarak görmek istiyorsan, bunu ayarlardan aktifleştirebilirsin.",
"Niteliklerini görmek için envanterindeki 'Nitelikler' düğmesine tıklayabilirsin.",
],
"npc.speech.villager_under_attack": [
"Saldırı altındayım, yardım edin!",

View File

@ -83,9 +83,9 @@ impl<'a> From<&'a Body> for Psyche {
_ => 1.0,
},
Body::QuadrupedSmall(quadruped_small) => match quadruped_small.species {
quadruped_small::Species::Pig => 0.8,
quadruped_small::Species::Pig => 0.5,
quadruped_small::Species::Fox => 0.4,
quadruped_small::Species::Sheep => 0.7,
quadruped_small::Species::Sheep => 0.5,
quadruped_small::Species::Boar => 1.0,
quadruped_small::Species::Jackalope => 0.4,
quadruped_small::Species::Skunk => 0.8,

View File

@ -47,6 +47,7 @@ gilrs = { version = "0.7", features = ["serde"] }
server = { package = "veloren-server", path = "../server", optional = true }
# Utility
format_num = "0.1.0"
glsl-include = "0.3.1"
failure = "0.1.6"
dot_vox = "4.0"

View File

@ -1146,7 +1146,7 @@ impl PlayState for SessionState {
}
/// Max distance an entity can be "targeted"
const MAX_TARGET_RANGE: f32 = 30.0;
const MAX_TARGET_RANGE: f32 = 150.0;
/// Calculate what the cursor is pointing at within the 3d scene
#[allow(clippy::type_complexity)]
fn under_cursor(

View File

@ -2,7 +2,7 @@ use crate::{
column::ColumnSample,
sim::SimChunk,
util::{RandomField, Sampler},
IndexRef,
Index, IndexRef, CONFIG,
};
use common::{
assets, comp,
@ -29,7 +29,7 @@ pub struct Colors {
fn close(x: f32, tgt: f32, falloff: f32) -> f32 {
(1.0 - (x - tgt).abs() / falloff).max(0.0).powf(0.5)
}
const MUSH_FACT: f32 = 0.001; // To balance everything around the mushroom spawning rate
pub fn apply_scatter_to<'a>(
wpos2d: Vec2<i32>,
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
@ -42,60 +42,221 @@ pub fn apply_scatter_to<'a>(
// TODO: Add back all sprites we had before
let scatter: &[(_, bool, fn(&SimChunk) -> (f32, Option<(f32, f32)>))] = &[
// (density, Option<(wavelen, threshold)>)
// Flowers
(BlueFlower, false, |c| {
(
close(c.temp, -0.3, 0.7).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.6)),
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
Some((48.0, 0.4)),
)
}),
(PinkFlower, false, |c| {
(
close(c.temp, 0.15, 0.5).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.6)),
)
}),
(DeadBush, false, |c| {
(
close(c.temp, 0.8, 0.3).min(close(c.humidity, 0.0, 0.4)) * 0.015,
None,
)
}),
(Twigs, false, |c| {
((c.tree_density - 0.5).max(0.0) * 0.00001, None)
}),
(Stones, false, |c| {
((c.rockiness - 0.5).max(0.0) * 0.00001, None)
}),
(ShortGrass, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.09,
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
Some((48.0, 0.4)),
)
}),
(PurpleFlower, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
Some((48.0, 0.4)),
)
}),
(RedFlower, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
Some((48.0, 0.4)),
)
}),
(WhiteFlower, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
Some((48.0, 0.4)),
)
}),
(YellowFlower, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
Some((48.0, 0.4)),
)
}),
// Herbs and Spices
(LingonBerry, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
None,
)
}),
(LeafyPlant, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
None,
)
}),
(Fern, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35))
* MUSH_FACT
* 0.5,
Some((48.0, 0.4)),
)
}),
(Blueberry, false, |c| {
(
close(c.temp, CONFIG.temperate_temp, 0.5).min(close(
c.humidity,
CONFIG.forest_hum,
0.35,
)) * MUSH_FACT
* 0.3,
None,
)
}),
// Collecable Objects
// Only spawn twigs in temperate forests
(Twigs, false, |c| {
((c.tree_density - 0.5).max(0.0) * MUSH_FACT, None)
}),
(Stones, false, |c| {
((c.rockiness - 0.5).max(0.0) * MUSH_FACT, None)
}),
// Don't spawn Mushrooms in snowy regions
(Mushroom, false, |c| {
(
close(c.temp, 0.3, 0.4).min(close(c.humidity, 0.6, 0.35)) * 0.00001,
close(c.temp, 0.3, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.35)) * MUSH_FACT,
None,
)
}),
// Grass
(ShortGrass, false, |c| {
(
close(c.temp, 0.0, 0.6).min(close(c.humidity, CONFIG.forest_hum, 0.35)) * 0.05,
Some((48.0, 0.7)),
)
}),
(MediumGrass, false, |c| {
(
close(c.temp, 0.0, 0.6).min(close(c.humidity, 0.6, 0.35)) * 0.05,
Some((48.0, 0.2)),
close(c.temp, 0.0, 0.6).min(close(c.humidity, CONFIG.forest_hum, 0.35)) * 0.05,
Some((48.0, 0.4)),
)
}),
(LongGrass, false, |c| {
(
close(c.temp, 0.4, 0.4).min(close(c.humidity, 0.8, 0.2)) * 0.05,
Some((48.0, 0.1)),
close(c.temp, 0.4, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.2)) * 0.05,
Some((48.0, 0.5)),
)
}),
/*(GrassSnow, false, |c| {
(WheatGreen, false, |c| {
(
close(c.temp, -0.4, 0.4).min(close(c.rockiness, 0.0, 0.5)) * 0.1,
Some((48.0, 0.6)),
close(c.temp, 0.4, 0.4).min(close(c.humidity, CONFIG.forest_hum, 0.1))
* MUSH_FACT
* 0.001,
None,
)
}),*/
}),
(GrassSnow, false, |c| {
(
close(c.temp, CONFIG.snow_temp - 0.2, 0.4).min(close(
c.humidity,
CONFIG.forest_hum,
0.5,
)) * 0.01,
Some((48.0, 0.2)),
)
}),
// Desert Plants
(DeadBush, false, |c| {
(
close(c.temp, CONFIG.desert_temp + 0.2, 0.3).min(close(
c.humidity,
CONFIG.desert_hum,
0.3,
)) * MUSH_FACT
* 0.01,
None,
)
}),
(LargeCactus, false, |c| {
(
close(c.temp, CONFIG.desert_temp + 0.2, 0.3).min(close(
c.humidity,
CONFIG.desert_hum,
0.2,
)) * MUSH_FACT
* 0.01,
None,
)
}),
(BarrelCactus, false, |c| {
(
close(c.temp, CONFIG.desert_temp + 0.2, 0.3).min(close(
c.humidity,
CONFIG.desert_hum,
0.2,
)) * MUSH_FACT
* 0.01,
None,
)
}),
(RoundCactus, false, |c| {
(
close(c.temp, CONFIG.desert_temp + 0.2, 0.3).min(close(
c.humidity,
CONFIG.desert_hum,
0.2,
)) * MUSH_FACT
* 0.01,
None,
)
}),
(ShortCactus, false, |c| {
(
close(c.temp, CONFIG.desert_temp + 0.2, 0.3).min(close(
c.humidity,
CONFIG.desert_hum,
0.2,
)) * MUSH_FACT
* 0.01,
None,
)
}),
(MedFlatCactus, false, |c| {
(
close(c.temp, CONFIG.desert_temp + 0.2, 0.3).min(close(
c.humidity,
CONFIG.desert_hum,
0.2,
)) * MUSH_FACT
* 0.01,
None,
)
}),
(ShortFlatCactus, false, |c| {
(
close(c.temp, CONFIG.desert_temp + 0.2, 0.3).min(close(
c.humidity,
CONFIG.desert_hum,
0.2,
)) * MUSH_FACT
* 0.01,
None,
)
}),
];
for y in 0..vol.size_xy().y as i32 {

View File

@ -237,8 +237,13 @@ impl World {
&& !sim_chunk.is_underwater()
{
let is_hostile: bool;
let is_giant = if rng.gen_range(0, 8) == 0 {
true
} else {
false
};
let entity = EntityInfo::at(gen_entity_pos())
.do_if(rng.gen_range(0, 8) == 0, |e| e.into_giant())
.do_if(is_giant, |e| e.into_giant())
.with_body(match rng.gen_range(0, 5) {
0 => {
is_hostile = true;
@ -263,6 +268,8 @@ impl World {
})
.with_alignment(if is_hostile {
comp::Alignment::Enemy
} else if is_giant {
comp::Alignment::Npc
} else {
comp::Alignment::Wild
})