add deer, more random fixes

This commit is contained in:
darkrose 2014-10-01 16:21:33 +10:00
parent fa98eac8ee
commit 9f5cbb3b14
8 changed files with 87 additions and 23 deletions

BIN
data/models/doe.b3d Normal file

Binary file not shown.

BIN
data/models/stag.b3d Normal file

Binary file not shown.

BIN
data/textures/mob_doe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
data/textures/mob_stag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -279,12 +279,60 @@ void content_mob_init()
f->contact_explosion_diameter = 3;
f->setCollisionBox(aabb3f(-BS/3.,0.0,-BS/3., BS/3.,BS/2.,BS/3.));
i = CONTENT_MOB_DEER;
i = CONTENT_MOB_DOE;
f = &g_content_mob_features[i];
//f->content = i;
i = CONTENT_MOB_SHEEP;
f->content = i;
f->level = MOB_PASSIVE;
f->hp = 30;
f->model = "doe.b3d";
f->model_scale = v3f(0.8,0.8,0.8);
f->model_rotation = v3f(0,-90,0);
f->model_offset = v3f(0,0.9,0);
f->setTexture("mob_doe.png");
f->setAnimationFrames(MA_STAND,61,120);
f->setAnimationFrames(MA_MOVE,0,60);
f->setAnimationFrames(MA_ATTACK,0,60);
f->punch_action = MPA_HARM;
f->motion = MM_SEEKER;
f->motion_type = MMT_WALK;
f->spawn_on = CONTENT_WILDGRASS_SHORT;
f->spawn_in = CONTENT_AIR;
f->spawn_min_height = -5;
f->spawn_max_height = 30;
f->spawn_min_light = LIGHT_MAX/2;
f->spawn_max_nearby_mobs = 3;
f->lifetime = 900.0;
f->setCollisionBox(aabb3f(-0.6*BS, 0., -0.6*BS, 0.6*BS, 1.25*BS, 0.6*BS));
i = CONTENT_MOB_STAG;
f = &g_content_mob_features[i];
//f->content = i;
f->content = i;
f->level = MOB_AGGRESSIVE;
f->hp = 40;
f->model = "stag.b3d";
f->model_scale = v3f(1,1,1);
f->model_rotation = v3f(0,-90,0);
f->model_offset = v3f(0,1.1,0);
f->setTexture("mob_stag.png");
f->setAnimationFrames(MA_STAND,61,120);
f->setAnimationFrames(MA_MOVE,0,60);
f->setAnimationFrames(MA_ATTACK,0,60);
f->punch_action = MPA_HARM;
f->motion = MM_WANDER;
f->motion_type = MMT_WALK;
f->angry_motion = MM_SEEKER;
f->spawn_on = CONTENT_WILDGRASS_SHORT;
f->spawn_in = CONTENT_AIR;
f->spawn_min_height = -5;
f->spawn_max_height = 30;
f->spawn_min_light = LIGHT_MAX/2;
f->spawn_max_nearby_mobs = 3;
f->spawn_chance = 150;
f->notices_player = true;
f->attack_player_damage = 3;
f->attack_player_range = v3f(1,1,1);
f->lifetime = 900.0;
f->setCollisionBox(aabb3f(-0.7*BS, 0., -0.7*BS, 0.7*BS, 1.5*BS, 0.7*BS));
i = CONTENT_MOB_FISH;
f = &g_content_mob_features[i];
@ -363,4 +411,7 @@ void content_mob_init()
f->lifetime = 900.0;
f->setCollisionBox(aabb3f(-0.5*BS, 0., -0.5*BS, 0.5*BS, 1.*BS, 0.5*BS));
i = CONTENT_MOB_SHEEP;
f = &g_content_mob_features[i];
//f->content = i;
}

View File

@ -58,12 +58,6 @@ enum MobMotionType
MMT_SWIM
};
enum MobState
{
MS_WILD = 0,
MS_TAME
};
enum MobAnimation
{
MA_STAND = 0,
@ -109,7 +103,7 @@ struct MobFeatures {
MobPunchAction punch_action;
MobMotion motion;
MobMotionType motion_type;
MobState spawn_state;
MobMotion angry_motion;
bool is_tamable;
bool notices_player;
content_t tamed_mob;
@ -218,7 +212,7 @@ struct MobFeatures {
punch_action = MPA_DIE;
motion = MM_STATIC;
motion_type = MMT_WALK;
spawn_state = MS_WILD;
angry_motion = MM_STATIC;
is_tamable = false;
notices_player = false;
tamed_mob = CONTENT_IGNORE;
@ -272,11 +266,12 @@ void content_mob_init();
#define CONTENT_MOB_OERKKI (CONTENT_MOB_MASK | 0x03)
#define CONTENT_MOB_DUNGEON_MASTER (CONTENT_MOB_MASK | 0x04)
#define CONTENT_MOB_FIREBALL (CONTENT_MOB_MASK | 0x05)
#define CONTENT_MOB_DEER (CONTENT_MOB_MASK | 0x06)
#define CONTENT_MOB_SHEEP (CONTENT_MOB_MASK | 0x07)
#define CONTENT_MOB_DOE (CONTENT_MOB_MASK | 0x06)
#define CONTENT_MOB_STAG (CONTENT_MOB_MASK | 0x07)
#define CONTENT_MOB_FISH (CONTENT_MOB_MASK | 0x08)
#define CONTENT_MOB_SHARK (CONTENT_MOB_MASK | 0x09)
#define CONTENT_MOB_WOLF (CONTENT_MOB_MASK | 0x0A)
#define CONTENT_MOB_TAMEWOLF (CONTENT_MOB_MASK | 0x0B)
#define CONTENT_MOB_SHEEP (CONTENT_MOB_MASK | 0x0C)
#endif

View File

@ -239,6 +239,7 @@ MobSAO::MobSAO(ServerEnvironment *env, u16 id, v3f pos, content_t type):
m_next_pos_exists(false),
m_age(0),
m_hp(10),
m_angry(false),
m_disturb_timer(100000),
m_random_disturb_timer(0),
m_walk_around(false),
@ -265,6 +266,7 @@ MobSAO::MobSAO(ServerEnvironment *env, u16 id, v3f pos, v3f speed, content_t typ
m_next_pos_exists(false),
m_age(0),
m_hp(10),
m_angry(false),
m_disturb_timer(100000),
m_random_disturb_timer(0),
m_walk_around(false),
@ -384,6 +386,8 @@ void MobSAO::step(float dtime, bool send_recommended)
disturbing_player_norm.normalize();
disturbing_player_dir = 180./PI*atan2(disturbing_player_norm.Z,disturbing_player_norm.X);
}
}else if (m_angry) {
m_angry = false;
}
m_disturb_timer += dtime;
@ -446,10 +450,12 @@ void MobSAO::step(float dtime, bool send_recommended)
}
}
if (m.motion != MM_CONSTANT && m.motion != MM_STATIC && !m_shooting) {
MobMotion mot = getMotion();
if (mot != MM_CONSTANT && mot != MM_STATIC) {
m_walk_around_timer -= dtime;
if (m_walk_around_timer <= 0.0) {
if (m.motion_type == MMT_FLY || (disturbing_player && m.motion == MM_SEEKER)) {
if (m.motion_type == MMT_FLY || (disturbing_player && mot == MM_SEEKER)) {
if (!m_walk_around) {
m_walk_around_timer = 0.2;
m_walk_around = true;
@ -457,7 +463,7 @@ void MobSAO::step(float dtime, bool send_recommended)
}else{
m_walk_around = !m_walk_around;
if (m_walk_around) {
if (!disturbing_player || m.motion != MM_SEEKER)
if (!disturbing_player || mot != MM_SEEKER)
m_walk_around_timer = 0.1*myrand_range(5,15);
}else{
m_walk_around_timer = 0.1*myrand_range(20,40);
@ -475,7 +481,7 @@ void MobSAO::step(float dtime, bool send_recommended)
v3f dir = diff;
dir.normalize();
float speed = BS;
if (m.motion == MM_SEEKER && disturbing_player)
if (mot == MM_SEEKER && m.level == MOB_AGGRESSIVE && disturbing_player)
speed = BS * 2.0;
if (m_falling)
speed = BS * 3.0;
@ -493,19 +499,21 @@ void MobSAO::step(float dtime, bool send_recommended)
}
}
if (m.motion == MM_WANDER) {
mot = getMotion();
if (mot == MM_WANDER) {
stepMotionWander(dtime);
}else if (m.motion == MM_SEEKER) {
}else if (mot == MM_SEEKER) {
if (!disturbing_player) {
stepMotionWander(dtime);
}else{
stepMotionSeeker(dtime);
}
}else if (m.motion == MM_SENTRY) {
}else if (mot == MM_SENTRY) {
stepMotionSentry(dtime);
}else if (m.motion == MM_THROWN) {
}else if (mot == MM_THROWN) {
stepMotionThrown(dtime);
}else if (m.motion == MM_CONSTANT) {
}else if (mot == MM_CONSTANT) {
stepMotionConstant(dtime);
}
@ -1104,6 +1112,7 @@ u16 MobSAO::punch(const std::string &toolname, v3f dir, const std::string &playe
m_disturb_timer = 0;
m_disturbing_player = playername;
m_next_pos_exists = false; // Cancel moving immediately
m_angry = true;
m_yaw = wrapDegrees_180(180./PI*atan2(dir.Z, dir.X) + 180.);
v3f new_base_position = m_base_position + dir * BS;

View File

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serverobject.h"
#include "mapnode.h"
#include "content_object.h"
#include "content_mob.h"
class ItemSAO : public ServerActiveObject
{
@ -66,6 +67,13 @@ private:
void sendPosition();
void doDamage(u16 d);
MobMotion getMotion()
{
if (m_angry)
return content_mob_features(m_content).angry_motion;
return content_mob_features(m_content).motion;
}
void stepMotionWander(float dtime);
void stepMotionSeeker(float dtime);
void stepMotionSentry(float dtime);
@ -90,6 +98,7 @@ private:
float m_age;
u8 m_hp;
bool m_angry;
float m_disturb_timer;
std::string m_disturbing_player;