Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Weapon Coding Problem

A Forum Thread for GameBanana

Now I coding my Half-Life mod and add some new weapons in it, but I have a problem... Do somebody know, how to make more than 32 weapons in Half-Life? It's a big problem to me, when I coded 32-th weapon - game crushes or this weapon works uncorrectly in game. In weapons.h there is a line: #define MAX_WEAPONS 32 I changed it to this (like in DMC code): #define MAX_WEAPONS 257 After that I made changes in cdll_dll.h, where was: #define MAX_WEAPONS 32 I wrote: #define MAX_WEAPONS 257 There were all changes, I made... I think, I must change something in Client.dll, but I don't know, WHAT! I combiled Dll and Client.dll and started game. Returned to my problem with crushing game. I think, something in client.dll is wrong (not changed) It's my opinion, that this bug is with client.dll Can you help me with fixing this bug? (with increacing maximum weapons in game)? Please!

Replies

Sign up to access this!
  • Ghoul [BB] avatar
    Ghoul [BB] Joined 17y ago
    Offline
    1,311 points Ranked 22428th
    9 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    access_time 16y
    Yes, I tryed to change weapon places, but (for example, WEAPON_CROWBAR #1 and WEAPON_AK74 # 33 I changed: ..AK74 # 1, ..CROWBAR # 33) But when I select crowbar, the game crushes...
    Bananite
    URL to post:
  • Haunter avatar
    Haunter Joined 18y ago
    Offline
    2,424 points Ranked 20182nd
    access_time 16y
    Hmm...... Try this: take one of the working weapons and place it at number 33. So let's say your number 15 weapon is a Jackhammer (WOW!). Change it to the 33rd weapon and see if it works. If it doesn't, that tutorial must be a lousy one. If it does, means the 33rd weapon is missing a few stuff.
    Bananite
    URL to post:
  • Ghoul [BB] avatar
    Ghoul [BB] Joined 17y ago
    Offline
    1,311 points Ranked 22428th
    9 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    access_time 16y
    Thanks for link, but I already seen it, and tryed to make 45 weapons... Nothing happened! I am about your topic.. 45 weapons.. I tryed to change maximum weapons to 45, but it doesn't work. For example, my weapon number is 33, (from defined 45) When I compile all dlls (client and hl) I start Half-Life and take this weapon. There is a bug: no animations/muzzleflash/bullet decals when I shoot from this weapon.
    Bananite
    URL to post:
  • Haunter avatar
    Haunter Joined 18y ago
    Offline
    2,424 points Ranked 20182nd
    access_time 16y
    It should be in the cl_dll.h file. The tutorial link I posted should be clear enough. You would need to alter two files for that. Just in case:
    Bananite
    URL to post:
  • Ghoul [BB] avatar
    Ghoul [BB] Joined 17y ago
    Offline
    1,311 points Ranked 22428th
    9 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    access_time 16y
    It's a big problem to me with increacing MAX_WEAPONS... How to do?
    Bananite
    URL to post:
  • Haunter avatar
    Haunter Joined 18y ago
    Offline
    2,424 points Ranked 20182nd
    access_time 16y
    Sweeper: True, true. Thanks, thanks. Ghoul: What seems to be the problem?
    Bananite
    URL to post:
  • Sweeper avatar
    Sweeper Joined 17y ago
    Offline
    1,496 points Ranked 21804th
    access_time 16y
    LOL, you should been using the code tags... You got a smilie in the C++ code :D Reminds me of some other forum I attended to... Didn't read the entire code, but clean and understandable, just remember the comments Haunter, otherwise you won't understand it yourself.
    Bananite
    URL to post:
  • Ghoul [BB] avatar
    Ghoul [BB] Joined 17y ago
    Offline
    1,311 points Ranked 22428th
    9 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    access_time 16y
    Yes... Throwable C4. You can throw it directly to your legs, because I changed it speed from 500 to 10, so you can't throw it to a long range. Not very good code, but it works correctly... ---------- About 45 weapons - it doesn't work! I tryed to change, but nothing happened... I don't know why, but it doesn't... Is there any way to fix this problem?
    Bananite
    URL to post:
  • Haunter avatar
    Haunter Joined 18y ago
    Offline
    2,424 points Ranked 20182nd
    access_time 16y
    Whoa! Thanks! Hm.....throwable C4s.....:D :D :D
    Bananite
    URL to post:
  • Ghoul [BB] avatar
    Ghoul [BB] Joined 17y ago
    Offline
    1,311 points Ranked 22428th
    9 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    access_time 16y
    to Haunter: no, I am not Ghoul from the collective Verc forums... I'm just GHOUL [BB>... About C4 coding... I heared, that you had a problem with coding it. But I found an easy way to code it - this code based on HandGrenade: //---------Start #include "extdll.h" #include "util.h" #include "cbase.h" #include "monsters.h" #include "weapons.h" #include "nodes.h" #include "player.h" #define C4_PRIMARY_VOLUME 500 enum c4_e { C4_IDLE1, C4_DRAW, C4_DROP, C4_PRESSBUTTON }; LINK_ENTITY_TO_CLASS( weapon_c4, Cc4 ); void Cc4::Spawn( ) { Precache( ); m_iId = WEAPON_c4; SET_MODEL(ENT(pev), "models/w_c4.mdl"); #ifndef CLIENT_DLL pev->dmg = gSkillData.plrDmgc4; #endif m_iDefaultAmmo = 1; FallInit(); } void Cc4::Precache( void ) { PRECACHE_MODEL("models/w_c4.mdl"); PRECACHE_MODEL("models/v_c4.mdl"); PRECACHE_MODEL("models/p_c4.mdl"); } int Cc4::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); p->pszAmmo1 = "c4"; p->iMaxAmmo1 = C4_MAX_CARRY; p->pszAmmo2 = NULL; p->iMaxAmmo2 = -1; p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 7; p->iPosition = 4; p->iId = m_iId = WEAPON_c4; p->iWeight = 40; p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE; return 1; } BOOL Cc4::Deploy( ) { m_flReleaseThrow = -1; return DefaultDeploy( "models/v_c4.mdl", "models/p_c4.mdl", C4_DRAW, "crowbar" ); } BOOL Cc4::CanHolster( void ) { return ( m_flStartThrow == 0 ); } void Cc4::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType > ) { SendWeaponAnim( C4_DRAW ); } else { // no more grenades! m_pPlayer->pev->weapons &= ~(1<nextthink = gpGlobals->time + 0.1; } EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM); } void Cc4::PrimaryAttack() { if ( !m_flStartThrow && m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType > > 0 ) { m_flStartThrow = gpGlobals->time; m_flReleaseThrow = 0; SendWeaponAnim( C4_PRESSBUTTON ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.5; } } void Cc4::WeaponIdle( void ) { if ( m_flReleaseThrow == 0 && m_flStartThrow ) m_flReleaseThrow = gpGlobals->time; if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; if ( m_flStartThrow ) { Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; if ( angThrow.x < 0 ) angThrow.x = -10 + angThrow.x * ( ( 20 - 10 ) / 20.0 ); else angThrow.x = -10 + angThrow.x * ( ( 20 + 10 ) / 20.0 ); float flVel = ( 20 - angThrow.x ) * 4; if ( flVel > 5 ) flVel = 5; UTIL_MakeVectors( angThrow ); Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16; Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity; float time = m_flStartThrow - gpGlobals->time + 45.0; if (time < 0) time = 0; CGrenade::ShootTimed3( m_pPlayer->pev, vecSrc, vecThrow, time ); if ( flVel < 5 ) { SendWeaponAnim( C4_DROP ); } else if ( flVel < 10 ) { SendWeaponAnim( C4_DROP ); } else { SendWeaponAnim( C4_DROP ); } m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_flReleaseThrow = 0; m_flStartThrow = 0; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType >--; if ( !m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType > ) { m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; } return; } else if ( m_flReleaseThrow > 0 ) { m_flStartThrow = 0; if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType > ) { SendWeaponAnim( C4_DRAW ); } else { RetireWeapon(); return; } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); m_flReleaseThrow = -1; return; } if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType> ) { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); if (flRand <= 0.75) { iAnim = C4_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } else { iAnim = C4_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 75.0 / 30.0; } SendWeaponAnim( iAnim ); } } //---------End
    Bananite
    URL to post:
  • Haunter avatar
    Haunter Joined 18y ago
    Offline
    2,424 points Ranked 20182nd
    access_time 16y
    URL to post:
  • Ghoul [BB] avatar
    Ghoul [BB] Joined 17y ago
    Offline
    1,311 points Ranked 22428th
    9 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    • 2 years a member Medal icon
    access_time 16y
    to SyntaxxSeven: why exactly "45" weapons? Whats the different? 257 or 45 or something else? to End Of Days: different weapons: energy, missile, alien, assault, heavy weapon tupes. Now I'm coding CS weapons... to Sweeper: of cource, HL engine has weapon limit, but I have source code, so I can change this limit to my own walue... But I don't know, what to change...
    Bananite
    URL to post:
  • Sweeper avatar
    Sweeper Joined 17y ago
    Offline
    1,496 points Ranked 21804th
    access_time 16y
    Hmmm I wonder if that value have to correspond to the amount of weapons you have. And the HL engine does have a weapon limit.
    Bananite
    URL to post:
  • Guest avatar
    Guest Joined 14y ago
    Offline
    19 medals 4 legendary 6 rare
    • Submitted 100 Skins Medal icon
    • Submitted 50 Maps Medal icon
    • Submitted 200 Threads Medal icon
    • Submitted 30 Tutorials Medal icon
    • Submitted 50 Skins Medal icon
    • Submitted 20 Maps Medal icon
    access_time 16y
    OT: i just thought of a really cool idea for a mod first person shooter Dopewars :D
    Bot Account
    URL to post:
  • End Of Days avatar
    End Of Days Joined 17y ago
    Offline
    access_time 16y
    What weapons are you trying to put in game?
    Bananite
    URL to post:
  • SyntaxxSeven avatar
    SyntaxxSeven Joined 16y ago
    Offline
    877 points Ranked 41472nd
    access_time 16y
    Try "45" weapons, then recompile and test your mod in game.
    Bananite
    URL to post:

Embed

menu
Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Author

Ghoul [BB] avatar
Ghoul [BB] Joined 17y ago
Offline
1,311 points Ranked 22428th
9 medals 1 legendary 1 rare
  • 10 years a member Medal icon
  • 6 years a member Medal icon
  • One month a member Medal icon
  • 6 months a member Medal icon
  • 1 year a member Medal icon
  • 2 years a member Medal icon
Ghoul [BB]
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • favorite 0
  • remove_red_eye 1.6k
  • mode_comment 16
  • access_time 16y

More from Submitter

menu

More Lost & Found Threads