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

War3:Source
September 21, 2012, 09:12:01 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Download: http://war3source.com/index.php?board=9.0
What is War3Source?: http://war3source.com/index.php?topic=200.0
Sample Stats: http://war3source.com/war3stats
Steam Community Group: http://steamcommunity.com/groups/war3source
War3Source SVN Checkout: http://ownageclan.com/svn/war3source/
War3Source servers: http://www.game-monitor.com/search.php?vars=war3_version=
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: [old topic] Headcrab  (Read 3941 times)
Elistor
Newbie
*
Posts: 7


View Profile
« on: May 27, 2010, 03:32:11 PM »

Headcrab race
Beta version

Require SDKHooks

  • 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);
}
}
}
}
« Last Edit: July 31, 2010, 09:10:15 AM by Ownz » Logged
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #1 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
Logged

stinkyfax
Full Member
***
Posts: 116


View Profile Email
« Reply #2 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.
Logged

[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #3 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
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #4 on: July 05, 2010, 10:19:28 PM »

if(War3_GetRace(client)== thisraceidvariable){
blah then check knife block
}
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #5 on: July 06, 2010, 12:09:33 AM »

is the blah knife chceck block Ihave there correct?
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #6 on: July 06, 2010, 08:51:50 AM »

dont know
Logged

DarkEnergy
Naris
Jr. Member
**
Posts: 60


View Profile Email
« Reply #7 on: July 06, 2010, 12:19:26 PM »

Yes, that should work.

Here is one that should work for all mods, not just CStrike
Logged
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #8 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?
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #9 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
}
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #10 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)
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #11 on: July 06, 2010, 02:30:19 PM »

War3_SetBuff can only be clients

you have to track the weapon yourself
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #12 on: July 06, 2010, 02:30:47 PM »

How to track weapon?

u cant change alpha of entity or weapon or whatever?
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #13 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)
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #14 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?
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #15 on: July 06, 2010, 02:33:26 PM »

try shopitems.sp, and search "weapon_knife"
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #16 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);

??
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #17 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
Logged

DarkEnergy
Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #18 on: July 06, 2010, 02:39:36 PM »

SetPlayerAlpha(..) in playertracking.inc
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #19 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
Logged

[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #20 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?
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #21 on: July 06, 2010, 02:41:53 PM »

you have to copy the code from SetPlayerAlpha, not use SetPlayerAlpha
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #22 on: July 06, 2010, 02:42:46 PM »

there already is a code for setweaponalpha why use setplayeralpha?
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2032



View Profile WWW Email
« Reply #23 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
Logged

DarkEnergy
[Oddity]TeacherCreature
Sr. Member
****
Posts: 461


View Profile
« Reply #24 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
Logged

Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!