Osker Lee 发表于 2008-3-15 14:08:14

以"Create_TE_BEAMFOLLOW"的方式定义手雷拖尾

一般的手雷拖尾都是以下面的形式编写的:
if (grenadeid) {
message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
write_byte( TE_BEAMFOLLOW )
write_short(grenadeid) // entity
write_short(m_iTrail) // model
write_byte( 10 ) // life
write_byte( 5 ) // width
write_byte( 0 ) // r, g, b
write_byte( 255 ) // r, g, b
write_byte( 0 ) // r, g, b
}
不过我发现魔兽插件里兽族手雷拖尾是这样定义的:
Create_TE_BEAMFOLLOW(index, g_siTrail, 20, 10, 255, 255, 0, 196)
我模仿着编写了一个仅仅适用于手雷(O4)的拖尾代码,不过编译不了,麻烦高手看看到底是什么原因。
#include <amxmodx>
#include <engine>
#define TE_BEAMFOLLOW 22
new m_iTrail
public plugin_init()
{
register_plugin("Grenade Trail","1.0","X-man")
register_event("SendAudio","FireInTheHole","bc","2=%!MRAD_FIREINHOLE")
register_cvar("amx_grentrail","1")
}
public plugin_precache() {
m_iTrail = precache_model("sprites/smoke.spr")
}
public FireInTheHole()
{
if( !get_cvar_num("amx_grentrail") )
return PLUGIN_HANDLED
new id = read_data(1)
set_task(0.3, "grenid", id)
return PLUGIN_HANDLED
}
public grenid(id){
new grenadeid = get_grenade(id)
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
if (wpnid == CSW_HEGRENADE)
if (grenadeid) {
Create_TE_BEAMFOLLOW(id, m_iTrail, 20, 10, 255, 255, 0, 196)
}
}

Rulzy 发表于 2008-3-15 15:48:53

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

Create_TE_BEAMFOLLOW其实就是调用前者,只是写成了一个函数了而已。现在你没有定义这个函数,当然无法编译了。

Osker Lee 发表于 2008-3-15 15:54:26

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

那应该怎么定义那个函数呢?

jim_yang 发表于 2008-3-15 20:23:25

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

stock Create_TE_BEAMFOLLOW(gid, trail, life, width, r, g, b, brightness)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(gid)
write_short(trail)
write_byte(life)
write_byte(width)
write_byte(r)
write_byte(g)
write_byte(b)
write_byte(brightness)
message_end()
}
你发的那个少了个参数

Cr@zyTreE 发表于 2008-3-15 22:42:48

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

Post by Osker Lee
一般的手雷拖尾都是以下面的形式编写的:
if (grenadeid) {
message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
write_byte( TE_BEAMFOLLOW )
write_short(grenadeid) // entity
write_short(m_iTrail) // model
write_byte( 10 ) // life
write_byte( 5 ) // width
write_byte( 0 ) // r, g, b
write_byte( 255 ) // r, g, b
write_byte( 0...

附件上传2个手雷拖尾插件代码。
我想知道grentrail中
new id = read_data(1)
set_task(0.3, "grenid", id)
上面的代码为什么这样写?
id是读到的数据代表的是什么意思呢?

“0.3秒执行一次grenid函数”这个我知道。

public plugin_init()
{
register_plugin("Grentrail","1.3","AssKicR")
register_event("SendAudio","FireInTheHole","bc","2=%!MRAD_FIREINHOLE")
register_cvar("sv_grentrail","3")
}
public plugin_precache() {
m_iTrail = precache_model("sprites/smoke.spr")
}
public FireInTheHole()
{
if(get_cvar_num("sv_grentrail") == 0)
return PLUGIN_HANDLED
new id = read_data(1)
set_task(0.3, "grenid", id)
return PLUGIN_HANDLED
}


grent_wforward看不懂(见http://www.dt-club.net/forum/thread/72/37214.htm 6楼的附件)。

zwfgdlc 发表于 2008-3-15 23:53:10

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾


SendAudio

Plays the specified audio. An example of AudioCode could be "%!MRAD_rounddraw".

Name: SendAudio Structure:
byte SenderID
string AudioCode
short Pitch

Osker Lee 发表于 2008-3-16 00:27:33

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

jim_yang楼主,我按照你的方法重新修改了源代码,不过测试的结果让人觉得很诧异:玩家扔雷时不会出现拖尾的效果,但扔完雷后玩家的身后倒是出现了一条长长的“尾巴”,一直到下局开始时才会消失,何解?(参见截图)
#include <amxmodx>
#include <engine>
#define TE_BEAMFOLLOW 22
new m_iTrail
public plugin_init()
{
register_plugin("Grenade Trail","1.0","X-man")
register_event("SendAudio","FireInTheHole","bc","2=%!MRAD_FIREINHOLE")
register_cvar("amx_grentrail","1")
}
public plugin_precache() {
m_iTrail = precache_model("sprites/smoke.spr")
}
public FireInTheHole()
{
if( !get_cvar_num("amx_grentrail") )
return PLUGIN_HANDLED
new id = read_data(1)
set_task(0.3, "grenid", id)
return PLUGIN_HANDLED
}
public grenid(id){
new grenadeid = get_grenade(id)
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
if (wpnid == CSW_HEGRENADE)
if (grenadeid) {
Create_TE_BEAMFOLLOW(id, m_iTrail, 20, 10, 255, 255, 0, 196)
}
}
stock Create_TE_BEAMFOLLOW(id, m_iTrail, life, width, r, g, b, brightness)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(id)
write_short(m_iTrail)
write_byte(life)
write_byte(width)
write_byte(r)
write_byte(g)
write_byte(b)
write_byte(brightness)
message_end()
}

zwfgdlc 发表于 2008-3-16 00:50:33

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

Create_TE_BEAMFOLLOW(id, m_iTrail, 20, 10, 255, 255, 0, 196)
改成
Create_TE_BEAMFOLLOW(grenadeid, m_iTrail, 20, 10, 255, 255, 0, 196)


Osker Lee 发表于 2008-3-16 02:15:22

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

Create_TE_BEAMFOLLOW(id, m_iTrail, 20, 10, 255, 255, 0, 196)
改成
Create_TE_BEAMFOLLOW(grenadeid, m_iTrail, 20, 10, 255, 255, 0, 196)
呵呵~ 你真厉害,问题还是让你给解决了!再次感谢zwfgdlc楼主!不过经过观察,我发现兽族手雷拖尾和普通手雷拖尾有一个不一样的地方:
1. 兽人把手雷扔出去时,马上就会出现拖尾的现象,贯穿始终;2. 而普通的手雷扔出去后,却不会马上出现拖尾的现象,而是等到手雷运动到一定的距离后才会出现拖尾的现象。(参见截图)所以我想问一下,怎么才能让普通的手雷扔出去后也立马产生拖尾的现象呢?(就像兽人的那样)

zwfgdlc 发表于 2008-3-16 15:14:39

回复: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾

不要那个延时应该可以,
<FONT style="BACKGROUND-COLOR: #f5f5ff">
#include <amxmodx>
#include <engine>
#include <csx>
#define TE_BEAMFOLLOW 22
new m_iTrail
public plugin_init()
{
register_plugin("Grenade Trail","1.0","X-man")
register_event("SendAudio","FireInTheHole","bc","2=%!MRAD_FIREINHOLE")
register_cvar("amx_grentrail","1")
}
public plugin_precache() {
m_iTrail = precache_model("sprites/smoke.spr")
}
public grenade_throw(id,greindex,wpn)
{
if( !get_cvar_num("amx_grentrail") )
return PLUGIN_HANDLED
Create_TE_BEAMFOLLOW(greindex, m_iTrail, 20, 10, 255, 255, 0, 196)
return PLUGIN_HANDLED
}
stock Create_TE_BEAMFOLLOW(id, m_iTrail, life, width, r, g, b, brightness)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(id)
write_short(m_iTrail)
write_byte(life)
write_byte(width)
write_byte(r)
write_byte(g)
write_byte(b)
write_byte(brightness)
message_end()
}
页: [1] 2
查看完整版本: 以&quot;Create_TE_BEAMFOLLOW&quot;的方式定义手雷拖尾