码迷,mamicode.com
首页 > 其他好文 > 详细

仿mp的RadiusDamage函数

时间:2015-07-19 11:50:58      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

 1 public RadiusDamage(Float:vecSrc[3], pevInflictor, pevAttacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType)
 2 {
 3     new pEntity;
 4     new Float:flAdjustedDamage, Float:falloff;
 5     new Float:vecOrigin[3];
 6     new Float:vecTemp[3];
 7     
 8     if (flRadius)
 9         falloff = flDamage / flRadius;
10     else
11         falloff = 1.0;
12     
13     new bInWater = engfunc(EngFunc_PointContents, vecSrc);
14     
15     vecSrc[2] += 1.0;
16     
17     if (!pevAttacker)
18         pevAttacker = pevInflictor;
19     
20     while ((pEntity = engfunc(EngFunc_FindEntityInSphere, pEntity, vecSrc, flRadius)) != 0)
21     {
22         if (pev(pEntity, pev_takedamage) == DAMAGE_NO)
23             continue;
24         
25         if (iClassIgnore != 0 && ExecuteHam(Ham_Classify, pEntity) == iClassIgnore)
26             continue;
27         
28         if (bInWater && !pev(pEntity, pev_waterlevel))
29             continue;
30         
31         if (!bInWater && pev(pEntity, pev_waterlevel) == 3)
32             continue;
33         
34         pev(pEntity, pev_origin, vecOrigin);
35         xs_vec_sub(vecSrc, vecOrigin, vecTemp);
36         
37         flAdjustedDamage = xs_vec_len(vecTemp) * falloff;
38         flAdjustedDamage = flDamage - flAdjustedDamage;
39         
40         ExecuteHamB(Ham_TakeDamage, pEntity, pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType);
41     }
42 }

 

仿mp的RadiusDamage函数

标签:

原文地址:http://www.cnblogs.com/crsky/p/4658343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!