Raised This Month: $ Target: $400
 0% 

Simple new Weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Max!
Member
Join Date: Jun 2009
Old 11-18-2010 , 21:27   Re: Simple new Weapon
Reply With Quote #1

im pretty sure you can change the weapon sound in the QC file of the weapon. I havent tried it in a while, so i dont remember exactly if it works, but if you're making a custom weapon, chances are you want to make a custom model for it, so it should all work out for you.

heres the qc file to a model i was editing for a mod im working on as an example:

PHP Code:
// 14 animation sequence(s)
$sequence "idle" "idle" fps 16 
$sequence 
"shoot1" "shoot1" fps 30 event 5001 0 "11" 
$sequence "shoot2" "shoot2" fps 30 event 5001 0 "11" 
$sequence "shoot3" "shoot3" fps 30 event 5001 0 "11" 
$sequence "reload" "reload" fps 70 {
  { 
event 5004 16 "weapons/m4a1_clipout.wav" 
  { 
event 5004 65 "weapons/m4a1_clipin.wav" 
  { 
event 5004 120 "weapons/m4a1_boltpull.wav" 
  { 
event 5004 156 "weapons/sliderelease1.wav" 
  { 
event 5004 197 "weapons/boltpull1.wav" 
 }
$sequence "draw" "draw" fps 8 event 5004 6 "weapons/m4a1_deploy.wav" } { event 5004 6 "weapons/m4a1_clipout.wav" 
$sequence "add_silencer" "add_silencer" fps 30 event 5004 28 "weapons/m4a1_silencer_on.wav" 
$sequence "idle_unsil" "idle_unsil" fps 30 
$sequence 
"shoot1_unsil" "shoot1_unsil" fps 30 event 5021 0 "22" 
$sequence "shoot2_unsil" "shoot2_unsil" fps 30 event 5021 0 "22" 
$sequence "shoot3_unsil" "shoot3_unsil" fps 30 event 5021 0 "22" 
$sequence "reload_unsil" "reload_unsil" fps 70 {
  { 
event 5004 16 "weapons/m4a1_clipout.wav" 
  { 
event 5004 65 "weapons/m4a1_clipin.wav" 
  { 
event 5004 120 "weapons/m4a1_boltpull.wav" 
  { 
event 5004 156 "weapons/sliderelease1.wav" 
  { 
event 5004 197 "weapons/boltpull1.wav" 
 }
$sequence "deploy_unsup" "deploy_unsup" fps 8 event 5004 6 "weapons/m4a1_deploy.wav" } { event 5004 6 "weapons/m4a1_clipout.wav" 
$sequence "detach_silencer" "detach_silencer" fps 30 event 5004 19 "weapons/m4a1_silencer_off.wav" 
try changing the wav files in the sequence event and precache the sound?

just to be clear though, im not entirely sure if this will work, im simply sharing info i saw in the qc file
Max! is offline
ARES[ro]
Senior Member
Join Date: Apr 2010
Old 11-18-2010 , 21:58   Re: Simple new Weapon
Reply With Quote #2

Dont they have to be precached separatelly?
__________________
okay
ARES[ro] is offline
Max!
Member
Join Date: Jun 2009
Old 11-18-2010 , 22:50   Re: Simple new Weapon
Reply With Quote #3

Quote:
Originally Posted by ARES[ro] View Post
Dont they have to be precached separatelly?
i think it assumes you have them if they are in the qc so i think they need to be precached in the plugin ;p

that is if it works at all
Max! is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-19-2010 , 06:05   Re: Simple new Weapon
Reply With Quote #4

Quote:
im pretty sure you can change the weapon sound in the QC file of the weapon
Theses files are precached by the mod, meaning referenced in each weapon class, etc. But the sound is played client-side.
So you are going to make custom models just to have custom sounds ? It's pretty stupid if you want to use the original weapon because you would need to redownload all the weapons. Also the fire sound is not included in the qc file, something you could not change.
To make a new weapon, using the event in the .qc file or making code in the plugin is the same thing.
__________________
Arkshine is offline
Max!
Member
Join Date: Jun 2009
Old 11-19-2010 , 20:59   Re: Simple new Weapon
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
Theses files are precached by the mod, meaning referenced in each weapon class, etc. But the sound is played client-side.
So you are going to make custom models just to have custom sounds ? It's pretty stupid if you want to use the original weapon because you would need to redownload all the weapons. Also the fire sound is not included in the qc file, something you could not change.
To make a new weapon, using the event in the .qc file or making code in the plugin is the same thing.
ah ok my bad. I didnt even notice that there was no sound for fire. Also, If you're going to make an entirely new weapon, you're probably going to use a custom model for it, so my thoughts were that you could just edit the model to have those sounds. :/
Max! is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 11-19-2010 , 06:54   Re: Simple new Weapon
Reply With Quote #6

Errmmm how about to decompile all default v_models and delete that shoot/fire sound. So no longer default sound will be play on client side. We need amxx plugin to set a shoot/fire sound for each weapon.

Is this idea will work?

**Sorry i use Engrish for my 2nd language**
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-19-2010 , 07:19   Re: Simple new Weapon
Reply With Quote #7

You have not read properly what said above...
__________________
Arkshine is offline
Lulu the hero
Senior Member
Join Date: Oct 2009
Location: Budapest, Hungary
Old 11-19-2010 , 15:25   Re: Simple new Weapon
Reply With Quote #8

I am currently making a medkit with my pal, here is where we are now. We are currently in the state of blocking all what is left of a knife. These are the things you need to look out, if you want to block a knife:
Code:
 - weapon sounds ( see the zp_extra_chainsaw plugin for sound changing )
 - view model - you see this inside
 - world model - attached to the player, seen from outside
 - weapon events, damaging
But there are 3 problems, that I see now:
Code:
 - The weapon animations( in viewmodel ) may differ from the one you would like to change( eg. knife )
 - The same goes for the world model( medkit in the left hand, right hand still animates knife moves - without any actual knife
 - The id of the changed weapon is not the same in other plugins, unless you hardcode it inside your plugin( Knife in CS != Crowbar in HL != Briefcase SI ) for every mod.
Our code so far is heavily under construction, but you can snatch out some ideas on weapon creating:
PHP Code:
#include <amxmodx>
#include <fakemeta>

//===========================================
//  Macros
//===========================================

#define xor(%1,%2)    ((%1 & ~%2) | (~%1 & %2))
#define id_to_flag(%1)    (1<<(%1-1))

#define toggle(%1,%2)    (%1 = xor(%1, id_to_flag(%2)))
#define clear(%1,%2)    (%1 = %1 & ~id_to_flag(%2))
#define set(%1,%2)    (%1 = %1 | id_to_flag(%2))
#define is_set(%1,%2)    (%1 & id_to_flag(%2))

//===========================================
//  Constants, defines
//===========================================

#define OFFSET_TEAM    114
#define OFFSET_DEATHS    444

#define DISTANCE    100

#define SND_ERROR    0
#define SND_HEAL    1
#define SND_REVIVE    2

new const medkit_models[][] =
{
    
"models/medkit/v_medkit.mdl",
    
"models/medkit/p_medkit.mdl"
}

new const 
medkit_sounds[][] =
{
    
"items/medshotno1.wav",
    
"items/medshot4.wav",
    
"items/suitchargeok1.wav"
}

//===========================================
//  Variables
//===========================================

new cvar_enabledcvar_revivecostcvar_maxmedkitammo;

new 
msg_scoreinfomsg_curweapon;

new 
dead_origin[32][3];
new 
medkit_ammo[32];
new 
max_health[32];

new 
knife_selected;
new 
medkit_selected;
new 
has_medkit;
new 
attack1attack2;

//===========================================
//  Plugin starts
//===========================================

public plugin_init()
{
    
register_plugin("SC Medkit""0.1""EXaNoVA & Lulu the hero");
    
    
attack1 0;
    
attack2 0;
    
knife_selected 0;
    
medkit_selected 0;
    
has_medkit 0;
    
    
msg_scoreinfo get_user_msgid("ScoreInfo");
    
msg_curweapon get_user_msgid("CurWeapon");
    
    
cvar_enabled        register_cvar("medkit_enabled""1");
    
cvar_reviveammo        register_cvar("medkit_revivecost""50");
    
cvar_maxmedkitammo    register_cvar("medkit_maxmedkitammo""100");
    
    
register_event("CurWeapon""event_weapon_change""be""1=1");
    
register_event("DeathMsg""event_death""a");
    
register_event("ResetHUD""event_resethud""be");
    
register_event("TeamInfo""event_teaminfo""a");
    
    
register_clcmd("say medkit""test");
    
    
register_forward(FM_EmitSound"fw_emit_sound");
    
register_forward(FM_PlayerPreThink"fw_player_think"); 
}

public 
plugin_precache()
{
    new 
i;
    
    for(
i=0i<sizeof medkit_soundsi++)
    {
        
precache_sound(medkit_sounds[i]);
    }
    for(
i=0i<sizeof medkit_modelsi++)
    {
        
precache_model(medkit_models[i]);
    }
}

public 
client_connect(id)
{
    
max_health[id-1] = 0;
    
clear(has_medkitid);
}

//===========================================
//  Events
//===========================================

public event_death(id)
{
    static 
victim;
    
victim read_data(2);
    
    
get_user_origin(victimdead_origin[victim-1])
}

public 
event_resethud(id)
{
    if(!
is_user_alive(id))
    {
        return;
    }
    
    
player_spawn(id);
}

// Code by ConnorMcLeod
public event_teaminfo()
{
    static 
idteam;
    
    
id read_data(1);
    
    if(!
is_user_alive(id) && is_user_connected(id))
    {
        
team get_pdata_int(idOFFSET_TEAM5);
        if(
team != get_user_team(id))
        {
            
emessage_begin(MSG_BROADCASTmsg_scoreinfo);
            
ewrite_byte(id);
            
ewrite_short(get_user_frags(id));
            
ewrite_short(get_pdata_int(idOFFSET_DEATHS5));
            
ewrite_short(0);
            
ewrite_short(team);
            
emessage_end();
        }
    }
}

public 
event_weapon_change(id)
{
    if(
read_data(2) == CSW_KNIFE)
    {
        
set(knife_selectedid);
        if(
is_set(has_medkitid))
        {
            
is_set(medkit_selectedid)
            {
                
set_medkit(id);
            }
        }
    }
    else
    {
        
clear(knife_selectedid);
    }
}

//===========================================
//  Forwards
//===========================================

public fw_emit_sound(idchannel, const sound[])
{    
    if(!
is_set(has_medkitid) || !is_set(knife_selectedid)
    || !
is_set(medkit_selectedid) || !is_user_alive(id)
    || !((
channel==CHAN_WEAPON) || (channel==CHAN_ITEM))
    || 
get_cvar_num(cvar_enabled))
    {
        return 
FMRES_IGNORED;
    }
    
    return 
FMRES_SUPERCEDE;
}

public 
fw_player_think(id)
{
    static 
buttonsa1a2;
    
    
buttons pev(idpev_button);
    
a1 is_set(attack1id);
    
a2 is_set(attack2id);
    
    if(
buttons IN_ATTACK)
    {
        if(!
a1)
        {
            
attack1_pressed(id);
        }
        
set(attack1id);
    }
    else
    {
        if(
a1)
        {
            
attack1_released(id);
        }
        
clear(attack1id);
    }
    
    if(
buttons IN_ATTACK2)
    {
        if(!
a2)
        {
            
attack2_pressed(id);
        }
        
set(attack2id);
    }
    else
    {
        if(
a2)
        {
            
attack2_released(id);
        }
        
clear(attack2id);
    }
}

//===========================================
//  Created events
//===========================================

public player_spawn(id)
{
    
max_health[id-1] = pev(idpev_health);
    
medkit_ammo[id-1] = get_cvar_num(cvar_maxmedkitammo)%2;
}

public 
player_respawn(id)
{
    
set_pev(idpev_healthfloat(max_health[id-1])/2);
}

public 
attack1_pressed(id)
{
    if(!
is_set(has_medkitid) || !is_set(knife_selectedid)
    || !
is_set(medkit_selectedid) || !is_user_alive(id)
    || 
get_cvar_num(cvar_enabled))
    {
        return;
    }
    
emit_sound(idCHAN_WEAPONmedkit_sounds[1], VOL_NORMATTN_NORM0PITCH_NORM);
}

public 
attack1_released(id)
{
    
}

public 
attack2_pressed(id)
{
    if(!
is_set(has_medkitid) || !is_set(knife_selectedid)
    || !
is_set(medkit_selectedid) || !is_user_alive(id)
    || 
get_cvar_num(cvar_enabled) || (medkit_ammo[id]>get_cvar_num(cvar_revivecost)))
    {
        return;
    }
    
emit_sound(idCHAN_WEAPONmedkit_sounds[2], VOL_NORMATTN_NORM0PITCH_NORM);
}

public 
attack2_released(id)
{
    
}

//===========================================
//  ??
//===========================================

public test(id)
{
    
toggle(has_medkitid);
}

public 
set_knife(id)
{
    
engclient_cmd(id"weapon_knife");
    
emessage_begin(MSG_ONEmsg_curweapon_id);
    
ewrite_byte(1);
    
ewrite_byte(CSW_KNIFE);
    
ewrite_byte(-1);
    
emessage_end();
}

public 
set_medkit(id)
{
    
set_pev(idpev_viewmodel2medkit_models[0]);
    
set_pev(idpev_weaponmodel2medkit_models[1]);
    

Hope this helps, but I also hope, that someone can give me some hints on the problems listed above.
Lulu the hero is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 11-19-2010 , 15:30   Re: Simple new Weapon
Reply With Quote #9

If you want to play your needed view model animations use this:
Code:
SendWeaponAnim( const Player, const Sequence )
{
    set_pev( Player, pev_weaponanim, Sequence )
    
    message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player )
    write_byte( Sequence )
    write_byte( pev( Player, pev_body ) )
    message_end( )
}
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode