Originally Posted by Exolent[jNr]
(Post 1690985)
PHP Code:
public grenade_explosion()
{
if (get_msg_arg_int( 1 ) == 3 && get_msg_arg_int ( 6 ) == 25 && get_msg_arg_int ( 7 ) == 30)
{
new id = get_grenade_owner()
if(!HasVanguard[id]) return
new pos[3]
pos[0] = floatround( get_msg_arg_float( 2 ) )
pos[1] = floatround( get_msg_arg_float( 3 ) )
pos[2] = floatround( get_msg_arg_float( 4 ) )
new cluster, Float:vAngle[3], Float:angles[3], Float:velocity[3], Rvelocity[3], Float:distance, Float:actualDistance, Float:multiplier
new Float:origin[3]
origin[0] = float( pos[0] )
origin[1] = float( pos[1] )
origin[2] = float( pos[2] )
new Float:minBox[3] = { -1.0, ... }
new Float:maxBox[3] = { 1.0, ... }
//This will launch the above specified number of clusters
for (new i = 0; i < CLUSTERS; i++)
{
//Create a random direction for the cluster to fly
velocity[0] = random_float( float( MIN_FLY_DISTANCE ), float( MAX_FLY_DISTANCE ) )
if ( random_num( 0, 1 ) == 1 ) velocity[0] = floatmul( velocity[0], -1.0 )
velocity[1] = random_float( float( MIN_FLY_DISTANCE ), float( MAX_FLY_DISTANCE ) )
if ( random_num( 0, 1 ) == 1 ) velocity[1] = floatmul( velocity[1], -1.0 )
velocity[2] = float( UPWARD_ARC )
Rvelocity[0] = pos[0] + floatround( velocity[0] )
Rvelocity[1] = pos[1] + floatround( velocity[1] )
Rvelocity[2] = pos[2] + floatround( velocity[2] )
//Create the distance the cluster will fly
distance = random_float( float( MIN_FLY_DISTANCE ), float( MAX_FLY_DISTANCE ) )
actualDistance = float( get_distance( pos, Rvelocity ) )
multiplier = floatdiv( distance, actualDistance )
velocity[0] = floatmul( velocity[0], multiplier )
velocity[1] = floatmul( velocity[1], multiplier )
velocity[2] = floatmul( velocity[2], multiplier )
//Create the angles for the facing of the cluster. PS: I have no idea how to do the angle thing really. This is a blind attempt.
vector_to_angle( velocity, angles )
vector_to_angle( velocity, vAngle )
//Create the entity of the cluster
cluster = create_entity( "info_target" )
//Set the identifying string of the cluster's entity
entity_set_string( cluster, EV_SZ_classname, "grenade_cluster")
//Set the model for the cluster's entity
entity_set_model( cluster, "models/grenade.mdl" )
//Set the bounds for the cluster's entity
entity_set_vector( cluster, EV_VEC_mins, minBox)
entity_set_vector( cluster, EV_VEC_maxs, maxBox)
//Set the origin for the cluster's entity (NOTE: The clusters will spawn in the same spot, but they will be set to ignore eachother
entity_set_origin( cluster, origin )
//Set the angles of the cluster's entity
entity_set_vector( cluster, EV_VEC_angles, angles )
entity_set_vector( cluster, EV_VEC_v_angle, vAngle )
//Set the behavior specific variables for the cluster's entity
entity_set_int( cluster, EV_INT_movetype, 6 ) //Has gravity and registers collisions
entity_set_int( cluster, EV_INT_solid, 1 ) //Collisions do not block
//Record who the owner of this nade is
entity_set_edict( cluster, EV_ENT_owner, get_grenade_owner() )
//Make the cluster fly!
entity_set_vector( cluster, EV_VEC_velocity, velocity )
}
}
return PLUGIN_CONTINUE
}
|