News: Celebrating over 10 years serving the creative community

Recent Posts

Pages: [1] 2 3 ... 10
1
Tutorials / Re: [Half-Life] How to create custom items and item_speed
« Last post by Vulpine Complex on June 08, 2020, 03:33:40 PM »
Very cool, thanks for getting this together!
2
Tutorials / [Half-Life] How to create custom items and item_speed
« Last post by Napoleon on April 26, 2020, 02:02:06 PM »
Hello Team. I've been part of this community for quite some time and I got a lot of knowledge from you.

So it's only natural to share some of my own as well. Below you can find explanation on how to add new items in Half-Life 1, plus 1 item i have coded for my mod FlatLine Arena.

Below I will outline the steps needed to code a generic item and then I'll give the code for my "Extra Speed" item for my mod "FlatLine Arena" (well most of it anyway; i have extra options, messages, effects and sounds - but let's keep it clear and simple).

I will try to keep it simple, but at the end of this you should be able to create your own custom items and you will have a working item that upon acquisition and pressing the "+speedpack" key will allow you to move a lot faster in all directions (including swimming and flying, assuming you have flight in your mod).

So what is an item? - Well that's easy it's a pick up that you can activate to use or a pickup that gives you a boost of stats when obtained.

Examples? Really - longjump module, battery, healthkit etc.

So what do you need to create custom items:

1. Code that will be the effect for the item, let's say you have an awesome code that can make you player fly, invisible, or give him extra HP, armor or DMG (in my example I will give the player more speed). :)

2. In "items.cpp" you need to define your new item routines.

3. In "weapons.h", look for "#define your item (make sure to pick unique number sine you will get errors if there is a conflict)

4. In "weapons.ccp" you need to precache your new item, or the game will crash the time you try to span/obtain your item, and you don't what that right?
(well you can create item that crash the game if that's the objective... for example when a player uses impulse 101, but I prefer different medicine.. like spawning a Gargantua or a black hole when using 101)

5. You can add the item to the impulse command in "player.cpp"; look for "case 101:"

6. Create an entry in the fgd file for mappers to place in maps.

7. That's pretty much everything you need to do in order to create a new item. Compile and profit

Bonus: You can add extra effects, sounds etc; you can make the item to take HEV battery etc. it's up to you. There are endless possibilities.

That said the code part starts here. The tutorial is pretty much copy-paste, but I hope you'll learn something from it.

We'll work only on the server side of the SDK code.

================================
Extra Speed Item :) Faster than a speeding bullet!
================================

1. This needs to be added in "player.h" in the public section of "class CBasePlayer : public CBaseMonster"
below this:

Code: [Select]
char m_szTeamName[TEAM_NAME_LENGTH];
add this:


Code: [Select]
// Napoleon was here
void ExtraSpeed( ); // Faster than a speeding bullet!
BOOL m_fExtraSpeed; // Yeah I do have the item...
BOOL m_fExtraSpeedKeyDown; // Yeah I see you're pressing the speed key
// End Speed code


2. This need to be added in : "player.cpp"
Note, normally I add those right above the routines for DeadHev; still anywhere in player.cpp will do.


Code: [Select]
//=========================================================
// ExtraSpeed routines (used for item)
//=========================================================
// Napoleon was here
// Entry for the extra speed item
void CBasePlayer::ExtraSpeed( )

{
if(!m_fExtraSpeed) //if we don't have extraspeed return
return;

if(m_fExtraSpeedKeyDown) // are we pressing the speed key?
{
if ( !FBitSet(pev->flags, FL_ONGROUND) ) // are we on the ground?
{
pev->movetype = MOVETYPE_WALK; // move!

return;
}

if( pev->button & IN_FORWARD ) // are we moving forward?
{
pev->movetype = MOVETYPE_FLY; // hack!
UTIL_MakeVectors( pev->v_angle + pev->punchangle );
Vector New_Position = pev->origin + gpGlobals->v_forward * 500; // how far forward?

pev->velocity = New_Position- pev->origin;

return;
}

if( pev->button & IN_BACK ) // are we moving back?
{
pev->movetype = MOVETYPE_FLY; // hack!
UTIL_MakeVectors( pev->v_angle + pev->punchangle );
Vector New_Position = pev->origin - gpGlobals->v_forward * 500; // how far back?
pev->velocity = New_Position- pev->origin;

return;

}

if( pev->button & IN_MOVERIGHT ) // are we moving right?
{
pev->movetype = MOVETYPE_FLY; // hack!
UTIL_MakeVectors( pev->v_angle + pev->punchangle );
Vector New_Position = pev->origin + gpGlobals->v_right * 500; // how far right?
pev->velocity = New_Position- pev->origin;

return;
}

if( pev->button & IN_MOVELEFT ) // are we moving left?
{
pev->movetype = MOVETYPE_FLY; // hack!
UTIL_MakeVectors( pev->v_angle + pev->punchangle );
Vector New_Position = pev->origin - gpGlobals->v_right * 500; // how far left?
pev->velocity = New_Position- pev->origin;

return;
}
}
}

// End Extra speed

Note you can experiment with the speed, I find it best at 500.

3. Now go to void CBasePlayer::PreThink(void) (again in player.cpp); and add the below code between:

Code: [Select]
UTIL_MakeVectors(pev->v_angle); // is this still used?
and

Code: [Select]
ItemPreFrame( );
add this:


Code: [Select]
// Napoleon was here
// extra speed entry :P
ExtraSpeed(); // Faster than a speeding bullet!
// End speed entry


Now why did I added this here? To get the player speeding when the "+speedpack" button is pressed. "+speedpack" button? Yeah, we'll define it in a second. Still before that...

4. One last thing to do in player.cpp we want to make sure they don't keep the speedpack when they die.

look for:
Code: [Select]
// this client isn't going to be thinking for a while, so reset the sound until they respawn

and above it add:


Code: [Select]
// Napoleon was here
// fatser than a speeding bullet
m_fExtraSpeed = FALSE; // you died so no speed bonus for you when respawning (unless you get the item again)
// end speed


5. Now on the topic of the speed button... OK now open client.cpp so we can add the "+speedpack" command. search for

Code: [Select]
GetClassPtr((CBasePlayer *)pev)->SelectLastItem();
and below it add this:


Code: [Select]
// Napoleon was here
// faster than a speeding bullet
// you need to bind "+speedpack" to a key for this to work
else if (FStrEq(pcmd, "+speedpack" ))
{
//We are holding the key set this.
GetClassPtr((CBasePlayer *)pev)->m_fExtraSpeedKeyDown = TRUE;
}
// you don't need to bind this
else if (FStrEq(pcmd, "-speedpack" ))
{
//We are not holding the key un-set this.
GetClassPtr((CBasePlayer *)pev)->m_fExtraSpeedKeyDown = FALSE;
}
// end speeding bullet


6. OK, now we have the awesome move code and we have the command for the speedpack activation, yet we're missing the item. Let's create it.

This needs to be added in "items.cpp" (at the very bottom)


Code: [Select]
// Napoleon was here
// ExtraSpeed item code goes below :)
class CItemExtraSpeed : public CItem
{
void Spawn( void )
{
Precache( );
//the mdl we see on the ground; make sure o precache it... or the game will crash
SET_MODEL(ENT(pev), "models/w_longjump.mdl"); // feel free to change the model
CItem::Spawn( );
}
void Precache( void )
{
//precache it here, else the game crash
PRECACHE_MODEL ("models/w_longjump.mdl"); // feel free to change the model
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ( pPlayer->m_fExtraSpeed )
{
return FALSE; //don't let us pick up a pack if we have one; you don't need to be that fast...
}

pPlayer->m_fExtraSpeed = TRUE;// player now has extra speed

// Go tell the world the good news (well tell the player)
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
WRITE_STRING( STRING(pev->classname) ); //i dunno why but this should be here
MESSAGE_END();

return TRUE;
}
};

//bind the class to entity
LINK_ENTITY_TO_CLASS( item_speed, CItemExtraSpeed ); // we use this for placement on maps

// End Extra speed

7. So now we're almost done. Few more touching moves.

We need to precahe the item, to include it in impulse 101 (the first one is mandatory, else expect crashes, the second one is to get the extra speed item)
we need to #define item_speed in "weapons.h". Don't forget to define that the player starts with no super speed :P

go to "weapons.h", look for

Code: [Select]
#define ITEM_BATTERY 4
and below that add the following:


Code: [Select]
// Napoleon was here
#define ITEM_SPEED 5 // entry for the speed item
// End speed item


Note: Make sure to place the appropriate number for the item (I'm assuming you have no extra items defined, if you do you need to change the value).

go to "weapons.ccp", in "void W_Precache(void)", look for

Code: [Select]
// common world objects
and below the entry for "item_longjump" add your item:


Code: [Select]
// Napoleon was here
// if you don't precache it here the game will crash when you try to get the item
UTIL_PrecacheOther( "item_speed" ); // Faster than a speeding bullet
// end speed item



now you'd like to add the new item to the impulse 101 cheat right? (admit it... you love cheating!)

go back to "player.cpp"; look for "case 101:" and "GiveNamedItem( "item_longjump" );" ad add the following below


Code: [Select]
// Napoleon was here
// and you do like cheating
GiveNamedItem( "item_speed" ); // faster than a speeding bullet
// end speed item


Again in "player.cpp" look for " " and below it add


Code: [Select]
// Napoleon was here
m_fExtraSpeed = FALSE; // no speedpack on spawn
// end extraspeed



8. Go and compile the server and the client dlls and try our new speed item.

(sv_cheats 1; restart; impule 101 or give item_speed ); Don't forget you need to bind a key to "+speedpack" to get the boost of speed when you have the item and you press the button :)

9. Now about the fgd file

Open the file with notepad++ and add this at the bottom of the file


Code: [Select]
@PointClass size(-16 -16 0, 16 16 36) base(Weapon, Targetx) studio("models/w_longjump.mdl") = item_speed : "SpeedPack Module" []

Change the mode if you added different model.

10. For extra points you can also add:
- announcer sounds when picked up
- sprites for extra effects and when picked up (for that you need knowledge on how to send messages)
- you can make it to use HEV battery and to make sound when used

The possibilities are endless. Still I'll leave that for you.

Feel free to use in your mod and give me a feedback if you like it.
If you use my code, please give credit when credit is due. :)

Have fun and happy coding. :)
3
Work In Progress / [WIP] Half-Life Mod: FlatLine Arena
« Last post by Napoleon on April 26, 2020, 01:54:40 PM »
Hello, I haven posted here for quite some time.
How are you boys and girls doing?

I'm actively working (again) on my mod. :)

Half-Life mod: FlatLine Arena

Below you can find the ModDB page.
FlatLine Arena

The mod has a lot of new features. I will list some of them below. Please note that the mod is currently in development and what you see here is most probably not the final product.

The mod has been in development for more than 12 years.

Features:

- 30 unique weapons (I have a nuke!; and chainsaw... check the screenshots on the moddb page)
- every single weapon has alternative attack
- bots
- enhanced configs and cavrs
- 5 different gamemodes at the moment - including "Last Man Standing" and "King of The Hill"
developing "Demolition", "Base Raid" and "Capture The Flag" gamemodes (disabled and buggy at the moment)
- 12 completely new items (pickups and usable) - including but not limited to: teleport , stealth suit, jetpack, speedpack, explode on kill pack and many more.

I'm trying to overcome the limit of 32 weapons imposed by the Half-Life engine (30 usable slots + 1 for the Suit and 1 for "weapon_none"If you have any ideas on how to overcome the limit of 32 weapons, just shoot me a PM. I will appreciate it.

===
Every single weapon has alternative attack :)

The weapons are separated in 9 categories:

1. Melee weapons - Crowbar, Katana, Chainsaw and Portable med-station
2. Pistols - Fnp-45, Colt Python
3. Machine guns - Bouncer Shotgun, XM29 OICW, AK-47, M249 Charger
4. Snipers - Automatic Crossbow, Compound Bow, AW50
5. Explosives - Chain grenade, USCM Satchel, Tripmine, Snark/Chumtoad
6. Alien weapons - Grapple, Hornetgun, Shickrifle, Sporelauncher
7. Energy weapons - Gauss gun, Egon gun, Railgun, Displacer
8. High explosives - RPG-7, M32 Grenadelauncher, M13 Flamethrower
9. Experimental - M134 Minigun, AT4 Nukelauncer

Here's a little demonstration video (excuse me for the longer intro, I was showcasing the new UI, sounds and menus)

FlatLine Arena Demonstration


In the same video you can see the following implementations:

- radar
- bots
- new HUD and UI
- enhanced effects

Screenshots (don't forget to check the screenshot section for more).




Make sure to check the image section on ModDB page. :)
4
Requests / Mirroring animation.
« Last post by nuricombat on January 10, 2020, 05:33:35 AM »
-already found a way and fixing it. sorry about that-
5
Requests / Re: Need help about gun sound.
« Last post by nuricombat on December 19, 2019, 11:26:57 AM »
here.
-i make a skin for custom weapon from server on sven co-op that i play recently-
the problem is sound is not loud or right quality.
6
Requests / Re: Need help about gun sound.
« Last post by AleKK on December 19, 2019, 10:11:18 AM »
Wait, shouldn't Sven Co-op be using FMOD, which allows to play any sound of any format?

Anyway, i would advice you against using Audacity, since it's pain in the butt to edit sounds with, and my experience so far was pretty miserable. Better try GoldWave, it is better suited for editing single sounds, especially of WAV format

Actually, first thing i should've asked (and first thing you should've start with), is what are the parameters of this sound? Its format, sampling rate, bitrate, etc. It would be helpful if you send this sound here for analysis
7
Requests / Re: Need help about gun sound.
« Last post by AleKK on December 19, 2019, 09:46:17 AM »
Wait, shouldn't Sven Co-op be using FMOD, which allows to play any sound of any format?

Anyway, i would advice you against using Audacity, since it's pain in the butt to edit sounds with, and my experience so far was pretty miserable. Better try GoldWave, it is better suited for editing single sounds, especially of WAV format
8
Requests / Re: Need help about gun sound.
« Last post by nuricombat on December 19, 2019, 08:52:24 AM »
How do i fix this?
9
Requests / Re: Need help about gun sound.
« Last post by Megan on December 19, 2019, 04:36:39 AM »
The sound is probably too high quality and is being resampled by the engine.
10
Requests / Need help about gun sound.
« Last post by nuricombat on December 19, 2019, 02:21:52 AM »
Hello everyone.
is been too long since my pc dead for like 5 years, i had to said im so sorry for everyone i had been bother or annoying when i was a kid with c-k nut attitude and somekind of nerd. i am so sorry
but now i came back to do my own stuff on half life again but mostly now on sven for my group that i know. -also sorry about my english too since im suck at grammar and very bad at it-

okay so i had a problem with gun sound. when review files is sound normally like loud and it should be
but when i put sound into weapon files and play sven. it doesnt sound like it at all, is like sound quality is different.  i had audacity ready but i forgot how to fix it.
anyone know why or how?
Pages: [1] 2 3 ... 10