|
|

CCI:
- /* MOD.Weapon.core */
- stock MOD_Weapon_PreCache () {}
- public @WeaponBeam ( Client, Weapon, const Class[], Size )
- {
- register_message( get_user_msgid("KillTrail"), "@KillTrail" );//我们最好在"PluginInit"里进行注册[] We had better register in 'PluginInit' tho
- set_task( 0.5, "@BeamDetach", Weapon );// 设置气功波分离时间[] Set detachment time
- }
- public @BeamDetach( Weapon )
- {
- set_pdata_int( pev( Weapon, pev_owner ), 202, false );// bool: AttackShooting
- /* 分离气功波[] Detach the Beam */
- message_begin( MSG_ALL, get_user_msgid( "DetachTrail" ) );
- write_long( Weapon );
- message_end( );
- setWeaponHOMING( Weapon, 550.0, 1, 1 | 2);// 设置气功波速度并给它跟踪功能[] Set weapon speed and trackable
- }
- public @KillTrail( MsgID, dest )
- {
- new Weapon = get_msg_arg_int( 1 );
- remove_task( Weapon );
- }
复制代码 AMX Mod X 1.0.0:
- #include <amxmodx>
- #include <engine>
- #include <fakemeta>
- #include <xs>
- public plugin_init()
- {
- register_plugin( "Set Beam Detachable And Trackable", "1.0", "ESFKAMI" );
- register_message( get_user_msgid( "EETrail" ), "@EETrail" );// Hook气功波被发出后[] Hook when a beam has been shot out
- register_message( get_user_msgid("KillTrail"), "@KillTrail" );// Hook气功波爆炸后[] Hook when the beem has been killed
- }
- public @EETrail( MsgID, dest )
- {
- /**
- 1 - LONG - Client ??? - do not edit
- 2 - LONG - Weapon - do not edit
- 3 - BYTE - Client ??? - do not edit
- 4 - SHORT - Head Start A
- 5 - SHORT - Head Start B
- 6 - SHORT - Head End A
- 7 - SHORT - Head End B
- 8 - SHORT - Trail
- 9 - BYTE - Size
- 10 - BYTE - Segement Length ???
- 11 - COORD - X - do not edit
- 12 - COORD - Y - do not edit
- 13 - COORD - Z - do not edit
- **/
- new Client = get_msg_arg_int( 1 );
- new Weapon = get_msg_arg_int( 2 );
- static WeaponClip, WeaponAmmo;
- new WeaponIndex = get_user_weapon( Client, WeaponClip, WeaponAmmo );
- if( WeaponIndex == 15 )
- {
- set_task( 0.5, "@BeamDetach", Weapon );// 设置气功波分离时间[] Set detachment time
- }
- }
- public @BeamDetach( Weapon )
- {
- set_pdata_int( pev( Weapon, pev_owner ), 202, false );// bool: AttackShooting
- /* 分离气功波[] Detach the Beam */
- message_begin( MSG_ALL, get_user_msgid( "DetachTrail" ) );
- write_long( Weapon );
- message_end( );
- setWeaponHoming( Weapon, 500, 5000.0 );// 设置气功波速度并给它跟踪功能[] Set weapon speed and trackable
- }
- stock setWeaponHoming( Weapon, Velocity, Float: DetectableRange )
- {
- new Target, Float: Range[33];
- for( new i = 1; i <= 32; i++ )// 存储有效范围内可被探测到的气功波与玩家的距离[] Save the range between the client and the beam if the client is in the detectable range
- {
- if( is_user_connected( i ) )
- {
- if( is_user_alive( i ) && i != pev( Weapon, pev_owner ) )
- {
- if( entity_range( Weapon, i ) <= DetectableRange )
- {
- Range[i] = entity_range( Weapon, i );
- Target = i;
- }
- }
- }
- }
- for( new n = 1; n <= 32; n++ )// 取出离气功波最近的玩家[] Get the index of the client who is nearest the beam
- {
- if( Range[n] < Range[Target] && Range[n] != 0.0 )
- {
- Target = n;
- }
- }
- new CORE[3];
- CORE[0] = Weapon;
- CORE[1] = Target;
- CORE[2] = Velocity;
- set_task( 0.1, "WeaponTrackThink", Weapon, CORE, 3, "b" )// 每过0.1秒刷新一次气功波对目标的向量[] Refresh the vector of the beam to the client every 0.1s
- }
- public WeaponTrackThink( CORE[] )
- {
- new Weapon = CORE[0];
- new Target = CORE[1];
- new Velocity = CORE[2];
- if( Target != 0 && is_user_alive( Target ) )
- {
- /* 获取气功波和目标的坐标[] Get the origins of the beam and the target */
- new Float: vec[3], Float: WeaponOrg[3], Float: TargetOrg[3];
- pev( Weapon, pev_origin, WeaponOrg );
- pev( Target, pev_origin, TargetOrg );
- /* 通过坐标计算向量[] Compute velocity by origins */
- vec[0] = TargetOrg[0] - WeaponOrg[0];
- vec[1] = TargetOrg[1] - WeaponOrg[1];
- vec[2] = TargetOrg[2] - WeaponOrg[2];
- xs_vec_normalize( vec, vec );
- /* 修正实体角度[] Update the angles of the entity */
- new Float: ang[3];
- vector_to_angle( vec, ang );
- set_pev( Weapon, pev_angles, ang );
- /* 设置实体速度[] Give velocity to the beam */
- xs_vec_mul_scalar(vec, float( Velocity ), vec);
- set_pev( Weapon, pev_velocity, vec );
- }
- }
- public @KillTrail( MsgID, dest )
- {
- new Weapon = get_msg_arg_int( 1 );
- remove_task( Weapon );
- }
复制代码 |
|