KK,Owns

Okay, It's the Human Alliance race, i just modified the teleport cooldown, so i typed it a bit wrong, didn't make it.
credits goes to Anthony Iacono

/**
* File: War3Source_HumanAlliance.sp
* Description: The Human Alliance race for War3Source.
* Author(s): Anthony Iacono
*/
#pragma semicolon 1
#include <sourcemod>
#include "W3SIncs/War3Source_Interface"
#include <sdktools>
#include <sdktools_functions>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>
new thisRaceID;
new iTeleportCount[65];
new Handle:MaxTeleportCvar;
new Handle:TeleportCooldownCvar;
new bool:bIsBashed[65];
new bool:bInFreezeTime;
new Handle:FreezeTimeCvar;
// Chance/Info Arrays
new Float:BashChance[5]={0.0,0.15,0.21,0.27,0.32};
new Float:TeleportDistance[5]={0.0,600.0,800.0,1000.0,1200.0};
new Float:InvisibilityAlphaTF[5]={1.0,0.84,0.68,0.53,0.35};
new Float:InvisibilityAlphaCS[5]={1.0,0.90,0.8,0.7,0.6};
new DevotionHealth[5]={0,15,25,35,45};
new Float:LastDamageTime[66];
// Effects
new BeamSprite,HaloSprite;
new String:teleportSound[]="war3source/blinkarrival.wav";
public Plugin:myinfo =
{
name = "War3Source Race - Human Alliance",
author = "PimpinJuice",
description = "The Human Alliance race for War3Source.",
version = "1.0.0.0",
url = "http://pimpinjuice.net/"
};
public OnPluginStart()
{
HookEvent("player_spawn",PlayerSpawnEvent);
HookEvent("round_start",RoundStartEvent);
FreezeTimeCvar=FindConVar("mp_freezetime");
MaxTeleportCvar=CreateConVar("war3_human_teleport_max","0","Max amount of teleports per round, 0 for unlimited");
TeleportCooldownCvar=CreateConVar("war3_human_teleport_cooldown","0.0","Cooldown between teleports");
CreateTimer(0.1,TFHPBuff,_,TIMER_REPEAT);
}
new bool:war3ready;
public OnWar3PluginReady()
{
war3ready=true;
thisRaceID=War3_CreateRace("Human Alliance",
"human",
"You are now part of the Human Alliance.",
"You will be part of the Human Alliance when you die or respawn.",
"Invisibility",
"Makes you partially invisible, \n62% visibility - 37% visibility.",
"Devotion Aura",
"Gives you additional 15-45 health pool.",
"Bash",
"Have a 15-32% chance to render an \nenemy immobile for 1 second.",
"Teleport",
"Allows you to teleport to where you \naim, 60-120 feet being the range.");
}
public OnMapStart()
{
BeamSprite=PrecacheModel("materials/sprites/lgtning.vmt");
HaloSprite=PrecacheModel("materials/sprites/halo01.vmt");
War3_PrecacheSound(teleportSound);
//CreateTimer(0.2, LoadSounds);
}
public Action:LoadSounds(Handle:h){
new String:longsound[512];
Format(longsound,sizeof(longsound), "sound/%s", teleportSound);
AddFileToDownloadsTable(longsound);
if(PrecacheSound(teleportSound, true)){
PrintToServer("TPrecacheSound %s",longsound);
}
else{
PrintToServer("Failed: PrecacheSound %s",longsound);
}
}
public OnWar3PlayerAuthed(client)
{
}
public OnRaceSelected(client,oldrace,race)
{
if(race!=thisRaceID)
{
War3_SetBuff(client,fInvisibilitySkill,thisRaceID,1.0); // if we aren't their race anymore we shouldn't be controlling their alpha
}
else
{
ActivateSkills(client);
}
}
public ActivateSkills(client)
{
if(War3_GetRace(client)==thisRaceID)
{
new skill_devo=War3_GetSkillLevel(client,thisRaceID,1);
if(skill_devo)
{
// Devotion Aura
new hpadd=DevotionHealth[skill_devo];
new Float:vec[3];
GetClientAbsOrigin(client,vec);
vec[2]+=25.0;
new ringColor[4]={0,0,0,0};
new team=GetClientTeam(client);
if(team==2)
{
ringColor={255,0,0,255};
}
else if(team==3)
{
ringColor={0,0,255,255};
}
TE_SetupBeamRingPoint(vec,40.0,10.0,BeamSprite,HaloSprite,0,15,1.0,15.0,0.0,ringColor,10,0);
TE_SendToAll();
SetEntityHealth(client,GetClientHealth(client)+hpadd);
//War3_ChatMessage(client,"+%d HP",hpadd);
}
new skilllevel=War3_GetSkillLevel(client,thisRaceID,0);
new Float:alpha=(War3_GetGame()==Game_CS)?InvisibilityAlphaCS[skilllevel]:InvisibilityAlphaTF[skilllevel];
//if(skill_invis>0)
//War3_ChatMessage(client,"You fade %s into the backdrop.",(skill_invis==1)?"slightly":(skill_invis==2)?"well":(skill_invis==3)?"greatly":"dramatically");
War3_SetBuff(client,fInvisibilitySkill,thisRaceID,alpha);
}
}
public OnUltimateCommand(client,race,bool:pressed)
{
new userid=GetClientUserId(client);
if(race==thisRaceID && pressed && userid>1 && IsPlayerAlive(client) && !bInFreezeTime && GetEntityMoveType(client)!=MOVETYPE_NONE)
{
new ult_level=War3_GetSkillLevel(client,race,3);
if(ult_level>0)
{
new max_teles=GetConVarInt(MaxTeleportCvar);
if(max_teles<0) max_teles=0;
//if(War3_HasFlag(client)){
// PrintHintText(client,"No teleporting with Flag");
//}
if(max_teles>0&&iTeleportCount[client]>=max_teles)
{
PrintHintText(client,"Used max of %d Teleports",max_teles);
}
else if(War3_SkillNotInCooldown(client,thisRaceID,3,true))
{
TeleportPlayerView(client,TeleportDistance[ult_level]);
}
}
else
{
PrintHintText(client,"Level Your Ultimate First");
}
}
}
public OnSkillLevelChanged(client,race,skill,oldskilllevel,newskilllevel)
{
if(race==thisRaceID&&skill==0&&newskilllevel>=0&&War3_GetRace(client)==thisRaceID)
{
new Float:alpha=(War3_GetGame()==Game_CS)?InvisibilityAlphaCS[newskilllevel]:InvisibilityAlphaTF[newskilllevel];
if(newskilllevel>0 && IsPlayerAlive(client)) // dont tell them if they are dead
//War3_ChatMessage(client,"You fade %s into the backdrop.",(newskilllevel==1)?"slightly":(newskilllevel==2)?"well":(newskilllevel==3)?"greatly":"dramatically");
War3_SetBuff(client,fInvisibilitySkill,thisRaceID,alpha);
}
}
public Action:OnWar3TakeDamage(victim,attacker,inflictor,Float:damage,damagetype)
{
LastDamageTime[victim]=GetGameTime();
if(IS_PLAYER(victim)&&IS_PLAYER(attacker)&&victim>0&&attacker>0&&attacker!=victim)
{
new vteam=GetClientTeam(victim);
new ateam=GetClientTeam(attacker);
if(vteam!=ateam)
{
new race=War3_GetRace(attacker);
if(race==thisRaceID)
{
new skill_bash=War3_GetSkillLevel(attacker,race,2);
if(skill_bash && !War3_GetImmunity(victim,Immunity_Skills))
{
// Bash
new Float:chance_mod=War3_ChanceModifier(attacker,inflictor,damagetype);
new Float:percent=BashChance[skill_bash];
if(GetRandomFloat(0.0,1.0)<=percent*chance_mod && !bIsBashed[victim] && IsPlayerAlive(attacker))
{
PrintHintText(victim,"You got Bashed");
PrintHintText(attacker,"Bash!");
bIsBashed[victim]=true;
SetEntityMoveType(victim,MOVETYPE_NONE);
War3_FlashScreen(victim,RGBA_COLOR_RED);
CreateTimer(0.25,UnfreezePlayer,GetClientUserId(victim));
}
}
}
}
}
}
// Events
public PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new userid=GetEventInt(event,"userid");
new client=GetClientOfUserId(userid);
if(client>0)
{
bIsBashed[client]=false;
SetEntityMoveType(client,MOVETYPE_WALK);
iTeleportCount[client]=0;
new race=War3_GetRace(client);
if(race==thisRaceID)
{
ActivateSkills(client);
}
}
}
public RoundStartEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
if(War3_GetGame()!=Game_TF)
{
bInFreezeTime=true;
CreateTimer(GetConVarFloat(FreezeTimeCvar),EndFreezeTime);
}
}
// Misc stuff
public Action:EndFreezeTime(Handle:timer,any:param)
{
bInFreezeTime=false;
}
public Action:UnfreezePlayer(Handle:timer,any:userid)
{
new client=GetClientOfUserId(userid);
if(client>0)
{
//PrintHintText(client,"NO LONGER BASHED");
SetEntityMoveType(client,MOVETYPE_WALK);
bIsBashed[client]=false;
}
}
// Teleport Stuff
// By: stinkyfax
// Much thanks, this would be a nightmare without him.
new ClientTracer;
new Float:emptypos[3];
new Float:oldpos[66][3];
new Float:teleportpos[66][3];
bool:TeleportPlayerView(client,Float:distance)
{
if(client>0)
{
if(IsPlayerAlive(client))
{
new Float:angle[3];
GetClientEyeAngles(client,angle);
new Float:endpos[3];
new Float:startpos[3];
GetClientEyePosition(client,startpos);
new Float:dir[3];
GetAngleVectors(angle, dir, NULL_VECTOR, NULL_VECTOR);
ScaleVector(dir, distance);
//PrintToChatAll("DIR %f %f %f",dir[0],dir[1],dir[2]);
AddVectors(startpos, dir, endpos);
GetClientAbsOrigin(client,oldpos[client]);
//PrintToChatAll("1");
ClientTracer=client;
TR_TraceRayFilter(startpos,endpos,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter);
TR_GetEndPosition(endpos);
//new Float:normal[3];
//TR_GetPlaneNormal(INVALID_HANDLE,normal);
//ScaleVector(normal, 20.0);
if(enemyImmunityInRange(client,endpos)){
PrintHintText(client,"Enemy Immunity");
return false;
}
//PrintToChatAll("1endpos %f %f %f",endpos[0],endpos[1],endpos[2]);
distance=GetVectorDistance(startpos,endpos);
GetAngleVectors(angle, dir, NULL_VECTOR, NULL_VECTOR);///get dir again
ScaleVector(dir, distance-33.0);
AddVectors(startpos,dir,endpos);
//PrintToChatAll("DIR %f %f %f",dir[0],dir[1],dir[2]);
//PrintToChatAll("2endpos %f %f %f",endpos[0],endpos[1],endpos[2]);
//endpos[1]=(startpos[1]+(distance*Sine(DegToRad(angle[1]))));
//endpos[0]=(startpos[0]+(distance*Cosine(DegToRad(angle[1]))));
//if(!CheckPlayerBox(endpos,startpos,client))
// return false;
emptypos[0]=0.0;
emptypos[1]=0.0;
emptypos[2]=0.0;
endpos[2]-=30.0;
getEmptyLocationHull(client,endpos);
//PrintToChatAll("emptypos %f %f %f",emptypos[0],emptypos[1],emptypos[2]);
if(GetVectorLength(emptypos)<1.0){
PrintHintText(client,"No empty teleport location found");
return false; //it returned 0 0 0
}
TeleportEntity(client,emptypos,NULL_VECTOR,NULL_VECTOR);
EmitSoundToAll(teleportSound,client);
EmitSoundToAll(teleportSound,client);
teleportpos[client][0]=emptypos[0];
teleportpos[client][1]=emptypos[1];
teleportpos[client][2]=emptypos[2];
CreateTimer(0.1,checkTeleport,client);
return true;
}
}
return false;
}
public Action:checkTeleport(Handle:h,any:client){
new Float:pos[3];
GetClientAbsOrigin(client,pos);
if(GetVectorDistance(teleportpos[client],pos)<0.1)//he didnt move in this 0.1 second
{
TeleportEntity(client,oldpos[client],NULL_VECTOR,NULL_VECTOR);
PrintHintText(client,"You cannot teleport there");
}
else{
iTeleportCount[client]+=1;
PrintHintText(client,"TELEPORTED");
new Float:cooldown=GetConVarFloat(TeleportCooldownCvar);
War3_CooldownMGR(client,cooldown,thisRaceID,3,_,_,_,"Teleport");
}
}
public bool:AimTargetFilter(entity,mask)
{
return !(entity==ClientTracer);
}
/*
bool:CheckPlayerBox(Float:bottom[3],Float:start[3],client)
{
new Float:edge[3][8];
//point A
edge[2][0]=bottom[2];
edge[0][0]=bottom[0]+12.5;
edge[1][0]=bottom[1]+12.5;
//point B
edge[2][1]=edge[2][0];
edge[0][1]=edge[0][0]+25.0;
edge[1][1]=edge[1][0];
//point C
edge[2][2]=edge[2][1];
edge[0][2]=edge[0][1];
edge[1][2]=edge[1][1]+25.0;
//point D
edge[2][3]=edge[2][2];
edge[0][3]=edge[0][2]-25.0;
edge[1][3]=edge[1][2];
//other buttons
for(new i=0;i<4;i++)
{
for(new x=0;x<2;x++)
{
edge[x][i+4]=edge[x][i];
}
edge[2][i+4]=edge[2][i]+67.0;
}
for(new i=0;i<4;i++)
{
decl Float:point[3];
point[0]=edge[0][i];
point[1]=edge[1][i];
point[2]=edge[2][i];
decl Float:endpoint[3];
endpoint[0]=edge[0][i+4];
endpoint[1]=edge[1][i+4];
endpoint[2]=edge[2][i+4];
TR_TraceRayFilter(point,endpoint,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter);
if(TR_DidHit())
{
return false;
}
}
for(new i=0;i<7;i++)
{
decl Float:point[3];
point[0]=edge[0][i];
point[1]=edge[1][i];
point[2]=edge[2][i];
decl Float:endpoint[3];
endpoint[0]=edge[0][i+1];
endpoint[1]=edge[1][i+1];
endpoint[2]=edge[2][i+1];
TR_TraceRayFilter(point,endpoint,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter);
if(TR_DidHit())
{
return false;
}
}
new Float:top[3];
top=bottom;
top[2]+=90;
ClientTracer=client;
TR_TraceRayFilter(top,bottom,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter);
new bool:temp;
temp=TR_DidHit();
if(temp)
{
return false;
}
ClientTracer=client;
TR_TraceRayFilter(start,top,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter);
temp=TR_DidHit();
if(temp)
{
return false;
}
return true;
} */
new absincarray[]={0,4,-4,8,-8,12,-12,18,-18,22,-22,25,-25};//,27,-27,30,-30,33,-33,40,-40}; //for human it needs to be smaller
public bool:getEmptyLocationHull(client,Float:originalpos[3]){
new Float:mins[3];
new Float:maxs[3];
GetClientMins(client,mins);
GetClientMaxs(client,maxs);
//PrintToChatAll("min : %.1f %.1f %.1f MAX %.1f %.1f %.1f",mins[0],mins[1],mins[2],maxs[0],maxs[1],maxs[2]);
new absincarraysize=sizeof(absincarray);
new limit=5000;
for(new x=0;x<absincarraysize;x++){
if(limit>0){
for(new y=0;y<=x;y++){
if(limit>0){
for(new z=0;z<=y;z++){
new Float:pos[3]={0.0,0.0,0.0};
AddVectors(pos,originalpos,pos);
pos[0]+=float(absincarray[x]);
pos[1]+=float(absincarray[y]);
pos[2]+=float(absincarray[z]);
//PrintToChatAll("hull at %.1f %.1f %.1f",pos[0],pos[1],pos[2]);
//PrintToServer("hull at %d %d %d",absincarray[x],absincarray[y],absincarray[z]);
TR_TraceHullFilter(pos,pos,mins,maxs,CONTENTS_SOLID|CONTENTS_MOVEABLE,CanHitThis,client);
//new ent;
if(TR_DidHit(_))
{
//PrintToChatAll("2");
//ent=TR_GetEntityIndex(_);
//PrintToChatAll("hit %d self: %d",ent,client);
}
else{
//TeleportEntity(client,pos,NULL_VECTOR,NULL_VECTOR);
AddVectors(emptypos,pos,emptypos); ///set this gloval variable
limit=-1;
break;
}
if(limit--<0){
break;
}
}
if(limit--<0){
break;
}
}
}
if(limit--<0){
break;
}
}
}
}
public bool:CanHitThis(entityhit, mask, any:data)
{
if(entityhit == data )
{// Check if the TraceRay hit the itself.
return false; // Don't allow self to be hit, skip this result
}
if(War3_ValidPlayer(entityhit)&&War3_ValidPlayer(data)&&War3_GetGame()==Game_TF&&GetClientTeam(entityhit)==GetClientTeam(data)){
return false; //skip result, prend this space is not taken cuz they on same team
}
return true; // It didn't hit itself
}
public bool:enemyImmunityInRange(client,Float:playerVec[3])
{
//ELIMINATE ULTIMATE IF THERE IS IMMUNITY AROUND
//new Float:playerVec[3];
//GetClientAbsOrigin(client,playerVec);
new Float:otherVec[3];
new team = GetClientTeam(client);
for(new i=1;i<=MaxClients;i++)
{
if(War3_ValidPlayer(i,true)&&GetClientTeam(i)!=team&&War3_GetImmunity(i,Immunity_Ultimates))
{
GetClientAbsOrigin(i,otherVec);
if(GetVectorDistance(playerVec,otherVec)<300)
{
return true;
}
}
}
return false;
}
public Action:TFHPBuff(Handle:h,any:data){
if(war3ready&&War3_GetGame()==Game_TF){
//only create timer of TF2
for(new i=1;i<=MaxClients;i++){
if(War3_ValidPlayer(i,true)){
if(War3_GetRace(i)==thisRaceID&&GetGameTime()>LastDamageTime[i]+10.0){
new skill_devo=War3_GetSkillLevel(i,thisRaceID,1);
if(skill_devo)
{
// Devotion Aura
new curhp =GetClientHealth(i);
new maxhp =War3_GetMaxHP(i);
new hpadd=DevotionHealth[skill_devo];
if(curhp>=maxhp&&curhp<maxhp+hpadd){ ///we should add
new newhp=curhp+2;
if(newhp>maxhp+hpadd){
newhp=maxhp+hpadd;
}
SetEntityHealth(i,newhp);
}
}
}
}
}
}
}