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.

ForumsShowcase → I need help...
I need help...
2004-12-07, 8:03 AM #1
Mental Help. :p

[http://www.hellraiser64.com/Pics/MouseCursor.jpg]

What you see is cog interpreting player mouse aiming as onscreen Mouse X/Y movement. :o

The cursor is FireProjectile()'d from the camera 'MouseX, 0.0025, MouseY', so relative position checking for menu clicks and whatnot are quite easy. You'd just make a menu sprite (or 3do if you wanna get fancy and can scale it down outside of JED :mad: ), test and see where the boundaries are with debug output, then code in the boundaries and associated code for clicks. (I did ALOT of QuickBasic coding in High School, working with meeses and menus ;) )

It has trails because of my special templates and coding style that I use to debug things.

So yea. Countin flowers on the wall, playin solitare till dawn.......
-Hell Raiser
2004-12-07, 8:15 AM #2
Ohh... the possibilities are endless...
>>untie shoes
2004-12-07, 10:37 AM #3
You came up with same idea I had, basically. I've already worked on one for a bit. It's roughly the same.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2004-12-07, 12:47 PM #4
Well, :p :)
-Hell Raiser
2004-12-07, 3:46 PM #5
Yay!
SnailIracing:n(500tpostshpereline)pants
-----------------------------@%
2004-12-07, 3:57 PM #6
NICE.

'With a deck of 51'
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-12-07, 4:30 PM #7
Cool. Can other players see the cursor?

Now we can make a 3d RTS with JK
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2004-12-07, 4:43 PM #8
Nope, anything done with the camera is locally created. :) And I'm thinking of doing up a demo "Point and Click" force power with sample menu system and whipping up an SDK. It's just too cool to leave on my back burner. ;)
-Hell Raiser
2004-12-07, 4:54 PM #9
Sorry to say, but this is *kinda* old, I was working on a natural selection mod a while back, before it got shut down by the HL NS team, that had a cursor system in the commander menu. More recently I have been working on and off on a freelancer mod that uses a mouse and will eventually include buttons to click on.
Maybe we could trade code and see if we can improve each other's system?
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-07, 5:07 PM #10
Why am I reinventing the wheel?! :p We all know about the probability if a JK mod will be released, why don't we, the coders/modders, release little bits of special coding like this as little demo/SDK packs on some kinda main site? Maybe make a new section for "Enhanced Coding Techniques" or some such on Massassi? Hell, I'll throw up some kinda .php site on hr64.com for developers and let them be able to upload their stuffs, (all for free) if nobody else wants to do it. *coughmassassicough* :p

And yes, I'd LOVE to see how others pulled this off. :o I was ready to shoot meself because of some logical errors. :o A bug with mine is if you modify the players Roll, it'll mess up the Z-Axis/Mouse Y detection.

[edit And on that Freelancer Mod, ever since I thought up this bright idea, I've been drooling over my JK life long mod idea of a JK/XWA MP type thing, with flight controls ala Freelancer [/drool]]
-Hell Raiser
2004-12-07, 5:12 PM #11
Wow! Nice work, Hell Raiser. I already knew LKOH_SniperWolf was working on the same thing; we will have to see how SniperWolf's version differs, so we can write-up a cool tutorial.

With all of the cool stuff Hell Raiser, SniperWolf, and others are working on, we should be able to convince more people to re-install JK. :)

*cough* Hub *cough*

(Off topic: I am working on the grappling hook cogs of HR, Quib Mask, and others. This weekend, I should be able to post some advances in the grappling hook 'technology'.)

:)
2004-12-07, 5:24 PM #12
RTS JK MOD OLOLOL :D :D :D :D :D :D
"Jayne, this is something the Captain has to do for himself"

"N-No it's not!"

"Oh."
2004-12-07, 6:32 PM #13
Quote:
Originally posted by Hell Raiser


And yes, I'd LOVE to see how others pulled this off. :o I was ready to shoot meself because of some logical errors. :o A bug with mine is if you modify the players Roll, it'll mess up the Z-Axis/Mouse Y detection.

[edit And on that Freelancer Mod, ever since I thought up this bright idea, I've been drooling over my JK life long mod idea of a JK/XWA MP type thing, with flight controls ala Freelancer [/drool]]


You're gonna love this, I got my ship (cursor included) to finally work with roll (your ship can move in ALL directions and flip over, including rolling.) I'm gonna do some checking on my exact code. E-mail me at lumpshare@yahoo.com
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-07, 6:57 PM #14
Can someone explain this better to the code challenged
people?? What are those yellow triangles doing?
"Nulla tenaci invia est via"
2004-12-07, 6:58 PM #15
It's a mouse cursor in-game in JK.
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2004-12-08, 4:42 PM #16
The reason you see 4 triangles is because he wanted trails for his cursor.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-08, 6:45 PM #17
Quote:
Originally posted by SG-fan
The reason you see 4 triangles is because he wanted trails for his cursor.


Well, I didn't want them, the trail is a side effect of using one of my visual position indicator templates as a base for the cursor template. I constantly create the cursor in a 0.001 pulse, and the VPI template has a timer of 0.1, so you get about 7-8 trails when moving it, because the last ones before that still have their timer going. This is easily fixed by just getting the handle of the cursor thing, and deleting it before creating the next one. :)
-Hell Raiser
2004-12-08, 6:51 PM #18
Or easier, just edit the template for the cursor... (You said you used the other as a base, so you could just edit the cursor itself)
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2004-12-08, 7:06 PM #19
Quote:
Originally posted by Hell Raiser
Why am I reinventing the wheel?! :p We all know about the probability if a JK mod will be released, why don't we, the coders/modders, release little bits of special coding like this as little demo/SDK packs on some kinda main site? Maybe make a new section for "Enhanced Coding Techniques" or some such on Massassi? Hell, I'll throw up some kinda .php site on hr64.com for developers and let them be able to upload their stuffs, (all for free) if nobody else wants to do it. *coughmassassicough* :p


It's called the tutorials section. :p Noone submits tutorials anymore. :(

2004-12-09, 1:50 AM #20
/me smells more support for the Editing Hub every day.....
-Hell Raiser
2004-12-09, 11:36 AM #21
Show us how you did this! Source code! Source code!
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2004-12-09, 2:07 PM #22
HellRaiser's is probably quite a bit different, but, I'll try to explain what I was doing with mine. Mine's setup more for a menu system thing, so there will be references to that in there. But I'll try to put it up anyways, I'm just going to do this in rough pseudo-code/code though. (My actual code is mainly skeleton stuff, besides which, I think I messed up some of the math in it) (I'll cut off letters or words of verbs, just try and figure out which I mean, lol...)

Code:
activated:  (activating a menu)
StopThing(player)
CreateThing(ghost, player)
SetThingLVec of ghost to that of player
FireProjectile(ghost, menu, set distance)
(We'll assume 1 as the distance for later calculations, as an example)

menuVec = vecSub(Position(menu),Position(player))
SetActorFlags(0x40000)
FireProj(ghost, altCam, (somewhere where menu viewed well))
SetCamera(altCam)
SetPulse(.001)

return

pulse:
positivex = 0;
positivey = 0;
FireProj(player, lookPosThing, Set Distance) (Again, assume 1)
LookPosVec = VecSub(lookPosThing, player)
horizontVec = (VecX(lookPosVec),VecY(lookPosVec), 0)
if(VecZ(VectorCross(menuVec, horizontVec)) < 0)
   positivex = 1;
sin = VecLen(VectorCross(MenuVec, horizontVec))/(VecLen(MenuVec)) * VecLen(horizontVec));
cos = VectorDot(menuVec, horizontVec) / (VecLen(MenuVec)) * (VecLen(horizontVec);

x = 1 (Distance to menu) * (sin/cos); (This comes from SOHCAHTOA)

if((positivex && (x < 0)) || (!positivex && (x > 0)))
   x = x * -1;

altH = x / sin; (Used in calculation of y)
if(VecZ(LookPosVec) > VecZ(menuVec))
   positivey = 1;

altHVec = VecScale(horizontVec, (altH / VecLen(HorizontVec)))

sin2 = VecLen(VectorCross(altHVec, LookPosVec)) / (VecLen(altHVec) * VecLen(LookPosVec));
cos2 = VectorDot(altHVec, lookPosVec) / (VecLen(altHVec) * VecLen(LookPosVec));

y = altH * (sin2/cos2);


if((positivey && (x < 0)) || (!positivey && (x > 0)))
   y = y * -1;

FireProjectile(altCam, cursorTemplate, VecSet(x, menuDistance (1), y), ...);

user0:
(Have Fire send user0 if menu on... (would allow mouse "clicks", since most people have at least one of the fire buttons set to mouse))
If(((x > 25) && (x < 45)) && ((y > 37) && (y < 40))){
  do such and such;
}


Hmm, an alternate method, which came to me like 1 minute ago as I was writing this, would be for fire a moving projectile, against the menu (collide = 3), or an invisible surface, and have it align to menu on explode, and send back a user message with x, y, z info, and use some minor displacement math to figure out the x (y would just be the z coord minus menu's z). This came about actually thinking about Slaw's aligning bullet holes. Probably would be easier that way...
(I wrote up the pseudo on the fly, so sue me if somethings a bit off... I personally get confused as hell when I'm working with a lot of vectors...)

[Edit] Fixed a minor thing. Forgot to account for the possibility of the sign of y getting messed up from switching due to sin/cos.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2004-12-09, 5:09 PM #23
Here should be all of my ship cursor code, but since it's for MOTS, I don't know how much it will help. (it uses the playeraction verb to capture player movements)

Code:
thing		shuttle				local
thing		cam                             local

vector		bankright

vector		rotation2			local

flex		xsens=30000 /.4		local
flex		zsens=1000 /.4		local

flex		xvector=0		local
flex		zvector=0		local


template	cursortpl

int		cursor			local nolink

flex		factor=0.4		local


vector		cursororient		local

end

# ====================================================================

code
playeraction:
   if (GetParam(0) == 4.0)             // Strafe	ROLLS SHiP
   {
      ReturnEx(0.0);
	  rotation2=GetThingRotVel(shuttle);
	  If(GetParam(2) > 0)		// BANK RIGHT
	  {
	  	if(VectorZ(rotation2)==VectorZ(bankright)) Return;	// If already banking, no need to run code

		rotation2=VectorAdd(rotation2, bankright);		// add the banking right vector to the current rotation vector
		SetThingRotVel(shuttle, rotation2);			// Set the roll
	  }
	  else if(GetParam(2) == 0)	// STOP BANKING
	  {
	  	if(VectorZ(rotation2)==VectorZ(bankright))		// If banking right...
			rotation2=Vectorsub(rotation2, bankright);	// ...subtract the bank so it can stop
		else if(VectorZ(rotation2)==(-1*VectorZ(bankright)))
			rotation2=Vectoradd(rotation2, bankright);
		SetThingRotVel(shuttle, rotation2);
	  }
	  else if(GetParam(2) < 0)	// BANK LEFT
	  {
		if(VectorZ(rotation2)==(-1*VectorZ(bankright))) Return;	// Same as right

		rotation2=VectorSub(rotation2, bankright);
		SetThingRotVel(shuttle, rotation2);
	  }
   }
   else
   if (GetParam(0) == 5.0)             // Turn
   {
         ReturnEx(0.0);
	  If(GetParam(2) > 0)		// left
	  {
		if(xvector-(GetParam(2)/xsens)>(-.05 * factor))		// If the movement of the mouse is within the screen boundary...
		{
			xvector=xvector-(GetParam(2)/xsens);		// Move the mouse the proper distance
		}

	  }
	  else if(GetParam(2) < 0)		// right
	  {
		if(xvector+((GetParam(2)*-1)/xsens)<(.05 * factor))	// See left
		{
			xvector=xvector+((GetParam(2)*-1)/xsens);
		}
	  }
   }

   else
   if (GetParam(0) == 8.0)             // Pitch up/down
   {
	If(GetParam(2) > 0)		// up
		if(zvector+(GetParam(2)/zsens)<(.038 * factor))		// see left
		{
			zvector=zvector+(GetParam(2)/zsens);
		}
	If(GetParam(2) < 0)		// down
		if(zvector-((GetParam(2)*-1)/zsens)>(-.038 * factor))	// see left
		{
			zvector=zvector-((GetParam(2)*-1)/zsens);
		}

      ReturnEx(0.0);
   }


   Return;

# .......................................................................

pulse:
	cam=GetPrimaryFocus(0);						// Get the current camera
	if((cursor>=0)&&(GetThingType(cursor)!=10))			// if the cursor exists, and isn't a player...
	{
		DestroyThing(cursor);					// remove it
	}
	cursor=FireProjectile(cam, cursortpl, -1, -1, VectorSet(xvector, 0.05 * factor, zvector), '0 0 0', 0, 0, 0, 0);	// create the 
cursor infront of the current camera in the proper spot left/right/up/down.

	AttachThingToThingEx(cursor, cam, 0xc);				// attach it to the camera

	cursororient=VectorSub(GetThingPos(cursor), GetThingPos(cam));	// Get the proper orientation vector for the cursor
	SetThingLook(cursor, cursororient);				// orient it.
   Return;


end


The numbers for the mouse sensitivity are ugly because I was fine tuning it and didn't feel like cleaning up the math.

Mine works with roll since the cursor is created in relation to the player's POV and is moved by a variable that is independent of the actual position of the cursor.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-09, 7:29 PM #24
Mine works by independently checking the LVec of the player for the Mouse X, and checking the pitch from a FP() for the Mouse Y. The Mouse Y just takes the Z-Axis difference between the origin Position and the Y Checker thing, and the Mouse X is done by getting the distance between the origin and the X Checker, with the X Checker having a Z-Axis even with the origin, so it just moves left/right. Then the cursor is FP()'d from the Camera based on lots of vector math and even a VectorDot. :)

SG-Fan, you're disqualified for using MotS and Playeraction. :p

I'm just about done with a demo/sdk for my code, and should have it up for download for all to see in less than 24 hours. I pretty much code anything inside TDiR now, so having to convert to JK is kinda tedious. ;)
-Hell Raiser
2004-12-10, 11:18 AM #25
*BAM!*

It's not gobbed because I'm lazy like that and it's not a final release. :p Anyway, run it like a mod, and what this'll do when you hotkey the new button, is bring up a sample menu with "buttons" that you can click. Only Button1 and the close button work, but it's very easy to add in more buttons. Submenu's will have to be something I work on later, unless somebody wants to beat me to it. :p

Looking back, there's tons of different ways to implament this kinda system, so I went with the simplest way I could think of. An ugly mat, some sprites, and X/Y co-ordinate checking. :)

Read the readme for further info. All the spiffy coding information is located throughout the comments in the cog. :D
-Hell Raiser
2004-12-10, 11:25 AM #26
Less lazy than you. Bwhaahhaha.

[Disclaimer: This is Hell Raiser's, gobbed for your pleasure.]

[Edit: Nm it doesn't work in GOB form for whatever reason O_o]

It's pretty cool, but firing should also be used to select stuff. As well, there needs to be a correction if the axis is inverted (not sure if it's possible to code that... but at least put a swap y axis menu option or hotkey or something, so menu authors can include one :))

2004-12-10, 12:35 PM #27
How about having a separate button (built in with SDK) to toggle whenever the menu is up to swap the Y axis? It would remain set for the length of the session of JK.exe. :)

Firing as a mouse click would require me to edit the weapon bins, and thats a bit complicated for such a tiny SDK. :p

Dunno why it doesn't work gobbed. Take out the .bmp under mat?

Eh, lets forward any discussion here? :)

http://forums.massassi.net/vb/showthread.php?s=&threadid=27854
-Hell Raiser
2004-12-10, 4:47 PM #28
Well, I'll be working on submenus soon. :) (This is really just stuff I wanted in my mod... I'd originally thought of doing one like savages, but that seemed to damn slow... so mouse idea came up) First though, gotta fix my damn camera system.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2004-12-10, 5:57 PM #29
This would make wishes, like a trillion times easier.

-I dunno, never played tDiR, though I desperately wanted to. Mayny times. Couldn't get the first release to work, lost JK before the more recent ones. I guess I'll just wait for tDiR and reinstall then.

↑ Up to the top!