Home   Help Search Login Register  

Author Topic: onMapSingleClick command  (Read 7666 times)

0 Members and 1 Guest are viewing this topic.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:onMapSingleClick command
« Reply #15 on: 20 Oct 2002, 01:30:20 »
i may b st00pid ;D but dere is 1 thing wid da onMapSingleClick command dat i cant figure out  :-\

wat is da _units part - nd how i use it ???

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:onMapSingleClick command
« Reply #16 on: 20 Oct 2002, 03:32:04 »
_units is a list of all units that are currently selected (F1 - F12) by the player (if he is leader of a group). If there are currently no selected units, _units is empty, [].

Its automatically provided within the onMapSingleClick command as a parameter. Take a look at the above code snippet. There I blocked the script execution when _units is not empty, because when the player did select units and clicks on the map he wants them to move there (the standard map click behaviour) rather than trigger a special action.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:onMapSingleClick command
« Reply #17 on: 20 Oct 2002, 03:36:44 »
tanks 4 da reply spinor  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:onMapSingleClick command
« Reply #18 on: 20 Oct 2002, 03:52:49 »
Top work Spinor ;)

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:onMapSingleClick command
« Reply #19 on: 20 Oct 2002, 15:50:17 »
uiox:
Quote
Take care with onmaSingleClick, when you are in a vehicle with commander, on single clic or shift single clic the unit move to the pos clic.
So use alt clic or shift alt clic for special use...
Are you sure about this. I just found that once you use onMapSingleClick, no movement order is given to the driver, i.e. the userdefined action takes precedence. You can of course still give orders to the driver by explicitly selecting him.

I find this nice because this means you always have four "free channels": CLICK, ALT+CLICK, SHIFT+CLICK, ALT+SHIFT+CLICK

Offline KTottE

  • Former Staff
  • ****
Re:onMapSingleClick command
« Reply #20 on: 31 Dec 2002, 18:19:42 »
Righto, I'll just dig this thread up instead of starting a new one. I'm trying to use onMapSingleClick in a moderately advanced fashion :P


Anyway, what I have are certain predefined points on a map (both markers and game logics for each place, though markers are more for show than anything else) where the player should click. Now, I want the following to happen:

1. Detect where the player clicks. If it's:
a) At one of the predefined points - > Exectue a script
b) Not at one of the predefined points - > prompt the player with a message telling him that he can sod off if he can't click at the right position (or something like that ;))

Now, the script to be executed has to be fed with the location of the click. Let's say the player clicks Pos01, then I want the game to detect that, then feed Pos01 to the following script, which will then use that for some nice createVehicle sweetness.

What I want are ideas how to do it, and if any of y'all feel up to writing a short example script I'd be most happy.

Names of positions: Pos01, 02, 03 and so on with a max of 08.

How would you go about this?
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:onMapSingleClick command
« Reply #21 on: 31 Dec 2002, 19:49:43 »
@ KTotte

da script itself is not dat hard but it have som maths stuff  :o wich im not very good @  :-\ but just 2 get more info - wat is da greates distance from da exact pos dat da script should b executed (cuz clicking exactly on da spot is hard 2 do ;)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:onMapSingleClick command
« Reply #22 on: 31 Dec 2002, 21:40:20 »
Hi,
for the Command Engine I had exactly the same problem, i.e. I want map markers to be clickable. For this I created the function "getClickedMarker.sqf",

_markerID = [ clickPos, maxDist, [ markersToCheck ] call loadFile "getClickedMarker.sqf"

into which you pass the click position, the max distance (clickPos <-> marker) for a viable click and an array of markers to be checked for. It then returns the index of the clicked marker (or -1, if no marker was clicked):

Code: [Select]
comment
{
   selectedMarkerID_integer = getClickedMarker (position_array, threshold_float, markers_array)
   returns ID of clicked marker (= closest marker to position and within threshold) within array markers
   if no viable marker is found, it returns -1
};

private ["_x", "_y", "_theshold", "_markers", "_ID", "_minDist", "_N", "_i", "_markerPos", "_dist"];

_x = (_this select 0) select 0;
_y = (_this select 0) select 1;
_threshold = _this select 1;
   _threshold = _threshold^2;
_markers = _this select 2;

_ID = -1;
_minDist = _threshold;
_N = count _markers;
_i = 0;
while {_i < _N}
do
   {
   _markerPos = getMarkerPos (_markers select _i);
   _dist = (_x - (_markerPos select 0))^2 + (_y - (_markerPos select 1))^2;
   if (_dist < _threshold)
   then
      {
      if (_dist < _minDist) then {_minDist = _dist; _ID = _i}
      };
   _i = _i + 1
   };

_ID

The algorithm is quite simply. I simply loop through all markers and calculate the distance between the click and each marker. If distance > maxDistance, the marker is discarded, if not, the distance is compared with the (yet) minimal distance click<->marker. If the new distance is smaller it is taken as the new minDist.
That way one can determine the marker with smallest (<maxDist) distance to clickPos.

Hope this helps,
Spinor

Offline KTottE

  • Former Staff
  • ****
Re:onMapSingleClick command
« Reply #23 on: 01 Jan 2003, 18:30:54 »
Whohoo, that's exactly what I'm looking for Spinor. You're da man ;D

I knew I could count on you guys.

And LCD, I'm having problems with the maths as well :P

That's what the forums are for ;D
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline KTottE

  • Former Staff
  • ****
Re:onMapSingleClick command
« Reply #24 on: 02 Jan 2003, 12:48:05 »
But alas, we've run into problems. I'm placing a dialog over the map, right. And then I can't use "forceMap", because you can't click on it and stuff, which is stupid. And I can't detect if the player has the map up (shownMap doesn't work like that) which means I can't do "If map is up then create dialog", and I can't do "Force dialog and map" either. Which puts me shit out of luck. Do you guys have a suggestion?

Everytime the map is opened I want to start a specific dialog, and I would like to force the player to open the map while not on a mission, can I make a player use an action? No, wait, I suppose a trigger could do it.

Argh, I'm getting a headache. Does any of you guys have an idea how to start a dialog each time the player opens the map?
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline uiox

  • Contributing Member
  • **
Re:onMapSingleClick command
« Reply #25 on: 02 Jan 2003, 14:08:31 »
I'm not sure to understand

fisrt u install onmap calls a script

In this script u call other scripts if user does a clic on the map

- 1st method Easy way

1) User calls map
2) clic on it
3) script calls by clic opens a dialog

- 2# (can be use for change a value)

1) call a dialog
2) a button with "set coord" close dialog, after clic on it launch a script

                         (you can do a small alert dialog with tempo with "clic on map for set after dialog closes")
3) wait for the clic in a loop stops after 15 seconds

4) open again first dialog and do your work if a clic ok

- 3# (easy to understand)

Use picture, a picture does not interupt mouse and key board, if you have many clic you can change the picture

1) a picture if map not shown "open the map plz"
2) a picture "Clic on map for enter coord", wait for clic

After you can do what you want (a pict with "alt clic for OK, alt shift clic for reenter", etc)

Tip for pictures : set the duration (time for show) to 0.2 and manage yourself the duration in a loop.

Offline KTottE

  • Former Staff
  • ****
Re:onMapSingleClick command
« Reply #26 on: 02 Jan 2003, 14:18:53 »
Erm, I'm not sure I'm following you, but that wouldn't work. Well, the thing that starts a dialog if the user clicks on the map would, but that defeats the purpose. I want the dialog up as soon as the player clicks the map.

I'll go over it once more, briefly.

Part 1:

Every time the user brings up the map (presses the "M" key) I want to start a certain dialog. As soon as he opens the map that is.

Part 2:
At certain points I want to force the map up. This will be "between missions" in the game, I also want the dialog to start here.

The dialog(s) are supposed to pop up instantly, not after the player clicks for the first time on the map.
Got any idea how to do this, so that I can still use onMapSingleClick (which eliminates forceMap true)
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline uiox

  • Contributing Member
  • **
Re:onMapSingleClick command
« Reply #27 on: 02 Jan 2003, 14:36:27 »
We don't have a command or a variable for testing if map is show or not.

The dream is an event with centerPosmap and zoom...

So the only way is :

Tell to the player : open the map and clic on it for calling a dialog.


But if someone has a tip, I take it immediatly  ::)

Offline KTottE

  • Former Staff
  • ****
Re:onMapSingleClick command
« Reply #28 on: 02 Jan 2003, 14:46:23 »
Damnit, then it's work-around time, or change the interface. Ah well, this was a last ditch anyway, I knew we didn't have any commands. But I figured someone might have a good work-around.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline Gadjuka

  • Members
  • *
  • Programmer
    • Operation Flashpoint: Commander
Re:onMapSingleClick command
« Reply #29 on: 12 Jun 2003, 13:37:22 »
Is it possible to use the onMapSingleClick command from within a script. Right now i'm doing it like this:
A trigger with "Condition: waitMapClick" and "On Activation: onMapSingleClick {mapPos = _pos......, continue=true}"
And the script looks like:
waitMapClick = true
@continue
continue = false
waitMapClick = false
...

It would be much easier to have onMapSingleClick directly in the script, is it possible? It doesn't seem to like it should...
Currently working on Operation Flashpoint: Commander.
Website: http://www.nordserver.se/commander/