673734294 发表于 2011-12-18 07:00:41

【插件分享】仿真手雷插件(转自Moddev)

别看这插件功能小,也是花了点心血的.以前CS的手雷爆炸效果,是一张NC的SPR.如果俯视的话就更悲剧.所以我把爆炸的效果和谐掉,再制作一个新的爆炸效果.不只是一张SPR那么简单了,爆炸时附近地面产生震动,然后会有烟.爆炸时在空中和地面的爆炸效果都不一样,在地面爆炸,手雷周围会有滚滚灰尘.还会飞出一些碎片和碎石(这些可是MDL不是SPR).立体感非常足,带震撼的感觉(起码比原版的好),尽管把威力改成原来的一样,也会感觉比原版的手雷厉害. 这插件的灵感来源与CS零点行动的单人任务版里面的手雷(它那效果灰长好)
在伤害方面也做了点修改,爆炸时会有击退,被炸中屏幕会瞬间变红,屏幕震动.爆炸伤害和手雷爆炸范围,还有手雷爆炸时间,都能自己设置.

使用方法
直接覆盖到CS里
以下是属性命令,在控制台输入或保存在cstrike\addons\amxmodx\configs的amxx.cfg里即可
grenade_explode_time 2.0 //手雷爆炸的时间
grenade_explode_damagerange 350.0 //手雷爆炸的影响范围
grenade_explode_damage 2.0 //手雷爆炸的伤害倍数(原来的伤害*伤害倍数)
grenade_explode_knock 500.0 //手雷爆炸的击退
grenade_explode_shakerange 700.0 //手雷爆炸引起震动的范围
grenade_explode_punchagele 30.0 //被手雷伤害时的屏幕震动幅度
grenade_explode_hitshowred 1 //被手雷炸中是否红屏
grenade_explode_mdltime 5 //爆炸碎片存在的时间(秒)

673734294 发表于 2011-12-18 07:01:31

就是 没源码   可惜

673734294 发表于 2011-12-18 07:33:21

鄙视 只看帖不回帖

Village 发表于 2011-12-18 15:32:31

1# 673734294


谢谢分享!只是可惜没有源码

ckn911 发表于 2011-12-18 21:52:28

可惜没源码··

小猫咪 发表于 2011-12-19 12:12:35

顶一个、、、

点通粉丝 发表于 2011-12-21 17:17:35

6# 小猫咪


没源码吗.......我这有一个
作者:DS小弟弟
使用方法
直接覆盖到CS里
以下是属性命令,在控制台输入或保存在cstrike\addons\amxmodx\configs的amxx.cfg里即可
grenade_explode_time 2.0//手雷爆炸的时间
grenade_explode_damagerange 350.0 //手雷爆炸的影响范围
grenade_explode_damage 2.0//手雷爆炸的伤害倍数(原来的伤害*伤害倍数)
grenade_explode_knock 500.0//手雷爆炸的击退
grenade_explode_shakerange 700.0 //手雷爆炸引起震动的范围
grenade_explode_punchagele 30.0//被手雷伤害时的屏幕震动幅度
grenade_explode_hitshowred 1   //被手雷炸中是否红屏
grenade_explode_mdltime 5//爆炸碎片存在的时间(秒)02.#include <amxmodx>

03.#include <fakemeta>

04.#include <hamsandwich>

05.#define PLUGIN "Heexplode"

06.#define VERSION "1.0"

07.#define AUTHOR "DSHGFHDS"

08.#define HEEXPLODE 13679

09.#define HESHOWSPR 19752

10.#define MDLCOUNT 24 //爆炸碎片的数量

11.new const breakmodels[] = {"models/gibs_wallbrown.mdl", "models/gibs_woodplank.mdl", "models/gibs_brickred.mdl"}

12.new szbreakmodels

13.new g_smokeSpr, g_smokeSpr2, grenadeexplodespr, g_lightspr

14.new cvar_damagerange, cvar_grenadetime, cvar_damage, cvar_knock, cvar_shakerange, cvar_punchagele, cvar_hitshowred, cvar_mdltime

15.new g_fwBotForwardRegister

16.const DMG_HEGRENADE = (1<<24)

17.public plugin_init()

18.{

19.register_plugin(PLUGIN, VERSION, AUTHOR)

20.register_forward(FM_SetModel, "fw_SetModel")

21.register_forward(FM_FindEntityInSphere, "fw_FindEntityInSphere")

22.register_message(SVC_TEMPENTITY, "Message_SVC_TEMP")

23.RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")

24.g_fwBotForwardRegister = register_forward(FM_PlayerPostThink, "fw_BotForwardRegister_Post", 1)

25.cvar_grenadetime = register_cvar("grenade_explode_time", "2.0") //手雷爆炸的时间

26.cvar_damagerange = register_cvar("grenade_explode_damagerange", "350.0") //手雷爆炸的影响范围

27.cvar_damage = register_cvar("grenade_explode_damage", "2.0") //手雷爆炸的伤害倍数(原来的伤害*伤害倍数)

28.cvar_knock = register_cvar("grenade_explode_knock", "500.0") //手雷爆炸的击退

29.cvar_shakerange = register_cvar("grenade_explode_shakerange", "700.0") //手雷爆炸引起震动的范围

30.cvar_punchagele = register_cvar("grenade_explode_punchagele", "30.0") //被手雷伤害时的屏幕震动幅度

31.cvar_hitshowred = register_cvar("grenade_explode_hitshowred", "1") //被炸中是否红屏

32.cvar_mdltime = register_cvar("grenade_explode_mdltime", "5") //爆炸碎片存在的时间(秒)

33.}

34.public plugin_precache()

35.{

36.g_smokeSpr = engfunc(EngFunc_PrecacheModel,"sprites/gas_smoke1.spr")

37.g_smokeSpr2 = engfunc(EngFunc_PrecacheModel,"sprites/exsmoke.spr")

38.g_lightspr = engfunc(EngFunc_PrecacheModel,"sprites/xflare1.spr")

39.grenadeexplodespr = engfunc(EngFunc_PrecacheModel,"sprites/zerog-frag1.spr")

40.for(new i = 0; i < sizeof breakmodels; i++) szbreakmodels = engfunc(EngFunc_PrecacheModel,breakmodels)

41.}

42.public Message_SVC_TEMP(messageId, messageType, messageEntity)

43.{

44.if(messageType == MSG_PAS && get_msg_arg_int(1) == TE_EXPLOSION && get_msg_arg_int(6) == 25)

45.{

46.set_msg_arg_int(1, ARG_BYTE, 0)

47.set_pev(messageEntity, pev_iuser2, HESHOWSPR)

48.}

49.if(messageType == MSG_PVS && get_msg_arg_int(1) == TE_SMOKE && pev(messageEntity, pev_iuser2) == HESHOWSPR)

50.{

51.set_msg_arg_int(5, ARG_SHORT, 0)

52.set_pev(messageEntity, pev_iuser2, 0)

53.}

54.}

55.public fw_BotForwardRegister_Post(iPlayer)

56.{

57.if (is_user_bot(iPlayer))

58.{

59.unregister_forward(FM_PlayerPostThink, g_fwBotForwardRegister, 1)

60.RegisterHamFromEntity(Ham_TakeDamage, iPlayer, "fw_TakeDamage")

61.}

62.}

63.public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)

64.{

65.if(!is_user_connected(victim))

66.return HAM_IGNORED

67.

68.if(!(damage_type & DMG_HEGRENADE))

69.return HAM_IGNORED

70.

71.SetHamParamFloat(4, damage*get_pcvar_float(cvar_damage))

72.

73.new Float:punchangle

74.pev(victim, pev_punchangle, punchangle)

75.punchangle +=random_float(-get_pcvar_float(cvar_punchagele),get_pcvar_float(cvar_punchagele))

76.punchangle +=random_float(-get_pcvar_float(cvar_punchagele),get_pcvar_float(cvar_punchagele))

77.punchangle +=random_float(-get_pcvar_float(cvar_punchagele),get_pcvar_float(cvar_punchagele))

78.set_pev(victim, pev_punchangle, punchangle)

79.if(get_pcvar_num(cvar_hitshowred))

80.{

81.message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), {0,0,0}, victim)

82.write_short(1<<12)

83.write_short(1<<12)

84.write_short(0x0000)

85.write_byte(255)

86.write_byte(20)

87.write_byte(20)

88.write_byte(random_num(50, 200))

89.message_end()

90.}

91.return HAM_IGNORED

92.}

93.public fw_FindEntityInSphere(iEntity, Float:vecOrigin, Float:flRadius)

94.{

95.if(get_pcvar_float(cvar_damagerange) <= -1.0 || flRadius != 350.0) return FMRES_IGNORED

96.

97.new iResult = engfunc(EngFunc_FindEntityInSphere, iEntity, vecOrigin, get_pcvar_float(cvar_damagerange))

98.

99.if(pev(iEntity, pev_iuser1) == HEEXPLODE)

100.{

101.engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, vecOrigin, 0)

102.write_byte(TE_SPRITE)

103.engfunc(EngFunc_WriteCoord,vecOrigin)

104.engfunc(EngFunc_WriteCoord,vecOrigin)

105.engfunc(EngFunc_WriteCoord,vecOrigin)

106.write_short(g_lightspr)

107.write_byte(40)

108.write_byte(100)

109.message_end()

110.

111.engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, vecOrigin, 0)

112.write_byte(TE_SPRITE)

113.engfunc(EngFunc_WriteCoord,vecOrigin)

114.engfunc(EngFunc_WriteCoord,vecOrigin)

115.engfunc(EngFunc_WriteCoord,vecOrigin)

116.write_short(grenadeexplodespr)

117.write_byte(18)

118.write_byte(255)

119.message_end()

120.

121.engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, vecOrigin, 0)

122.write_byte(TE_EXPLOSION2)

123.engfunc(EngFunc_WriteCoord, vecOrigin)

124.engfunc(EngFunc_WriteCoord, vecOrigin)

125.engfunc(EngFunc_WriteCoord, vecOrigin)

126.write_byte(1)

127.write_byte(10)

128.message_end()

129.

130.engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, vecOrigin, 0)

131.write_byte(TE_DLIGHT)

132.engfunc(EngFunc_WriteCoord,vecOrigin)

133.engfunc(EngFunc_WriteCoord,vecOrigin)

134.engfunc(EngFunc_WriteCoord,vecOrigin)

135.write_byte(20)

136.write_byte(255)

137.write_byte(128)

138.write_byte(112)

139.write_byte(1)

140.write_byte(0)

141.message_end()

142.

143.for(new i = 1;i<33;i++)

144.{

145.new Float:origin

146.pev(i, pev_origin, origin)

147.new Float:range = get_distance_f(origin, vecOrigin)

148.if(range < get_pcvar_float(cvar_damagerange))

149.{
296.}

点通粉丝 发表于 2011-12-21 17:18:42

7# 点通粉丝 148.if(range < get_pcvar_float(cvar_damagerange))

149.{

150.new Float:explodeknock = get_pcvar_float(cvar_knock)*(get_pcvar_float(cvar_damagerange)-range)/get_pcvar_float(cvar_damagerange)

151.set_velocity_from_origin(i, vecOrigin, explodeknock)

152.}

153.if(range <= get_pcvar_float(cvar_shakerange) && is_user_alive(i))

154.{

155.message_begin(MSG_ONE,get_user_msgid("ScreenShake"),{0,0,0},i)

156.write_short(1<<12)

157.write_short(1<<12)

158.write_short(1<<12)

159.message_end()

160.}

161.}

162.

163.makesmoke(iEntity, vecOrigin)

164.set_pev(iEntity, pev_iuser1, 0)

165.}

166.forward_return(FMV_CELL, iResult)

167.

168.return FMRES_SUPERCEDE

169.}

170.public fw_SetModel(iEntity, szModel[])

171.{

172.if(strlen(szModel) < 8)

173.return FMRES_IGNORED

174.

175.if(szModel != 'w' || szModel != '_')

176.return FMRES_IGNORED

177.

178.if(szModel == 'h' && szModel == 'e')

179.{

180.new Float:dmgtime

181.pev(iEntity, pev_dmgtime, dmgtime)

182.set_pev(iEntity, pev_dmgtime, get_gametime()+get_pcvar_float(cvar_grenadetime))

183.set_pev(iEntity, pev_iuser1, HEEXPLODE)

184.}

185.

186.return FMRES_IGNORED

187.}

188.public makesmoke(iEntity, Float:position)

189.{

190.new Float:origin, Float:iorigin, Float:iposition

191.

192.if(pev(iEntity, pev_flags) & FL_ONGROUND)

193.{

194.iposition=position

195.iposition=position

196.iposition=position

197.get_spherical_coord(iposition, 40.0, 0.0, -15.0, iorigin)

198.get_spherical_coord(iposition, 40.0, 90.0, -15.0, iorigin)

199.get_spherical_coord(iposition, 40.0, 180.0, -15.0, iorigin)

200.get_spherical_coord(iposition, 40.0, 270.0, -15.0, iorigin)

201.get_spherical_coord(iposition, 100.0, 0.0, -15.0, iorigin)

202.get_spherical_coord(iposition, 100.0, 45.0, -15.0, iorigin)

203.get_spherical_coord(iposition, 100.0, 90.0, -15.0, iorigin)

204.get_spherical_coord(iposition, 100.0, 135.0, -15.0, iorigin)

205.get_spherical_coord(iposition, 100.0, 180.0, -15.0, iorigin)

206.get_spherical_coord(iposition, 100.0, 225.0, -15.0, iorigin)

207.get_spherical_coord(iposition, 100.0, 270.0, -15.0, iorigin)

208.get_spherical_coord(iposition, 100.0, 315.0, -15.0, iorigin)

209.for(new i = 0; i < MDLCOUNT; i++)

210.{

211.new Float:velocity

212.velocity = random_float(-500.0,500.0)

213.velocity = random_float(-500.0,500.0)

214.velocity = random_float(-300.0,300.0)

215.makebreakmodels(position, 1.0, 1.0, 1.0, velocity, velocity, velocity, szbreakmodels, 1, get_pcvar_num(cvar_mdltime))

216.}

217.for(new e = 0; e < 12; e++) make_smoke(iorigin, g_smokeSpr2, 16, 100)

218.position+=120.0

219.}

220.get_spherical_coord(position, 0.0, 0.0, 135.0, origin)

221.get_spherical_coord(position, 0.0, 80.0, 80.0, origin)

222.get_spherical_coord(position, 41.0, 43.0, 60.0, origin)

223.get_spherical_coord(position, 90.0, 90.0, 40.0, origin)

224.get_spherical_coord(position, 80.0, 25.0, 135.0, origin)

225.get_spherical_coord(position, 101.0, 100.0, 112.0, origin)

226.get_spherical_coord(position, 68.0, 35.0, 139.0, origin)

227.get_spherical_coord(position, 0.0, 95.0, 105.0, origin)

228.

229.for(new c = 0; c < 8; c++) make_smoke(origin, g_smokeSpr, 40, 30)

230.}

231.stock make_smoke(Float:position, sprite_index, size, light)

232.{

233.engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, position, 0)

234.write_byte(TE_SPRITE)

235.engfunc(EngFunc_WriteCoord, position)

236.engfunc(EngFunc_WriteCoord, position)

237.engfunc(EngFunc_WriteCoord, position)

238.write_short(sprite_index)

239.write_byte(size)

240.write_byte(light)

241.message_end()

242.}

243.stock makebreakmodels(Float:vecOrigin, Float:sizex, Float:sizey, Float:sizez, Float:velocityx, Float:velocityy, Float:velocityz, const models_index, count, livetime)

244.{

245.engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, vecOrigin, 0)

246.write_byte(TE_BREAKMODEL)

247.engfunc(EngFunc_WriteCoord, vecOrigin)

248.engfunc(EngFunc_WriteCoord, vecOrigin)

249.engfunc(EngFunc_WriteCoord, vecOrigin)

250.engfunc(EngFunc_WriteCoord, sizex)

251.engfunc(EngFunc_WriteCoord, sizey)

252.engfunc(EngFunc_WriteCoord, sizez)

253.engfunc(EngFunc_WriteCoord, velocityx)

254.engfunc(EngFunc_WriteCoord, velocityy)

255.engfunc(EngFunc_WriteCoord, velocityz)

256.write_byte(10)

257.write_short(models_index)

258.write_byte(count)

259.write_byte(livetime*10)

260.write_byte(0x40)

261.message_end()

262.}

263.stock get_velocity_from_origin( ent, Float:fOrigin, Float:fSpeed, Float:fVelocity )

264.{

265.new Float:fEntOrigin

266.pev( ent, pev_origin, fEntOrigin )

267.

268.new Float:fDistance

269.fDistance = fEntOrigin - fOrigin

270.fDistance = fEntOrigin - fOrigin

271.fDistance = fEntOrigin - fOrigin

272.

273.new Float:fTime = ( vector_distance( fEntOrigin,fOrigin ) / fSpeed )

274.

275.fVelocity = fDistance / fTime

276.fVelocity = fDistance / fTime

277.fVelocity = fDistance / fTime

278.

279.return ( fVelocity && fVelocity && fVelocity )

280.}

281.stock set_velocity_from_origin(ent, Float:fOrigin, Float:fSpeed)

282.{

283.new Float:fVelocity

284.get_velocity_from_origin(ent,fOrigin,fSpeed,fVelocity)

285.fVelocity/=2

286.set_pev(ent,pev_velocity,fVelocity)

287.return 1

288.}

289.stock get_spherical_coord(const Float:ent_origin, Float:redius, Float:level_angle, Float:vertical_angle, Float:origin)

290.{

291.new Float:length

292.length=redius*floatcos(vertical_angle, degrees)

293.origin=ent_origin+length*floatcos(level_angle,degrees)

294.origin=ent_origin+length*floatsin(level_angle,degrees)

295.origin=ent_origin+redius*floatsin(vertical_angle,degrees)

296.}

673734294 发表于 2012-1-23 14:35:13

;P 谢谢

673734294 发表于 2012-2-3 14:04:41

源码 来了
页: [1] 2
查看完整版本: 【插件分享】仿真手雷插件(转自Moddev)