Make dungeon masters though and make oerkkis disappear when they get to you (because hitting them doesn't work for some unknown reason)

master
Perttu Ahola 2011-10-15 16:04:25 +03:00
parent 94dfececf6
commit 3f58028d31
7 changed files with 74 additions and 18 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -1574,7 +1574,7 @@ void Client::clickActiveObject(u8 button, u16 id, u16 item_i)
v3f dir = (objpos - playerpos).normalize(); v3f dir = (objpos - playerpos).normalize();
bool disable_send = obj->directReportPunch(toolname, dir); bool disable_send = obj->directReportPunch(toolname, dir);
if(disable_send) if(disable_send)
return; return;
} }

View File

@ -606,7 +606,7 @@ void Oerkki1CAO::step(float dtime, ClientEnvironment *env)
v2f playerpos_2d(playerpos.X,playerpos.Z); v2f playerpos_2d(playerpos.X,playerpos.Z);
v2f objectpos_2d(m_position.X,m_position.Z); v2f objectpos_2d(m_position.X,m_position.Z);
if(fabs(m_position.Y - playerpos.Y) < 3.0*BS && if(fabs(m_position.Y - playerpos.Y) < 1.5*BS &&
objectpos_2d.getDistanceFrom(playerpos_2d) < 1.5*BS) objectpos_2d.getDistanceFrom(playerpos_2d) < 1.5*BS)
{ {
if(m_attack_interval.step(dtime, 0.5)) if(m_attack_interval.step(dtime, 0.5))
@ -709,6 +709,18 @@ void Oerkki1CAO::initialize(const std::string &data)
updateNodePos(); updateNodePos();
} }
bool Oerkki1CAO::directReportPunch(const std::string &toolname, v3f dir)
{
m_damage_visual_timer = 1.0;
m_position += dir * BS;
pos_translator.sharpen();
pos_translator.update(m_position);
updateNodePos();
return false;
}
/* /*
FireflyCAO FireflyCAO
*/ */
@ -1003,9 +1015,9 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
v3f cam_to_mob = m_node->getAbsolutePosition() - camera->getAbsolutePosition(); v3f cam_to_mob = m_node->getAbsolutePosition() - camera->getAbsolutePosition();
cam_to_mob.normalize(); cam_to_mob.normalize();
int col = 0; int col = 0;
if(cam_to_mob.Y > 0.7) if(cam_to_mob.Y > 0.75)
col = 5; col = 5;
else if(cam_to_mob.Y < -0.7) else if(cam_to_mob.Y < -0.75)
col = 4; col = 4;
else{ else{
float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / M_PI * 180.; float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / M_PI * 180.;

View File

@ -248,6 +248,9 @@ public:
{return pos_translator.vect_show;} {return pos_translator.vect_show;}
//{return m_position;} //{return m_position;}
// If returns true, punch will not be sent to the server
bool directReportPunch(const std::string &toolname, v3f dir);
private: private:
IntervalLimiter m_attack_interval; IntervalLimiter m_attack_interval;
core::aabbox3d<f32> m_selection_box; core::aabbox3d<f32> m_selection_box;

View File

@ -523,13 +523,14 @@ void Oerkki1SAO::step(float dtime, bool send_recommended)
Player *player = *i; Player *player = *i;
v3f playerpos = player->getPosition(); v3f playerpos = player->getPosition();
f32 dist = m_base_position.getDistanceFrom(playerpos); f32 dist = m_base_position.getDistanceFrom(playerpos);
if(dist < BS*1.45) if(dist < BS*0.6)
{ {
m_removed = true;
return;
player_is_too_close = true; player_is_too_close = true;
near_player_pos = playerpos; near_player_pos = playerpos;
break;
} }
else if(dist < BS*15.0) else if(dist < BS*15.0 && !player_is_too_close)
{ {
player_is_close = true; player_is_close = true;
near_player_pos = playerpos; near_player_pos = playerpos;
@ -681,7 +682,7 @@ u16 Oerkki1SAO::punch(const std::string &toolname, v3f dir)
{ {
m_speed_f += dir*12*BS; m_speed_f += dir*12*BS;
u16 amount = 5; u16 amount = 20;
doDamage(amount); doDamage(amount);
return 65536/100; return 65536/100;
} }
@ -917,7 +918,9 @@ MobV2SAO::MobV2SAO(ServerEnvironment *env, u16 id, v3f pos,
m_shooting(false), m_shooting(false),
m_shooting_timer(0), m_shooting_timer(0),
m_falling(false), m_falling(false),
m_disturb_timer(100000) m_disturb_timer(100000),
m_random_disturb_timer(0),
m_shoot_y(0)
{ {
ServerActiveObject::registerType(getType(), create); ServerActiveObject::registerType(getType(), create);
@ -1073,18 +1076,46 @@ void MobV2SAO::step(float dtime, bool send_recommended)
return; return;
} }
m_random_disturb_timer += dtime;
if(m_random_disturb_timer >= 5.0)
{
m_random_disturb_timer = 0;
// Check connected players
core::list<Player*> players = m_env->getPlayers(true);
core::list<Player*>::Iterator i;
for(i = players.begin();
i != players.end(); i++)
{
Player *player = *i;
v3f playerpos = player->getPosition();
f32 dist = m_base_position.getDistanceFrom(playerpos);
if(dist < BS*16)
{
if(myrand_range(0,2) == 0){
dstream<<"ACTION: id="<<m_id<<" got randomly disturbed by "
<<player->getName()<<std::endl;
m_disturbing_player = player->getName();
m_disturb_timer = 0;
break;
}
}
}
}
Player *disturbing_player = Player *disturbing_player =
m_env->getPlayer(m_disturbing_player.c_str()); m_env->getPlayer(m_disturbing_player.c_str());
v3f disturbing_player_off = v3f(0,1,0); v3f disturbing_player_off = v3f(0,1,0);
v3f disturbing_player_norm = v3f(0,1,0);
float disturbing_player_distance = 1000000; float disturbing_player_distance = 1000000;
float disturbing_player_dir = 0; float disturbing_player_dir = 0;
if(disturbing_player){ if(disturbing_player){
disturbing_player_off = disturbing_player_off =
disturbing_player->getPosition() - m_base_position; disturbing_player->getPosition() - m_base_position;
disturbing_player_distance = disturbing_player_off.getLength(); disturbing_player_distance = disturbing_player_off.getLength();
disturbing_player_off.normalize(); disturbing_player_norm = disturbing_player_off;
disturbing_player_dir = 180./M_PI*atan2(disturbing_player_off.Z, disturbing_player_norm.normalize();
disturbing_player_off.X); disturbing_player_dir = 180./M_PI*atan2(disturbing_player_norm.Z,
disturbing_player_norm.X);
} }
m_disturb_timer += dtime; m_disturb_timer += dtime;
@ -1100,6 +1131,8 @@ void MobV2SAO::step(float dtime, bool send_recommended)
shoot_pos.Y += m_properties->getFloat("shoot_y") * BS; shoot_pos.Y += m_properties->getFloat("shoot_y") * BS;
if(shoot_type == "fireball"){ if(shoot_type == "fireball"){
v3f dir(cos(m_yaw/180*PI),0,sin(m_yaw/180*PI)); v3f dir(cos(m_yaw/180*PI),0,sin(m_yaw/180*PI));
dir.Y = m_shoot_y;
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;
dstream<<__FUNCTION_NAME<<": Shooting fireball from "<<PP(pos) dstream<<__FUNCTION_NAME<<": Shooting fireball from "<<PP(pos)
@ -1130,13 +1163,16 @@ 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;
if(m_shoot_reload_timer >= reload_time && !m_next_pos_exists) if(!m_shooting && m_shoot_reload_timer >= reload_time &&
!m_next_pos_exists)
{ {
m_shoot_y = 0;
if(m_disturb_timer < 30.0 && disturbing_player && if(m_disturb_timer < 30.0 && disturbing_player &&
disturbing_player_distance < 16*BS && disturbing_player_distance < 16*BS &&
fabs(disturbing_player_off.Y) < 5*BS){ 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_reload_timer = 0.0; m_shoot_reload_timer = 0.0;
m_shooting = true; m_shooting = true;
@ -1292,9 +1328,13 @@ 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();
dstream<<"ACTION: "<<playername<<" punches id="<<m_id
<<" with a \""<<toolname<<"\""<<std::endl;
m_disturb_timer = 0; m_disturb_timer = 0;
m_disturbing_player = playername; m_disturbing_player = playername;
m_next_pos_exists = false; // Cancel moving immediately
m_yaw = wrapDegrees_180(180./M_PI*atan2(dir.Z, dir.X) + 180.); m_yaw = wrapDegrees_180(180./M_PI*atan2(dir.Z, dir.X) + 180.);
v3f new_base_position = m_base_position + dir * BS; v3f new_base_position = m_base_position + dir * BS;
@ -1313,14 +1353,13 @@ u16 MobV2SAO::punch(const std::string &toolname, v3f dir,
sendPosition(); sendPosition();
u16 amount = 2; u16 amount = 2;
dstream<<"id="<<m_id<<": punch with \""<<toolname<<"\""<<std::endl;
/* See tool names in inventory.h */ /* See tool names in inventory.h */
if(toolname == "WSword") if(toolname == "WSword")
amount = 4; amount = 4;
if(toolname == "STSword") if(toolname == "STSword")
amount = 7; amount = 6;
if(toolname == "SteelSword") if(toolname == "SteelSword")
amount = 10; amount = 8;
if(toolname == "STAxe") if(toolname == "STAxe")
amount = 3; amount = 3;
if(toolname == "SteelAxe") if(toolname == "SteelAxe")

View File

@ -186,6 +186,8 @@ private:
bool m_falling; bool m_falling;
float m_disturb_timer; float m_disturb_timer;
std::string m_disturbing_player; std::string m_disturbing_player;
float m_random_disturb_timer;
float m_shoot_y;
Settings *m_properties; Settings *m_properties;
}; };

View File

@ -647,7 +647,7 @@ static void getMob_dungeon_master(Settings &properties)
{ {
properties.set("looks", "dungeon_master"); properties.set("looks", "dungeon_master");
properties.setFloat("yaw", 1.57); properties.setFloat("yaw", 1.57);
properties.setFloat("hp", 20); properties.setFloat("hp", 30);
properties.setBool("bright_shooting", true); properties.setBool("bright_shooting", true);
properties.set("shoot_type", "fireball"); properties.set("shoot_type", "fireball");
properties.set("shoot_y", "0.7"); properties.set("shoot_y", "0.7");