Home   Help Search Login Register  

Author Topic: Help with onMapSingleClick script  (Read 927 times)

0 Members and 1 Guest are viewing this topic.

mr.sert

  • Guest
Help with onMapSingleClick script
« on: 29 Oct 2002, 13:29:20 »
I downloaded what sounds like a sweet script, that uses onmapsingleclick. I put the script in my missions folder, and tried to test it. I get radio messages that say request complete, but nothing happens. Here are the scripts, sorry if they are really long.. What am I doing wrong? Do I need to add tanks? I'm a complete newb at scripting so bare with me. One thing I noticed was that in the init.sqs file it reffered to the cannon.sqf file? I assumed this was a typo and renamed it .sqs, I also did this when I saved the cannon.sqs file, as it read in the download cannon.sqf. Is there such thing as an .sqf file? Thanks in advance.....

- Mr. Sert

Howitzer. sqs

_cannontime = 15

_side = side (_this select 0)
_pos = _this select 1
_units = _this select 2
_shift = _this select 3
_alt = _this select 4

? _side == east : goto "cannonE"
goto "cannonW"

#busy
[_side, "hq"] sidechat "BUSY WITH OTHER MISSION."
exit

#range
[_side, "hq"] sidechat "EXCESSIVE RANGE TO TARGET."
exit

#complete
[_side, "hq"] sidechat "FIRE REQUEST COMPLETE."
exit

#cannonW
? howitzerWtime > time : goto "busy"
_return = [howitzerW_1, _pos, _units, _shift, _alt] call CannonFunction
;If one is out of range, they probably all are
? _return == "RANGE" : goto "range"
_return = [howitzerW_2, _pos, _units, _shift, _alt] call CannonFunction
_return = [howitzerW_3, _pos, _units, _shift, _alt] call CannonFunction
howitzerWtime = time + _cannontime
publicVariable "howitzerWtime"
goto "complete"

#cannonE
? howitzerEtime > time : goto "busy"
_return = [howitzerE_1, _pos, _units, _shift, _alt] call CannonFunction
;If one is out of range, they probably all are
? _return == "RANGE" : goto "range"
_return = [howitzerE_2, _pos, _units, _shift, _alt] call CannonFunction
_return = [howitzerE_3, _pos, _units, _shift, _alt] call CannonFunction
howitzerEtime = time + _cannontime
publicVariable "howitzerEtime"
goto "complete"

Init. sqs

onMapSingleClick "[player, _pos, _units, _shift, _alt] exec ""howitzer.sqs"""

CannonFunction = preprocessFile "cannon.sqs"
howitzerWtime = 0
howitzerEtime = 0

Cannon. sqs

private ["_muzzle", "_src", "_tgt", "_units", "_shift", "_alt", "_return"];
private ["_x", "_y", "_dist", "_dir", "_tmp", "_angle", "_hyp", "_vx", "_vz", "_vy", "_type", "_obj"];

_muzzle = 180;
_src = getPos (_this select 0);
_tgt = _this select 1;
_units = _this select 2;
_shift = _this select 3;
_alt = _this select 4;

_x = ((_tgt select 0) - (_src select 0));
_z = ((_tgt select 1) - (_src select 1));
_dist = sqrt ((_x * _x) + (_z * _z));
_dir = _z atan2 _x;

_tmp = ((9.8 * _dist) / (_muzzle * _muzzle));
if (_tmp > -1 && _tmp < 1) then {
   _angle = (asin _tmp) / 2;

   _dir = _dir - 1 + random 2;
   _angle = _angle - 1 + random 2;

   _vy = _muzzle * sin _angle;
   _hyp = _muzzle * cos _angle;
   _vx = _hyp * cos _dir;
   _vz = _hyp * sin _dir;

   _type = "Shell105";
   if (_shift) then {_type = "Heat105"};
   if (_alt) then {_type = "SmokeShell"};

   _obj = _type camCreate [_src select 0, _src select 1, 3];
   _obj setVelocity [_vx, _vz, _vy];
   _obj setDir -(_dir - 90);
   "Cannon30HE" camCreate [_src select 0, _src select 1, 0];
   _return = "COMPLETE";
} else {
   _return = "RANGE";
};

_return

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Help with onMapSingleClick script
« Reply #1 on: 29 Oct 2002, 15:12:35 »
Yes, there are sqf files. I understand they contain code with newer commands like if, while etc... you should leave all sqf files and requests as they are - these are no typos.  :D *gg*
hehehehe  ;D (sorry can't hold it)

Best thing would be to zip your whole mission folder, upload it somewhere and post the link here, so we could look what you did wrong.

In case you wanna do this: if you saved it as a "User Mission", it resides at :"../OperationFlashpoint/Users/<yourName>/missions/<Name_of_saved_mission>"