區分 Zbot 和 Yapb/Podbot/Sypb , 解決 hamsandwich 重覆 Bug

Home Home
引用 | 編輯 HsK
2012-06-30 02:18
樓主
推文 x6
很多有寫過 amxx 的人也用過 RegisterHam 吧.
例如 RegisterHam(Ham_TakeDamage,"player","fw_TakeDamage");

但是 "player" 是指定不到 zbot 的...
因此, 便發展出以下方法

在bot 入ser 時, 再進行一次
RegisterHamFromEntity(Ham_TakeDamage,id,"fw_TakeDamage");

的確可以令 zbot 也進行 Ham_TakeDamage 內容...
但是, 當 ser 中不是只有 zbot
那便可能做成
zbot 不進行 Ham_TakeDamage 內容
而 Yapb/Podbot/Sypb 進行 Ham_TakeDamage 內容2次 的bug了....

____ 前言很長哦=.='''

因此我參考了一下 podbot 和 sypb 源碼..
寫出以下代碼..

複製程式
stock is_bot_type (id)
{
     if (!is_user_bot (id))
           return 0; // not bot

     new tracker[2], friends[2], ah[2];
     get_user_info(id,"tracker",tracker,1);
     get_user_info(id,"friends",friends,1);
     get_user_info(id,"_ah",ah,1);

     if (tracker[0] == '0' && friends[0] == '0' && ah[0] == '0')
           return 1; // PodBot / YaPB / SyPB

     return 2; // Zbot
}


當用到  hamsandwich 之中

複製程式
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN_NAME        "Ham - Bot Get (ZBOT-PODBOT-SyPB)"
#define PLUGIN_VERSION        "1.0"
#define PLUGIN_AUTHOR        "HsK"

new bool:Ham_load = false;

public plugin_init()
{
        register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);

        RegisterHam(Ham_TakeDamage,"player","fw_TakeDamage");
}

public client_putinserver(id)
        set_task (1.0, "Ham_run", id);

public Ham_run (id)
{
        server_print("Bot Type : %s", (is_bot_type (id) == 2 ? "Zbot" : (is_bot_type (id) == 1 ? "SyPB/YaPB/PodBot" : "This is not Bot")));

        if (!is_user_connected(id) || Ham_load)
                return;

        if (is_bot_type (id) != 2)
                return;

        Ham_load = true;
        RegisterHamFromEntity(Ham_TakeDamage,id,"fw_TakeDamage");
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
        if (victim == attacker || !attacker)
                return;

        client_print (attacker, print_chat, "** fw_TakeDamage **Damage! Bot id : %d", victim);
}

stock is_bot_type (id)
{
        if (!is_user_bot (id))
                return 0; // not bot

        new tracker[2], friends[2], ah[2];
        get_user_info(id,"tracker",tracker,1);
        get_user_info(id,"friends",friends,1);
        get_user_info(id,"_ah",ah,1);

        if (tracker[0] == '0' && friends[0] == '0' && ah[0] == '0')
                return 1; // PodBot / YaPB / SyPB

        return 2; // Zbot
}


獻花 x3
引用 | 編輯 zxzyman
2012-07-04 08:19
1樓
  
WOW!!


可以讓ZP道具傷害都能對BOT造成效果

我正好也是PODBOT+ZBOT來搞ZP的.




題外:
BOT好像不會辨識ZP中的倖存者 或 復仇者... 

 

獻花 x0
引用 | 編輯 ccw111
2012-07-06 18:52
2樓
  
雖然未遇到過這個問題
不過分析bot的特性也要付出
大大辛苦了

獻花 x0
引用 | 編輯 觀眾甲
2012-07-08 14:14
3樓
  
@@遲來的教學 板上很多文章貌似只寫支援zbot.

獻花 x0
引用 | 編輯 yzhyzlm
2012-07-15 12:57
4樓
  
大大好像對Damage_Control2.amxx這個插件沒用啊,攻擊力還是很高。

獻花 x0
引用 | 編輯 williamyii77
2012-07-16 20:08
5樓
  
辛苦你了
我收下了 表情

獻花 x0
引用 | 編輯 a7811311622
2013-02-28 22:25
6樓
  
我想問…既然知道ZBOT會在client_putinserver做個task去debug…
在那個時間點判斷是否為ZBOT後無腦remove_task有效嗎…? 表情

獻花 x0
引用 | 編輯 tonyyoung
2014-10-07 21:34
7樓
  
下面是引用 zxzyman 於 2012-07-04 08:19 發表的 : 到引言文
WOW!!


可以讓ZP道具傷害都能對BOT造成效果

我正好也是PODBOT+ZBOT來搞ZP的.




題外:
BOT好像不會辨識ZP中的倖存者 或 復仇者... 

 
BOT不都是看到敵人就開火嗎…
分辨倖存者跟復仇者做啥啊…= _ =?

獻花 x0
引用 | 編輯 丘俊
2016-11-22 20:56
8樓
  
谢谢大大,学习了!

獻花 x0
引用 | 編輯 spiral
2017-01-04 11:36
9樓
  
感謝大大分享讓我可以了解研究BOT

獻花 x0
引用 | 編輯 sombarihelp
2019-07-14 00:31
10樓
  
回 覆 鎖 定 :

  此回覆已被鎖定,只有『管理員及回覆者』看的到 !!!



獻花 x0