PHP Code:
//Jacobi
/*THE CVARS TO COPY AND PASTE IN SHCONFIG.CFG
//Jacobi
Jacobi_level 10
Jacobi_damage 200
Jacobi_cooldown 50
Jacobi_diskspeed 750
Jacobi_disklife 50
Jacobi_health 1000
Jacobi_armor 1000
Jacobi_speed 1000
jacobi_disk_ammo -1
Jacobi_multishot 0.1
*/
#include <amxmodx>
#include <engine>
#include <superheromod>
new gHeroName[] = "Jacobi"
new bool:g_hasJacobiPowers[SH_MAXSLOTS+1]
new bool:gdiskFired[SH_MAXSLOTS+1]
new diskTimer[SH_MAXSLOTS+1]
//This variable will represent the disk being made.
new disk[SH_MAXSLOTS+1]
new flash
//------------------------------------------------------------------------------------
public plugin_init()
{
//Special thanks to avalanche for helping me to debug my hero.
register_plugin("SUPERHERO Jacobi", "1.1", "Jacobi")
//THE CVARS
register_cvar("Jacobi_level", "30")
register_cvar("Jacobi_damage", "200")
register_cvar("Jacobi_cooldown", "0")
register_cvar("Jacobi_diskspeed", "750")
register_cvar("Jacobi_disklife", "500")
register_cvar("Jacobi_disk_ammo", "-1")
register_cvar("Jacobi_multishot", "0.1")
register_cvar("Jacobi_health", "200")
register_cvar("Jacobi_armor", "200")
register_cvar("Jacobi_speed", "200")
//THIS LINE MAKES THE HERO SELECTABLE
shCreateHero(gHeroName, "Jacobi(ADMIN ONLY)", "Get Some HP/AP/Speed/Unlimited Black Discs", true, "Jacobi_level")
//INITIAL ACTIONS
register_srvcmd("Jacobi_init", "Jacobi_init")
shRegHeroInit(gHeroName, "Jacobi_init")
//KEY DOWN COMMAND
register_srvcmd("Jacobi_kd", "Jacobi_kd")
shRegKeyDown(gHeroName, "Jacobi_kd")
// KEY UP
register_srvcmd("Jacobi_ku", "Jacobi_ku")
shRegKeyUp(gHeroName, "Jacobi_ku")
//SPAWNING EVENT
register_event("ResetHUD", "newSpawn", "b")
// DEATH
register_event("DeathMsg", "Jacobi_death", "a")
//THIS EVENT IS TRIGGERED WHEN SOMEONE DIES
register_event("DeathMsg", "Jacobi_kill", "a")
//SET THE LIFE OF THE DISK
set_task(0.1, "Jacobi_disklife", 0, "", 0, "b")
//REGISTERS A TOUCH EVENT, WHEN TWO THINGS TOUCH
register_touch("disk", "*", "touch_event")
// Let Server know about Jacobi's Variables
shSetMaxHealth(gHeroName, "Jacobi_health")
shSetMaxArmor(gHeroName, "Jacobi_armor")
shSetMaxSpeed(gHeroName, "Jacobi_speed", "[0]")
}
//--------------------------------------------------------------------------------------
public plugin_precache()
{
precache_model("models/shmod/Jacobi_disc.mdl")
precache_sound("shmod/frieza_destructodisc.wav")
flash = precache_model("sprites/muzzleflash2.spr")
}
//---------------------------------------------------------------------------------------
public Jacobi_init()
{
//First Argument is the id of the player
new temp[6]
read_argv(1,temp,5) //Converts the string to a number
new id = str_to_num(temp) //gets the id of the player
//Second Argument is either 0 or 1 depending on whether the person has the hero or not
read_argv(2,temp,5)
new hasPowers = str_to_num(temp) //Makes the string into a number
g_hasJacobiPowers[id] = (hasPowers != 0) //tells if player has power or not
if(hasPowers){
disk[id] = get_cvar_num("bass_laser_ammo")
diskTimer[id] = -1
}
if(!hasPowers && diskTimer[id] > 0){ //When a player doesn't have power anymore
diskTimer[id] = -1
new Float: fOrigin[3]
new origin[3]
if(is_valid_ent(disk[id])){
entity_get_vector(disk[id], EV_VEC_origin, fOrigin)
FVecIVec(fOrigin, origin)
decay_effects(disk[id], origin)
// This gets run if they had the power but don't anymore
if ( hasPowers && is_user_connected(id))
Jacobi_admincheck(id);
gPlayerUltimateUsed[id] = false
disk[id] = get_cvar_num("Jacobi_disk_ammo")
}
}
else if( !hasPowers && g_hasJacobiPowers[id] && is_user_alive(id) ) {
shRemHealthPower(id)
shRemGravityPower(id)
shRemArmorPower(id)
shRemSpeedPower(id)
}
}
//---------------------------------------------------------------------------------------
public Jacobi_kd()
{
if ( !hasRoundStarted() ) return
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
if ( !is_user_alive(id) ) return
if ( disk[id] == 0 ) {
client_print(id, print_center, "Cant Fire Disk")
playSoundDenySelect(id)
return
}
if ( gPlayerUltimateUsed[id] ) {
playSoundDenySelect(id)
return
}
fire_disk(id) // 1 immediate shot
if ( get_cvar_float("Jacobi_multishot") >= 0.0 ) {
set_task(get_cvar_float("Jacobi_multishot"), "fire_disk", id, "", 0, "b") //delayed shots
}
gdiskFired[id] = true
}
//----------------------------------------------------------------------------------------------
public Jacobi_ku()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
remove_task(id)
if ( !hasRoundStarted() || gPlayerUltimateUsed[id] || !gdiskFired[id] ) return
// Use the ultimate
if ( get_cvar_float("Jacobi_cooldown") > 0.0 ) ultimateTimer(id, get_cvar_float("Jacobi_cooldown"))
gdiskFired[id] = false
}
//----------------------------------------------------------------------------------------
public newSpawn(id)
{
if ( shModActive() && g_hasJacobiPowers[id] && is_user_alive(id) ) {
remove_task(id)
gPlayerUltimateUsed[id] = false
disk[id] = get_cvar_num("Jacobi_disk_ammo")
gdiskFired[id] = false
}
}
//----------------------------------------------------------------------------------------
public Jacobi_kill() //triggered everytime someone dies
{
new id = read_data(2) //This tells who the victim is
if(g_hasJacobiPowers[id] && diskTimer[id] > 0){
diskTimer[id] = -1
new Float: fOrigin[3]
new origin[3]
//gets current position of entity
entity_get_vector(disk[id], EV_VEC_origin, fOrigin)
//converts a floating vector into an integer vector
FVecIVec(fOrigin, origin)
decay_effects(disk[id], origin)
}
}
//----------------------------------------------------------------------------------------
public Jacobi_disklife(){
for(new id = 1; id <= SH_MAXSLOTS; id++){
if(g_hasJacobiPowers[id] && is_user_alive(id)){
if(diskTimer[id] > 0){
diskTimer[id]--
new Float: fVelocity[3]
//gets the velocity by the direction you are looking at
velocity_by_aim(id, get_cvar_num("frieza_diskspeed"), fVelocity)
//sets the new velocity
entity_set_vector(disk[id], EV_VEC_velocity, fVelocity)
}
else if(diskTimer[id] == 0){
new Float: fOrigin[3]
new origin[3]
//gets the current position of entity
entity_get_vector(disk[id], EV_VEC_origin, fOrigin)
//converts a floating vector to an integer vector
FVecIVec(fOrigin, origin)
decay_effects(disk[id], origin)
diskTimer[id]--
}
}
}
}
//----------------------------------------------------------------------------------------
public fire_disk(id)
{ //makes sure that the number of entities created does not exceed the maximum amount
//of entities allowed
if(entity_count() == get_global_int(GL_maxEntities)){
client_print(id, print_chat, "[SH] Cannot create more entities")
return
}
//Makes an array of origin in the (x,y,z) coordinate system.
new origin[3]
//Makes an array of velocity, specifically in the (x,y,z) coordinate system
new velocity[3]
new Float:fOrigin[3], Float:fVelocity[3]
get_user_origin(id, origin, 1)
new Float: minBound[3] = {-50.0, -50.0, 0.0} //sets the minimum bound of entity
new Float: maxBound[3] = {50.0, 50.0, 0.0} //sets the maximum bound of entity
IVecFVec(origin, fOrigin)
//This will make it so that the disk appears in front of the user
new Float:viewing_angles[3]
new distance_from_user = 70
entity_get_vector(id, EV_VEC_angles, viewing_angles)
fOrigin[0] += floatcos(viewing_angles[1], degrees) * distance_from_user
fOrigin[1] += floatsin(viewing_angles[1], degrees) * distance_from_user
fOrigin[2] += floatsin(-viewing_angles[0], degrees) * distance_from_user
new NewEnt = create_entity("info_target") //Makes an object
entity_set_string(NewEnt, EV_SZ_classname, "disk") //sets the classname of the entity
disk[id] = NewEnt
//This tells what the object will look like
entity_set_model(NewEnt, "models/shmod/jacobi_disc.mdl")
//This will set the origin of the entity
entity_set_origin(NewEnt, fOrigin)
//This will set the movetype of the entity
entity_set_int(NewEnt,EV_INT_movetype, MOVETYPE_NOCLIP)
//This makes the entity touchable
entity_set_int(NewEnt, EV_INT_solid, SOLID_TRIGGER)
//This will set the velocity of the entity
velocity_by_aim(id, get_cvar_num("frieza_diskspeed"), fVelocity)
FVecIVec(fVelocity, velocity) //converts a floating vector to an integer vector
//Sets the size of the entity
entity_set_size(NewEnt, minBound, maxBound)
//Sets who the owner of the entity is
entity_set_edict(NewEnt, EV_ENT_owner, id)
//This will set the entity in motion
entity_set_vector(NewEnt, EV_VEC_velocity, fVelocity)
//This will make the entity have sound.
emit_sound(NewEnt, CHAN_VOICE, "shmod/frieza_destructodisc.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
new lifetime = get_cvar_num("Jacobi_disklife")
//This is the trail effects, to learn more about animation effects go to this link
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22) //TE_BEAMFOLLOW
write_short(NewEnt) //The entity to attach the sprite to
write_short(flash) //sprite's model
write_byte(lifetime) //life in 0.1 seconds
write_byte(50) //width of sprite
write_byte(255) //red
write_byte(0) //green
write_byte(255) //blue
write_byte(255) //brightness
message_end()
return
}
//-----------------------------------------------------------------------------------------
public touch_event(pToucher, pTouched) //This is triggered when two entites touch
{
new aimvec[3], Float:fAimvec[3] //This is the position where the disk collides
entity_get_vector(pTouched, EV_VEC_origin, fAimvec)
FVecIVec(fAimvec, aimvec)
new self_immune = get_cvar_num("frieza_disklife") - 2 //Gives split-second immunity
if(pTouched == entity_get_edict(pToucher, EV_ENT_owner) && diskTimer[pTouched] > self_immune)
return PLUGIN_HANDLED
//Checks to see if entity is a player or an inanimate object.
if(is_user_connected(pTouched)){
special_effects(pToucher, pTouched, aimvec)
return PLUGIN_CONTINUE
}
special_effects(pToucher, 0, aimvec)
return PLUGIN_CONTINUE
}
//-----------------------------------------------------------------------------------------
public special_effects(pToucher, pTouched, aimvec[3]) //effects for when disk touch
{
new Float:fVelocity[3]
new velocity[3]
new damage
entity_get_vector(pToucher, EV_VEC_velocity, fVelocity)
FVecIVec(fVelocity, velocity)
//Got to know who's the one using the disk
//So that when the victim dies, he knows who's the killer
//That used the disk
new killer = entity_get_edict(pToucher, EV_ENT_owner)
//To learn more about animation effects go to this link
//http://shero.rocks-hideout.com/forums/viewtopic.php?t=1941
if(is_user_alive(pTouched)){
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(101) //BLOODSTREAM
write_coord(aimvec[0])
write_coord(aimvec[1])
write_coord(aimvec[2])
write_coord(velocity[0])
write_coord(velocity[1])
write_coord(velocity[2])
write_byte(95)
write_byte(100)
message_end()
damage = get_cvar_num("Jacobi_damage")
new victim = pTouched
shExtraDamage(victim, killer, damage, "Jacobi's Energy Disk")
}
//Same link for here to http://shero.rocks-hideout.com/forums/viewtopic.php?t=1941
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(9) //SPARKS
write_coord(aimvec[0])
write_coord(aimvec[1])
write_coord(aimvec[2])
message_end()
}
//-----------------------------------------------------------------------------------------
public decay_effects(NewEnt, origin[3]) //removes the entity plus adds a decaying effect
{
if(is_valid_ent(NewEnt)){
remove_entity(NewEnt)
//To learn more about animation effects go to this link
//http://shero.rocks-hideout.com/forums/viewtopic.php?t=1941
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(14) //IMPLOSION
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_byte(50)
write_byte(10)
write_byte(10)
message_end()
}
}
//------------------------------------------------------------------------------------------
public client_disconnect(id) //This makes sure that the disk isn't flying after disconnect
{
if(g_hasJacobiPowers[id] && diskTimer[id] > 0){
new Float: fOrigin[3]
new origin[3]
entity_get_vector(disk[id], EV_VEC_origin, fOrigin)
FVecIVec(fOrigin, origin)
decay_effects(disk[id], origin)
}
}
//------------------------------------------------------------------------------------------
public Jacobi_death()
{
new id = read_data(2)
if ( id <= 0 || id > SH_MAXSLOTS ) return
remove_task(id)
}
//----------------------------------------------------------------------------------------------
public Jacobi_admincheck(id)
{
new accessLevel[10] = "b"
if (g_hasJacobiPowers[id] && !(get_user_flags(id)&read_flags(accessLevel)))
{
client_print(id, print_chat, "[SH] (%s) ***Admin Only*** You are not an admin!", gHeroName)
g_hasJacobiPowers[id] = false
client_cmd(id, "say drop %s", gHeroName)
}
}
//----------------------------------------------------------------------------------------------