Code:
/**
* File: War3Source_CryptLord.sp
* Description: The Crypt Lord race for War3Source.
* Author(s): Anthony Iacono & Ownage | Ownz
*/
#pragma semicolon 1
#include <sourcemod>
#include "W3SIncs/War3Source_Interface"
#include <sdktools>
#include <sdktools_functions>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>
#include <smlib>
new thisRaceID;
new SKILL_IMPALE,SKILL_SPIKE,SKILL_BEETLES,ULT_LOCUST;
//Increase length from 5 to 6
//skill 1
//Impale
new Float:ImpaleChanceArr[]={0.0,0.1,0.16,0.22,0.26,0.33};
//skill 2
//Spiked Carapace
//new Float:SpikeDamageRecieve[]={1.0,0.95,0.9,0.85,0.8,0.75};
//new Float:SpikeArmorGainArr[]={0.0,0.0,0.0,0.0,0.0,0.0};
new Float:SpikeChanceArr[]={0.0,0.2,0.25,0.3,0.35,0.4};
new Float:SpikeReturnDmgArr[]={0.0,0.1,0.13,0.15,0.17,0.2};
new ArmorArr[]={0,110,130,160,180,200};
//skill 3
//Carrion Beetles
new BeetleDamageArr[]={0,5,7,9,12,15};
new Float:BeetleChanceArr[]={0.0,0.2,0.25,0.28,0.3,0.33};
//ultimate
//Locust Swarm
new Handle:ultCooldownCvar;
new Handle:ultRangeCvar;
new const LocustDamage=25;
new const LocustMaxHealth=150;
new RemoveArmorArr[]={0,10,15,20,25,30};
new String:ultimateSound[]="war3source/locustswarmloop.wav";
public Plugin:myinfo =
{
name = "War3Source Race - Crypt LordZ",
author = "PimpinJuice & Ownz -ZERO <ibis>",
description = "The Crypt Lord race for War3Source.",
version = "2.0.0.5",
url = "http://Www.OwnageClan.Com"
};
public OnPluginStart()
{
ultCooldownCvar=CreateConVar("war3_crypt_locust_cooldown","20","Cooldown between ultimate usage");
ultRangeCvar=CreateConVar("war3_crypt_locust_range","800","Range of locust ultimate");
LoadTranslations("w3s.race.crypt.phrases");
}
public OnWar3LoadRaceOrItemOrdered(num)
{
if(num==80)
{
//Update levels from 4 to 5
thisRaceID=War3_CreateNewRaceT("crypt");
SKILL_IMPALE=War3_AddRaceSkill(thisRaceID,"Impale","Shake and push the enemy, 10-33% chance",false,5);
SKILL_SPIKE=War3_AddRaceSkill(thisRaceID,War3_GetGame()==Game_CS?"SpikedCarapaceCS":"SpikedCarapaceTF","Get 110-200 armor on spawn, 20-40% chance to deal 10-20% mirror damage",false,5);
SKILL_BEETLES=War3_AddRaceSkill(thisRaceID,"CarrionBeetles","20-33% chance of your beetles attacking the enemy for 5-15 extra damage",false,5);
ULT_LOCUST=War3_AddRaceSkill(thisRaceID,"LocustSwarm","steals 25HP and 10-30 armor from one random enemy",true,5);
War3_CreateRaceEnd(thisRaceID);
}
}
public OnMapStart()
{
War3_PrecacheSound(ultimateSound);
}
public OnWar3PlayerAuthed(client)
{
}
public OnRaceChanged(client,oldrace,newrace)
{
if(oldrace==thisRaceID)
{
}
}
public OnWar3EventSpawn( client )
{
new race = War3_GetRace( client );
if( race == thisRaceID )
{
new skilllevel_spike = War3_GetSkillLevel( client, thisRaceID, SKILL_SPIKE );
if( skilllevel_spike > 0)
{
GivePlayerItem(client, "item_assaultsuit");
War3_SetCSArmor(client,ArmorArr[skilllevel_spike]);
}
}
}
public OnUltimateCommand(client,race,bool:pressed)
{
if(race==thisRaceID && pressed && ValidPlayer(client,true) )
{
new ult_level=War3_GetSkillLevel(client,race,ULT_LOCUST);
if(ult_level>0)
{
if(!Silenced(client)&&War3_SkillNotInCooldown(client,thisRaceID,ULT_LOCUST,true))
{
new Float:posVec[3];
GetClientAbsOrigin(client,posVec);
new Float:otherVec[3];
new Float:bestTargetDistance=999999.0;
new team = GetClientTeam(client);
new bestTarget=0;
new Float:ultmaxdistance=GetConVarFloat(ultRangeCvar);
for(new i=1;i<=MaxClients;i++)
{
if(ValidPlayer(i,true)&&GetClientTeam(i)!=team&&!W3HasImmunity(i,Immunity_Ultimates))
{
GetClientAbsOrigin(i,otherVec);
new Float:dist=GetVectorDistance(posVec,otherVec);
if(dist<bestTargetDistance&&dist<ultmaxdistance)
{
bestTarget=i;
bestTargetDistance=GetVectorDistance(posVec,otherVec);
}
}
}
if(bestTarget==0)
{
PrintHintText(client,"%T","No Target Found within {amount} feet",client,ultmaxdistance/10);
}
else
{
//Locous Attack
//new damage=RoundFloat(float(War3_GetMaxHP(bestTarget))*LocustDamagePercent[ult_level]);
new damage=LocustDamage;
if(damage>0)
{
//Damage Player
if(War3_DealDamage(bestTarget,damage,client,DMG_BULLET,"locust")) //default magic
{
W3PrintSkillDmgHintConsole(bestTarget,client,War3_GetWar3DamageDealt(),ULT_LOCUST);
W3FlashScreen(bestTarget,RGBA_COLOR_RED);
EmitSoundToAll(ultimateSound,client);
War3_CooldownMGR(client,GetConVarFloat(ultCooldownCvar),thisRaceID,ULT_LOCUST,false,_);
//Armor Remove Part
if(War3_GetGame()==Game_CS)
{
new armor=War3_GetCSArmor(bestTarget);
new armor_subtract=RemoveArmorArr[ult_level];
new armor_new=armor-armor_subtract;
if(armor_new < 0)
{
armor_new=0;
}
War3_SetCSArmor(bestTarget,armor_new);
//Give armor and health to client
//Health
new old_health=GetClientHealth(client);
new max_health=LocustMaxHealth;
if(old_health<max_health)
{
SetEntityHealth(client,old_health+LocustDamage);
}
new givearmor=War3_GetCSArmor(client);
new givearmor_add=RemoveArmorArr[ult_level];
new givearmor_new=givearmor+givearmor_add;
War3_SetCSArmor(client,givearmor_new);
}
}
}
}
}
}
else
{
PrintHintText(client,"%T","Level Your Ultimate First",client);
}
}
}
//Removes damge as part of Spike ability, DISABLED
/*
public OnW3TakeDmgBullet(victim,attacker,Float:damage){
if(ValidPlayer(victim,true)&&ValidPlayer(attacker,true)&&GetClientTeam(victim)!=GetClientTeam(attacker))
{
if(War3_GetRace(victim)==thisRaceID)
{
new skill_level=War3_GetSkillLevel(victim,thisRaceID,SKILL_SPIKE);
if(skill_level>0&&!Hexed(victim,false))
{
War3_DamageModPercent(SpikeDamageRecieve[skill_level]);
}
}
}
}
*/
public OnWar3EventPostHurt(victim,attacker,damage)
{
if(W3GetDamageIsBullet()&&ValidPlayer(victim,true)&&ValidPlayer(attacker,true)&&GetClientTeam(victim)!=GetClientTeam(attacker))
{
if(War3_GetRace(victim)==thisRaceID)
{
//Spike Ability
new skill_level=War3_GetSkillLevel(victim,thisRaceID,SKILL_SPIKE);
if(skill_level>0&&!Hexed(victim,false))
{
if(!W3HasImmunity(attacker,Immunity_Skills)){
//Gives armor when attacked!? DISABLED
/*
if(War3_GetGame()==Game_CS)
{
new armor=War3_GetCSArmor(victim);
new armor_add=RoundFloat(damage*SpikeArmorGainArr[skill_level]);
if(armor_add>20) armor_add=20;
War3_SetCSArmor(victim,armor+armor_add);
}
*/
//Deal Damage back to attacker
if(Math_GetRandomFloat( 0.00, 1.00 ) <= SpikeChanceArr[skill_level])
{
new returndmg=RoundFloat(FloatMul(SpikeReturnDmgArr[skill_level],float(damage)));
War3_DealDamage(attacker,returndmg,victim,_,"spiked_carapace",W3DMGORIGIN_SKILL,W3DMGTYPE_PHYSICAL);
PrintToConsole(victim,"%T","Returned {amount} damage to {player}",victim,War3_GetWar3DamageDealt(),attacker);
PrintToConsole(attacker,"%T","Received {amount} damage from Spiked Carapace from {player}",attacker,War3_GetWar3DamageDealt(),victim);
}
}
}
//Impale Ability (when being attacked!?)
//skill_level = War3_GetSkillLevel(attacker,thisRaceID,SKILL_IMPALE);
//if(skill_level>0&&!Hexed(victim,false)&&Math_GetRandomFloat(0.0,1.0)<=ImpaleChanceArr[skill_level])
//{
//if(W3HasImmunity(attacker,Immunity_Skills))
//{
//PrintHintText(attacker,"%T","Blocked Impale",attacker);
//PrintHintText(victim,"%T","Enemy Blocked Impale",victim);
//}
//else
//{
//War3_ShakeScreen(attacker,2.0,50.0,40.0);
//PrintHintText(victim,"%T","Impaled enemy",victim);
//PrintHintText(attacker,"%T","You got impaled by enemy",attacker);
//W3FlashScreen(attacker,{0,0,128,80});
//}
//}
}
if(War3_GetRace(attacker)==thisRaceID)
{
//Beetles ability
new skill_level = War3_GetSkillLevel(attacker,thisRaceID,SKILL_BEETLES);
if(!Hexed(attacker,false)&&Math_GetRandomFloat(0.0,1.0)<=BeetleChanceArr[skill_level])
{
if(W3HasImmunity(victim,Immunity_Skills))
{
PrintHintText(victim,"%T","You blocked beetles attack",victim);
PrintHintText(attacker,"%T","Beetles attack was blocked",attacker);
}
else
{
War3_DealDamage(victim,BeetleDamageArr[skill_level],attacker,DMG_BULLET,"beetles");
W3PrintSkillDmgHintConsole(victim,attacker,War3_GetWar3DamageDealt(),SKILL_BEETLES);
W3FlashScreen(victim,RGBA_COLOR_RED);
}
}
//Impale ability
skill_level = War3_GetSkillLevel(attacker,thisRaceID,SKILL_IMPALE);
if(skill_level>0&&!Hexed(attacker,false)&&Math_GetRandomFloat(0.0,1.0)<=ImpaleChanceArr[skill_level]) //spike always activates except chancemod reduction
{
if(W3HasImmunity(attacker,Immunity_Skills)){
PrintHintText(victim,"%T","Blocked Impale",victim);
PrintHintText(attacker,"%T","Enemy Blocked Impale",attacker);
}
else
{
War3_ShakeScreen(victim,2.0,50.0,40.0);
PrintHintText(victim,"%T","You got impaled by enemy",victim);
PrintHintText(attacker,"%T","Impaled enemy",attacker);
W3FlashScreen(victim,{0,0,128,80});
}
}
}
}
}