Home   Help Search Login Register  

Author Topic: onMapSingleClick command  (Read 7669 times)

0 Members and 1 Guest 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