Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2012-10-24 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog

War3:Source

War3Source Races => Races / Items - Recycle Bin => Topic started by: Elistor on May 27, 2010, 03:32:11 PM



Title: [old topic] Headcrab
Post by: Elistor on May 27, 2010, 03:32:11 PM
Headcrab race
Beta version

Require SDKHooks (http://forums.alliedmods.net/showthread.php?t=106748)

  • 50% of HP on spawn.
  • Knife only race.
  • White headcrab model for CT, and black for T.


Skill 1 - Power legs
This is longjump. When level skill higher, then longjump is biggest.

Skill 2 - Four legs
Low gravity.
  • Level 1 - To 90%
  • Level 2 - To 80%
  • Level 3 - To 70%
  • Level 4 - To 60%


Race code:
Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#include "War3Source/War3Source_Interface"

new raceID;

public Plugin:myinfo =
{
name = "War3Source Race - Headcrab",
author = "Vladislav Dolgov",
description = "Headcrab race for War3Source.",
version = "1.0.0.0",
url = "http://elistor.ru/"
};


public OnWar3PluginReady()
{
raceID=War3_CreateRace("Headcrab", "headcrab",
"You being a headcrab!", "You being a headrab when he die or respawn.",
"Power legs", "Long jump.",
"Four legs", "Low gravity.",
"No skill", "No skill",
"No skill", "No skill");
}

public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("player_jump", Event_PlayerJump);
}

public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
MarkNativeAsOptional("SDKHook");
MarkNativeAsOptional("SDKUnhook");
return APLRes_Success;
}

public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}

public Action:OnWeaponCanUse(client, weapon)
{
decl String:name[64];
GetEdictClassname(weapon, name, sizeof(name));

if(StrEqual(name, "weapon_knife", false))
return Plugin_Continue;

return Plugin_Handled;
}

public OnMapStart()
{
PrecacheModel("models/headcrab.mdl", true);
PrecacheModel("models/headcrabblack.mdl", true);
}
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client > 0)
{
new race = War3_GetRace(client);
if (race == raceID)
{
SetEntityHealth(client, 50);

if(GetClientTeam(client) == 3)
SetEntityModel(client, "models/headcrab.mdl");
else
SetEntityModel(client, "models/headcrabblack.mdl");

new skill3_fourlegs = War3_GetSkillLevel(client, race, 1);
new Float:gravity = 1.00;
switch (skill3_fourlegs)
{
case 0:
gravity = 1.00;
case 1:
gravity = 0.90;
case 2:
gravity = 0.80;
case 3:
gravity = 0.70;
case 4:
gravity = 0.60;
}
War3_SetMinGravity(client, gravity);
}
}
}

public OnSkillLevelChanged(client, race, skill, oldskilllevel, newskilllevel)
{
if (client > 0)
{
if (race == raceID && skill == 1)
{
new Float:gravity = 1.00;
switch (newskilllevel)
{
case 0:
gravity = 1.00;
case 1:
gravity = 0.90;
case 2:
gravity = 0.80;
case 3:
gravity = 0.70;
case 4:
gravity = 0.60;
}
War3_SetMinGravity(client, gravity);
}
}
}

public OnRaceSelected(client, oldrace, newrace)
{
if(newrace != raceID)
{
SetEntityHealth(client, 100);
War3_SetMinGravity(client, 1.00);
}
}

public Event_PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event,"userid"));
if (client > 0)
{
new race = War3_GetRace(client);
if (race == raceID)
{
new skill2_longjump = War3_GetSkillLevel(client, race, 0);
new Float:long_push = 1.00;
switch (skill2_longjump)
{
case 0:
long_push = 1.00;
case 1:
long_push = 1.05;
case 2:
long_push = 1.10;
case 3:
long_push = 1.15;
case 4:
long_push = 1.20;
}

if (skill2_longjump > 0)
{
new v_0 = FindSendPropOffs("CBasePlayer","m_vecVelocity[0]");
new v_1 = FindSendPropOffs("CBasePlayer","m_vecVelocity[1]");
new v_b = FindSendPropOffs("CBasePlayer","m_vecBaseVelocity");
new Float:finalvec[3];
finalvec[0] = GetEntDataFloat(client, v_0) * long_push / 2.0;
finalvec[1] = GetEntDataFloat(client, v_1) * long_push / 2.0;
finalvec[2] = long_push * 50.0;
SetEntDataVector(client, v_b, finalvec, true);
}
}
}
}


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 02, 2010, 12:32:07 AM
Needs 2 more skills,

1. Fangs - Damage over time!
2. Latch On - % when attacker kills headcrab to latch on applying slow dmg until attacker dies and headcrab is reborn


Title: Re: Headcrab
Post by: stinkyfax on July 05, 2010, 02:29:08 PM
Needs 2 more skills,

1. Fangs - Damage over time!
2. Latch On - % when attacker kills headcrab to latch on applying slow dmg until attacker dies and headcrab is reborn
Damn I love 'latch on' idea, though I would make it require you to knife (not kill but just hurt) attacker before he kills you, or any enemy before you are killed.


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 05, 2010, 10:14:53 PM
This race has some errors which I fixed since it was coded for an old version but I dont have paw nknowledge yet for weapon restrictions: 

I think this is the part of the code that restricts:
Code:
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}

public Action:OnWeaponCanUse(client, weapon)
{
decl String:name[64];
GetEdictClassname(weapon, name, sizeof(name));

if(StrEqual(name, "weapon_knife", false))
return Plugin_Continue;

return Plugin_Handled;
}

but it is restrictin ALL races to knife only instead of just headcrab,,
should I put a check to see if client is thisRaceID or will that not do it because the commadn is global?

someone please explain this to me


Title: Re: Headcrab
Post by: Ownz on July 05, 2010, 10:19:28 PM
if(War3_GetRace(client)== thisraceidvariable){
blah then check knife block
}


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 12:09:33 AM
is the blah knife chceck block Ihave there correct?


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 08:51:50 AM
dont know


Title: Re: Headcrab
Post by: Naris on July 06, 2010, 12:19:26 PM
Yes, that should work.

Here is one that should work for all mods, not just CStrike


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:26:57 PM
I want to fix the floating knife above models head

in EST we would set invisible alpha to 0 with weapon and then after short delay like 1 second
we woudl set alpha back to max but not the weapon

this way the weapon is still there but invisible

Is there a command to only set invisibility of knife?

or do we do somethign like this?

Code:
            if(GetClientTeam(client) == 3)
                SetEntityModel(client, "models/headcrab.mdl"),
                War3_SetBuff(client,fInvisibilitySkill,raceID,0.0),
                CreateTimer(1.50,War3_SetBuff(client,fInvisibilitySkill,raceID,1.0));
            else
                SetEntityModel(client, "models/headcrabblack.mdl"),
                War3_SetBuff(client,fInvisibilitySkill,raceID,0.0),
                CreateTimer(1.50,War3_SetBuff(client,fInvisibilitySkill,raceID,1.0));

also how to set have buff not include weapon on third line?


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:29:18 PM
you cant use createtimer to directly issue a function call with parameters
you ahve to use a helper function

CreateTimer(1.5,helperfunc);

public Action:helperfunc(Handle:h, any:data){
   War3_SetBuff(client,fInvisibilitySkill,raceID,1.0); //make visible again
}


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:29:39 PM
can we do
War3_SetBuff(weapon,fInvisibilitySkill,raceID,0.0)
or
War3_SetBuff(knife,fInvisibilitySkill,raceID,0.0)
or
War3_SetBuff(weapon_knife,fInvisibilitySkill,raceID,0.0)


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:30:19 PM
War3_SetBuff can only be clients

you have to track the weapon yourself


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:30:47 PM
How to track weapon?

u cant change alpha of entity or weapon or whatever?


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:31:46 PM
you can change the alpha of a weapon, its an entity

you have to find the entity of the weapon wiht some function (i dont know which function but there is one)


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:32:31 PM
can u name another race or file that does this already so I can look and learn from it instead of googling random and never finding it?


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:33:26 PM
try shopitems.sp, and search "weapon_knife"


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:36:45 PM
         new ent=GetEntDataEnt2(x,ActiveWeaponOffset);//MyWeaponsOffset);//ActiveWeaponOffset);
         if(ent>0 && IsValidEdict(ent))
         {
            decl String:wepName[64];
            GetEdictClassname(ent,wepName,64);
            if(StrEqual(wepName,"weapon_knife",true))
            {
               War3_SetBuffItem(x,fInvisibilityItem,64,0.0);

??


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:38:45 PM
weapon is not a client, you cant use buff, you ahve to manually remember this weapon, and use SetAlpha of some sort

search for setalpha in playertracking


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:39:36 PM
SetPlayerAlpha(..) in playertracking.inc


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:40:41 PM
public SetWeaponAlpha(client,alpha)
{
   new wep=GetEntDataEnt2(client,m_OffsetActiveWeapon);
   if(wep>MaxClients && IsValidEdict(wep))
   {
      SetPlayerAlpha(wep,alpha);
   }
}

how to use


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:41:26 PM
Code:
public SetWeaponAlpha(client,alpha)
{
   new wep=GetEntDataEnt2(client,m_OffsetActiveWeapon);
   if(wep>MaxClients && IsValidEdict(wep))
   {
      SetPlayerAlpha(wep,0);
   }
}
Do I need to do all this or can I just put setPlayerAlpha(wep,0) in race file?


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:41:53 PM
you have to copy the code from SetPlayerAlpha, not use SetPlayerAlpha


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:42:46 PM
there already is a code for setweaponalpha why use setplayeralpha?


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:47:56 PM
you cant reach that code cuz its in war3source.smx so you have to implement it yourself in your race


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 02:50:22 PM
yea how , can u show me what to put for the sake of learning, I dont know how to implement myself yet


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 02:53:20 PM
public SetWeaponAlpha(client,alpha)
{
   new wep=GetEntDataEnt2(client,m_OffsetActiveWeapon);
   if(wep>MaxClients && IsValidEdict(wep))
   {
      SetEntityRenderMode(index,RENDER_TRANSCOLOR);
SetEntityRenderColor(index,255,255,255,alpha);
   }
}


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 03:24:22 PM
undefined error for index


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 03:26:38 PM
replace with wep


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 03:28:26 PM
undefined error for m_OffsetActiveWeapon
 

Should I just put this at the top of the racefile?
new m_OffsetActiveWeapon;
new index;


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 03:29:22 PM
new m_OffsetActiveWeapon=FindSendPropOffs("CBasePlayer","m_hActiveWeapon");


Title: Re: Headcrab
Post by: Naris on July 06, 2010, 03:32:17 PM
How to track weapon?

u cant change alpha of entity or weapon or whatever?


Look in the SourceMod forums.

Here is a thread about making weapons invisible --> http://forums.alliedmods.net/showthread.php?t=118760 (http://forums.alliedmods.net/showthread.php?t=118760)

Code:
public SetWeaponColor(client,r,g,b,o)
{
    for(new i=0; i < 4; i++)
    {
        new entity = GetPlayerWeaponSlot(client,i);
        if(entity != -1)
        {
            SetEntityRenderMode(entity,RENDER_TRANSCOLOR);
            SetEntityRenderColor(entity,r,g,b,o);
        }
    }     
} 


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 03:38:59 PM
also knife restriction is not wokring right

it restricts headcrab race to knife but it restricts all weapons form other races


Title: Re: Headcrab
Post by: Ownz on July 06, 2010, 03:40:34 PM
do a race check


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 03:47:24 PM
I did

Code:
public Action:OnWeaponCanUse(client, weapon)
{
if (War3_GetRace(client)== raceID)
{
decl String:name[64];
GetEdictClassname(weapon, name, sizeof(name));

//if(StrEqual(name, "weapon_knife", false))
if (IsEquipmentMelee(name))
      return Plugin_Continue;
}

return Plugin_Handled;
}


Title: Re: Headcrab
Post by: stinkyfax on July 06, 2010, 03:51:33 PM
Exclusively for padawan.


public OnPluginStart() {
 ACTIVEWEAPON=FindSendPropOffs("CAI_BaseNPC", "m_hActiveWeapon");
}

public SetMyhSuperActiveWeaponInvisible(client)
{
  new weapon =  GetEntDataEnt2(client, ACTIVEWEAPON);
  SetColor(weapon, {255, 255, 255, 0});
}


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 04:05:57 PM
Thanks Jedi but I got knife color finished Iam still having a major issue with weapon restrictions


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 05:54:25 PM
Ok I got most of this race finished

anyone want to help me finish,

The last skill should be a playerdeath skill like undead with a chance to small chance to proc

if it procs it latches on and does a 10% of starting health as damage to killer every second until it kills the attacker or until he dies normally

either way when he dies the headcrab is reborn at the point of death.


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 06, 2010, 07:41:09 PM
Exclusively for padawan.


public OnPluginStart() {
 ACTIVEWEAPON=FindSendPropOffs("CAI_BaseNPC", "m_hActiveWeapon");
}

public SetMyhSuperActiveWeaponInvisible(client)
{
  new weapon =  GetEntDataEnt2(client, ACTIVEWEAPON);
  SetColor(weapon, {255, 255, 255, 0});
}


BTW this doesnt work


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 13, 2010, 11:09:49 PM
Can anyone update this to the newer version, it is whats keeping me form updating, it works right now on the old version ehre is what I have
skill4 is empty just doesnt say empty- cause I never finished it



Title: Re: Headcrab
Post by: Ownz on July 14, 2010, 08:41:23 AM
common.....................learn sourcemod and what the compile errors mean

requires 1.1.2/+


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 14, 2010, 09:12:02 AM
Thanks - I would like to learn it but I am bound by life (time) constraints.

thank you


Title: Re: Headcrab
Post by: stinkyfax on July 14, 2010, 04:56:15 PM
Thanks - I would like to learn it but I am bound by life (time) constraints.

thank you
did you mean by WCS?  8)


Title: Re: Headcrab
Post by: Ownz on July 14, 2010, 04:57:01 PM
i think thats what he meant


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 14, 2010, 06:32:46 PM
stinky u arent developing are u

I am heling WCS since they asked and I can

but my server is running WAR3


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 17, 2010, 05:09:51 PM
This was working:
Code:
public SetWeaponColor(client,r,g,b,o)
{
    for(new i=0; i < 4; i++)
    {
        new entity = GetPlayerWeaponSlot(client,i);
        if(entity != -1)
        {
            SetEntityRenderMode(entity,RENDER_TRANSCOLOR);
            SetEntityRenderColor(entity,r,g,b,o);
        }
    }     
} 
and it got rid of the floating knife but it no longer works on new version can anyone figure out why?

also

Can someone code a 4th skill called latchon triggers at player death

Latch on will slay attacker and respawn head crab instantly to attackers positon

% chance small controllable by convar?


Title: Re: Headcrab
Post by: [Oddity]TeacherCreature on July 19, 2010, 07:13:15 PM
OK this race now has a 4th latch on skill

It works well and seems pretty balanced along with some new sounds, the only remaining issues is the knife is not invisible, it kind of floats above the headcrabs head.

 


Title: Re: [old topic] Headcrab
Post by: Ownz on July 31, 2010, 09:11:37 AM
create a new topic