Code:
/**
* File: War3Source_[Cereal] NINJA.sp
* Description: a race for War3Source.
* Author(s): Cereal Killer + Ownz
*/
// War3Source stuff
#pragma semicolon 1
#include <sourcemod>
#include "W3SIncs/War3Source_Interface"
#include <sdktools>
#include <sdktools_functions>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>
#include <sdkhooks>
new thisRaceID;
new Float:InvisibilityAlpha[7]={1.0,0.85,0.70,0.65,0.55,0.45,0.4};
new Float:SkillLongJump[7]={0.0,2.0,2.5,3.0,4.5,5.0,5.5};
new Float:DodgeChance[7]={0.0,0.05,0.10,0.15,0.20,0.25,0.3};
new Float:VanishChance[7]={0.0,0.04,0.7,0.11,0.14,0.17,0.2};
new Handle:ultRangeCvar;
new g_offsCollisionGroup;
new m_vecVelocity_0, m_vecVelocity_1, m_vecBaseVelocity;
new Float:ASSASSINATION_cooldown[7]={40.0,35.0,30.0,25.0,20.0,15.0,10.0};
new String:ultimateSound[]="ambient/office/coinslot1.wav";
new SKILL_INVIS, SKILL_LONGJUMP, SKILL_DODGE, SKILL_VANISH, ULT_ASSASSINATION;
public Plugin:myinfo =
{
name = "War3Source Race - Ninja",
author = "Cereal Killer + Ownz ",
description = "The Ninja race for War3Source.",
version = "1.0.0.0",
url = "http://war3source.com"
};
// War3Source Functions
public OnPluginStart()
{
ultRangeCvar=CreateConVar("war3_ninja_ult_range","99999","Range of ninja assination ultimate");
g_offsCollisionGroup = FindSendPropOffs("CBaseEntity", "m_CollisionGroup");
m_vecVelocity_0 = FindSendPropOffs("CBasePlayer","m_vecVelocity[0]");
m_vecVelocity_1 = FindSendPropOffs("CBasePlayer","m_vecVelocity[1]");
m_vecBaseVelocity = FindSendPropOffs("CBasePlayer","m_vecBaseVelocity");
HookEvent("player_jump",PlayerJumpEvent);
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}
public Action:OnWeaponCanUse(client, weapon)
{
if(War3_GetRace(client)==thisRaceID)
{
decl String:name[64];
GetEdictClassname(weapon, name, sizeof(name));
if(!StrEqual(name, "weapon_knife", false)){
return Plugin_Handled;
}
}
return Plugin_Continue;
}
public OnWar3LoadRaceOrItemOrdered2(num)
{
if(num==180)
{
thisRaceID=War3_CreateNewRace("[Cereal] Ninja","ninja");
SKILL_INVIS=War3_AddRaceSkill(thisRaceID,"Camo","blend in with the environment",false,6);
SKILL_LONGJUMP=War3_AddRaceSkill(thisRaceID,"Long Jump","Jump farther",false,6);
SKILL_DODGE=War3_AddRaceSkill(thisRaceID,"Dodge Bullets","Evade Bullets",false,6);
SKILL_VANISH=War3_AddRaceSkill(thisRaceID,"Vanish","Chance to vanish into thin air when hit",false,6);
ULT_ASSASSINATION=War3_AddRaceSkill(thisRaceID,"Assassination","Get behind a random enemy",true,6);
War3_CreateRaceEnd(thisRaceID);
}
}
// *************************************************************
public OnMapStart()
{
War3_PrecacheSound(ultimateSound);
}
new Float:pOsition[3];
public OnUltimateCommand(client,race,bool:pressed)
{
new userid=GetClientUserId(client);
if(race==thisRaceID && pressed && userid>1 && IsPlayerAlive(client) )
{
new ult_level=War3_GetSkillLevel(client,race,ULT_ASSASSINATION);
if(ult_level>0)
{
if(War3_SkillNotInCooldown(client,thisRaceID,ULT_ASSASSINATION,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(War3_ValidPlayer(i,true)&&GetClientTeam(i)!=team&&!War3_GetImmunity(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,"No Target Found");
}
else
{
new damage=RoundFloat(float(War3_GetMaxHP(bestTarget))/2.0);
if(damage>0)
{
War3_CachedPosition(bestTarget,Float:pOsition);
TeleportEntity(client,pOsition,NULL_VECTOR,NULL_VECTOR);
SetEntData(bestTarget, g_offsCollisionGroup, 2, 4, true);
EmitSoundToAll(ultimateSound,client);
CooldownUltimate(client);
}
}
}
}
else
{
PrintHintText(client,"Level Your Ultimate First");
}
}
}
public CooldownUltimate(client)
{
new skilllevel_assassination=War3_GetSkillLevel(client,thisRaceID,ULT_ASSASSINATION);
War3_CooldownMGR(client,ASSASSINATION_cooldown[skilllevel_assassination],thisRaceID,ULT_ASSASSINATION,false,false,_,"Assasination");
}
public OnRaceSelected(client,newrace)
{
if(newrace!=thisRaceID)
{
War3_SetBuff(client,fInvisibilitySkill,thisRaceID,1.0);
War3_SetBuff(client,fMaxSpeed,thisRaceID,1.0);
}
else
{
ActivateSkills(client);
}
}
// *************************************************************************************************
public ActivateSkills(client)
{
if(War3_GetRace(client)==thisRaceID)
{
new skilllevel=War3_GetSkillLevel(client,thisRaceID,SKILL_INVIS);
new Float:alpha=InvisibilityAlpha[skilllevel];
War3_SetBuff(client,fInvisibilitySkill,thisRaceID,alpha);
SetEntData(client, g_offsCollisionGroup, 2, 4, true);
}
}
public OnSkillLevelChanged(client,race,skill,newskilllevel)
{
if(War3_GetRace(client)==thisRaceID)
{
ActivateSkills(client);
}
}
public Action:OnWar3TakeDamage(victim,attacker,inflictor,Float:damage,damagetype)
{
new skill_level_dodge=War3_GetSkillLevel(victim,thisRaceID,SKILL_DODGE);
if(victim==thisRaceID && skill_level_dodge>0 &&GetClientTeam(attacker)!=GetClientTeam(victim))
{
if(GetRandomFloat(0.0,1.0)<=DodgeChance[skill_level_dodge] && !War3_GetImmunity(attacker,Immunity_Skills))
{
War3_FlashScreen(victim,RGBA_COLOR_BLUE);
War3_DamageModPercent(0.0); //NO DAMAMGE
}
}
}
public OnWar3EventPostHurt(victim,attacker,dmg){
if(War3_ValidPlayer(victim,true)&&War3_GetRace(victim)==thisRaceID){
new skilllevel=War3_GetSkillLevel(victim,thisRaceID,SKILL_VANISH);
if(skilllevel>0&&War3_Chance(VanishChance[skilllevel])){
PrintHintText(victim,"You disapear in the shadows");
War3_SetBuff(victim,fInvisibilitySkill,thisRaceID,0);
CreateTimer(1.5,Invis1,victim);
}
}
}
public Action:Invis1(Handle:timer,any:victim)
{
if(War3_GetRace(victim)==thisRaceID)
{
new skilllevel=War3_GetSkillLevel(victim,thisRaceID,SKILL_INVIS);
War3_SetBuff(victim,fInvisibilitySkill,thisRaceID,InvisibilityAlpha[skilllevel]);
}
else{
War3_SetBuff(victim,fInvisibilitySkill,thisRaceID,1.0);
}
}
public OnWar3EventSpawn(client)
{
new race=War3_GetRace(client);
if(race==thisRaceID)
{
War3_SetMaxHP(client,War3_GetMaxHP(client)-60);
ActivateSkills(client);
}
}
public PlayerJumpEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client=GetClientOfUserId(GetEventInt(event,"userid"));
if(War3_GetRace(client)==thisRaceID){
new skilllevel=War3_GetSkillLevel(client,thisRaceID,SKILL_LONGJUMP);
if(skilllevel>0){
new Float:velocity[3]={0.0,0.0,0.0};
velocity[0]= GetEntDataFloat(client,m_vecVelocity_0);
velocity[1]= GetEntDataFloat(client,m_vecVelocity_1);
velocity[0]*=SkillLongJump[skilllevel]*0.25;
velocity[1]*=SkillLongJump[skilllevel]*0.25;
SetEntDataVector(client,m_vecBaseVelocity,velocity,true);
}
}
}
* File: War3Source_[Cereal] NINJA.sp
* Description: a race for War3Source.
* Author(s): Cereal Killer + Ownz
*/
// War3Source stuff
#pragma semicolon 1
#include <sourcemod>
#include "W3SIncs/War3Source_Interface"
#include <sdktools>
#include <sdktools_functions>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>
#include <sdkhooks>
new thisRaceID;
new Float:InvisibilityAlpha[7]={1.0,0.85,0.70,0.65,0.55,0.45,0.4};
new Float:SkillLongJump[7]={0.0,2.0,2.5,3.0,4.5,5.0,5.5};
new Float:DodgeChance[7]={0.0,0.05,0.10,0.15,0.20,0.25,0.3};
new Float:VanishChance[7]={0.0,0.04,0.7,0.11,0.14,0.17,0.2};
new Handle:ultRangeCvar;
new g_offsCollisionGroup;
new m_vecVelocity_0, m_vecVelocity_1, m_vecBaseVelocity;
new Float:ASSASSINATION_cooldown[7]={40.0,35.0,30.0,25.0,20.0,15.0,10.0};
new String:ultimateSound[]="ambient/office/coinslot1.wav";
new SKILL_INVIS, SKILL_LONGJUMP, SKILL_DODGE, SKILL_VANISH, ULT_ASSASSINATION;
public Plugin:myinfo =
{
name = "War3Source Race - Ninja",
author = "Cereal Killer + Ownz ",
description = "The Ninja race for War3Source.",
version = "1.0.0.0",
url = "http://war3source.com"
};
// War3Source Functions
public OnPluginStart()
{
ultRangeCvar=CreateConVar("war3_ninja_ult_range","99999","Range of ninja assination ultimate");
g_offsCollisionGroup = FindSendPropOffs("CBaseEntity", "m_CollisionGroup");
m_vecVelocity_0 = FindSendPropOffs("CBasePlayer","m_vecVelocity[0]");
m_vecVelocity_1 = FindSendPropOffs("CBasePlayer","m_vecVelocity[1]");
m_vecBaseVelocity = FindSendPropOffs("CBasePlayer","m_vecBaseVelocity");
HookEvent("player_jump",PlayerJumpEvent);
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}
public Action:OnWeaponCanUse(client, weapon)
{
if(War3_GetRace(client)==thisRaceID)
{
decl String:name[64];
GetEdictClassname(weapon, name, sizeof(name));
if(!StrEqual(name, "weapon_knife", false)){
return Plugin_Handled;
}
}
return Plugin_Continue;
}
public OnWar3LoadRaceOrItemOrdered2(num)
{
if(num==180)
{
thisRaceID=War3_CreateNewRace("[Cereal] Ninja","ninja");
SKILL_INVIS=War3_AddRaceSkill(thisRaceID,"Camo","blend in with the environment",false,6);
SKILL_LONGJUMP=War3_AddRaceSkill(thisRaceID,"Long Jump","Jump farther",false,6);
SKILL_DODGE=War3_AddRaceSkill(thisRaceID,"Dodge Bullets","Evade Bullets",false,6);
SKILL_VANISH=War3_AddRaceSkill(thisRaceID,"Vanish","Chance to vanish into thin air when hit",false,6);
ULT_ASSASSINATION=War3_AddRaceSkill(thisRaceID,"Assassination","Get behind a random enemy",true,6);
War3_CreateRaceEnd(thisRaceID);
}
}
// *************************************************************
public OnMapStart()
{
War3_PrecacheSound(ultimateSound);
}
new Float:pOsition[3];
public OnUltimateCommand(client,race,bool:pressed)
{
new userid=GetClientUserId(client);
if(race==thisRaceID && pressed && userid>1 && IsPlayerAlive(client) )
{
new ult_level=War3_GetSkillLevel(client,race,ULT_ASSASSINATION);
if(ult_level>0)
{
if(War3_SkillNotInCooldown(client,thisRaceID,ULT_ASSASSINATION,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(War3_ValidPlayer(i,true)&&GetClientTeam(i)!=team&&!War3_GetImmunity(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,"No Target Found");
}
else
{
new damage=RoundFloat(float(War3_GetMaxHP(bestTarget))/2.0);
if(damage>0)
{
War3_CachedPosition(bestTarget,Float:pOsition);
TeleportEntity(client,pOsition,NULL_VECTOR,NULL_VECTOR);
SetEntData(bestTarget, g_offsCollisionGroup, 2, 4, true);
EmitSoundToAll(ultimateSound,client);
CooldownUltimate(client);
}
}
}
}
else
{
PrintHintText(client,"Level Your Ultimate First");
}
}
}
public CooldownUltimate(client)
{
new skilllevel_assassination=War3_GetSkillLevel(client,thisRaceID,ULT_ASSASSINATION);
War3_CooldownMGR(client,ASSASSINATION_cooldown[skilllevel_assassination],thisRaceID,ULT_ASSASSINATION,false,false,_,"Assasination");
}
public OnRaceSelected(client,newrace)
{
if(newrace!=thisRaceID)
{
War3_SetBuff(client,fInvisibilitySkill,thisRaceID,1.0);
War3_SetBuff(client,fMaxSpeed,thisRaceID,1.0);
}
else
{
ActivateSkills(client);
}
}
// *************************************************************************************************
public ActivateSkills(client)
{
if(War3_GetRace(client)==thisRaceID)
{
new skilllevel=War3_GetSkillLevel(client,thisRaceID,SKILL_INVIS);
new Float:alpha=InvisibilityAlpha[skilllevel];
War3_SetBuff(client,fInvisibilitySkill,thisRaceID,alpha);
SetEntData(client, g_offsCollisionGroup, 2, 4, true);
}
}
public OnSkillLevelChanged(client,race,skill,newskilllevel)
{
if(War3_GetRace(client)==thisRaceID)
{
ActivateSkills(client);
}
}
public Action:OnWar3TakeDamage(victim,attacker,inflictor,Float:damage,damagetype)
{
new skill_level_dodge=War3_GetSkillLevel(victim,thisRaceID,SKILL_DODGE);
if(victim==thisRaceID && skill_level_dodge>0 &&GetClientTeam(attacker)!=GetClientTeam(victim))
{
if(GetRandomFloat(0.0,1.0)<=DodgeChance[skill_level_dodge] && !War3_GetImmunity(attacker,Immunity_Skills))
{
War3_FlashScreen(victim,RGBA_COLOR_BLUE);
War3_DamageModPercent(0.0); //NO DAMAMGE
}
}
}
public OnWar3EventPostHurt(victim,attacker,dmg){
if(War3_ValidPlayer(victim,true)&&War3_GetRace(victim)==thisRaceID){
new skilllevel=War3_GetSkillLevel(victim,thisRaceID,SKILL_VANISH);
if(skilllevel>0&&War3_Chance(VanishChance[skilllevel])){
PrintHintText(victim,"You disapear in the shadows");
War3_SetBuff(victim,fInvisibilitySkill,thisRaceID,0);
CreateTimer(1.5,Invis1,victim);
}
}
}
public Action:Invis1(Handle:timer,any:victim)
{
if(War3_GetRace(victim)==thisRaceID)
{
new skilllevel=War3_GetSkillLevel(victim,thisRaceID,SKILL_INVIS);
War3_SetBuff(victim,fInvisibilitySkill,thisRaceID,InvisibilityAlpha[skilllevel]);
}
else{
War3_SetBuff(victim,fInvisibilitySkill,thisRaceID,1.0);
}
}
public OnWar3EventSpawn(client)
{
new race=War3_GetRace(client);
if(race==thisRaceID)
{
War3_SetMaxHP(client,War3_GetMaxHP(client)-60);
ActivateSkills(client);
}
}
public PlayerJumpEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client=GetClientOfUserId(GetEventInt(event,"userid"));
if(War3_GetRace(client)==thisRaceID){
new skilllevel=War3_GetSkillLevel(client,thisRaceID,SKILL_LONGJUMP);
if(skilllevel>0){
new Float:velocity[3]={0.0,0.0,0.0};
velocity[0]= GetEntDataFloat(client,m_vecVelocity_0);
velocity[1]= GetEntDataFloat(client,m_vecVelocity_1);
velocity[0]*=SkillLongJump[skilllevel]*0.25;
velocity[1]*=SkillLongJump[skilllevel]*0.25;
SetEntDataVector(client,m_vecBaseVelocity,velocity,true);
}
}
}
This race contains 4 skills and 6 level for a max of 24 total levels.
-The first skill is Camo which make you invisible.
-The second skill is Long Jump which make you jump longer.
-The third skill is dodge bullets which make you evade enemy damage.
-The ultimate is Assassination, which is basically smoke and mirrors for old WCS ninja but for War3: Source and coded by me
.-There is one pre-leveled skill or wtv you would call it xD. when someone shoots you it turn you 100% for 1 second but still take damage ofc.
-You spawn with 40 HP and a knife.
Again thx to TC and Ownz for helping me
*Edit : I changed the race. Ownz help me on improving my race it was OP before according to him. Dont worry, ultimate hasn't changed. Im too lazy to reenter changes but most importantly there another skill and thats taking the pre-leveled skill and turning it into a real on xD. so theres a fifth skill named vanish.
**Edit: i fixed an error that evryone turned 100% invis thx to syther O.o






Logged


DarkEnergy
!! I didn't know what precached mean in sourcepawn