Welcome, Guest! Login | Register

CTF Gameplay Part 3 [Print this Article]
Posted by: DarkNight
Date posted: Apr 15 2003
User Rating: 5 out of 5.0
Number of views: 1832
Number of comments: 1
Description: Setting up Client side and FGD
This part of the tutorial will show you how to setup the client side and the FGD for the CTF Gamerules.

NOTE: This code will need modifying to suit your team system,ect so don't take this as a complete C&P (which it basically is).



Open up hl_events.cpp and find the following:
void EV_TripmineFire( struct event_args_s *args );
and put this after it:
 CODE  

void EV_Flag( struct event_args_s *args );



Next, in the same file, find:
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
and after it put this:

 CODE  

gEngfuncs.pfnHookEvent( "events/object.sc", EV_Flag );


Next, in ev_hldm.cpp, find:
void EV_TripmineFire( struct event_args_s *args );
and at the end of that function put this:
 CODE  

void EV_Flag(struct event_args_s *args );



Same file, ev_hldm.cpp, find:
void EV_TripmineFire( event_args_t *args )
and at the end of that function put this:
 CODE  

#define FLAG_STOLEN 1
#define FLAG_CAPTURE    2
#define FLAG_DROPPED    3

void EV_Flag( event_args_t *args )
{
  int idx = args->entindex;
  int type = args->iparam1;


  // Feel free to change the model that is attached to the player

  int FlagModel = gEngfuncs.pEventAPI->EV_FindModelIndex("models/flag.mdl");

  switch( type )
  {
  case FLAG_STOLEN:

  // Attach model to player

  gEngfuncs.pEfxAPI->R_AttachTentToPlayer( idx, FlagModel, 52, 9999);
// The 52 is the z offset from
  the player and the 9999 is how long you want it to be attached for
  // Add more stuff here if you like

  break;
  case FLAG_CAPTURE:

  // Add stuff here if you like

  case FLAG_DROPPED:

  // Add more stuff here if you like
  // This gets rid of the attached model

  gEngfuncs.pEfxAPI->R_KillAttachedTents(idx);
  break;
  }
}



Now to setup the FGD we do the following at the bottom of the FGD:
 CODE  

@PointClass = object_flag: "The Flag" []
@SolidClass base(Targetx) = capture_team1: "Where Team 1 brings the Flag"
[
    m_iPoints(integer) : "Points" : 1
]
@SolidClass base(Targetx) = capture_team2: "Where Team 2 brings the Flag"
[
    m_iPoints(integer) : "Points" : 1
]



And that concludes my 3 Part tutorial on the CTF Gameplay. If you have any complaints, suggestions,problems,ect. Feel free to email me at the_dark_wonderer@hotmail.com

Rate This Article
This article is currently rated: 5 out of 5.0 (1 Votes)

You have to register to rate this article.
User Comments Showing comments 1-1

Posted By: AlperiNi on Jul 22 2005 at 18:18:30
Where I can find ctf_objects.h?


You must register to post a comment. If you have already registered, you must login.
Donate
Any money that is donated will go towards the server costs that I incur for running our server. Don't feel you HAVE to donate, but the link is there if you want to help us out a little. Thanks :)

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 04 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 
Debugging your half-life 2 mod
Half-Life 2 | Coding | Articles
By: blackshark | Aug 17 2007
 
How to add Ammocrates for missing ammo type and/or create new ammo types
Half-Life 2 | Coding | Server Side Tutorials
By: EoD | Aug 15 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: G.I. Jimbo | May 19 2007
 
Reading and Writing Entire Structures
General | General Coding
By: monokrome | Jan 27 2007
 
VGUI Scope
Half-Life | Coding | Client Side Tutorials
By: Pongles | Jan 19 2007
 
Where do we go from here
General | News
By: SilentSounD | Jan 18 2007
 

Site Info
296 Approved Articless
3 Pending Articles
3940 Registered Members
0 People Online (18 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!