More coding troubles

Grab your favourite IDE and tinker with the innards of game engines

More coding troubles

Postby TechieUK on Mon May 06, 2013 12:47 pm

I have far too many coding troubles. :smt021

My problem this time is adding new player models to HL2DM.
I've gone into hl2mp_player.cpp and made this change...
Code: Select all
const char *g_ppszRandomCitizenModels[] =
{
   "models/player/gman_blue.mdl",
   "models/player/gman_red.mdl",
};

const char *g_ppszRandomCombineModels[] =
{
   "",
};

Adding two new playermodels- Red and Blue G-Men. I then replaced all instances of combine_soldier.mdl with gman_blue.mdl. In-game, you spawn as blue G-Man. However, you can only become the red one with cl_playermodel- In other words, picking gman_red through the console asks you to wait 5 seconds. After 5 seconds, you can attempt to change again. However, it simply does nothing. It even does this on the menu. When you pick it before you're even in a game it asks for a 5 second wait. Do I need to add gman_red elsewhere? How have I gone wrong?
Also know as WILLAM; TechieUK is my old name. If you see WILLAM on Steam or ModDB, it's me.
User avatar
TechieUK
Regular
Regular
 
Joined: Sat Apr 13, 2013 4:29 pm

Re: More coding troubles

Postby Corewarp on Mon May 06, 2013 1:19 pm

Perhaps you should find the actual code that picks which model to use? :3
User avatar
Corewarp
Been Here A While
Been Here A While
 
Joined: Thu Mar 13, 2008 6:29 pm

Re: More coding troubles

Postby TechieUK on Mon May 06, 2013 1:40 pm

Heh, hello again.
I think I might've fixed it somehow, just by randomly messing about with some code. I'll edit this post/post again if I have.
Also know as WILLAM; TechieUK is my old name. If you see WILLAM on Steam or ModDB, it's me.
User avatar
TechieUK
Regular
Regular
 
Joined: Sat Apr 13, 2013 4:29 pm

Re: More coding troubles

Postby TechieUK on Wed May 08, 2013 6:50 pm

Sorry for the double post, but I think I might use this thread for all my coding troubles, that is, if I can have them fast enough not for the thread to be inactive.
So, more trouble:
I'm using the viewbob code from the VDC, and I've adapted it to an, in my opinion, better version.
Code: Select all
if ( cl_viewbob_enabled.GetInt() == 1 && !engine->IsPaused() )
{
float zoffset = sin( gpGlobals->curtime * cl_viewbob_timer.GetFloat() ) * player->GetAbsVelocity().Length() * cl_viewbob_scale.GetFloat() / 400;
float zoffset = sin( gpGlobals->curtime * cl_viewbob_timer.GetFloat() ) * player->GetAbsVelocity().Length() * cl_viewbob_scale.GetFloat() / 400;
}

Some of it is on 2 lines, because it won't all fit in. Anyway, it works, and I've switched it to a z offset. However, it sort of diagonally moves forward and backward. Is there anyway to reverse the second one? I would like the view to go in a /\ pattern, rather than just a / pattern.
Also know as WILLAM; TechieUK is my old name. If you see WILLAM on Steam or ModDB, it's me.
User avatar
TechieUK
Regular
Regular
 
Joined: Sat Apr 13, 2013 4:29 pm

Re: More coding troubles

Postby Corewarp on Thu May 09, 2013 12:32 am

Add a cosine in there instead of double sine?
User avatar
Corewarp
Been Here A While
Been Here A While
 
Joined: Thu Mar 13, 2008 6:29 pm

Re: More coding troubles

Postby stoopdapoop on Thu May 09, 2013 9:31 am

I wrote some code that does something similar, except instead of moving forward and backwards it moves from middle-height left, to high center, to middle-height right

viewtopic.php?f=25&t=36201&p=480127&hilit=viewbob#p480127

Code: Select all
if(IsSprinting())
{
   Vector newoffset = GetViewOffset();
   Vector lean,jump;
   AngleVectors(EyeAngles(),NULL,&lean, &jump);
   newoffset.x = lean.x * sin(gpGlobals->curtime * 10.0f) * 10.0f;
   newoffset.y = lean.y * sin(gpGlobals->curtime * 10.0f) * 10.0f;
   newoffset.z = (jump.z * cos(gpGlobals->curtime * 20.0f) * 5.0f) + VEC_VIEW.z;
   SetViewOffset(newoffset);
}
else
{
   SetViewOffset(VEC_VIEW);
}
I'm Brown
Image
User avatar
stoopdapoop
Veteran
Veteran
 
Joined: Sun Aug 21, 2005 2:14 am
Location: Ann Arbor, MI

Re: More coding troubles

Postby TechieUK on Thu May 09, 2013 2:17 pm

@Corewarp
I'm assuming to do that I replace
Code: Select all
zoffset = sin

With
Code: Select all
zoffset = cos

?
@stoopdapoop
Ohhhh, I saw that code ages ago before I registered here. I'm assuming that code works only when sprinting? I might try implement that, so the screen shakes more than it does when walking regularly.
Also know as WILLAM; TechieUK is my old name. If you see WILLAM on Steam or ModDB, it's me.
User avatar
TechieUK
Regular
Regular
 
Joined: Sat Apr 13, 2013 4:29 pm

Re: More coding troubles

Postby Corewarp on Thu May 09, 2013 5:59 pm

TechieUK wrote:@Corewarp
I'm assuming to do that I replace
Code: Select all
zoffset = sin

With
Code: Select all
zoffset = cos

?
@stoopdapoop
Ohhhh, I saw that code ages ago before I registered here. I'm assuming that code works only when sprinting? I might try implement that, so the screen shakes more than it does when walking regularly.


Should be that easy, yes.
User avatar
Corewarp
Been Here A While
Been Here A While
 
Joined: Thu Mar 13, 2008 6:29 pm

Re: More coding troubles

Postby TechieUK on Thu May 09, 2013 8:10 pm

It was indeed that easy. It looks really cool now.
Also know as WILLAM; TechieUK is my old name. If you see WILLAM on Steam or ModDB, it's me.
User avatar
TechieUK
Regular
Regular
 
Joined: Sat Apr 13, 2013 4:29 pm

Return to Programming

Who is online

Users browsing this forum: No registered users