[ZP] 仿 CSO 殭屍回血

Home Home
引用 | 編輯 ryoson
2011-09-26 17:27
樓主
推文 x0
這是我參考 zdt 大的回血插件的
第一次發教學 對amxx又不怎麼認識
可能會有錯 但是我做出來是可以回血的...

==========================================================

1. 打開想要增加回復效果殭屍的 sma 檔

2. 在最上加入:
#include <fakemeta_util>
#include <fun>

3. 在 public plugin_init() 上面加入:
new cvar_regain_hp
new stay[33]
new const zombie_heal[] = "zombie_plague/zombi_heal.wav" // 殭屍回復音效

4. 在 public plugin_init() 中加入:
cvar_regain_hp = register_cvar("zp_regain_hp", "200") // 每秒回復的血量
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")

5. 在 public plugin_precache() 中加入:
precache_sound(zombie_heal)

6. 在SMA底部加入:
public fw_PlayerPreThink(id)
{
    if (!is_user_alive(id) || !zp_get_user_zombie(id))
        return FMRES_IGNORED;
   
    static speed
    speed = fm_get_speed(id)
   
    if (speed == 0.0)
    {
        if (!stay[id])
        {
            stay[id] = true
            set_task(5.0, "regain", id) // 停止多少秒開始回復
        }
    }
    else
    {
        if (stay[id])
        {
            stay[id] = false
            remove_task(id)
        }
    }
    return FMRES_IGNORED;
}

public regain(id)
{
    if (zp_get_user_zombie(id) && is_user_alive(id) && stay[id] && (pev(id, pev_health) < zp_get_zombie_maxhealth(id)) && (pev(id, pev_health) <= (zp_get_zombie_maxhealth(id) - get_pcvar_num(cvar_regain_hp))))
    {
          set_pev(id, pev_health, (pev(id, pev_health) * 1.0 + get_pcvar_num(cvar_regain_hp)))
          engfunc(EngFunc_EmitSound, id, CHAN_ITEM, zombie_heal, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
          set_task(1.0, "regain", id)
    }
    else if (zp_get_user_zombie(id) && is_user_alive(id) && stay[id] && (pev(id, pev_health) >= (zp_get_zombie_maxhealth(id) - get_pcvar_num(cvar_regain_hp)) && (pev(id, pev_health) < zp_get_zombie_maxhealth(id))))
    {
          set_user_health(id, zp_get_zombie_maxhealth(id))
          engfunc(EngFunc_EmitSound, id, CHAN_ITEM, zombie_heal, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    }
}

回復音效是 C$O 的就不發了
如想回復者附近的人也聽到他回血的音效就更改 CHAN_ITEM CHAN_VOICE)
如沒有 fakemeta_util.inc 就下載附件... 放到 amxmodx/scripting/include


本帖包含附件
檔名: zip fakemeta_util.rar   (2022-06-09 14:19 / 7 KB)   下載次數:53


獻花 x0
引用 | 編輯 i-c0112
2011-09-26 18:56
1樓
  
應該還少了這3個
複製程式
#include <amxmodx>
#include <fun>
#include <zombieplague>
還有這條件應該也是多餘的
複製程式
zp_get_user_zombie_class(id) == g_zclass_light

感覺就像是直接複製別人sma的內容而成的 表情

獻花 x0
引用 | 編輯 ryoson
2011-09-26 19:34
2樓
  
下面是引用 i-c0112 於 2011-09-26 18:56 發表的 : 到引言文
應該還少了這3個
複製程式
#include <amxmodx>
#include <fun>
#include <zombieplague>
還有這條件應該也是多餘的
複製程式
zp_get_user_zombie_class(id) == g_zclass_light

感覺就像是直接複製別人sma的內容而成的 表情
<zombieplague> <--- 這個不會沒有吧 -_-"
差不多吧 /.\
改殭屍的sma應該可以更易判斷進化等血量上限

獻花 x0
引用 | 編輯 fouury
2011-09-26 21:28
3樓
  
只用maxhealth還是會有血量誤差的表情

簡單的方法是設個變數

利用zp的forward

在被感染為殭屍時用get_user_health取得血量

再讓 取得的血量 = 變數

把maxhealth換成變數即可

不過這只用於純感染0.0 如果用甚麼怒氣指數或重生等等的是絕對不行的= =""
--
對了.

你有沒有考慮到被攻擊也不能回血的設定??

用takedamage來判斷傷害較簡單0.0

還有
複製程式
#include <amxmodx> 
#include <fun> 
#include <zombieplague>
插件中少了讀取這三個inc就無法轉檔= =

你應該趕快將這些內容補充到你的教學才是....

獻花 x0
引用 | 編輯 ryoson
2011-09-26 22:44
4樓
  
下面是引用 fouury 於 2011-09-26 21:28 發表的 : 到引言文
只用maxhealth還是會有血量誤差的表情

簡單的方法是設個變數

利用zp的forward

在被感染為殭屍時用get_user_health取得血量

再讓 取得的血量 = 變數

把maxhealth換成變數即可

不過這只用於純感染0.0 如果用甚麼怒氣指數或重生等等的是絕對不行的= =""
--
對了.

你有沒有考慮到被攻擊也不能回血的設定??

用takedamage來判斷傷害較簡單0.0

還有
複製程式
#include <amxmodx> 
#include <fun> 
#include <zombieplague>
插件中少了讀取這三個inc就無法轉檔= =

你應該趕快將這些內容補充到你的教學才是....
#include <amxmodx>
#include <zombieplague>
^
這2個不是一定有的嗎-0-

其實我打算用這方法加進可以進化的殭屍

獻花 x0
引用 | 編輯 hanxuan2121
2011-09-27 13:30
5樓
  
其实那3个INC不用+了,僵尸的SMA里本身就有了。

獻花 x0
引用 | 編輯 cs_library
2011-09-27 15:07
6樓
  
希望能用在bb上面,我收下嚕
謝謝A___A

獻花 x0
引用 | 編輯 fouury
2011-09-27 21:15
7樓
  
下面是引用 ryoson 於 2011-09-26 22:44 發表的 : 到引言文

#include <amxmodx>
#include <zombieplague>
^
這2個不是一定有的嗎-0-

其實我打算用這方法加進可以進化的殭屍

喔~   抱歉....0.0

我看成是要做成獨立的插件了= =|||

獻花 x0
引用 | 編輯 kenzen
2021-05-15 11:02
8樓
  
不知道能不能用這個做出新的殭屍類型

獻花 x0