Basic Map
It's alias is often m_pGame .. this depends on where you trying to use it.
• m_pGame = Basics and some common things
• m_pGame->GetSystem( ) = ISystem
• m_pGame->GetSystem( )->GetAISystem( ) = IAISystem
• m_pGame->GetSystem( )->GetI3DEngine( ) = I3DEngine [play with the game engine. It'll be interesting, they said..]
• m_pGame->GetSystem( )->GetIMovieSystem( ) = IMovieSystem [cutscene stuff]
• m_pGame->GetSystem( )->GetIMusicSystem( ) = IMusicSystem
• m_pGame->GetSystem( )->GetIProfileSystem( ) = IFrameProfileSystem [not sure what you're gonna do with this one]
• m_pGame->GetSystem( )->GetIRenderer( ) = IRenderer [sometimes known locally as m_pRenderer. Fancy stuff]
• m_pGame->GetSystem( )->GetIScriptSystem( ) = IScriptSystem [execute script files, get and set global values, etc]
• m_pGame->GetSystem( )->GetISoundSystem( ) = ISoundSystem [play sounds, stop sounds. All sorts of cool sound stuff]
• And a million more things. Also check out other classes and objects. If you need to get a reference to a specific item, ask on the FarCry Labs Discord and we'll try to help.
Game HWND
(HWND)m_pRenderer->GetHWND( )
There's other ways, but this is the one that CryTek provided. This HWND can be used for generic Win32 calls. Think creatively :)Game Title
SetWindowText( HWND , "Far Cry - Another amazing Mod" );
Note: There's multiple ways to get the HWND of the game. Should be documented in FCDB as wellAdd a Hud message
m_pClient->AddHudMessage( "This message will appear in the hud." , 50.0f , false );
Add a Hud subtitle
m_pClient->AddHudSubtitle( "Subtitles from C++? Devious!" , 200.0f );
Draw Line
• In this specific case, the IRenderer has an alias of m_pRenderer
m_pRenderer->Set2DMode( true , 800 , 600 );
m_pRenderer->Draw2dLine( 400 , 600 , 400 , 0 );
Draw Text
• In this specific case, the IRenderer has an alias of m_pRenderer
Basic and easy:
m_pRenderer->Draw2dText( 100 , 250 , "This mod is epic!" , SDrawTextInfo( ) );
If you want more control, then use the following syntax:
SDrawTextInfo TextProp;
TextProp.flags = 0; // Flags
TextProp.color[ 0 ] = 1; // R
TextProp.color[ 1 ] = 1; // G
TextProp.color[ 2 ] = 0; // B
TextProp.color[ 3 ] = 1; // A
TextProp.xfont = 0; // Specify a valid CXFont
m_pRenderer->Draw2dText( 100 , 250 , "This mod is epic!" , TextProp );
Note: There's additional options not documented here that may or may not work. There's a third and fancier method, but these should handle basic needs.Dealing with trigonometry and angles
Convert an angle from degrees to radian: DEG2RAD( ANGLE )
Convert an angle from radians to degree: RAD2DEG( ANGLE )
The Player
• In this specific case, m_pGame is a reference to the CXGame instance
m_pGame->GetMyPlayer( )
• Get the player angles.
Vec3 Angles = m_pGame->GetMyPlayer( )->GetAngles( )
• Get the player rotation angle.
float Rotation = m_pGame->GetMyPlayer( )->GetAngles( ).z
• Get the player's position on the map. Then accessed such as: Pos.x, or Pos.y, or Pos.z
Vec3 Pos = m_pGame->GetMyPlayer( )->GetPos( )
• Set the player's position on the map. It's a simple way to teleport the player.
Vec3 Destination( 100 , 100 , 100 );
m_pGame->GetMyPlayer( )->SetPos( Destination , true );
Logging
CryLogAlways( "%s" , "This message will show up inside log.txt" );
The first argument is the type of message. %s seems to work fine for strings.