Make dungeon masters not shoot the walls with no reason
parent
143dce6672
commit
6470743e51
|
@ -84,7 +84,6 @@ void TestSAO::step(float dtime, bool send_recommended)
|
||||||
if(m_timer1 < 0.0)
|
if(m_timer1 < 0.0)
|
||||||
{
|
{
|
||||||
m_timer1 += 0.125;
|
m_timer1 += 0.125;
|
||||||
//infostream<<"TestSAO: id="<<getId()<<" sending data"<<std::endl;
|
|
||||||
|
|
||||||
std::string data;
|
std::string data;
|
||||||
|
|
||||||
|
@ -1091,8 +1090,10 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||||
f32 dist = m_base_position.getDistanceFrom(playerpos);
|
f32 dist = m_base_position.getDistanceFrom(playerpos);
|
||||||
if(dist < BS*16)
|
if(dist < BS*16)
|
||||||
{
|
{
|
||||||
if(myrand_range(0,2) == 0){
|
if(myrand_range(0,3) == 0){
|
||||||
infostream<<"ACTION: id="<<m_id<<" got randomly disturbed by "
|
actionstream<<"Mob id="<<m_id<<" at "
|
||||||
|
<<PP(m_base_position/BS)
|
||||||
|
<<" got randomly disturbed by "
|
||||||
<<player->getName()<<std::endl;
|
<<player->getName()<<std::endl;
|
||||||
m_disturbing_player = player->getName();
|
m_disturbing_player = player->getName();
|
||||||
m_disturb_timer = 0;
|
m_disturb_timer = 0;
|
||||||
|
@ -1135,7 +1136,8 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||||
dir.normalize();
|
dir.normalize();
|
||||||
v3f speed = dir * BS * 10.0;
|
v3f speed = dir * BS * 10.0;
|
||||||
v3f pos = m_base_position + shoot_pos;
|
v3f pos = m_base_position + shoot_pos;
|
||||||
infostream<<__FUNCTION_NAME<<": Shooting fireball from "<<PP(pos)
|
infostream<<__FUNCTION_NAME<<": Mob id="<<m_id
|
||||||
|
<<" shooting fireball from "<<PP(pos)
|
||||||
<<" at speed "<<PP(speed)<<std::endl;
|
<<" at speed "<<PP(speed)<<std::endl;
|
||||||
Settings properties;
|
Settings properties;
|
||||||
properties.set("looks", "fireball");
|
properties.set("looks", "fireball");
|
||||||
|
@ -1152,7 +1154,8 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||||
//m_env->addActiveObjectAsStatic(obj);
|
//m_env->addActiveObjectAsStatic(obj);
|
||||||
m_env->addActiveObject(obj);
|
m_env->addActiveObject(obj);
|
||||||
} else {
|
} else {
|
||||||
infostream<<__FUNCTION_NAME<<": Unknown shoot_type="<<shoot_type
|
infostream<<__FUNCTION_NAME<<": Mob id="<<m_id
|
||||||
|
<<": Unknown shoot_type="<<shoot_type
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1163,16 +1166,23 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||||
if(m_disturb_timer <= 15.0)
|
if(m_disturb_timer <= 15.0)
|
||||||
reload_time = 3.0;
|
reload_time = 3.0;
|
||||||
|
|
||||||
|
bool shoot_without_player = false;
|
||||||
|
if(m_properties->getBool("mindless_rage"))
|
||||||
|
shoot_without_player = true;
|
||||||
|
|
||||||
if(!m_shooting && m_shoot_reload_timer >= reload_time &&
|
if(!m_shooting && m_shoot_reload_timer >= reload_time &&
|
||||||
!m_next_pos_exists)
|
!m_next_pos_exists &&
|
||||||
|
(m_disturb_timer <= 60.0 || shoot_without_player))
|
||||||
{
|
{
|
||||||
m_shoot_y = 0;
|
m_shoot_y = 0;
|
||||||
if(m_disturb_timer < 30.0 && disturbing_player &&
|
if(m_disturb_timer < 60.0 && disturbing_player &&
|
||||||
disturbing_player_distance < 16*BS &&
|
disturbing_player_distance < 16*BS &&
|
||||||
fabs(disturbing_player_norm.Y) < 0.8){
|
fabs(disturbing_player_norm.Y) < 0.8){
|
||||||
m_yaw = disturbing_player_dir;
|
m_yaw = disturbing_player_dir;
|
||||||
sendPosition();
|
sendPosition();
|
||||||
m_shoot_y += disturbing_player_norm.Y;
|
m_shoot_y += disturbing_player_norm.Y;
|
||||||
|
} else {
|
||||||
|
m_shoot_y = 0.01 * myrand_range(-30,10);
|
||||||
}
|
}
|
||||||
m_shoot_reload_timer = 0.0;
|
m_shoot_reload_timer = 0.0;
|
||||||
m_shooting = true;
|
m_shooting = true;
|
||||||
|
@ -1229,7 +1239,8 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||||
m_base_position = pos_f;
|
m_base_position = pos_f;
|
||||||
|
|
||||||
if((pos_f - next_pos_f).getLength() < 0.1 || arrived){
|
if((pos_f - next_pos_f).getLength() < 0.1 || arrived){
|
||||||
//infostream<<"id="<<m_id<<": arrived to "<<PP(m_next_pos_i)<<std::endl;
|
verbosestream<<"Mob id="<<m_id<<": arrived to "
|
||||||
|
<<PP(m_next_pos_i)<<std::endl;
|
||||||
m_next_pos_exists = false;
|
m_next_pos_exists = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1271,16 +1282,10 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||||
}
|
}
|
||||||
u32 order[3*3*3];
|
u32 order[3*3*3];
|
||||||
get_random_u32_array(order, num_dps);
|
get_random_u32_array(order, num_dps);
|
||||||
/*infostream<<"At pos "<<PP(pos_i)<<"; Random array: ";
|
|
||||||
for(int i=0; i<num_dps; i++){
|
|
||||||
infostream<<order[i]<<" ";
|
|
||||||
}
|
|
||||||
infostream<<std::endl;*/
|
|
||||||
for(int i=0; i<num_dps; i++){
|
for(int i=0; i<num_dps; i++){
|
||||||
v3s16 p = dps[order[i]] + pos_i;
|
v3s16 p = dps[order[i]] + pos_i;
|
||||||
bool is_free = checkFreeAndWalkablePosition(map,
|
bool is_free = checkFreeAndWalkablePosition(map,
|
||||||
p + pos_size_off, size_blocks);
|
p + pos_size_off, size_blocks);
|
||||||
//infostream<<PP(p)<<" is_free="<<is_free<<std::endl;
|
|
||||||
if(!is_free)
|
if(!is_free)
|
||||||
continue;
|
continue;
|
||||||
m_next_pos_i = p;
|
m_next_pos_i = p;
|
||||||
|
@ -1310,7 +1315,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
infostream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
|
errorstream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
|
||||||
<<m_move_type<<"\""<<std::endl;
|
<<m_move_type<<"\""<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,7 +1334,7 @@ u16 MobV2SAO::punch(const std::string &toolname, v3f dir,
|
||||||
assert(m_env);
|
assert(m_env);
|
||||||
Map *map = &m_env->getMap();
|
Map *map = &m_env->getMap();
|
||||||
|
|
||||||
infostream<<"ACTION: "<<playername<<" punches id="<<m_id
|
actionstream<<playername<<" punches mob id="<<m_id
|
||||||
<<" with a \""<<toolname<<"\" at "
|
<<" with a \""<<toolname<<"\" at "
|
||||||
<<PP(m_base_position/BS)<<std::endl;
|
<<PP(m_base_position/BS)<<std::endl;
|
||||||
|
|
||||||
|
@ -1405,6 +1410,7 @@ void MobV2SAO::setPropertyDefaults()
|
||||||
m_properties->setDefault("size", "(1,2)");
|
m_properties->setDefault("size", "(1,2)");
|
||||||
m_properties->setDefault("shoot_type", "fireball");
|
m_properties->setDefault("shoot_type", "fireball");
|
||||||
m_properties->setDefault("shoot_y", "0");
|
m_properties->setDefault("shoot_y", "0");
|
||||||
|
m_properties->setDefault("mindless_rage", "false");
|
||||||
}
|
}
|
||||||
void MobV2SAO::readProperties()
|
void MobV2SAO::readProperties()
|
||||||
{
|
{
|
||||||
|
|
|
@ -657,6 +657,7 @@ static void getMob_dungeon_master(Settings &properties)
|
||||||
properties.set("player_hit_damage", "1");
|
properties.set("player_hit_damage", "1");
|
||||||
properties.set("player_hit_distance", "1.0");
|
properties.set("player_hit_distance", "1.0");
|
||||||
properties.set("player_hit_interval", "0.5");
|
properties.set("player_hit_interval", "0.5");
|
||||||
|
properties.setBool("mindless_rage", myrand_range(0,100)==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerEnvironment::step(float dtime)
|
void ServerEnvironment::step(float dtime)
|
||||||
|
@ -866,7 +867,7 @@ void ServerEnvironment::step(float dtime)
|
||||||
// TODO: Implement usage of ActiveBlockModifier
|
// TODO: Implement usage of ActiveBlockModifier
|
||||||
|
|
||||||
// Find out how many objects the block contains
|
// Find out how many objects the block contains
|
||||||
u32 active_object_count = block->m_static_objects.m_active.size();
|
//u32 active_object_count = block->m_static_objects.m_active.size();
|
||||||
// Find out how many objects this and all the neighbors contain
|
// Find out how many objects this and all the neighbors contain
|
||||||
u32 active_object_count_wider = 0;
|
u32 active_object_count_wider = 0;
|
||||||
for(s16 x=-1; x<=1; x++)
|
for(s16 x=-1; x<=1; x++)
|
||||||
|
|
Loading…
Reference in New Issue