Esempio n. 1
0
        public void die(IBaseUnit killer)
        {
            if (this.dying)
            {
                return;
            }
            this.dying = true;

            long cur_clock_tm = DateTime.Now.ToBinary();
            // 尝试触发死亡ai动作
            this._trig_dying_act(cur_clock_tm);

            // TO DO : player die

            // 中断打坐
            //this.try_stop_recover();

            this.respawn_tm = cur_clock_tm + 30000; // 30 秒后安全复活
            this.pinfo.isdie = true;
            pinfo.atking = null;
            pinfo.moving = null;

            if (pinfo.states != null)
            {
                bool _remark_pl_state = false;
                if (this.pinfo.states.state_par.Count > 0)
                {
                    for (var idx = 0; idx < this.pinfo.states.state_par.Count; ++idx)
                    {
                        var val = this.pinfo.states.state_par[idx];
                        if (val.desc.die_keep == 1)
                            continue;

                        this.pinfo.states.state_par.RemoveAt(idx);
                        --idx;
                        _remark_pl_state = true;
                    }
                }

                //pinfo.states.state = 0;
                //pinfo.states.mov_spd_mul = 1.0;
                //pinfo.states.atk_spd_mul = 1.0;
                //pinfo.states.mp2hp = 0;
                //pinfo.states.dmglnkper = 0;
                //re_calc_cha_data();
                if (_remark_pl_state)
                    Skill._remark_pl_state(this, pinfo);
            }

            if (pinfo.jumping != null)
            {
                // 跳跃中死亡,落在目标点
                pinfo.x = pinfo.jumping.dest_x;
                pinfo.y = pinfo.jumping.dest_y;

                if (!this.is_in_lvl)
                {
                    pinfo.lx = pinfo.x;
                    pinfo.ly = pinfo.y;
                }

                pinfo.jumping = null;
            }

            if (gmap != null)
            {
                if (gmap.blvlmap)
                {
                    //if (this.gmap.worldsvr.is_lvlmis_lvl())
                    //{
                    //    this.allow_respawn_tm = sys.clock_time() + 6000; // 侠客行副本中,必须6秒后复活
                    //}

                    this.gmap.worldsvr.on_ply_die(this);
                }
                else
                {
                    if (gmap.pk_seting != map_pk_setting_type.MPST_PK)
                    {//经验惩罚                       

                    }
                }

                if (killer != null && killer.get_sprite_type() == map_sprite_type.MstMonster)
                {
                    if (killer.owner_ply != null)
                    {
                        killer = killer.owner_ply; // 宠物击杀相当于玩家角色击杀
                    }
                }

                if (killer != null && killer.get_sprite_type() == map_sprite_type.MstPlayer)
                {
                    IMapUnit killer_pl = killer.get_pack_data();
                    //local pkdp = true;
                    if (!gmap.blvlmap)
                    {
                        // 添加仇敌
                        //_add_foes(this, killer.pinfo);

                        //计算pk值 
                        //是否为中立地图
                        if (gmap.pk_seting == map_pk_setting_type.MPST_NORMAL)
                        {
                            if (!this.can_atk_direct())
                            {
                                //自己为正义玩家
                                //sys.dumpobj( defend_tm_map );
                                //sys.trace( sys.SLT_ERR, "killer.pinfo.cid = " + killer.pinfo.cid + "sys.time()" + sys.time() + "\n")
                                int killer_cid = killer_pl.cid;
                                long defend_en_tm = 0;
                                long now_s = DateTime.Now.ToBinary();
                                defend_tm_map.TryGetValue(killer_cid, out defend_en_tm);
                                if (defend_en_tm > 0)
                                {
                                    //自己是正当防卫 则
                                    if (defend_en_tm >= now_s)
                                    {
                                        //增加对方pk值 
                                        int add_val = 1;
                                        int pkv = killer_pl.pk_v;
                                        if (pkv < 0)
                                        {//击杀者 有正义值 则清除
                                            add_val = 1 - pkv;
                                        }
                                        killer.add_pk_v(add_val);
                                    }
                                    else
                                    {
                                        defend_tm_map.Remove(killer_cid);
                                    }
                                }
                            }
                            else
                            {//可直接攻击的玩家
                                if (killer.is_justice())
                                {//击杀者 为正义玩家 降低PK值
                                    killer.sub_pk_v(1, true);
                                }
                            }
                        }
                        this.check_tsk_attribute(true);
                    }
                    else
                    {
                        // 在副本中
                        // 增加击杀值
                        killer_pl.kp++;
                        killer_pl.cur_kp++;

                        this.gmap.worldsvr.on_kp(killer, this);
                    }
                }

                // remove atking from atker
                // TO DO : 增加被锁定列表,死亡后清理被锁定列表中的对象的攻击信息即可
                foreach (var val in gmap.map_sprites.Values)
                {
                    val.on_spr_die(pinfo.iid);
                }
            }

            // 清理助攻列表
            if (this.kp_asist_rec)
            {
                this.beatk_ply_cids.Clear();
            }
        }