#include <amxmodx>
#include <reapi>
#include <fakemeta_util>
const TASK_ACTION2 = 3592;
new const BSP_RESOURCES[][] =
{
"maps/water2.bsp",
"maps/wall_new5.bsp",
"maps/wall_new4.bsp",
"maps/wall_new6.bsp"
};
new const SHARK_MODEL[] = "models/shark/shark_new_v1.mdl";
new const SHARK_CLASSNAME[] = "ent_shark";
new WaterEntity, SHARK_MODEL_INDEX;
public plugin_precache()
{
register_plugin("water_room_dd2", "1.0.0", "wellasgood");
new Float:Origin[3];
precache_model(BSP_RESOURCES[0]);
WaterEntity = fm_create_entity("func_water");
fm_set_kvd(WaterEntity,"classname","func_water")
fm_set_kvd(WaterEntity,"rendermode","2")
fm_set_kvd(WaterEntity,"renderamt","130")
fm_set_kvd(WaterEntity,"skin","-3")
fm_set_kvd(WaterEntity,"WaveHeight","5")
fm_entity_set_model(WaterEntity, BSP_RESOURCES[0]);
fm_entity_set_origin(WaterEntity, Origin);
fm_DispatchSpawn(WaterEntity);
fm_drop_to_floor(WaterEntity);
precache_model(BSP_RESOURCES[1]);
new GlassEntities1 = fm_create_entity("func_wall");
fm_set_kvd(GlassEntities1,"classname","func_wall");
fm_set_kvd(GlassEntities1,"rendermode","2");
fm_set_kvd(GlassEntities1,"renderamt","100");
fm_entity_set_model(GlassEntities1, BSP_RESOURCES[1]);
fm_entity_set_origin(GlassEntities1, Origin);
fm_DispatchSpawn(GlassEntities1);
fm_drop_to_floor(GlassEntities1);
precache_model(BSP_RESOURCES[2]);
new GlassEntities2 = fm_create_entity("func_wall");
fm_set_kvd(GlassEntities2,"classname","func_wall");
fm_set_kvd(GlassEntities2,"rendermode","2");
fm_set_kvd(GlassEntities2,"renderamt","100");
fm_entity_set_model(GlassEntities2, BSP_RESOURCES[2]);
fm_entity_set_origin(GlassEntities2, Origin);
fm_DispatchSpawn(GlassEntities2);
fm_drop_to_floor(GlassEntities2);
precache_model(BSP_RESOURCES[3]);
new GlassEntities3 = fm_create_entity("func_wall");
fm_set_kvd(GlassEntities3,"classname","func_wall");
fm_set_kvd(GlassEntities3,"rendermode","2");
fm_set_kvd(GlassEntities3,"renderamt","100");
fm_entity_set_model(GlassEntities3, BSP_RESOURCES[3]);
fm_entity_set_origin(GlassEntities3, Origin);
fm_DispatchSpawn(GlassEntities3);
fm_drop_to_floor(GlassEntities3);
SHARK_MODEL_INDEX = precache_model(SHARK_MODEL);
}
public plugin_init()
{
RegisterHookChain(RG_CSGameRules_CleanUpMap, "@CleanUpMap_Post", true);
register_clcmd("say shark!", "@CreateShark");
register_clcmd("water+", "@pWater");
register_clcmd("water-", "@mWater");
}
@CleanUpMap_Post()
{
new ent = rg_find_ent_by_class(NULLENT, SHARK_CLASSNAME, false);
while(ent > 0)
{
remove_task(ent);
remove_task(ent + TASK_ACTION2);
set_entvar(ent, var_flags, FL_KILLME);
set_entvar(ent, var_nextthink, get_gametime() + 0.01);
ent = rg_find_ent_by_class(ent, SHARK_CLASSNAME, false);
}
}
@mWater(id)
{
new Float:origin[3];
get_entvar(WaterEntity, var_origin, origin);
origin[2] -= 15.0;
set_entvar(WaterEntity, var_origin, origin);
}
@pWater(id)
{
new Float:origin[3];
get_entvar(WaterEntity, var_origin, origin);
origin[2] += 15.0;
set_entvar(WaterEntity, var_origin, origin);
}
@CreateShark(id)
{
new Entity = rg_create_entity("info_target", false);
set_entvar(Entity, var_classname, SHARK_CLASSNAME);
set_entvar(Entity, var_model, SHARK_MODEL);
set_entvar(Entity, var_modelindex, SHARK_MODEL_INDEX);
set_entvar(Entity, var_movetype, MOVETYPE_FLY);
set_entvar(Entity, var_solid, SOLID_TRIGGER);
new Float:Origin[3];
get_entvar(id, var_origin, Origin);
Origin[2] += random_float(0.0, 50.0);
set_entvar(Entity, var_origin, Origin);
set_entvar(Entity, var_framerate, 0.5);
set_entvar(Entity, var_sequence, 0);
set_entvar(Entity, var_animtime, get_gametime());
new Float:vecTransformVelosity[3];
velocity_by_aim(Entity, random_num(30, 60), vecTransformVelosity);
set_entvar(Entity, var_velocity, vecTransformVelosity);
new array[3];
array[0] = floatround(vecTransformVelosity[0]);
array[1] = floatround(vecTransformVelosity[1]);
array[2] = floatround(vecTransformVelosity[2]);
set_task(0.1, "@SharkAction2", Entity + TASK_ACTION2, array, sizeof array, "b");
set_task(6.0, "@SharkAction", Entity, _, _, "b");
}
@SharkAction(Entity)
{
if(is_nullent(Entity)) return;
remove_task(Entity + TASK_ACTION2);
new Float:vecAngles[3];
get_entvar(Entity, var_angles, vecAngles);
vecAngles[1] -= 180.0;
set_entvar(Entity, var_v_angle, vecAngles);
set_entvar(Entity, var_angles, vecAngles);
set_entvar(Entity, var_fixangle, 1);
new Float:vecTransformVelosity[3];
velocity_by_aim(Entity, random_num(30, 60), vecTransformVelosity);
set_entvar(Entity, var_velocity, vecTransformVelosity);
new array[3];
array[0] = floatround(vecTransformVelosity[0]);
array[1] = floatround(vecTransformVelosity[1]);
array[2] = floatround(vecTransformVelosity[2]);
set_task(0.1, "@SharkAction2", Entity + TASK_ACTION2, array, sizeof array, "b");
}
@SharkAction2(array[], Entity)
{
Entity -= TASK_ACTION2;
if(is_nullent(Entity)) return;
new Float:vecTransformVelosity[3];
vecTransformVelosity[0] = float(array[0]);
vecTransformVelosity[1] = float(array[1]);
vecTransformVelosity[2] = float(array[2]);
set_entvar(Entity, var_velocity, vecTransformVelosity);
}