start transfering old mobs to new format

This commit is contained in:
darkrose 2014-09-25 20:38:37 +10:00
parent bf44366a5e
commit bf49ed590b
11 changed files with 91 additions and 115 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

View File

@ -35,120 +35,6 @@ static void setBillboardTextureMatrix(scene::IBillboardSceneNode *bill,
core::map<u16, ClientActiveObject::Factory> ClientActiveObject::m_types;
/*
TestCAO
*/
// Prototype
TestCAO proto_TestCAO;
TestCAO::TestCAO():
ClientActiveObject(0),
m_node(NULL),
m_position(v3f(0,10*BS,0))
{
ClientActiveObject::registerType(getType(), create);
}
TestCAO::~TestCAO()
{
}
ClientActiveObject* TestCAO::create()
{
return new TestCAO();
}
void TestCAO::addToScene(scene::ISceneManager *smgr)
{
if(m_node != NULL)
return;
video::IVideoDriver* driver = smgr->getVideoDriver();
scene::SMesh *mesh = new scene::SMesh();
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
video::SColor c(255,255,255,255);
video::S3DVertex vertices[4] =
{
video::S3DVertex(-BS/2,-BS/4,0, 0,0,0, c, 0,1),
video::S3DVertex(BS/2,-BS/4,0, 0,0,0, c, 1,1),
video::S3DVertex(BS/2,BS/4,0, 0,0,0, c, 1,0),
video::S3DVertex(-BS/2,BS/4,0, 0,0,0, c, 0,0),
};
u16 indices[] = {0,1,2,2,3,0};
buf->append(vertices, 4, indices, 6);
// Set material
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
buf->getMaterial().setTexture
(0, driver->getTexture(getTexturePath("rat.png").c_str()));
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
// Add to mesh
mesh->addMeshBuffer(buf);
buf->drop();
m_node = smgr->addMeshSceneNode(mesh, NULL);
mesh->drop();
updateNodePos();
}
void TestCAO::removeFromScene()
{
if(m_node == NULL)
return;
m_node->remove();
m_node = NULL;
}
void TestCAO::updateLight(u8 light_at_pos)
{
}
v3s16 TestCAO::getLightPosition()
{
return floatToInt(m_position, BS);
}
void TestCAO::updateNodePos()
{
if(m_node == NULL)
return;
m_node->setPosition(m_position);
//m_node->setRotation(v3f(0, 45, 0));
}
void TestCAO::step(float dtime, ClientEnvironment *env)
{
if(m_node)
{
v3f rot = m_node->getRotation();
//infostream<<"dtime="<<dtime<<", rot.Y="<<rot.Y<<std::endl;
rot.Y += dtime * 180;
m_node->setRotation(rot);
}
}
void TestCAO::processMessage(const std::string &data)
{
infostream<<"TestCAO: Got data: "<<data<<std::endl;
std::istringstream is(data, std::ios::binary);
u16 cmd;
is>>cmd;
if(cmd == 0)
{
v3f newpos;
is>>newpos.X;
is>>newpos.Y;
is>>newpos.Z;
m_position = newpos;
updateNodePos();
}
}
/*
ItemCAO
*/

View File

@ -60,4 +60,73 @@ void content_mob_init()
content_t i;
MobFeatures *f = NULL;
i = CONTENT_MOB_RAT;
f = &g_content_mob_features[i];
f->content = i;
f->level = MOB_PASSIVE;
f->model = "rat.x";
f->setTexture("mob_rat.png");
f->punch_action = MPA_PICKUP;
f->motion = MM_WANDER;
f->setCollisionBox(aabb3f(-BS/3.,0.0,-BS/3., BS/3.,BS/2.,BS/3.));
i = CONTENT_MOB_FIREFLY;
f = &g_content_mob_features[i];
f->content = i;
f->level = MOB_PASSIVE;
f->setTexture("mob_firefly.png");
f->punch_action = MPA_PICKUP;
f->motion = MM_WANDER;
f->glow_light = LIGHT_MAX-1;
f->setCollisionBox(aabb3f(-BS/3.,0.0,-BS/3., BS/3.,BS/2.,BS/3.));
i = CONTENT_MOB_OERKKI;
f = &g_content_mob_features[i];
f->content = i;
f->level = MOB_AGGRESSIVE;
f->model = "oerkki.x";
f->setTexture("mob_oerkki.png");
f->punch_action = MPA_HARM;
f->motion = MM_SEEKER;
f->setCollisionBox(aabb3f(-BS/3.,0.0,-BS/3., BS/3.,BS*2.,BS/3.));
i = CONTENT_MOB_DUNGEON_MASTER;
f = &g_content_mob_features[i];
f->content = i;
f->level = MOB_DESTRUCTIVE;
f->model = "dungeon_master.x";
f->setTexture("mob_dungeon_master.png");
f->punch_action = MPA_HARM;
f->motion = MM_SENTRY;
f->attack_throw_object = CONTENT_MOB_FIREBALL;
f->attack_glow_light = LIGHT_MAX-1;
f->setCollisionBox(aabb3f(-0.4*BS,-0.4*BS,-0.4*BS, 0.4*BS,0.8*BS,0.4*BS));
i = CONTENT_MOB_FIREBALL;
f = &g_content_mob_features[i];
f->content = i;
f->level = MOB_DESTRUCTIVE;
f->setTexture("mob_fireball.png");
f->punch_action = MPA_IGNORE;
f->motion = MM_THROWN;
f->motion_type = MMT_FLY;
f->glow_light = LIGHT_MAX-1;
f->setCollisionBox(aabb3f(-BS/3.,0.0,-BS/3., BS/3.,BS/2.,BS/3.));
i = CONTENT_MOB_DEER;
f = &g_content_mob_features[i];
f->content = i;
i = CONTENT_MOB_SHEEP;
f = &g_content_mob_features[i];
f->content = i;
i = CONTENT_MOB_FISH;
f = &g_content_mob_features[i];
f->content = i;
i = CONTENT_MOB_SHARK;
f = &g_content_mob_features[i];
f->content = i;
i = CONTENT_MOB_WOLF;
f = &g_content_mob_features[i];
f->content = i;
}

View File

@ -34,6 +34,7 @@ enum MobPunchAction
{
MPA_IGNORE = 0,
MPA_DIE,
MPA_HARM,
MPA_PICKUP
};
@ -42,13 +43,15 @@ enum MobMotion
MM_STATIC = 0,
MM_WANDER,
MM_SEEKER,
MM_SENTRY
MM_SENTRY,
MM_THROWN
};
enum MobMotionType
{
MMT_WALK = 0,
MMT_FLY,
MMT_FLYLOW,
MMT_SWIM
};
@ -85,8 +88,12 @@ struct MobFeatures {
MobState spawn_state;
bool is_tamable;
content_t tamed_mob;
content_t attack_throw_object;
u8 glow_light;
u8 attack_glow_light;
u16 hp;
std::string dropped_item;
f32 lifetime;
MobFeatures()
{
@ -156,6 +163,9 @@ struct MobFeatures {
spawn_state = MS_WILD;
is_tamable = false;
tamed_mob = CONTENT_IGNORE;
attack_throw_object = CONTENT_IGNORE;
glow_light = 0;
attack_glow_light = 0;
hp = 20;
dropped_item = "";
}
@ -181,4 +191,15 @@ inline std::string mobLevelS(u8 level)
void content_mob_init();
#define CONTENT_MOB_RAT (CONTENT_MOB_MASK | 0x01)
#define CONTENT_MOB_FIREFLY (CONTENT_MOB_MASK | 0x02)
#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_FISH (CONTENT_MOB_MASK | 0x08)
#define CONTENT_MOB_SHARK (CONTENT_MOB_MASK | 0x09)
#define CONTENT_MOB_WOLF (CONTENT_MOB_MASK | 0x0A)
#endif