Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Reseting the player's pitch
Reseting the player's pitch
2005-09-04, 9:52 PM #1
Ok, I'm trying to convert my ship cog to JK, but I need a way to reset the player's internal pitch. TeleportThing will fix the yaw, but not the pitch. Also SetThingLook doesn't seem to do anything to pitch either.
How can I reset the player's pitch back to 0?
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-04, 9:57 PM #2
Their internal pitch as in their up and down aiming? I don't think it's possible. If you mean the player's normal pitch just set the Z value in the player's look vector to 0.

playerlvec = GetThingLVec(player);
SetThingLook(player, VectorSet(VectorX(playerlvec), VectorY(playerlvec), 0));
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-09-04, 9:59 PM #3
I mean the internal pitch. I'm trying to get key trapping for my ship cog, but once the player's pitch hits the top, I have no way to know if the key is being pressed.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-04, 10:06 PM #4
maybe you can try turning the player into an actor momentarilly and use one of the AI aim functions.
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-09-04, 10:11 PM #5
I didn't think I could do that. I thought that if the player wasn't of type=player then the game crashes. I'll test it, but I'm not sure it will work.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-04, 10:31 PM #6
BINGO!!!

Ok, it was really simple. All you have to do is give the player a blank .ai file in his template then the ai look verb can be used, (without changing the player's type) then just fire a ghost 1 JKU infront of the proper look position and use the AISetLookPos verb.

Thank you ProdigyOddigy for the idea.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-04, 10:33 PM #7
holy ****, that actually worked? MYCRAZY IUDEA WORKED! I can make DOD aim now! AHAAHAH
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-09-04, 10:51 PM #8
Ya, just make an empty ai file and put it in the players template. (you'll probably want to just make a new walkplayer template for your levels)
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-04, 11:00 PM #9
Document that somewhere. Like on the Hub. There should be an easy method of collecting this type of information. I haven't cogged in over 4 years but back in the day I discovered dozens of little tricks and quirks that I'm sure would've been useful to other coggers.

[edit] this always happens to me. I'm referring to the empty AI file/AiSetLookPos trick.
Dreams of a dreamer from afar to a fardreamer.
2005-09-04, 11:10 PM #10
I think a mix of ParseArg() used on min and max pitch values and actor flags 0x1 and 0x2 can be used to force a view recenter. It may be even simpler and you may be able to do it by quickly removing actor flag 0x1, setting 0x2 then resetting 0x1.

QM

[There, fixed the post order Fardreamer ^_^]
2005-09-06, 10:45 AM #11
uh... couldnt you just center the players view by doing this?
SetActorFlags(player, 0x2);
that makes their pitch go to 0
thats how i usually do it.
Famous last words - "It seemed like a good idea at the time."
2005-09-06, 1:04 PM #12
Originally posted by DSLS_DeathSythe:
uh... couldnt you just center the players view by doing this?
SetActorFlags(player, 0x2);
that makes their pitch go to 0
thats how i usually do it.

Doesn't it take a second to settle back down to the center when you do that? Or does it instantly pop back to center?

QM
2005-09-06, 1:24 PM #13
Using 0x10 instead of 0x2 does it instantly I think. I never experimented to make sure though...
May the mass times acceleration be with you.
2005-09-06, 1:38 PM #14
it takes a little time to center the view depending on the pitch, a second at most.
just tested 0x10 and it doesnt do anything. i think its just a flag that is set telling the engine when the view is done centering.
Famous last words - "It seemed like a good idea at the time."
2005-09-06, 3:33 PM #15
Ok, the 0x2 flag takes too long, I need an instant reset since the code was in a .03second pulse and the 0x10 flag does nothing visable. I even tried setting 0x2 then 0x10 right after, but it didn't change anything.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-06, 4:01 PM #16
Has anyone tried what I suggested? Clearing 0x1 before setting 0x2 then resetting 0x1, or ParseArg()ing min and max pitch values of 0, then setting 0x2, then using ParseArg() to set pitch values back to what they should be? I'm pretty sure something along those lines allows an instant recenter.

QM
2005-09-06, 4:18 PM #17
I havn't tried clearing 0x1 yet, but the parsearg wont work if another mod changes the pitch value. As far as I know, there isn't a way to restore it to normal. Either way, parsearg isn't the most stable and syncable verb. It may leave the player pitched up on other computers over the network. It'll need some testing of course, but I can't test till I get to my computer. Who knows, it might work.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-06, 4:42 PM #18
[QUOTE=Quib Mask]Has anyone tried what I suggested? Clearing 0x1 before setting 0x2 then resetting 0x1...[/QUOTE]
tried it and its not any faster than just setting 0x2

hey SG-fan this doesnt really have much to do with the current topic but heres a cog a that i made for Darth Slaw (i think) a while ago. It makes the raildet a guided missle that the player can control. Maybe you can use some of the code to help with converting your ship cog to jk.
Code:
##########################################################
# Jedi Knight Cog Script  (JK)
#---------------------------------------------------------
# 00_SMOKETRAIL.COG
# -Leaves a smoke trail behind a moving object.
# -Allows the player to have control of the raildet
#  and makes it a player guided missle
#---------------------------------------------------------
# Modified version of LEC's 00_smoketrail.cog
# Written By DSLS_DeathSythe
# This COG is NOT supported by LucasArts Entertainment Co.
##########################################################
flags=0x240
symbols
#---------------------------------------------------------
message     startup
message     created
message     removed
message     pulse
#--------------------#
thing       player=-1                        local
thing       rocket=-1                        local

thing       temp_thng=-1                     local
template    temp_tpl=+repeaterball           local

template    smoke=+smoke                     local
thing       dummy=-1                         local
int         smoke_count=0                    local

vector      old_lookVec                      local
int         old_camera=0                     local
int         count=0                          local

vector      look_dir                         local
flex        y_dir=0.0                        local
flex        z_dir=0.0                        local
flex        yaw_max=100.0                    local
flex        pitch_max=100.0                  local
#---------------------------------------------------------
end
#=========================================================
code
#---------------------------------------------------------
startup:
	player = GetLocalPlayerThing();
	rocket = -1;
return;
#---------------------------------------------------------
created:
	//-Only one rocket at time.
	//-If there is already one going, destroy it and
	// send the new one in the right direction.
	if(rocket != -1)
		{
		SetLifeLeft(rocket, 0.1);
		StopThing(GetSenderRef());
		SetThingLook(GetSenderRef(), old_lookVec);
		SetThingVel(rocket, VectorScale(GetThingLVec(rocket), 2));
		}
	else
		{
		old_lookVec = GetThingLVec(player);
		old_camera = GetCurrentCamera();
		}
	rocket = GetSenderRef();

	//-Let the rocket fly for 30 seconds...
	SetLifeLeft(rocket, 30.0);

	//-set 100 msec timer for smoke release and control stuff
	SetThingPulse(rocket, 0.01);

	//-Stop the rockets spinning...
//	ParseArg(rocket, "angvel=(0.0/0.0/0.0)");
	SetThingRotVel(rocket, '0 0 0');
	SetWeaponFlags(rocket, 0x100);

	//-Stop the players movements, center his view on the Y axis,
	// and adjust the min and max headpitch...
	SetActorFlags(player, 0x40002);
	SetThingLook(player, '0 1.0 0');
	ParseArg(player, "minheadpitch=-90.00");
	ParseArg(player, "maxheadpitch=90.00");

	//-If the player isnt in internal view, switch cameras
	if(old_camera != 0) CycleCamera();
	SetCameraFocus(0, rocket);
	count = 0;
return;
#---------------------------------------------------------
removed:
	//-If its not the currently controlled rocket then ignore it...
	if(GetSenderRef() != rocket) return;

	//-Else reset all the players stuff...
	ClearActorFlags(player, 0x40000);
	SetCameraFocus(0, player);
	if(GetCurrentCamera() != old_camera) CycleCamera();
	SetThingLook(player, old_lookVec);
	SetActorFlags(player, 0x2);
	ParseArg(player, "minheadpitch=-80.00");
	ParseArg(player, "maxheadpitch=80.00");
	rocket = -1;
return;
#---------------------------------------------------------
pulse:
	//-Dont let the smoke come out every pulse...
	smoke_count = smoke_count + 1;
	if(smoke_count >= 5)
		{
		//-create smoke at our current location
		dummy = CreateThing(smoke, GetSenderRef());
		smoke_count = 0;
		}

	//-Small delay before we take control of the rocket...
	if(count < 10)
		{
		count = count + 1;
		return;
		}
	else
		{
		//-Limit the players YAW movements...
		look_dir = GetThingLVec(player);
		if(VectorX(look_dir) > 0 && VectorY(look_dir) < 0)
			SetThingLook(player, '1.0 0 0');
		if(VectorX(look_dir) < 0 && VectorY(look_dir) < 0)
			SetThingLook(player, '-1.0 0 0');

		//-Get the playes true look vector...
		temp_thng = FireProjectile(player, temp_tpl, -1, -1, '0 0 0', '0 0 0', 1.0, 0x0, 0.0, 0.0);
		StopThing(temp_thng);
		SetLifeLeft(temp_thng, 0.02);
		SetThingFlags(temp_thng, 0x80000);
		look_dir = GetThingLVec(temp_thng);

		//-Adjust the rockets look by the players look_dir...
		y_dir = VectorX(GetThingLVec(player)) * -yaw_max;
		z_dir = VectorZ(look_dir) * pitch_max;
		look_dir = VectorSet(z_dir, y_dir, 0.0);
		SetThingRotVel(rocket, look_dir);
		SetThingVel(rocket, VectorScale(GetThingLVec(rocket), 2));
		}
return;
##########################################################
end
Famous last words - "It seemed like a good idea at the time."
2005-09-06, 5:13 PM #19
Thanks, but the way I'm making it won't let me use that code. I'm making the ship control like Freelancer where you have a cursor on screen that controls the direction the ship moves. I also can't let the player's head pitch limit the cursor's movement. Thanks anyway, and if you have any other ideas I am more than willing to listen.

[edit] I've been looking at SaberMaster's ship cogs and I think I can convert his method of movement into my system. I have most of the cog converted already except pitch (It's converted, but buggy) and key trapping for fire, use inventory, and selecting weapons. [/edit]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-07, 9:16 AM #20
Originally posted by Fardreamer:
Document that somewhere. Like on the Hub. There should be an easy method of collecting this type of information.
Indeed. I am working on it. ;)

Nice work, SG-fan. I think Hell Raiser (aka PhantomCoder) might have solved the pitch problem in his version of mouse-controlled flying. (Now, I just need to find those cogs.)

:)

↑ Up to the top!