Post tutorial RSS HL2MP Ironsight IN FRENCH !

VOILA UN TUTO POUR LES FRANCAIS QUI MARCHE ! Bon Tuto ! et bonne lecture !

Posted by on - Basic Client Side Coding

Bienvenu sur se tutorial français pour ajouter un IronSight dans votre mod HL2MP !
Se tutorial proviens de Hl2world.com
Je l’ai traduit et un peu modifié pour qu’il soit bien compris.
J’utilise Microsoft Visual Studio .net 2003
Commençons :
1) hl2mp_weapon_parse.h
Se fichier se trouve dans server>HL2MP
Aller à la ligne (~:29)

public:<br><br>  int m_iPlayerDamage;<br>};

Et ajouter :

 Vector m_expOffset; //SA<br> QAngle m_expOriOffset; //ET SA

Donc votre code ressemble à :

public:<br><br>  Vector m_expOffset; //ADDED<br> QAngle m_expOriOffset; //ADDED<br><br>  int m_iPlayerDamage;<br>};

2) hl2mp_weapon_parse.cpp
Se fichier se trouve dans server>HL2MP
Aller a la ligne (~ :29)
Vous avez cette ligne :

void CHL2MPSWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )

Sous :

BaseClass::Parse( pKeyValuesData, szWeaponName );

Ajouter :

// this just saves off the data in the script file for later use<br>   KeyValues *pEt = pKeyValuesData->FindKey("ExpOffset");<br>   if (pEt)<br>   {<br>  m_expOffset.x     = pEt->GetFloat("x", 0.0f);<br>  m_expOffset.y     = pEt->GetFloat("y", 0.0f);<br>  m_expOffset.z     = pEt->GetFloat("z", 0.0f);<br><br>   m_expOriOffset.x  = pEt->GetFloat("xori", 0.0f);<br>  m_expOriOffset.y  = pEt->GetFloat("yori", 0.0f);<br>  m_expOriOffset.z  = pEt->GetFloat("zori", 0.0f);<br>   }<br>   else<br>   {<br>      m_expOffset = vec3_origin;<br>      m_expOriOffset.Init();<br>   }<br>

Donc votre code ressemble à :

void CHL2MPSWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )<br>{<br><br>  BaseClass::Parse( pKeyValuesData, szWeaponName );<br>   // this just saves off the data in the script file for later use<br>   KeyValues *pEt = pKeyValuesData->FindKey("ExpOffset");<br>   if (pEt)<br>   {<br>  m_expOffset.x     = pEt->GetFloat("x", 0.0f);<br>  m_expOffset.y     = pEt->GetFloat("y", 0.0f);<br>  m_expOffset.z     = pEt->GetFloat("z", 0.0f);<br><br>   m_expOriOffset.x  = pEt->GetFloat("xori", 0.0f);<br>  m_expOriOffset.y  = pEt->GetFloat("yori", 0.0f);<br>  m_expOriOffset.z  = pEt->GetFloat("zori", 0.0f);<br>   }<br>   else<br>   {<br>      m_expOffset = vec3_origin;<br>      m_expOriOffset.Init();<br>   }<br><br>  m_iPlayerDamage = pKeyValuesData->GetInt( "damage", 0 );<br>}<br>

3) baseviewmodel_shared.cpp
Se fichier se trouve dans : Server>…
Sélectionner toute cette partie :

<br>#include "cbase.h" <br>#include "baseviewmodel_shared.h" <br>#include "datacache/imdlcache.h" <br>#if defined( CLIENT_DLL ) <br>#include "iprediction.h" <br>#include "prediction.h" <br>// cin: 070105 - ironsight mode changes <br>#include "convar.h"<br> #include "c_hl2mp_player.h" <br>#include "weapon_hl2mpbase.h" <br>#else<br> #include "vguiscreen.h"<br> #endif // memdbgon must be the last include file in a .cpp file!!! <br>#include "tier0/memdbgon.h" <br>

Et remplacer par :

<br>//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//<br>//<br>// Purpose: <br>//<br>// $NoKeywords: ~TEXTAREATEMP8~lt;br>//=============================================================================//<br>#include "cbase.h"<br>#include "baseviewmodel_shared.h"<br>#include "datacache/imdlcache.h"<br><br> #if defined( CLIENT_DLL )<br>#include "iprediction.h"<br>#include "prediction.h"<br>// cin: 070105 - ironsight mode changes<br>#include "convar.h"<br>#include "c_hl2mp_player.h"<br>#include "weapon_hl2mpbase.h"<br>#else<br>#include "vguiscreen.h"<br>#endif<br><br> <br>// memdbgon must be the last include file in a .cpp file!!!<br>#include "tier0/memdbgon.h"<br><br> #define VIEWMODEL_ANIMATION_PARITY_BITS 3<br>#define SCREEN_OVERLAY_MATERIAL "vgui/screens/vgui_overlay"<br>#if defined( CLIENT_DLL )<br>void ExpWpnTestOffset(ConVar *pConVar, char *pszString);<br>ConVar   cl_exp_test_wpn_offset("cl_exp_test_wpn_offset", "0", 0, "Tests weapon offsets",<br>      (FnChangeCallback)ExpWpnTestOffset);<br><br> ConVar   cl_exp_test_wpn_offset_x("cl_exp_test_wpn_offset_x", "0");<br>ConVar   cl_exp_test_wpn_offset_y("cl_exp_test_wpn_offset_y", "0");<br>ConVar   cl_exp_test_wpn_offset_z("cl_exp_test_wpn_offset_z", "0");<br><br> ConVar   cl_exp_test_wpn_ori_offset_x("cl_exp_test_wpn_ori_offset_x", "0");<br>ConVar   cl_exp_test_wpn_ori_offset_y("cl_exp_test_wpn_ori_offset_y", "0");<br>ConVar   cl_exp_test_wpn_ori_offset_z("cl_exp_test_wpn_ori_offset_z", "0");<br><br> // cin: 070105 - applies existing weapon offsets when<br>// entering test mode (this will not be called upon<br>// weapon change, so beware)<br>// this mode should only be used for calibrating the<br>// ironsighted mode offests for a particular weapon<br>void ExpWpnTestOffset(ConVar *pConVar, char *pszString)<br>{<br>   CBasePlayer *pPlayer = UTIL_PlayerByIndex(engine->GetLocalPlayer());<br>   if (pPlayer)<br>   {<br>      CWeaponHL2MPBase *pWeapon  = dynamic_cast<CWeaponHL2MPBase *>(pPlayer->GetActiveWeapon());<br>      if (pWeapon)<br>      {<br>         cl_exp_test_wpn_offset_x.SetValue(pWeapon->GetHL2MPWpnData().m_expOffset.x);<br>         cl_exp_test_wpn_offset_y.SetValue(pWeapon->GetHL2MPWpnData().m_expOffset.y);<br>         cl_exp_test_wpn_offset_z.SetValue(pWeapon->GetHL2MPWpnData().m_expOffset.z);<br><br>          cl_exp_test_wpn_ori_offset_x.SetValue(pWeapon->GetHL2MPWpnData().m_expOriOffset.x);<br>         cl_exp_test_wpn_ori_offset_y.SetValue(pWeapon->GetHL2MPWpnData().m_expOriOffset.y);<br>         cl_exp_test_wpn_ori_offset_z.SetValue(pWeapon->GetHL2MPWpnData().m_expOriOffset.z);<br>      }<br>   }<br>}<br><br> <br>// last time ironsighted mode was toggled<br>float gIronsightedTime(0.0f);<br>float gMoveTime(0.5f); //Jorg40 - Seconds to use to move the model up to players view<br><br> // i bound this to a key for testing(i.e. bind [ ironsight_toggle)<br>CON_COMMAND(ironsight_toggle, "toggles ironsight mode for the current weapon")<br>{<br>   if (gpGlobals->curtime - gIronsightedTime < 0.5f)<br>      return;<br><br>    CBasePlayer *pPlayer = UTIL_PlayerByIndex(engine->GetLocalPlayer());<br>   if (pPlayer)<br>   {<br>     C_BaseViewModel  *pVm = pPlayer->GetViewModel();<br>      if (pVm)<br>      {<br>  //pPlayer->m_Local.m_iHideHUD |= HIDEHUD_CROSSHAIR;)<br>         pVm->m_bExpSighted  ^= true;<br>         gIronsightedTime     = gpGlobals->curtime;<br>      }<br>   }<br>}<br><br> void CalcExpWpnOffsets(CBasePlayer *owner, Vector &amp;pos, QAngle &amp;ang)<br>{<br>   Vector   forward, right, up, offset;<br><br>    // this is a simple test mode to help determine the proper values<br>   // to place in the weapon script<br>   if (cl_exp_test_wpn_offset.GetBool())<br>   {<br>      ang.x      += cl_exp_test_wpn_ori_offset_x.GetFloat();<br>      ang.y      += cl_exp_test_wpn_ori_offset_y.GetFloat();<br>      ang.z      += cl_exp_test_wpn_ori_offset_z.GetFloat();<br>      offset.Init(cl_exp_test_wpn_offset_x.GetFloat(),<br>                  cl_exp_test_wpn_offset_y.GetFloat(),<br>                  cl_exp_test_wpn_offset_z.GetFloat());<br>   }<br>   else<br>   {<br>      CWeaponHL2MPBase *pWeapon  = dynamic_cast<CWeaponHL2MPBase *>(ToHL2MPPlayer(owner)->GetActiveWeapon());<br>      if (pWeapon)<br>      {<br>         ang        += pWeapon->GetHL2MPWpnData().m_expOriOffset;<br>         offset      = pWeapon->GetHL2MPWpnData().m_expOffset;<br>      }<br>   }<br><br>    // get eye direction angles<br>   AngleVectors(ang, &amp;forward, &amp;right, &amp;up);<br><br>    // apply the offsets<br>   pos        += forward   * offset.x;<br>   pos        += right     * offset.y;<br>   pos        += up        * offset.z;<br>}<br>#endif<br>

Puis rechercher :
Ligne(~ :170)

<br>ViewModel::Spawn<br><br> Remplacer le code par:<br><br> void CBaseViewModel::Spawn( void )<br>{<br> Precache( );<br> SetSize( Vector( -8, -4, -2), Vector(8, 4, 2) );<br> SetSolid( SOLID_NONE );<br><br>  #ifdef CLIENT_DLL<br>   // cin: 070105 - ironsighted mode changes<br>   m_bExpSighted  = false;<br>   m_expFactor    = 0.0f;<br>#endif 

4) baseviewmodel_shared.h
Ce fichier se trouve dans le même dossier que baseviewmodel_shared.cpp
Chercher :

 class CBaseViewModel : public CBaseAnimating<br>{<br> DECLARE_CLASS( CBaseViewModel, CBaseAnimating );<br>public:<br>

puis ajouter entre :

 public: 

Et :

<br> DECLARE_NETWORKCLASS();<br> DECLARE_PREDICTABLE();<br>

Ceci :

<br> bool m_bExpSighted; //AJOUTER SA<br> float m_expFactor; /AJOUTER SA<br>

votre code resemble a :

<br>public:<br><br>  bool m_bExpSighted; //AJOUTER SA<br> float m_expFactor; /AJOUTER SA<br><br>  DECLARE_NETWORKCLASS();<br> DECLARE_PREDICTABLE();<br>

!!!!!!!!! COMPILER LE CODE !!!!!!!!!

5) **VOTRE_ARME***_weapon.txt
Ajouter :

<br>    ExpOffset<br>    {<br>       "x"   "-9.9"<br>        "y"   "-3.8"<br>        "z"   "2.1"<br>       // "xori"   "-2.9" //Does not work<br>       // "yori"   "1.1" //Does not work<br>    // "zori"   "2.0" // Does not work<br>}<br>

Sous :

"item_flags"

ATTENTION :

Modifier

"x"   "-9.9",   "y"   "-3.8" et "z"   "2.1" 

pour bien positioner votre arme au centre !
Pour supprimer le viseur ajouté dans autoexec.cfg (dans votre dossier cfg du mod)

crosshair 0


POUR ACTIVER VOTRE IRONSIGHT !
Utiliser la commande :

ironsight_toggle

BONUS (facultatif) :
Pour tous ceux qui trouve que c’est un PEU lent.
Voici le code pour modifier le TEMPS de déplacement.
Aller dans baseviewmodel_shared.cpp
Puis rechercher :
Ligne (~ :67)

 float gIronsightedTime(0.0f);

Et ajouter en dessous :

 float gMoveTime(0.5f); // (0.5f) est le temps de déplacement en secondes 

Modifier 0.5 pour aller plus vite ou moins vite (temps en secondes)
Et enfin rechercher :

 float delta(gpGlobals->curtime - gIronsightedTime); 

Et remplacer par:

 float delta((gpGlobals->curtime - gIronsightedTime) / gMoveTime);

Voila fin de se tutorial !

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Tutorial
Browse
Tutorials
Share
Related Mods
Related Games
Half-Life 2
Half-Life 2 First Person Shooter
Related Groups