Home   Help Search Login Register  

Author Topic: onMapSingleClick command  (Read 8045 times)

0 Members and 2 Guests are viewing this topic.

Offline RT-SuperTron

  • Members
  • *
  • Prey...you will be
onMapSingleClick command
« on: 17 Oct 2002, 03:34:36 »
onMapSingleClick command, in ver. 1.85

This new command looks very interessting, but could someone please elaborate in more details how this works.

Could we be so lucky that we can make it read a grid reference...im thinking MultiPlayer Arty Coordinates, without the old complications.

[RT]SuperTron
+- PAIN IS YOUR FRIEND, IT WILL REMIND YOU THAT YOU ARE ALIVE -+

Offline RT-SuperTron

  • Members
  • *
  • Prey...you will be
Re:onMapSingleClick command
« Reply #1 on: 17 Oct 2002, 03:51:03 »
 :o  OMFG :o :o

1. open the editor place your self as usual.

2. Place a 0-0 size trigger anywhere, activation Radio Alpha, Repeatedly, Text = Click Map

3. put this line in your On activation

Hint "Click Map"; onMapSingleClick {"SoldierWB" createUnit [_pos,group player];true}


Now preview and figure the rest out for your self.

Somebody..please make some nice advanced Arty scripts with this..

[RT]SuperTron

..Dont blame me if you have to call in "SICK" to work or school tomorrow..
+- PAIN IS YOUR FRIEND, IT WILL REMIND YOU THAT YOU ARE ALIVE -+

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:onMapSingleClick command
« Reply #2 on: 17 Oct 2002, 08:04:38 »
keep pants on.
a good arty script takes months, you know ;)
Dinger/Cfit

Offline KTottE

  • Former Staff
  • ****
Re:onMapSingleClick command
« Reply #3 on: 17 Oct 2002, 11:15:13 »
This, teamed up with the setVelocity command, will do wonders for all the arty scripts out there.

* KTottE is happy about the 1.85 patch.
"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 RT-SuperTron

  • Members
  • *
  • Prey...you will be
Re:onMapSingleClick command
« Reply #4 on: 17 Oct 2002, 15:05:25 »
Quote
This, teamed up with the setVelocity command, will do wonders for all the arty scripts out there.

* KTottE is happy about the 1.85 patch.

Oh I agree whit you.

Dinger
I will keep my pants on..I am aware of the time it takes, and that is exacly what I dont have right now, so I will let other people do the dirty laundry this time :)

[RT]SuperTron
+- PAIN IS YOUR FRIEND, IT WILL REMIND YOU THAT YOU ARE ALIVE -+

Offline KTottE

  • Former Staff
  • ****
Re:onMapSingleClick command
« Reply #5 on: 17 Oct 2002, 15:18:47 »
Can I take my pants off?

I see lots of usefulness for these things.

And think, onMapSingleClick teamed up with CreateVehicle, hmm.

RTS-OFP come 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 DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:onMapSingleClick command
« Reply #6 on: 17 Oct 2002, 18:18:21 »
One good scripter could do an easy scenario editor with this where you point and click a simple mission together in 10 seconds !

Some ideas:
- the players base set
- the enemy main base set
- 2 enemy outpost sets
- 2 enemy vehicle groups
- 4 enemy infantry patrols
- 1 enemy sniper team
- 1 enemy reinforcement group

The script records the next 12 clicks of the server/player and spawns all above things at those positions - voila ! Give the players 1.000.000 $ and a buy script, so they can decide how to get the job done.

Should make for pretty good entertainment, especially on LANs.

A5hley

  • Guest
Re:onMapSingleClick command
« Reply #7 on: 17 Oct 2002, 21:02:19 »
Hey this is one nice command, u could do alot with it.

Can anyone tell me how i would give a unit a name after i have created it? that would be helpful to.

Offline uiox

  • Contributing Member
  • **
Re:onMapSingleClick command
« Reply #8 on: 17 Oct 2002, 21:25:29 »
In a dialog call by onMapSingleClick

A5hley

  • Guest
Re:onMapSingleClick command
« Reply #9 on: 17 Oct 2002, 22:04:22 »
in a diolog? dont know much about them

walker

  • Guest
Re:onMapSingleClick command
« Reply #10 on: 17 Oct 2002, 22:51:11 »
Hi all

Look here.http://www.thechainofcommand.net/cgi-bin/ikonboard/ikonboard.cgi?s=93621f07016f83e845150865b46a48d0;act=ST;f=34;t=1;st=0;&#entry4

It may aid your understanding of the command

Quote
I see lots of usefulness for these things.

And think, onMapSingleClick teamed up with CreateVehicle, hmm.

RTS-OFP come true

As you can see KTottE your last point is very relavent and dinger already is aware of its potential as are all at CoC.

Expect to see it in future versions of the Command Engine

Kind Regards walker
« Last Edit: 17 Oct 2002, 22:56:52 by walker »

Bremmer

  • Guest
Re:onMapSingleClick command
« Reply #11 on: 18 Oct 2002, 02:07:20 »
Hello

Here's a quick artillery script I knocked up to simulate a rifle mortar using setvelocity and onmapsingleclick (although it could used without onmapsingleclick as well). It seems to work OK as I have it set up, but a bug appears when higher velocities are used (eg for mortars heavy artillery etc). I'll try to fix that in the fullness of time, but I thought some fun might be had with this in the mean time  ;)

Cheers



Code: [Select]
;set up a trigger as below:

;   Radio Alpha
;   Artillery Strike
;   Zero size
;   Repeating
;   Delay 5
;   On Activation: onMapSingleClick {[_pos, artillerty nit name, _innaccuracy] exec "artillery.sqs" }

;target position
_target = _this select 0
;firing unit
_gunner = _this select 1
;innaccuracy of soultion - range 0 (most accurate) to 1 (+/- 20 % total distance)
_innaccuracy = _this select 2
? _innaccuracy > 1 : _innaccuracy = 1
? _innaccuracy < 0 : _innaccuracy = 0

;muzzle velocity
_mv = 100

;position of firing unit
_pos = getpos _gunner
_x1 = _pos select 0
_y1 = _pos select 1
_x2 = _target select 0
_y2 = _target select 1

;horizontal distance to target
dist = sqrt ((_x2 - _x1)^2 + (_y2 - _y1)^2)

;calculate innaccuracy
_innaccuracy = _innaccuracy * dist * 0.2
_randx = (random (2 * _innaccuracy)) - _innaccuracy
_randy = (random (2 * _innaccuracy)) - _innaccuracy
_x2 = _x2 + _randx
_y2 = _y2 + _randy

;recalculate distance for new position
dist = sqrt ((_x2 - _x1)^2 + (_y2 - _y1)^2)

;acceleration due to gravity
_g = 9.806

;calculate the maximum distance at 45 deg
_vel = (sin 45) * _mv
_tim = (2 * _vel) / _g
_max = _vel * _tim
? dist > _max : hint format ["Target out of range.\nDistance : %1\nMaximum : %2", dist, _max] ; exit

;calculate the minimum distance at 89 deg
_vel = (sin 89) * _mv
_tim = (2 * _vel) / _g
_vel = (cos 89) * _mv
_min = _vel * _tim
? dist < _min : hint format ["Target too close.\nDistance : %1\nMinimum : %2", dist, _min] ; exit

;inital guess for horizontal velocity
_hv = _mv

;set up parameters for iteration
_step = -1
_depth = 0

#iterate
_C = abs _B
_hv = _hv + _step
_A = sqrt (_hv^2 + (dist^2 * _g^2) / (4 * _hv^2))
_B = _mv - _A
? abs _B < 0.1 : goto "direction"
? abs _B > _C : goto "refine"
goto "iterate"

#refine
_depth = _depth + 1
? _depth > 10 : goto "no_solution"
_hv = _hv - _step
_step = - (_step / 2)
goto "iterate"

#direction
_x = _x2 - _x1
_y = _y2 - _y1
? _x == 0 : _x = 0.001
? _x > 0  : _ang = atan (_y / _x)
? _x < 0  : _ang = 180 + atan (_y / _x)
_xv = _hv * cos (_ang)
_yv = _hv * sin (_ang)

#solution
_gunner dowatch _target
~2
;need to find out why this expression is sometimes less than zero.
? _mv^2 -_xv^2 - _yv^2 < 0 : hint "Fatal Error"; exit
_zv = sqrt (_mv^2 -_xv^2 - _yv^2)
_shell = "mortarshell" camcreate [_x1 + cos (_ang), _y1 + sin (_ang), 1]
_shell setdir getdir _gunner
_shell setvelocity [_xv, _yv, _zv]
exit

#no_solution
~1
hint "No targeting solution."
exit

Offline uiox

  • Contributing Member
  • **
Re:onMapSingleClick command
« Reply #12 on: 18 Oct 2002, 12:57:28 »
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...

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:onMapSingleClick command
« Reply #13 on: 19 Oct 2002, 22:14:42 »
I'm setting this up for use in RTS2, the 2nd version of my RTS series, but there's some things I'm trying to find out about it.

I have several markers which are used for tracking different squad divisions and it also determines their placements, i.e. when I click on the map and move their marker, then their commands are to move to the marker.

Once the OnMapSingleClick command is active, is there a way to deactivate it so that every time you click on the map it doesn't move the marker?  Also, is there a way to pause the script before processing the move command until the map has been clicked and the marker placed?  I know I can simply place a 5 second pause or something, but I don't want them to move until the click has been done.

Also, how do you specify which key combo will activate the script?  From reading the info in the comref it looks like you can have shift+click, alt+click or shift+alt+click.

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:onMapSingleClick command
« Reply #14 on: 20 Oct 2002, 00:49:15 »
To completely disable the command you probably have to use an empty action string like

onMapSingleClick {}

but I donÂ't recommend that. Personally I setup the command the following way:

onMapSingleClick {[_pos, _units, _shift, _alt] exec "OnMapClick.sqs"}

i.e. whenever the player clicks on the map, a script "OnMapClick.sqs" is called with all the available parameters as arguments. This also answers your question about reading the status of the SHIFT and ALT keys. Their status is contained in the reserved boolean variables _shift and _alt (if true, key is pressed). _units is an array of the currently selected units.

Within "OnMapClick.sqs" you can do whatever you want with the info given

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
OnMapClick.sqs

_pos = _this select 0
_units = _this select 1
_shift = _this select 2
_alt = _this select 3

;block execution when player did select units
?Count _units != 0: Exit

;block execution when player is commander of a vehicle
_vehicle = Vehicle Player
?(_vehicle != Player) AND (Commander _vehicle == Player): Exit

.....

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

e.g. you can block execution of the script under some curcumstances or include a pause between click and movement.

Spinor

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/

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:onMapSingleClick command
« Reply #30 on: 12 Jun 2003, 14:01:43 »
wats da prob exactly ?

put - onmapsingleclick in da script ;) - den u use it from within da script

or im misin somthin here ?

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