From: Perttu Ahola Date: Sat, 15 Oct 2011 13:04:25 +0000 (+0300) Subject: Make dungeon masters though and make oerkkis disappear when they get to you (because... X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=3f58028d3198e77ce26d09680f0a637188610871;p=zefram%2Fminetest%2Fminetest_engine.git Make dungeon masters though and make oerkkis disappear when they get to you (because hitting them doesn't work for some unknown reason) --- diff --git a/data/dungeon_master.png b/data/dungeon_master.png index 77e015c1..3457c822 100644 Binary files a/data/dungeon_master.png and b/data/dungeon_master.png differ diff --git a/src/client.cpp b/src/client.cpp index 1af91703..c40c9e51 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1574,7 +1574,7 @@ void Client::clickActiveObject(u8 button, u16 id, u16 item_i) v3f dir = (objpos - playerpos).normalize(); bool disable_send = obj->directReportPunch(toolname, dir); - + if(disable_send) return; } diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 53e4a6d1..d9b88967 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -606,7 +606,7 @@ void Oerkki1CAO::step(float dtime, ClientEnvironment *env) v2f playerpos_2d(playerpos.X,playerpos.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) { if(m_attack_interval.step(dtime, 0.5)) @@ -709,6 +709,18 @@ void Oerkki1CAO::initialize(const std::string &data) 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 */ @@ -1003,9 +1015,9 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env) v3f cam_to_mob = m_node->getAbsolutePosition() - camera->getAbsolutePosition(); cam_to_mob.normalize(); int col = 0; - if(cam_to_mob.Y > 0.7) + if(cam_to_mob.Y > 0.75) col = 5; - else if(cam_to_mob.Y < -0.7) + else if(cam_to_mob.Y < -0.75) col = 4; else{ float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / M_PI * 180.; diff --git a/src/content_cao.h b/src/content_cao.h index a362b6be..963e1a48 100644 --- a/src/content_cao.h +++ b/src/content_cao.h @@ -248,6 +248,9 @@ public: {return pos_translator.vect_show;} //{return m_position;} + // If returns true, punch will not be sent to the server + bool directReportPunch(const std::string &toolname, v3f dir); + private: IntervalLimiter m_attack_interval; core::aabbox3d m_selection_box; diff --git a/src/content_sao.cpp b/src/content_sao.cpp index d81e3f87..c849c7a9 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -523,13 +523,14 @@ void Oerkki1SAO::step(float dtime, bool send_recommended) Player *player = *i; v3f playerpos = player->getPosition(); 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; 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; near_player_pos = playerpos; @@ -681,7 +682,7 @@ u16 Oerkki1SAO::punch(const std::string &toolname, v3f dir) { m_speed_f += dir*12*BS; - u16 amount = 5; + u16 amount = 20; doDamage(amount); return 65536/100; } @@ -917,7 +918,9 @@ MobV2SAO::MobV2SAO(ServerEnvironment *env, u16 id, v3f pos, m_shooting(false), m_shooting_timer(0), m_falling(false), - m_disturb_timer(100000) + m_disturb_timer(100000), + m_random_disturb_timer(0), + m_shoot_y(0) { ServerActiveObject::registerType(getType(), create); @@ -1073,18 +1076,46 @@ void MobV2SAO::step(float dtime, bool send_recommended) return; } + m_random_disturb_timer += dtime; + if(m_random_disturb_timer >= 5.0) + { + m_random_disturb_timer = 0; + // Check connected players + core::list players = m_env->getPlayers(true); + core::list::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="<getName()<getName(); + m_disturb_timer = 0; + break; + } + } + } + } + Player *disturbing_player = m_env->getPlayer(m_disturbing_player.c_str()); v3f disturbing_player_off = v3f(0,1,0); + v3f disturbing_player_norm = v3f(0,1,0); float disturbing_player_distance = 1000000; float disturbing_player_dir = 0; if(disturbing_player){ disturbing_player_off = disturbing_player->getPosition() - m_base_position; disturbing_player_distance = disturbing_player_off.getLength(); - disturbing_player_off.normalize(); - disturbing_player_dir = 180./M_PI*atan2(disturbing_player_off.Z, - disturbing_player_off.X); + disturbing_player_norm = disturbing_player_off; + disturbing_player_norm.normalize(); + disturbing_player_dir = 180./M_PI*atan2(disturbing_player_norm.Z, + disturbing_player_norm.X); } 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; if(shoot_type == "fireball"){ 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 pos = m_base_position + shoot_pos; dstream<<__FUNCTION_NAME<<": Shooting fireball from "<= 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 && disturbing_player_distance < 16*BS && - fabs(disturbing_player_off.Y) < 5*BS){ + fabs(disturbing_player_norm.Y) < 0.8){ m_yaw = disturbing_player_dir; sendPosition(); + m_shoot_y += disturbing_player_norm.Y; } m_shoot_reload_timer = 0.0; m_shooting = true; @@ -1292,9 +1328,13 @@ u16 MobV2SAO::punch(const std::string &toolname, v3f dir, { assert(m_env); Map *map = &m_env->getMap(); + + dstream<<"ACTION: "<