After you registered your race and skills, you basically start implementing what they do. Start hooking events or use War3Source functions to modify their properties. HOWEVER, you must only do it if the person has a relation to your race. this is when thisRaceID and War3_GetRace comes in.
Following the example of the Undead race
when the player dies, we make him suicide
IF: he is our race, and he has our ultimate skill leveled, he hasnt already suicided since last spawn (exploit check)
public OnWar3EventDeath(victim,attacker)
{
if(!bSuicided[victim])
{
new race=War3_GetRace(victim);
new skill=War3_GetSkillLevel(victim,thisRaceID,SKILL_SUICIDE);
if(race==thisRaceID && skill>0)
{
bSuicided[victim]=true;
GetClientAbsOrigin(victim,SuicideLocation[victim]); //this is a global variable we are storing to, so he doesnt bomb in a position different than where he died.
CreateTimer(0.15,DelayedBomber,victim); ///we want a delay in the bombing
}
}
}
War3_GetSkillLevel( client, race, what skill id of this race) returns what level the player is at this skill.
For now we just check if skill level is > 0, to say that he has a level in this skill.
//DelayedBomber expires, it just calls SuicideBomber. DelayedBomber is what i call a "timer helper function" lol.
public Action:DelayedBomber(Handle:h,any:client){
if(War3_ValidPlayer(client)){
SuicideBomber(client,War3_GetSkillLevel(client,thisRaceID,SKILL_SUICIDE));
}
}
public SuicideBomber(client,level)
{
///bombing effects here...kinda long, see race file
}
When player spawns he should be able to suicide again (if hes our race lol):
public OnWar3EventSpawn(client)
{
new race=War3_GetRace(client);
if(race==thisRaceID)
{
InitSkills(client);
}
else{
bSuicided[client]=true; //kludge, not to allow some other race switch to this race and explode on death (ultimate)
}
}
And whats this InitSkills(client)??
It grants passive abilities to the player: speed and low gravity.
You will get a lesson in "buffs and debuffs" later.
public InitSkills(client){
if(War3_GetRace(client)==thisRaceID)
{
bSuicided[client]=false;
new skilllevel_unholy=War3_GetSkillLevel(client,thisRaceID,SKILL_SPEED);
if(skilllevel_unholy)
{
new Float:speed=UnholySpeed[skilllevel_unholy];
War3_SetBuff(client,fMaxSpeed,thisRaceID,speed);
}
new skilllevel_levi=War3_GetSkillLevel(client,thisRaceID,SKILL_LOWGRAV);
if(skilllevel_levi)
{
new Float:gravity=LevitationGravity[skilllevel_levi];
War3_SetBuff(client,fLowGravitySkill,thisRaceID,gravity);
}
}
}
We also set his buff on race selection (instead of waiting at next spawn to grant his powers)
But we also have to be aware if he switches to another race, we need to cancel his buffs!
public OnRaceSelected(client,newrace)
{
if(newrace!=thisRaceID) ///new race aint ours!!!!! cancel his buffs
{
War3_SetBuff(client,fMaxSpeed,thisRaceID,1.0);
War3_SetBuff(client,fLowGravitySkill,thisRaceID,1.0);
}
else ///ok then he is our race, grant powers if any
{
if(IsPlayerAlive(client)){
InitSkills(client);
}
}
}
If he leveled up (or leved down by an admin), we can reinitiate his skills, but with different levels since InitSkills gives buffs based on his current skill level.
public OnSkillLevelChanged(client,race,skill,newskilllevel)
{
if(War3_GetRace(client)==thisRaceID) ///why check race again? cuz the "race" parameter is what race's skills changed, not nessarily that the client is on this race. This is kinda redundant cuz InitSkills checks for it again LOL.
{
InitSkills(client);
}
}
We could have combined InitSkills to check if he is this race, and if he is not just remove all buffs.
This is separated just to let you know in which situations you should deal with passive skills, otherwise if not done right the player gets to double stack a race's skill with another race or do some exploits!