Make dungeon masters though and make oerkkis disappear when they get to you (because...
authorPerttu Ahola <celeron55@gmail.com>
Sat, 15 Oct 2011 13:04:25 +0000 (16:04 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 15 Oct 2011 13:04:25 +0000 (16:04 +0300)
data/dungeon_master.png
src/client.cpp
src/content_cao.cpp
src/content_cao.h
src/content_sao.cpp
src/content_sao.h
src/environment.cpp

index 77e015c16a8d27616279150fec477d92a1554ae9..3457c8228fce6572daa79e219e0bb22f568062ea 100644 (file)
Binary files a/data/dungeon_master.png and b/data/dungeon_master.png differ
index 1af91703ea63c1281696b5e29dced0e709cf802d..c40c9e5136db6eff9f450fca75c84cfbfca2d296 100644 (file)
@@ -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;
                }
index 53e4a6d13e5374b569f896a13052f12c5f806c15..d9b88967d60c73a0ec366a99d75017eb565459e2 100644 (file)
@@ -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.;
index a362b6be5d7fe50471a94adade873fdd6b7fd94a..963e1a4889aef425dd302546f5b81caa9a38453f 100644 (file)
@@ -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<f32> m_selection_box;
index d81e3f87135ad779c8d9b61daa94e2ab45ee4fd4..c849c7a9806185a4cf3cc3948b21dc6b8f0538aa 100644 (file)
@@ -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<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 =
                        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 "<<PP(pos)
@@ -1130,13 +1163,16 @@ void MobV2SAO::step(float dtime, bool send_recommended)
                if(m_disturb_timer <= 15.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 &&
                                        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: "<<playername<<" punches id="<<m_id
+                       <<" with a \""<<toolname<<"\""<<std::endl;
 
        m_disturb_timer = 0;
        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.);
        v3f new_base_position = m_base_position + dir * BS;
@@ -1313,14 +1353,13 @@ u16 MobV2SAO::punch(const std::string &toolname, v3f dir,
        sendPosition();
        
        u16 amount = 2;
-       dstream<<"id="<<m_id<<": punch with \""<<toolname<<"\""<<std::endl;
        /* See tool names in inventory.h */
        if(toolname == "WSword")
                amount = 4;
        if(toolname == "STSword")
-               amount = 7;
+               amount = 6;
        if(toolname == "SteelSword")
-               amount = 10;
+               amount = 8;
        if(toolname == "STAxe")
                amount = 3;
        if(toolname == "SteelAxe")
index 0586ef434def652116b1e78c9ff7d1400b14242f..42e8cab7d6e816fa745c618f12a476be4f330eb8 100644 (file)
@@ -186,6 +186,8 @@ private:
        bool m_falling;
        float m_disturb_timer;
        std::string m_disturbing_player;
+       float m_random_disturb_timer;
+       float m_shoot_y;
        
        Settings *m_properties;
 };
index 28a2ff339ccf63072a4d2517117cbcb64a4abc91..a88d600bb8bb0875a812390093dd7ca5d1a96a0d 100644 (file)
@@ -647,7 +647,7 @@ static void getMob_dungeon_master(Settings &properties)
 {
        properties.set("looks", "dungeon_master");
        properties.setFloat("yaw", 1.57);
-       properties.setFloat("hp", 20);
+       properties.setFloat("hp", 30);
        properties.setBool("bright_shooting", true);
        properties.set("shoot_type", "fireball");
        properties.set("shoot_y", "0.7");