Porting 3d-skybox from Spirit SDK to Hal Created 10 years ago2014-01-28 14:46:58 UTC by vitoss vitoss

Created 10 years ago2014-01-28 14:46:58 UTC by vitoss vitoss

Posted 10 years ago2014-01-28 14:46:58 UTC Post #317654
Hi Guys! I'm not native speaker of english, so excuses if i have some mistakes :)

I'm making a mod for HL1 based on SDK2.3 and i need to insert the 3dskybox ability. I tried to copy it from Spirit, but it doesnt work, cause i'm not a coder, and may be i missed some little things. If here are some experienced guys, can you help me please to complete my task.
I show below what exactly i did, if you'll see something missing, gratefuly if you correct it

THIS below IS IN HL.DLL

effects.cpp added a class:
[blue]
class CEnvSky : public CBaseEntity
{
public:
void Activate( void );
void Think( void );
};

void CEnvSky :: Activate ( void )
{
pev->effects |= EF_NODRAW;
pev->nextthink = gpGlobals->time + 1.0;
}

extern int gmsgSetSky;

void CEnvSky :: Think ()
{
MESSAGE_BEGIN(MSG_BROADCAST, gmsgSetSky, NULL);
WRITE_BYTE(1); // mode
WRITE_COORD(pev->origin.x); // view position
WRITE_COORD(pev->origin.y);
WRITE_COORD(pev->origin.z);
MESSAGE_END();
}

LINK_ENTITY_TO_CLASS( env_sky, CEnvSky );

[/blue]

then i went toplayer.cpp and after line

int gmsgTeamNames = 0;

i put:

int gmsgSetSky = 0;

In same file, i found:
gmsgSelAmmo = REG_USER_MSG("SelAmmo", sizeof(SelAmmo));

and put nearby:
gmsgSetSky = REG_USER_MSG( "SetSky", 7 );

At this i've finished working in hl.dll

Go to c_dll.dll

Open hud.cpp
find:
//DECLARE_MESSAGE(m_Logo, Logo)
int __MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf)
{
return gHUD.MsgFunc_ResetHUD(pszName, iSize, pbuf );
}

and put after that this new code:

[blue]
int __MsgFunc_SetSky(const char *pszName, int iSize, void *pbuf)
{
gHUD.MsgFunc_SetSky( pszName, iSize, pbuf );
return 1;
}
[/blue]

In same file find this line:

HOOK_MESSAGE( Concuss );

and put neraby:
HOOK_MESSAGE( SetSky );

Now i go to hud.h
and before this line:

class CHud

i put:

#define SKY_OFF 0
#define SKY_ON 1


in same file, after this line:

int GetNumWidth(int iNumber, int iFlags);

i put:
Vector m_vecSkyPos;
int m_iSkyMode;


next, i find this existing line:

int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf );

and put nearby:
void _cdecl MsgFunc_SetSky( const char *pszName, int iSize, void *pbuf );

now i go to hud_msg.cpp
find:

void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{

and after braket i put:
m_iSkyMode = SKY_OFF;

it must come like that:
[blue]
void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{
m_iSkyMode = SKY_OFF;

// prepare all hud data
HUDLIST *pList = m_pHudList;

while (pList)
{
    if ( pList->p )
        pList->p->InitHUDData();
    pList = pList->pNext;
}

//Probably not a good place to put this.
pBeam = pBeam2 = NULL;
}
[/blue]

and below i put:
[blue]
void CHud :: MsgFunc_SetSky( const char *pszName, int iSize, void *pbuf )
{
//  CONPRINT("MSG:SetSky");
BEGIN_READ( pbuf, iSize );

m_iSkyMode = READ_BYTE();
m_vecSkyPos.x = READ_COORD();
m_vecSkyPos.y = READ_COORD();
m_vecSkyPos.z = READ_COORD();
}
[/blue]

open view.cpp
find:

void V_CalcNormalRefdef ( struct ref_params_s *pparams )

and in the end of it i put this:

[blue]
if (gHUD.m_iSkyMode == SKY_ON && pparams->nextView == 0)
{
pparams->vieworg[0] = gHUD.m_vecSkyPos.x;
pparams->vieworg[1] = gHUD.m_vecSkyPos.y;
pparams->vieworg[2] = gHUD.m_vecSkyPos.z;
pparams->nextView = 1;
}

[/blue]

in the same file find this:

view = gEngfuncs.GetViewModel();

and after i put this:

[blue]

if (gHUD.m_iSkyMode == SKY_ON)
{
savedviewmodel = view->model;
view->model = NULL;
}
[/blue]

Im really noob in the programming and need your help!
It could be nice tutor for newbies like me if to finish it with help of expirienced dads :)
Posted 10 years ago2014-01-28 23:34:26 UTC Post #317657
Why don't you just base your mod on Spirit?
ChickenFist ChickenFist<Witty Title>
Posted 10 years ago2014-01-28 23:34:27 UTC Post #317658
Why don't you just base your mod on Spirit?
ChickenFist ChickenFist<Witty Title>
Posted 10 years ago2014-01-29 05:21:20 UTC Post #317662
Because it's more interesting to learn the programming at least copying a code from spirit to hl.
Oh and all that I wrote above is WORKING!! The problem was that I compiled cl_DLL to wrong folder.
So, now admin of this site can add my tutor to tutors page if u want.
You must be logged in to post a response.