Author Topic: [old topic] Lifestealer - N'aix [DotA]  (Read 18631 times)

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
[old topic] Lifestealer - N'aix [DotA]
« on: December 11, 2009, 04:54:16 PM »
Hi all, PimpinJuice helped me with tracing bug so as a thanks I'll make next race.

I need:
   Somebody who is willing to run beta version of race and report bugs if found.
   Somebody who could care about the effects, since I really don't have time and enthusiasm to worry about visual effects.

Idea of the race is taken from famous and glorious Map(some ppl call it game, and I agree with them) DotA (dota-allstars.com)
Description:

Character Story

There once was a man in Lordaeron so consumed by greed that he was beyond remorse. Eventually caught trying to steal Prince Arthas' sacred ring, he was tried and hanged. Yet his body, so corrupted by his desire to steal, had risen by itself in the form of a monstrous ghoul. So came into being N'aix, his old name long forgotten: the embodiment of lust and greed, bent on stealing the life of every living creature he encounters.

Skills:

Infest

The Lifestealer tears its way into the unfortunate body of a target unit, consume it and come to out killing the target. Regains health from the infested unit.
Level 1 - Gains 20% of target's maximum health
Level 2 - Gains 30% of target's maximum health
Level 3 - Gains 35% of target's maximum health
Level 4 - Gains 40% of target's maximum health


Blood Bath

Increases maximum health of the N'aix, making all his other skils be worthfy.
Please notice skill doesn't increase his health directly.
Level 0(Yes, level 0) - 30.
Level 1 - 50.
Level 2 - 70.
Level 3 - 85.
Level 4 - 100.


Feast

Regenerates a portion of enemy's current HP.
Level 1 - 4%.
Level 2 - 5%.
Level 3 - 6%.
Level 4 - 7%.


Rage

N'aix goes into a maddened rage, gaining increased attack speed.
Level 1 - 20% Increased Attack Speed. Lasts for 2 seconds.
Level 2 - 30% Increased Attack Speed. Lasts for 2.5 seconds.
Level 3 - 40% Increased Attack Speed. Lasts for 2.8 seconds.
Level 4 - 50% Increased Attack Speed. Lasts for 3 seconds.

Requires at least 0.9.1.5 version.
Source is in next post.
« Last Edit: July 31, 2010, 09:09:19 AM by Ownz »

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #1 on: December 11, 2009, 08:11:16 PM »
Source:

Code: [Select]
/* ============================================================================ */
/* */
/*   naix.sp */
/*   (c) 2009 Stinkyfax */
/* */
/*   Description is availible at site: */
/* http://war3source.com/index.php?topic=30.msg191#new */
/* */
/* ============================================================================ */


#include <sourcemod>
#include <sdktools_functions> //For teleport
#include <sdktools_sound> //For sound effect
#include "War3Source/War3Source_Interface"


// Colors
#define COLOR_DEFAULT 0x01
#define COLOR_LIGHTGREEN 0x03
#define COLOR_GREEN 0x04 // DOD = Red

//Skills Settings
new  bool:Infest_Ignore_Immunity = false;
#define RAGE_COOLDOWN 20.0
new Float:g_Skill0_1[4] = { 0.2,  0.3,  0.35,  0.40 }; //infest settings
//Skill 1_1 really has 5 settings, so it's not a mistake
new g_Skill1_1[5]       = { 30, 50, 70, 85, 100 };     //Increases Maximum health
new Float:g_Skill2_1[4] = { 0.04,  0.05,  0.06,  0.07 };   //Feast ratio
new Float:g_Skill3_1[4] = { 1.2,  1.3,  1.4,  1.5 };   //Rage Attack Rate
new Float:g_Skill3_2[4] = { 2.0,  2.5,  2.8,  3.0 };   //Rage duration

//End of skill Settings

//Ultimate temporary vars
new Float:g_fLastUlti[65];  //Stores when last ultimate was made for each player
new g_iOffs_ActiveWeapon; //offset of active weapon
new g_iOffs_NextPrimaryAttack;  //offset of ... well quite obvious
new g_iWeaponRateQueue[65][2];
new g_iWeaponRateQueueLength;
new Float:g_fMulti[65], Float:g_fDuration[65];
//end of ultimate vars



new raceID;

public Plugin:myinfo =
{
name = "War3Source Race - Lifestealer",
author = "Stinkyfax",
description = "N'aix - the embodiment of lust and greed, bent on stealing the life of every living creature he encounters.",
version = "1.0",
url = "http://sugardas.lt/~jozh/"
};


public OnWar3PluginReady()
{
raceID=War3_CreateRace("Lifestealer","naix","Your new name - N'aix!",
                          "You will be N'aix in your next life.",
                          "Infest","The Lifestealer tears its way into the unfortunate body of a target unit, consume it and come to out killing the target. Regains health from the infested unit.",
                          "Blood Bath","Increases maximum health of the N'aix, making all his other skils be worthfy.",
                          "Feast","Regenerates a portion of enemy's current HP.",
                          "Rage","N'aix goes into a maddened rage, gaining increased attack speed.");
}

public OnPluginStart()
{
HookEvent("player_death",PlayerKill);
HookEvent("player_spawn",PlayerSpawn);
HookEvent("weapon_fire",WeaponFireEvent, EventHookMode_Pre);
g_iOffs_ActiveWeapon = FindSendPropOffs("CBasePlayer","m_hActiveWeapon");
g_iOffs_NextPrimaryAttack = FindSendPropOffs("CBaseCombatWeapon","m_flNextPrimaryAttack");
}

stock bool:IsRace(client) {
  return War3_GetRace(client)==raceID;
}

/*
 * I suggest this stock will be depricated soon as
 * Give HP is supposed to be part of War3 Interface
 */
stock GiveHP(client, amount) {
  new oldHp = GetClientHealth(client);
  new health = oldHp + amount;
  if(health>War3_GetMaxHP(client))
    health=War3_GetMaxHP(client);
  if(health>oldHp) {
    SetEntityHealth(client, health);
    return  health-oldHp; //how much hp added
  }
  return 0; //didn't add anything
}

public OnMapStart() { //some precaches
  PrecacheSound("npc/zombie/zombie_pain2.wav");
}


public OnWar3TakeDamage(victim,client,inflictor,Float:damage,damagetype) {
  new chance=RoundFloat(100.0*War3_ChanceModifier(client,inflictor,damagetype));
  if(GetRandomInt(1,100)>chance)
return;
  if(!IsRace(client))
    return;
  //We check if attacker is a player (it might be world, c4, etc)
  //Also check if both victim and attacker are alive since it is essential for skill
  if( (client<0) || (client>GetMaxClients()) || (!IsPlayerAlive(client)) || (!IsPlayerAlive(victim)) )
    return;
  new level = War3_GetSkillLevel(client, raceID, 2);
  if(level<=0)
    return; //Of course don't run skill if we don't have skill
  
  //Now apply the skill since all the checks are passed
  new targetHp = GetClientHealth(victim);
  new Float:ratio = g_Skill2_1[level-1];
  new restore = RoundToNearest( float(targetHp) * ratio );
  GiveHP(client, restore);
}

public WeaponFireEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event,"userid"));
    if(!IsRace(client))
      return;
    if( (g_fDuration[client] < GetEngineTime()) || ( g_fMulti[client] < 1.0 ) )
      return;
    new ent = GetEntDataEnt2(client,g_iOffs_ActiveWeapon);
    if(ent != -1)
    {
        //fill the stack for next frame
        g_iWeaponRateQueue[g_iWeaponRateQueueLength][0] = ent;
        g_iWeaponRateQueue[g_iWeaponRateQueueLength++][1] = client;
    }
}

public OnGameFrame()  {
  if(g_iWeaponRateQueueLength<=0)
    return;
  decl ent, client, Float:time;
  new Float:enginetime = GetGameTime();
  for(new i = 0; i < g_iWeaponRateQueueLength; i++) if(IsValidEntity(g_iWeaponRateQueue[i][0])) {
    ent = g_iWeaponRateQueue[i][0];
    client = g_iWeaponRateQueue[i][1];
    new Float:multi = 1.0/g_fMulti[client];
    time = (GetEntDataFloat(ent,g_iOffs_NextPrimaryAttack) - enginetime) * multi;
    SetEntDataFloat(ent,g_iOffs_NextPrimaryAttack,time + enginetime,true);
  }
  g_iWeaponRateQueueLength = 0;
}

public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)  {
  new client = GetClientOfUserId(GetEventInt(event,"userid"));
  if(!IsRace(client))
    return Plugin_Continue;
  if(client>0 && client < 65)
    g_fLastUlti[client]=0.0;

  new level = War3_GetSkillLevel(client, raceID, 1);
  if(level<0)
    level=0;
  War3_SetMaxHP(client, War3_GetMaxHP(client) +
                    g_Skill1_1[level]);
  War3_ChatMessage(client, "Your Maximum Health now is %c%d%c.",
                    COLOR_LIGHTGREEN, War3_GetMaxHP(client), COLOR_DEFAULT);    
  
  return Plugin_Continue;
}

public Action:PlayerKill(Handle:event,const String:empty[],bool:dontBroadcast)
{
  new userid=GetClientOfUserId(GetEventInt(event,"userid"));
  new attacker=GetClientOfUserId(GetEventInt(event,"attacker"));
  if(attacker<=0)
    return Plugin_Continue;
  if(!IsRace(attacker))
    return Plugin_Continue;

  new iSkillLevel=War3_GetSkillLevel(attacker,raceID,0);
  if(iSkillLevel<=0)
    return Plugin_Continue;

  //check the users
  if( (userid<0) || (userid>GetMaxClients()) || (GetClientTeam(userid) == GetClientTeam(attacker)) )
    return Plugin_Continue;
  
  decl String:name[50];
  GetClientName(userid, name, sizeof(name));
  if(!Infest_Ignore_Immunity) { //Check for ultimate immunity of victim
    if(War3_GetImmunity(userid, War3Immunity:Immunity_Ultimates) == 1)  {
      War3_ChatMessage(attacker, "%c%s%c's Immunity prevented you from %cInfesting%c", COLOR_GREEN, name,
                        COLOR_DEFAULT, COLOR_LIGHTGREEN, COLOR_DEFAULT);
      return Plugin_Continue; //Do not run skill because of Immunity
    }
  }

  //All conditions are fine, now run the ultimate
  new Float:fRatio=g_Skill0_1[iSkillLevel-1]; //so we got the hp ration now
  new targetMaxHealth=War3_GetMaxHP(userid);
  
  decl Float:location[3];
  GetClientAbsOrigin(userid,location);
  TeleportEntity(attacker, location, NULL_VECTOR, NULL_VECTOR);

  new addHealth = RoundToNearest(float(targetMaxHealth) * fRatio);
  addHealth = GiveHP(attacker, addHealth);
  War3_ChatMessage(attacker, "%c%s%c's flesh has increased your health by %c%d%c",
        COLOR_GREEN, name, COLOR_DEFAULT, COLOR_LIGHTGREEN, addHealth, COLOR_DEFAULT);
        
  //Effects?
  EmitAmbientSound("npc/zombie/zombie_pain2.wav",location);
  
  return Plugin_Continue; //The happy end (skill has worked successfuly)
}

public OnUltimateCommand(client,race,bool:pressed)
{
  new userid=GetClientUserId(client);
  if(race==raceID && pressed && userid>1 && IsPlayerAlive(client))
  {
    new ultLevel=War3_GetSkillLevel(client,race,3);
    if(ultLevel>0)
    {
      if(g_fLastUlti[client]+RAGE_COOLDOWN > GetEngineTime() )  {
        PrintCenterText(client,"COOLDOWN LEFT: %.1f SECONDS", g_fLastUlti[client]+RAGE_COOLDOWN-GetEngineTime());
        return;
      }
      /* Since this moment we assume ultimate is being run and not cancelled */
      g_fLastUlti[client]=GetEngineTime();
      g_fMulti[client]=g_Skill3_1[ultLevel-1];
      g_fDuration[client]=GetEngineTime()+g_Skill3_2[ultLevel-1];
      War3_ChatMessage(client,
          "You have enabled %cRage%c for %c%.1f%c seconds and extra attack speed +%.0f percent",
          COLOR_GREEN, COLOR_DEFAULT, COLOR_LIGHTGREEN, g_Skill3_2[ultLevel-1],
          COLOR_DEFAULT, (g_Skill3_1[ultLevel-1]-1.0)*100.0 );
    }
  }
}



Race is tested and working.
Requires at least 0.9.1.5 version
« Last Edit: December 14, 2009, 11:34:48 PM by Anthony Iacono »

DisturbeD

  • Newbie
  • *
  • Posts: 39
  • Me fail English? That’s unpossible.
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #2 on: December 12, 2009, 02:42:56 PM »
This race looks really nice  :D
wanna test it!

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #3 on: December 12, 2009, 02:54:31 PM »
Aya, it rly looks interesting I want to test this one myself :D
Though I need next warcraft version which will have 2 natives race uses. Don't try to compile it, I usually make very many syntax errors before compiling, it is faster to make errors and fix at compiling phase rather than be careful in syntax before :D

Naris

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #4 on: December 12, 2009, 04:07:02 PM »

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #5 on: December 12, 2009, 04:10:49 PM »
are u asking the definition of the word?

Naris

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #6 on: December 12, 2009, 04:34:57 PM »
are u asking the definition of the word?

"worthful is an adjective!

Quote
making all his other skils be worthful.
is nonsensical.

Even if Blood Bath is a worthful skill that enhances his other skills and makes them worthy.
« Last Edit: December 12, 2009, 04:38:14 PM by Naris »

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #7 on: December 13, 2009, 05:21:25 PM »
Modified code after fixing compiling issues.

kooch

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #8 on: December 14, 2009, 07:34:44 AM »
I'll test this race as well. 

[Oddity]TeacherCreature

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: Lifestealer - N'aix [DotA]
« Reply #9 on: July 05, 2010, 11:39:50 AM »
Found error

public OnWar3TakeDamage(victim,client,inflictor,Float:damage,damagetype)

should say

public Action:OnWar3TakeDamage(victim,client,inflictor,Float:damage,damagetype)


Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Lifestealer - N'aix [DotA]
« Reply #10 on: July 05, 2010, 11:45:29 AM »
is stinkyfax supporting this himself?

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Lifestealer - N'aix [DotA]
« Reply #11 on: July 05, 2010, 11:48:16 AM »
and there is no attack speed modifier in war3source

[Oddity]TeacherCreature

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: Lifestealer - N'aix [DotA]
« Reply #12 on: July 05, 2010, 12:04:28 PM »
Hmmm whether there is or isnt I just used it in game and the ultimate WORKS

it adds 30 - 50% speed depending on level I tested this and it was obviously working as the gun speed felt like it doubled!

Anyway that one fix Imade will make this race compile smoothly and work well

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #13 on: July 05, 2010, 12:08:33 PM »
Hmmm whether there is or isnt I just used it in game and the ultimate WORKS

it adds 30 - 50% speed depending on level I tested this and it was obviously working as the gun speed felt like it doubled!

Anyway that one fix Imade will make this race compile smoothly and work well
then post it.
I've taken alter weapon speed algorithm from my mod long time ago. By the way the weapon speed idea goes to HOLLIDAY because I though it's impossible before he made some weired skill for pistols :)

[Oddity]TeacherCreature

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: Lifestealer - N'aix [DotA]
« Reply #14 on: July 05, 2010, 12:12:06 PM »
yea I saw that haha

I made it req levvel 75 sorry if that annoys people
but this works fine

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Lifestealer - N'aix [DotA]
« Reply #15 on: July 05, 2010, 10:39:47 PM »
attack speed modifier will be implemented into war3source
this code works with css, not tf2, so i used TF2_CalcIsAttackCritical as the weapon fire event

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #16 on: July 06, 2010, 04:35:56 AM »
attack speed modifier will be implemented into war3source
this code works with css, not tf2, so i used TF2_CalcIsAttackCritical as the weapon fire event
I got attack speed to work with TF2 (most weapons but not all) Though the code differs, used it for wow:tf2  ;)

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Lifestealer - N'aix [DotA]
« Reply #17 on: July 06, 2010, 08:54:43 AM »
eh....i got TF2 to work, but changing it abit, reread the sentence or is my grammar that bad?

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #18 on: July 06, 2010, 09:18:45 AM »
eh....i got TF2 to work, but changing it abit, reread the sentence or is my grammar that bad?
It's said you made it work in TF2 as critical, not speed.  ???

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Lifestealer - N'aix [DotA]
« Reply #19 on: July 06, 2010, 09:27:07 AM »
by using the on critical calculation to simulate a weapon-fire event

Naris

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • Email
Re: Lifestealer - N'aix [DotA]
« Reply #20 on: July 10, 2010, 11:25:18 AM »
This is a version that I modified to work in both CSS and TF2 (using the TF2_CalcIsAttackCritical() method). I also modified it to use the new 1.1.2 War3Source API. However, this version will be superseded by the version Ownz has, probably in the next War3Source release.

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Lifestealer - N'aix [DotA]
« Reply #21 on: July 10, 2010, 11:26:19 AM »
oh im still implementing attack speed modifier in the war3source main lol

[Oddity]TeacherCreature

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: Lifestealer - N'aix [DotA]
« Reply #22 on: July 17, 2010, 11:49:56 AM »
This race does not load with version 1.4 for some reason

if it is added to plugins the entire mod will not load!

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Lifestealer - N'aix [DotA]
« Reply #23 on: July 17, 2010, 11:53:20 AM »
error logs would be nice

[Oddity]TeacherCreature

  • Sr. Member
  • ****
  • Posts: 467
    • View Profile
Re: Lifestealer - N'aix [DotA]
« Reply #24 on: July 17, 2010, 01:33:46 PM »
I didnt get any

The hwole mod just wouldnt load

all I did was add naix.smx the most recent one.
I am using new beta 1.4 everything else is workin except that race. The hwolle mod would not load at all