a7811311622
我…在工作了…
级别: 版主
版区: CS提问区
x771
x2152
|
分享:
▲
▼
下面是引用 i-c0112 于 2011-01-11 19:29 发表的 : 复制程式
// Fix for the HL engine bug when HP is multiples of 256
public message_health(msg_id, msg_dest, msg_entity)
{
// Get player's health
static health
health = get_msg_arg_int(1)
// 请勿打扰
if (health < 256) return;
// Check if we need to fix it
if (health % 256 == 0)
fm_set_user_health(msg_entity, pev(msg_entity, pev_health) + 1)
// HUD can only show as much as 255 hp
//set_msg_arg_int(1, get_msg_argtype(1), 256) //错误在这...256会显示为0
set_msg_arg_int(1, get_msg_argtype(1), 255)
}
为何我记得256溢位后是变成254呢…? 不是要找类似「set_pev(id, pev_health, 0)」的错误用法吗…? 而且如果真是错在「pev_health」的话就不只是ZP主插件需要检查了…
|
|
x0
[4 楼]
From:台湾教育部 | Posted:2011-01-11 23:19 |
|
|
i-c0112
|
分享:
▲
下面是引用 史来姆 于 2011-01-12 16:46 发表的 :
这样便做成了"假死"状态了么? 玩家虽然显示为死亡 但游戏却能继续 我的计分版竟未显示死亡!!而且还是可以被敌人攻击才会死, 光是pev_health设为小于等于0的话(以下称假死) CS好像不会判断为死亡 不过高处时摔下不会死亡, 摔下后再把pev_health设为正数后才会死亡...... 可能CS关于死亡的内容跟HL原本定义的不太一样吧 个人写了个插件测试...结果发现了不少意外 ex: 假死状态think会变为观察者 然后pev_health会变为1.000, is_user_alive(id)回传true 变回假死再think会变成动弹不得的观察者 然后重复动作突然发现我的玩者id从1变为2 = =" 还有不知如何正确Execute的TraceAttack 执行结果也蛮奇怪的 我先开枪射破了A窗户然后执行TraceAttack...窗户就再破了一次 之后继续执行就没用了... 复制程式
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
new cmd_heal, cmd_status, cmd_think, cmd_dmg, cmd_trace_atk;
public plugin_init()
{
register_plugin("^^0", "^^0", "^^0")
cmd_heal = register_concmd("test_heal", "cmd_test", ADMIN_RCON|ADMIN_MENU, "<#id> <Float:amount>")
cmd_status = register_concmd("test_status", "cmd_test", ADMIN_USER, "Display your health and alive flag")
cmd_think = register_concmd("test_think", "cmd_test", ADMIN_USER, "Make your entity ^"player^" think")
cmd_dmg = register_concmd("test_damage", "cmd_test", ADMIN_ADMIN|ADMIN_MENU, "<#id> <Float:amount>")
cmd_trace_atk = register_concmd("test_trace_attack", "cmd_test", ADMIN_ADMIN|ADMIN_MENU, "<#id> <Float:amount>")
}
public cmd_test(id, level, cid)
{
if (cid == cmd_heal || cid == cmd_dmg || cid == cmd_trace_atk)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED;
new arg[32], player = 0;
read_argv(1, arg, charsmax(arg))
player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_ALLOW_SELF)
if (!player) return PLUGIN_HANDLED;
new Float:amount;
read_argv(2, arg, charsmax(arg))
amount = str_to_float(arg)
if (cid == cmd_heal)
{
new Float:health;
pev(player, pev_health, health)
set_pev(player, pev_health, health + amount)
}
else if (cid == cmd_dmg)
ExecuteHam(Ham_TakeDamage, player, id, id, amount, DMG_FALL)
else
{
new trace_handle = create_tr2();
ExecuteHam(Ham_TraceAttack, player, id, amount, {2048, 2048, 2048}, trace_handle, DMG_FALL)
free_tr2(trace_handle);
}
}
else if (cid == cmd_status || cid == cmd_think)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED;
if (cid == cmd_status)
{
new Float:health; pev(id, pev_health, health)
client_print(id, print_center, "ID:%i ;Health: %f; Is_Alive? %i;", id, health, is_user_alive(id))
}
else
//dllfunc(DLLFunc_Think, id)
ExecuteHam(Ham_Think, id)
}
else console_print(id, "Unhandled command ID.")
return PLUGIN_HANDLED;
}
|
|
x1
[9 楼]
From:台湾中华电信 | Posted:2011-01-12 21:11 |
|
|
|