Help with angles


(Indloon) #1

Hello, first take a look at example code piece:


void somefunc( void ) {
    int              reload = 0;
    if( cg.snap->ps.weaponstate == WEAPON_RELOADING ) {
	    reload = 1;
		CG_Printf("reloading
");
	} else {
	    reload = 0;
	}
		
	if( reload != 0 ) {
		cg.refdefViewAngles[ROLL] += 40;
		cg.refdefViewAngles[YAW] += 40;
		cg.refdefViewAngles[PITCH] += 40;
		CG_Printf("DONE 2
");
	}
}

Now, if I call it out and reload an weapons, then NOTHING happens with the screen :confused:

I tried all the way that, but it doesn’t work…

I just want to change view angles…

Yes, I have called the function out, yes the code located in file is included into project.

Maybe I must use VectorAdd??


(ailmanki) #2

Dunno, but since ‘nothing’ happens, maybe

cg.snap->ps.weaponstate == WEAPON_RELOADING

is always false.


(Indloon) #3

[QUOTE=ailmanki;400182]Dunno, but since ‘nothing’ happens, maybe

cg.snap->ps.weaponstate == WEAPON_RELOADING

is always false.[/QUOTE]

No, that type gets updated while the weopen gets reloaded by client.

But I got it working, I forgotted to link the function in cg_view.c


(acQu) #4

When nothing happens, then you might reference it from wrong place. Including it in CG_CalcViewValues seems to do something. Also better to add AnglesToAxis to it, else you get weird stuff ^^

void somefunc( void ) {
int reload = 0;
if( cg.snap->ps.weaponstate == WEAPON_RELOADING ) {
reload = 1;
CG_Printf("reloading
");
} else {
reload = 0;
}

if( reload != 0 ) {
	
	cg.refdefViewAngles[YAW] += 40.0f;
	cg.refdefViewAngles[PITCH] += 40.0f;
	AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
	CG_Printf("DONE 2

");
}
}

edit: lol posted at exact same time.


(Indloon) #5

[QUOTE=acQu;400195]When nothing happens, then you might reference it from wrong place. Including it in CG_CalcViewValues seems to do something. Also better to add AnglesToAxis to it, else you get weird stuff ^^

edit: lol posted at exact same time.[/QUOTE]

Yes, weird things happen:D


(ailmanki) #6

Well if it writes something to console, I would not say nothing happens :stuck_out_tongue: