Page 1 of 1

Context Sensitive Cursor.

Posted: Fri Aug 18, 2006 8:14 am
by Fallen
I am trying to make my cursor/crosshair context sensitive ... I've kind of gotten it to work...

What my intentions are is when I look at something my cursor changes to an icon that tells me the type of interaction "using" that object will achieve. Picking it up, talking to it, examining it and so on.

So far i made a script that uses:

Code: Select all

SetPlayerWeapon(int WeaponSlot# );
To change weapon types when certain triggers are true ... I don't know if this is the best way, but it is how I've come up with doing it. (please suggest better ways if you have them).

The issue I have is I can't get the triggers to turn true when my cursor is over the entity in question. Only when I touch it or use it. Which defeats the purpose to a certain extent.

I thought using some of the distance options like:

Code: Select all

bool CheckArea(char *FromEntityName, char *ToEntityName, bool DistanceMode, float MinScreenX, float MaxScreenX, float MinDistance/MinScreenY, float MaxDistance/MaxScreenX, bool IgnoreX, bool IgnoreY, bool IgnoreZ);
might be useful ... but haven't seemed to have any luck so far ... I'll keep trying, just thought i'd ask.

Posted: Fri Aug 18, 2006 8:29 am
by Juutis
To change weapon types when certain triggers are true ... I don't know if this is the best way, but it is how I've come up with doing it. (please suggest better ways if you have them).
That's a good way, unless you want to have more than one weapon... You would have to make several versions of every weapon and that's a lot of work!

A better way is to define the different cursors as hud elements and then use the ActivateHudElement() command to activate them.
Another way is to define the bitmaps in a flipbook and then draw them on the screen with the DrawFlipBookImage() command.



The MouseSelect() command comes handy here too. It's supposed to return the EntityName of the entity over which the mouse cursor is (I've never gotten it to work...). You could name your entitys like "button1_use" and use the new RightCopy() command like this:

Code: Select all

if(RightCopy(MouseSelect(false),3) = "use")
{
     ActivateHudElement("usecursor",true);
}
So it checks if the last 3 letters of the entity, that the mouse points at, are "use" and then activates the right hud element.

Posted: Fri Aug 18, 2006 6:02 pm
by Fallen
hmm ... awesome feeback! I will go try to put it to work as soon as I can ... hope I can get MouseSelect to work better than the distance functions.

Posted: Fri Aug 18, 2006 6:15 pm
by Fallen
Wow ... that was quick and painless ... works like a charm! Thanks Juutis!

Posted: Sat Aug 19, 2006 2:50 pm
by Jay
Juutis wrote:The MouseSelect() command comes handy here too. It's supposed to return the EntityName of the entity over which the mouse cursor is (I've never gotten it to work...)
I think the MouseSelect() command only works when the thing the mouse is over; is either a pawn, an attribute, or a staticentityproxy - but it is important that it does has collision applied (because i figured all it does is a TraceLine() command from the camera in rotation xyz)


Also remember i had got some problems which cause i don't know when i specified less than 2 parameters.