mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-12 16:58:39 +00:00
Entity damage system WIP; Remove C++ mobs
This commit is contained in:
parent
f1cb91cd93
commit
e9cdb938fe
14 changed files with 516 additions and 3296 deletions
|
@ -88,119 +88,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class SpawnRatsAroundTreesABM : public ActiveBlockModifier
|
||||
{
|
||||
private:
|
||||
public:
|
||||
virtual std::set<std::string> getTriggerContents()
|
||||
{
|
||||
std::set<std::string> s;
|
||||
s.insert("tree");
|
||||
s.insert("jungletree");
|
||||
return s;
|
||||
}
|
||||
virtual float getTriggerInterval()
|
||||
{ return 10.0; }
|
||||
virtual u32 getTriggerChance()
|
||||
{ return 200; }
|
||||
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
|
||||
u32 active_object_count, u32 active_object_count_wider)
|
||||
{
|
||||
if(active_object_count_wider != 0)
|
||||
return;
|
||||
|
||||
INodeDefManager *ndef = env->getGameDef()->ndef();
|
||||
ServerMap *map = &env->getServerMap();
|
||||
|
||||
v3s16 p1 = p + v3s16(myrand_range(-2, 2),
|
||||
0, myrand_range(-2, 2));
|
||||
MapNode n1 = map->getNodeNoEx(p1);
|
||||
MapNode n1b = map->getNodeNoEx(p1+v3s16(0,-1,0));
|
||||
if(n1b.getContent() == ndef->getId("dirt_with_grass") &&
|
||||
n1.getContent() == CONTENT_AIR)
|
||||
{
|
||||
v3f pos = intToFloat(p1, BS);
|
||||
ServerActiveObject *obj = new RatSAO(env, pos);
|
||||
env->addActiveObject(obj);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static void getMob_dungeon_master(Settings &properties)
|
||||
{
|
||||
properties.set("looks", "dungeon_master");
|
||||
properties.setFloat("yaw", 1.57);
|
||||
properties.setFloat("hp", 30);
|
||||
properties.setBool("bright_shooting", true);
|
||||
properties.set("shoot_type", "fireball");
|
||||
properties.set("shoot_y", "0.7");
|
||||
properties.set("player_hit_damage", "1");
|
||||
properties.set("player_hit_distance", "1.0");
|
||||
properties.set("player_hit_interval", "0.5");
|
||||
properties.setBool("mindless_rage", myrand_range(0,100)==0);
|
||||
}
|
||||
|
||||
class SpawnInCavesABM : public ActiveBlockModifier
|
||||
{
|
||||
private:
|
||||
public:
|
||||
virtual std::set<std::string> getTriggerContents()
|
||||
{
|
||||
std::set<std::string> s;
|
||||
s.insert("stone");
|
||||
s.insert("mossycobble");
|
||||
return s;
|
||||
}
|
||||
virtual float getTriggerInterval()
|
||||
{ return 2.0; }
|
||||
virtual u32 getTriggerChance()
|
||||
{ return 1000; }
|
||||
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
|
||||
u32 active_object_count, u32 active_object_count_wider)
|
||||
{
|
||||
if(active_object_count_wider != 0)
|
||||
return;
|
||||
|
||||
INodeDefManager *ndef = env->getGameDef()->ndef();
|
||||
ServerMap *map = &env->getServerMap();
|
||||
|
||||
v3s16 p1 = p + v3s16(0,1,0);
|
||||
MapNode n1a = map->getNodeNoEx(p1+v3s16(0,0,0));
|
||||
if(n1a.getLightBlend(env->getDayNightRatio(), ndef) <= 3){
|
||||
MapNode n1b = map->getNodeNoEx(p1+v3s16(0,1,0));
|
||||
if(n1a.getContent() == CONTENT_AIR &&
|
||||
n1b.getContent() == CONTENT_AIR)
|
||||
{
|
||||
v3f pos = intToFloat(p1, BS);
|
||||
int i = myrand()%5;
|
||||
if(i == 0 || i == 1){
|
||||
actionstream<<"A dungeon master spawns at "
|
||||
<<PP(p1)<<std::endl;
|
||||
Settings properties;
|
||||
getMob_dungeon_master(properties);
|
||||
ServerActiveObject *obj = new MobV2SAO(
|
||||
env, pos, &properties);
|
||||
env->addActiveObject(obj);
|
||||
} else if(i == 2 || i == 3){
|
||||
actionstream<<"Rats spawn at "
|
||||
<<PP(p1)<<std::endl;
|
||||
for(int j=0; j<3; j++){
|
||||
ServerActiveObject *obj = new RatSAO(
|
||||
env, pos);
|
||||
env->addActiveObject(obj);
|
||||
}
|
||||
} else {
|
||||
actionstream<<"An oerkki spawns at "
|
||||
<<PP(p1)<<std::endl;
|
||||
ServerActiveObject *obj = new Oerkki1SAO(
|
||||
env, pos);
|
||||
env->addActiveObject(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class MakeTreesFromSaplingsABM : public ActiveBlockModifier
|
||||
{
|
||||
private:
|
||||
|
@ -261,8 +148,6 @@ void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef)
|
|||
{
|
||||
env->addActiveBlockModifier(new GrowGrassABM());
|
||||
env->addActiveBlockModifier(new RemoveGrassABM());
|
||||
env->addActiveBlockModifier(new SpawnRatsAroundTreesABM());
|
||||
env->addActiveBlockModifier(new SpawnInCavesABM());
|
||||
env->addActiveBlockModifier(new MakeTreesFromSaplingsABM());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue