Hey guys,
I am going to show you guys how to create a new race! First of all, before you do anything, please remember that this plugin requires SourceMod, and races are created via the plugin system. How about this, lets create a race called Maniac, sorry about the lame name. First thing you would do is paste this into Notepad or a text editor of your choice.
Code:
#include <sourcemod>
#include "War3Source/War3Source_Interface"
new raceID;
public Plugin:myinfo =
{
name = "War3Source Race - Maniac",
author = "Anthony Iacono",
description = "An example race called Maniac.",
version = "1.0.0.0",
url = "http://war3source.com/"
};
public OnWar3PluginReady()
{
raceID=War3_CreateRace("Maniac","maniac","You are now a Maniac!","You will be a Maniac when you respawn.","Happy Feet","20-80% Speed Increase","Gift of Life","15-60 addition spawn HP","Hurdle","Allows you to jump with 20-80% less gravity","Rampage","Use your ultimate for 10 seconds of 225-300% speed");
}
#include "War3Source/War3Source_Interface"
new raceID;
public Plugin:myinfo =
{
name = "War3Source Race - Maniac",
author = "Anthony Iacono",
description = "An example race called Maniac.",
version = "1.0.0.0",
url = "http://war3source.com/"
};
public OnWar3PluginReady()
{
raceID=War3_CreateRace("Maniac","maniac","You are now a Maniac!","You will be a Maniac when you respawn.","Happy Feet","20-80% Speed Increase","Gift of Life","15-60 addition spawn HP","Hurdle","Allows you to jump with 20-80% less gravity","Rampage","Use your ultimate for 10 seconds of 225-300% speed");
}
Alright, before I go any further let me explain.
Code:
#include <sourcemod>
#include "War3Source/War3Source_Interface"
These are includes, which contain functions. The first one is SourceMod's important functions, and the second one is the War3Source interface (please note I haven't posted this file yet but I will soon).#include "War3Source/War3Source_Interface"
Code:
new raceID;
War3Source identifies each race by an ID. new means we are defining a variable, so we are telling SourceMod to define a variable named raceID.Code:
public OnWar3PluginReady()
{
raceID=War3_CreateRace("Maniac","maniac","You are now a Maniac!","You will be a Maniac when you respawn.","Happy Feet","20-80% Speed Increase","Gift of Life","15-60 addition spawn HP","Hurdle","Allows you to jump with 20-80% less gravity","Rampage","Use your ultimate for 10 seconds of 300% speed",6);
}
First, public OnWar3PluginRead() defines the function called when War3Source has finished loading. Next, we do raceID=War3_CreateRace(...) which means store the race's ID to raceID. Now let me go through the big list of parameters with you. First is the race's name, easy. Second is the race's database name identifier, easy, make sure it is one word and preferably lower-case. Third is the message that the player sees when they are changed to the race, simple. Fourth is, you guessed it, the message they see when they try to choose the race while still alive (they will become X race when dead.) Fifth is the first skill's name. Sixth is the first skill's description. Seventh is the second skill's name. Eighth is the second skill's description. Ninth is the third skill's name. Tenth is the third skill's description. Eleventh is the ultimate skill's name. Twelfth is ultimate skill's description. Last but not least, thirteenth is the required total level to use the race, please remember that this is optional, and if you leave it out it will default to 0.{
raceID=War3_CreateRace("Maniac","maniac","You are now a Maniac!","You will be a Maniac when you respawn.","Happy Feet","20-80% Speed Increase","Gift of Life","15-60 addition spawn HP","Hurdle","Allows you to jump with 20-80% less gravity","Rampage","Use your ultimate for 10 seconds of 300% speed",6);
}
Phew. Alright, lets more on to actually making the skills.
Lets start with Happy Feet, which is a speed increase. Some of you logical thinkers might be thinking, what if two race's or shopmenu item's contradict each other? I'll get to that in a second, I have designed a simple system (simple for you at least) to combat this issue.
First, we need to paste in two more function definitions.
Code:
public OnPluginStart()
{
HookEvent("player_spawn",PlayerSpawnEvent);
}
public PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
}
{
HookEvent("player_spawn",PlayerSpawnEvent);
}
public PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
}
This will make our plugin listen for player spawning. We'll make it actually do something soon. Next, add this:
Code:
public OnSkillLevelChanged(client,race,skill,oldskilllevel,newskilllevel)
{
}
{
}
Ah, seeming sort of cool yet? This function is called any time a skill's level changes.
Now add this:
Code:
public OnRaceSelected(client,oldrace,newrace)
{
}
{
}
This function gets called whenever a player changes their race. Alright, now lets put some code inside these functions. Change you public PlayerSpawnEvent(...) to look like this:
Code:
public PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new userid=GetEventInt(event,"userid"); // read "userid" from event information
new client=GetClientOfUserId(userid); // get the client index of userid
if(client>0) // make sure client is valid
{
new race=War3_GetRace(client); // get the race of the client
if(race==raceID) // this client is our race, they may get some of our skills
{
new happyfeet_skill=War3_GetSkillLevel(client,race,0); // get skill level of CLIENT in RACE, 0 means that we want skill 1. (0 mean skill 1, 1 means skill 2, 2 means skill 3, and 3 means ultimate)
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(happyfeet_skill) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed); // War3_SetMaxSpeed actually tells War3: Source that if our speed provided is greater than any other race's speed, use it. This prevents failure due to multiple speed settings
}
}
}
{
new userid=GetEventInt(event,"userid"); // read "userid" from event information
new client=GetClientOfUserId(userid); // get the client index of userid
if(client>0) // make sure client is valid
{
new race=War3_GetRace(client); // get the race of the client
if(race==raceID) // this client is our race, they may get some of our skills
{
new happyfeet_skill=War3_GetSkillLevel(client,race,0); // get skill level of CLIENT in RACE, 0 means that we want skill 1. (0 mean skill 1, 1 means skill 2, 2 means skill 3, and 3 means ultimate)
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(happyfeet_skill) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed); // War3_SetMaxSpeed actually tells War3: Source that if our speed provided is greater than any other race's speed, use it. This prevents failure due to multiple speed settings
}
}
}
Phew. Well, now we need to do something similar inside of public OnSkillLevelChanged(...):
Code:
public OnSkillLevelChanged(client,race,skill,oldskilllevel,newskilllevel)
{
if(race==raceID && skill==0) // if the race is our race and the skill is 0 (skill 1, Happy Feet)
{
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(newskilllevel) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed);
}
}
{
if(race==raceID && skill==0) // if the race is our race and the skill is 0 (skill 1, Happy Feet)
{
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(newskilllevel) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed);
}
}
Not so bad now eh?
Now, what happens if they change races?! We need to tell War3: Source to stop giving them the speed boost. Easy peezy lemon squeezy 
Code:
public OnRaceSelected(client,oldrace,newrace)
{
if(newrace!=raceID) // well they aren't our race anymore
{
War3_SetMaxSpeed(client,1.0);
}
}
{
if(newrace!=raceID) // well they aren't our race anymore
{
War3_SetMaxSpeed(client,1.0);
}
}
See, your getting the hang of it already! Happy Feet is done
Lets move on to Gift of Life, which is incredibly easy. Lets modify public PlayerSpawnEvent(...):Code:
public PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new userid=GetEventInt(event,"userid"); // read "userid" from event information
new client=GetClientOfUserId(userid); // get the client index of userid
if(client>0) // make sure client is valid
{
new race=War3_GetRace(client); // get the race of the client
if(race==raceID) // this client is our race, they may get some of our skills
{
new happyfeet_skill=War3_GetSkillLevel(client,race,0); // get skill level of CLIENT in RACE, 0 means that we want skill 1. (0 mean skill 1, 1 means skill 2, 2 means skill 3, and 3 means ultimate)
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(happyfeet_skill) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed); // War3_SetMaxSpeed actually tells War3: Source that if our speed provided is greater than any other race's speed, use it. This prevents failure due to multiple speed settings
new giftoflife_skill=War3_GetSkillLevel(client,race,1); // get skill level of CLIENT in RACE, 1 means that we want skill 2.
new old_health=GetClientHealth(client); // get their old health
new add_health=0; // define our variable for additional health
switch(giftoflife_skill) // again, conditional statement
{
case 0: // skill level 0, no increase
add_health=0;
case 1: // skill level 1, 15 extra HP
add_health=15;
case 2: // skill level 2, 30 extra HP
add_health=30;
case 3: // skill level 3, 45 extra HP
add_health=45;
case 4: // skill level 4, 60 extra HP
add_health=60;
}
SetEntityHealth(client,old_health+add_health); // easy, set CLIENT's health to old_health + add_health
}
}
}
{
new userid=GetEventInt(event,"userid"); // read "userid" from event information
new client=GetClientOfUserId(userid); // get the client index of userid
if(client>0) // make sure client is valid
{
new race=War3_GetRace(client); // get the race of the client
if(race==raceID) // this client is our race, they may get some of our skills
{
new happyfeet_skill=War3_GetSkillLevel(client,race,0); // get skill level of CLIENT in RACE, 0 means that we want skill 1. (0 mean skill 1, 1 means skill 2, 2 means skill 3, and 3 means ultimate)
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(happyfeet_skill) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed); // War3_SetMaxSpeed actually tells War3: Source that if our speed provided is greater than any other race's speed, use it. This prevents failure due to multiple speed settings
new giftoflife_skill=War3_GetSkillLevel(client,race,1); // get skill level of CLIENT in RACE, 1 means that we want skill 2.
new old_health=GetClientHealth(client); // get their old health
new add_health=0; // define our variable for additional health
switch(giftoflife_skill) // again, conditional statement
{
case 0: // skill level 0, no increase
add_health=0;
case 1: // skill level 1, 15 extra HP
add_health=15;
case 2: // skill level 2, 30 extra HP
add_health=30;
case 3: // skill level 3, 45 extra HP
add_health=45;
case 4: // skill level 4, 60 extra HP
add_health=60;
}
SetEntityHealth(client,old_health+add_health); // easy, set CLIENT's health to old_health + add_health
}
}
}
Alright, not bad, not bad. Lets move on to Hurdle, this is very similar to Happy Feet's mechanism so I am not going to hold your hand through this one.
Code:
public PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new userid=GetEventInt(event,"userid"); // read "userid" from event information
new client=GetClientOfUserId(userid); // get the client index of userid
if(client>0) // make sure client is valid
{
new race=War3_GetRace(client); // get the race of the client
if(race==raceID) // this client is our race, they may get some of our skills
{
new happyfeet_skill=War3_GetSkillLevel(client,race,0); // get skill level of CLIENT in RACE, 0 means that we want skill 1. (0 mean skill 1, 1 means skill 2, 2 means skill 3, and 3 means ultimate)
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(happyfeet_skill) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed); // War3_SetMaxSpeed actually tells War3: Source that if our speed provided is greater than any other race's speed, use it. This prevents failure due to multiple speed settings
new giftoflife_skill=War3_GetSkillLevel(client,race,1); // get skill level of CLIENT in RACE, 1 means that we want skill 2.
new old_health=GetClientHealth(client); // get their old health
new add_health=0; // define our variable for additional health
switch(giftoflife_skill) // again, conditional statement
{
case 0: // skill level 0, no increase
add_health=0;
case 1: // skill level 1, 15 extra HP
add_health=15;
case 2: // skill level 2, 30 extra HP
add_health=30;
case 3: // skill level 3, 45 extra HP
add_health=45;
case 4: // skill level 4, 60 extra HP
add_health=60;
}
SetEntityHealth(client,old_health+add_health); // easy, set CLIENT's health to old_health + add_health
new hurdle_skill=War3_GetSkillLevel(client,race,2);
new Float:gravity=1.0;
switch(hurdle_skill)
{
case 0:
gravity=1.0;
case 1:
gravity=0.8;
case 2:
gravity=0.6;
case 3:
gravity=0.4;
case 4:
gravity=0.2;
}
War3_SetMinGravity(client,gravity); // War3_SetMinGravity actually tells War3: Source that if our gravity provided is less than any other race's gravity, use it.
}
}
}
public OnSkillLevelChanged(client,race,skill,oldskilllevel,newskilllevel)
{
if(race==raceID && skill==0) // if the race is our race and the skill is 0 (skill 1, Happy Feet)
{
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(newskilllevel) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed);
}
if(race==raceID && skill==2) // Hurdle
{
new Float:gravity=1.0;
switch(newskilllevel)
{
case 0:
gravity=1.0;
case 1:
gravity=0.8;
case 2:
gravity=0.6;
case 3:
gravity=0.4;
case 4:
gravity=0.2;
}
War3_SetMinGravity(client,gravity); // War3_SetMinGravity actually tells War3: Source that if our gravity provided is less than any other race's gravity, use it.
}
}
public OnRaceSelected(client,oldrace,newrace)
{
if(newrace!=raceID) // well they aren't our race anymore
{
War3_SetMaxSpeed(client,1.0);
War3_SetMinGravity(client,1.0);
}
}
{
new userid=GetEventInt(event,"userid"); // read "userid" from event information
new client=GetClientOfUserId(userid); // get the client index of userid
if(client>0) // make sure client is valid
{
new race=War3_GetRace(client); // get the race of the client
if(race==raceID) // this client is our race, they may get some of our skills
{
new happyfeet_skill=War3_GetSkillLevel(client,race,0); // get skill level of CLIENT in RACE, 0 means that we want skill 1. (0 mean skill 1, 1 means skill 2, 2 means skill 3, and 3 means ultimate)
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(happyfeet_skill) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed); // War3_SetMaxSpeed actually tells War3: Source that if our speed provided is greater than any other race's speed, use it. This prevents failure due to multiple speed settings
new giftoflife_skill=War3_GetSkillLevel(client,race,1); // get skill level of CLIENT in RACE, 1 means that we want skill 2.
new old_health=GetClientHealth(client); // get their old health
new add_health=0; // define our variable for additional health
switch(giftoflife_skill) // again, conditional statement
{
case 0: // skill level 0, no increase
add_health=0;
case 1: // skill level 1, 15 extra HP
add_health=15;
case 2: // skill level 2, 30 extra HP
add_health=30;
case 3: // skill level 3, 45 extra HP
add_health=45;
case 4: // skill level 4, 60 extra HP
add_health=60;
}
SetEntityHealth(client,old_health+add_health); // easy, set CLIENT's health to old_health + add_health
new hurdle_skill=War3_GetSkillLevel(client,race,2);
new Float:gravity=1.0;
switch(hurdle_skill)
{
case 0:
gravity=1.0;
case 1:
gravity=0.8;
case 2:
gravity=0.6;
case 3:
gravity=0.4;
case 4:
gravity=0.2;
}
War3_SetMinGravity(client,gravity); // War3_SetMinGravity actually tells War3: Source that if our gravity provided is less than any other race's gravity, use it.
}
}
}
public OnSkillLevelChanged(client,race,skill,oldskilllevel,newskilllevel)
{
if(race==raceID && skill==0) // if the race is our race and the skill is 0 (skill 1, Happy Feet)
{
new Float:speed=1.0; // remember to define speed as a Float because it is a decimal
switch(newskilllevel) // switch means conditional statement
{
case 0: // skill level 0, no speed increase
speed=1.0;
case 1: // skill level 1, 20% speed increase
speed=1.2;
case 2: // skill level 2, 40% speed increase
speed=1.4;
case 3: // skill level 3, 60% speed increase
speed=1.6;
case 4: // skill level 4, 80% speed increase
speed=1.8;
}
War3_SetMaxSpeed(client,speed);
}
if(race==raceID && skill==2) // Hurdle
{
new Float:gravity=1.0;
switch(newskilllevel)
{
case 0:
gravity=1.0;
case 1:
gravity=0.8;
case 2:
gravity=0.6;
case 3:
gravity=0.4;
case 4:
gravity=0.2;
}
War3_SetMinGravity(client,gravity); // War3_SetMinGravity actually tells War3: Source that if our gravity provided is less than any other race's gravity, use it.
}
}
public OnRaceSelected(client,oldrace,newrace)
{
if(newrace!=raceID) // well they aren't our race anymore
{
War3_SetMaxSpeed(client,1.0);
War3_SetMinGravity(client,1.0);
}
}







Logged





DarkEnergy