Witam,
Chciałbym zapoznać się z waszymi opiniami czy według was jest to stabilna forma zmiany obrażeń poszczególnej broni:
#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers) new g_iMaxPlayers; new const Float:hit_area[][] = { { 1.0, 1.0, 1.0 }, // HIT_GENERIC { 50.0, 10.0, 30.0 }, // HIT_HEAD { 25.0, 8.0, 15.0 }, // HIT_CHEST { 20.25, 6.25, 12.25 }, // HIT_STOMACH { 10.0, 4.0, 8.0 }, // HIT_LEFTARM { 10.0, 4.0, 8.0 }, // HIT_RIGHTARM { 8.75, 2.75, 5.75 }, // HIT_LEFTLEG { 8.75, 2.75, 5.75 }, // HIT_RIGHTLEG { 0.0, 0.0, 0.0 } // HIT_SHIELD } public plugin_init() { RegisterHam(Ham_TakeDamage, "player", "Ham_CBasePlayer_TakeDamage_Pre", 0); g_iMaxPlayers = get_maxplayers(); } public Ham_CBasePlayer_TakeDamage_Pre(id, iInflictor, iAttacker, Float:flDamage, bitsDamageType) { if(id != iAttacker && is_user_connected(iAttacker) && IsPlayer(iAttacker)) { const XTRA_OFS_PLAYER = 5; const m_LastHitGroup = 75; const m_iTeam = 114; new weapon = get_user_weapon(iAttacker), hitbox = get_pdata_int(id, m_LastHitGroup, XTRA_OFS_PLAYER); switch(weapon) { case CSW_KNIFE: if(bitsDamageType & DMG_BULLET && get_pdata_int(id, m_iTeam, XTRA_OFS_PLAYER) != get_pdata_int(iAttacker, m_iTeam, XTRA_OFS_PLAYER)) SetHamParamFloat(4, hit_area[hitbox][0]) case CSW_FIVESEVEN: if(bitsDamageType & DMG_BULLET && get_pdata_int(id, m_iTeam, XTRA_OFS_PLAYER) != get_pdata_int(iAttacker, m_iTeam, XTRA_OFS_PLAYER)) SetHamParamFloat(4, hit_area[hitbox][1]) case CSW_M4A1: if(bitsDamageType & DMG_BULLET && get_pdata_int(id, m_iTeam, XTRA_OFS_PLAYER) != get_pdata_int(iAttacker, m_iTeam, XTRA_OFS_PLAYER)) SetHamParamFloat(4, hit_area[hitbox][2]) } return HAM_OVERRIDE } return HAM_IGNORED }
Dodam, że łącznie będzie tam 24 case'ów z każdą bronią
Czy według was jest to dobrze zoptymalizowane?
Z góry dziękuję za wszelkie sugestie!