Add treant npc

This commit is contained in:
Snowram 2020-10-04 15:00:45 +02:00 committed by Robin Gilh
parent 6bc72f7f0b
commit dbac820034
23 changed files with 190 additions and 15 deletions

View File

@ -603,6 +603,10 @@
"stonegolem": {
"keyword": "stonegolem",
"generic": "StoneGolem"
},
"treant": {
"keyword": "treant",
"generic": "Treant"
}
}
},

View File

@ -4,6 +4,10 @@
offset: (-3.5, -4.0, -0.0),
central: ("npc.stonegolem.male.head"),
),
jaw: (
offset: (-3.5, -4.0, -0.0),
central: ("armor.empty"),
),
torso_upper: (
offset: (-10.5, -10.5, -10.5),
central: ("npc.stonegolem.male.chest_upper"),
@ -18,6 +22,10 @@
offset: (-3.5, -4.0, -0.0),
central: ("npc.stonegolem.male.head"),
),
jaw: (
offset: (-3.5, -4.0, -0.0),
central: ("armor.empty"),
),
torso_upper: (
offset: (-10.5, -10.5, -10.5),
central: ("npc.stonegolem.male.chest_upper"),
@ -27,4 +35,40 @@
central: ("npc.stonegolem.male.chest_lower"),
),
),
(Treant, Male): (
head: (
offset: (-6.0, -6.5, -0.0),
central: ("npc.treant.male.head"),
),
jaw: (
offset: (-4.0, 0.0, -3.0),
central: ("npc.treant.male.jaw"),
),
torso_upper: (
offset: (-18.0, -16.0, -15.5),
central: ("npc.treant.male.chest_upper"),
),
torso_lower: (
offset: (-8.0, -9.0, -8.0),
central: ("npc.treant.male.chest_lower"),
),
),
(Treant, Female): (
head: (
offset: (-6.0, -6.5, -0.0),
central: ("npc.treant.male.head"),
),
jaw: (
offset: (-4.0, 0.0, -3.0),
central: ("npc.treant.male.jaw"),
),
torso_upper: (
offset: (-18.0, -16.0, -15.5),
central: ("npc.treant.male.chest_upper"),
),
torso_lower: (
offset: (-8.0, -9.0, -8.0),
central: ("npc.treant.male.chest_lower"),
),
),
})

View File

@ -67,4 +67,72 @@
lateral: ("npc.stonegolem.male.foot_r"),
)
),
(Treant, Male): (
shoulder_l: (
offset: (-16.0, -7.0, -8.5),
lateral: ("npc.treant.male.shoulder_l"),
),
shoulder_r: (
offset: (0.0, -7.0, -8.5),
lateral: ("npc.treant.male.shoulder_r"),
),
hand_l: (
offset: (-5.5, -5.5, -17.0),
lateral: ("npc.treant.male.hand_l"),
),
hand_r: (
offset: (-5.5, -5.5, -17.0),
lateral: ("npc.treant.male.hand_r"),
),
leg_l: (
offset: (-6.0, -9.5, -9.0),
lateral: ("npc.treant.male.leg_l"),
),
leg_r: (
offset: (0.0, -9.5, -9.0),
lateral: ("npc.treant.male.leg_r"),
),
foot_l: (
offset: (-4.5, -4.5, -8.0),
lateral: ("npc.treant.male.foot_l"),
),
foot_r: (
offset: (-4.5, -4.5, -8.0),
lateral: ("npc.treant.male.foot_r"),
)
),
(Treant, Female): (
shoulder_l: (
offset: (-16.0, -7.0, -8.5),
lateral: ("npc.treant.male.shoulder_l"),
),
shoulder_r: (
offset: (0.0, -7.0, -8.5),
lateral: ("npc.treant.male.shoulder_r"),
),
hand_l: (
offset: (-5.5, -5.5, -17.0),
lateral: ("npc.treant.male.hand_l"),
),
hand_r: (
offset: (-5.5, -5.5, -17.0),
lateral: ("npc.treant.male.hand_r"),
),
leg_l: (
offset: (-6.0, -9.5, -9.0),
lateral: ("npc.treant.male.leg_l"),
),
leg_r: (
offset: (0.0, -9.5, -9.0),
lateral: ("npc.treant.male.leg_r"),
),
foot_l: (
offset: (-4.5, -4.5, -8.0),
lateral: ("npc.treant.male.foot_l"),
),
foot_r: (
offset: (-4.5, -4.5, -8.0),
lateral: ("npc.treant.male.foot_r"),
)
),
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -35,6 +35,7 @@ make_case_elim!(
#[repr(u32)]
pub enum Species {
StoneGolem = 0,
Treant = 1,
}
);
@ -44,6 +45,7 @@ make_case_elim!(
#[derive(Clone, Debug, Deserialize)]
pub struct AllSpecies<SpeciesMeta> {
pub stonegolem: SpeciesMeta,
pub treant: SpeciesMeta,
}
impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies<SpeciesMeta> {
@ -53,11 +55,15 @@ impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies<SpeciesMeta>
fn index(&self, &index: &'a Species) -> &Self::Output {
match index {
Species::StoneGolem => &self.stonegolem,
Species::Treant => &self.treant,
}
}
}
pub const ALL_SPECIES: [Species; 1] = [Species::StoneGolem];
pub const ALL_SPECIES: [Species; 2] = [
Species::StoneGolem,
Species::Treant,
];
impl<'a, SpeciesMeta: 'a> IntoIterator for &'a AllSpecies<SpeciesMeta> {
type IntoIter = std::iter::Copied<std::slice::Iter<'static, Self::Item>>;

View File

@ -80,6 +80,7 @@ impl LoadoutBuilder {
"common.items.npc_weapons.npcweapon.stone_golems_fist",
));
},
_ => {},
},
Body::BipedLarge(biped_large) => match (biped_large.species, biped_large.body_type) {
(biped_large::Species::Occultlizardman, _) => {
@ -306,6 +307,7 @@ impl LoadoutBuilder {
head: None,
tabard: None,
},
_ => LoadoutBuilder::animal(body).build(),
},
Body::BipedLarge(_) => Loadout {
active_item,

View File

@ -56,7 +56,7 @@ impl Animation for IdleAnimation {
let breathing = if skeleton_attr.beast {
let breathe = if skeleton_attr.beast {
// Controls for the beast breathing
let intensity = 0.04;
let lenght = 1.5;
@ -72,24 +72,24 @@ impl Animation for IdleAnimation {
skeleton_attr.head.0,
skeleton_attr.head.1 + torso * 0.2,
) * 1.02;
next.head.orientation = Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6 + breathing);
next.head.scale = Vec3::one() * 1.02 + breathing * 0.4;
next.head.orientation = Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6 + breathe);
next.head.scale = Vec3::one() * 1.02 + breathe * 0.4;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + torso * 0.5,
);
next.upper_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(- breathing);
next.upper_torso.scale = Vec3::one() - breathing * 0.4;
next.upper_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(- breathe);
next.upper_torso.scale = Vec3::one() - breathe * 0.4;
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1 + torso * 0.15,
);
next.lower_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathing);
next.lower_torso.scale = Vec3::one() * 1.02 + breathing * 0.4;
next.lower_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathe);
next.lower_torso.scale = Vec3::one() * 1.02 + breathe * 0.4;
if skeleton_attr.beast {
next.jaw.position = Vec3::new(
@ -104,7 +104,7 @@ impl Animation for IdleAnimation {
skeleton_attr.jaw.1 + slow * 0.2,
);
}
next.jaw.orientation = Quaternion::rotation_x(-0.1 + breathing * 2.0);
next.jaw.orientation = Quaternion::rotation_x(-0.1 + breathe * 2.0);
next.jaw.scale = Vec3::one() * 0.98;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
@ -131,16 +131,16 @@ impl Animation for IdleAnimation {
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathing);
next.shoulder_l.scale = Vec3::one() + breathing;
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathe);
next.shoulder_l.scale = Vec3::one() + breathe;
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathing);
next.shoulder_r.scale = Vec3::one() + breathing;
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathe);
next.shoulder_r.scale = Vec3::one() + breathe;
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,

View File

@ -49,6 +49,15 @@ impl Animation for IdleAnimation {
Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.head.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - breathe * 0.12,
skeleton_attr.jaw.1 + breathe * 0.2,
) * 1.02;
next.jaw.orientation = Quaternion::rotation_x(-0.1 + breathe * 0.1);
next.jaw.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,

View File

@ -18,6 +18,7 @@ pub type Body = comp::golem::Body;
skeleton_impls!(struct GolemSkeleton {
+ head,
+ jaw,
+ upper_torso,
+ lower_torso,
+ shoulder_l,
@ -35,7 +36,7 @@ impl Skeleton for GolemSkeleton {
type Attr = SkeletonAttr;
type Body = Body;
const BONE_COUNT: usize = 11;
const BONE_COUNT: usize = 12;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"golem_compute_mats\0";
@ -55,6 +56,7 @@ impl Skeleton for GolemSkeleton {
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(upper_torso_mat * Mat4::<f32>::from(self.head)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.head) * Mat4::<f32>::from(self.jaw)),
make_bone(upper_torso_mat),
make_bone(lower_torso_mat),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.shoulder_l)),
@ -72,6 +74,7 @@ impl Skeleton for GolemSkeleton {
pub struct SkeletonAttr {
head: (f32, f32),
jaw: (f32, f32),
upper_torso: (f32, f32),
lower_torso: (f32, f32),
shoulder: (f32, f32, f32),
@ -95,6 +98,7 @@ impl Default for SkeletonAttr {
fn default() -> Self {
Self {
head: (0.0, 0.0),
jaw: (0.0, 0.0),
upper_torso: (0.0, 0.0),
lower_torso: (0.0, 0.0),
shoulder: (0.0, 0.0, 0.0),
@ -111,24 +115,35 @@ impl<'a> From<&'a Body> for SkeletonAttr {
Self {
head: match (body.species, body.body_type) {
(StoneGolem, _) => (0.0, 2.0),
(Treant, _) => (18.0, -8.0),
},
jaw: match (body.species, body.body_type) {
(StoneGolem, _) => (0.0, 0.0),
(Treant, _) => (-6.5, -1.0),
},
upper_torso: match (body.species, body.body_type) {
(StoneGolem, _) => (0.0, 34.5),
(Treant, _) => (0.0, 28.5),
},
lower_torso: match (body.species, body.body_type) {
(StoneGolem, _) => (0.0, -10.5),
(Treant, _) => (0.0, -10.5),
},
shoulder: match (body.species, body.body_type) {
(StoneGolem, _) => (8.0, -1.5, 4.0),
(Treant, _) => (8.0, 4.5, -3.0),
},
hand: match (body.species, body.body_type) {
(StoneGolem, _) => (12.5, -1.0, -7.0),
(Treant, _) => (8.5, -1.0, -7.0),
},
leg: match (body.species, body.body_type) {
(StoneGolem, _) => (4.0, 0.0, -3.5),
(Treant, _) => (2.0, 9.5, -1.0),
},
foot: match (body.species, body.body_type) {
(StoneGolem, _) => (3.5, 0.5, -9.5),
(Treant, _) => (3.5, -5.0, -8.5),
},
}
}

View File

@ -73,6 +73,13 @@ impl Animation for RunAnimation {
next.head.orientation = Quaternion::rotation_z(short * -0.3) * Quaternion::rotation_x(-0.2);
next.head.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0,
skeleton_attr.jaw.1,
) * 1.02;
next.jaw.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,

View File

@ -2989,6 +2989,7 @@ struct GolemCentralSpec(HashMap<(GSpecies, GBodyType), SidedGCentralVoxSpec>);
#[derive(Deserialize)]
struct SidedGCentralVoxSpec {
head: GolemCentralSubSpec,
jaw: GolemCentralSubSpec,
torso_upper: GolemCentralSubSpec,
torso_lower: GolemCentralSubSpec,
}
@ -3030,6 +3031,10 @@ make_vox_spec!(
body.species,
body.body_type,
)),
Some(spec.central.asset.mesh_jaw(
body.species,
body.body_type,
)),
Some(spec.central.asset.mesh_torso_upper(
body.species,
body.body_type,
@ -3074,7 +3079,6 @@ make_vox_spec!(
None,
None,
None,
None,
]
},
);
@ -3096,6 +3100,22 @@ impl GolemCentralSpec {
(central, Vec3::from(spec.head.offset))
}
fn mesh_jaw(&self, species: GSpecies, body_type: GBodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No jaw specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.jaw.central.0);
(central, Vec3::from(spec.jaw.offset))
}
fn mesh_torso_upper(&self, species: GSpecies, body_type: GBodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,