Home   Help Search Login Register  

Author Topic: Strange side effect using EH "HIT"  (Read 1359 times)

0 Members and 1 Guest are viewing this topic.

Offline Odin

  • Members
  • *
Strange side effect using EH "HIT"
« on: 03 Nov 2008, 02:44:09 »
G'day, I have just made a deployable MGnest for a mission I am making, it worked great but I wanted more so I added a few eventhandlers to make the MG near on indestructable, But I have a strange side effect resulting in once deployed and mounted, when Tanks fire the tank's shell explodes underneath themselves?? and I cant seem to fix it.

To make the Deployable MGnest I placed an Empty Marker and called it "MGnest"
I placed an empty MGnest/US and named it "nest" (It's class type is "WarfareBWestMGNest_M240"

in the init I gave the player an action,
Code: [Select]
deploy = player addAction ["Deploy MG nest", "mgnest.sqs"]
mgnest.sqs
Code: [Select]
_vehicle = _this select 0
_position = _this select 1
_unit = _this select 2

titleText ["Deploying MG nest...", "Plain Down"]
deleteMarker "MGnest"
deleteVehicle nest
~1
_markerObj = createMarker ["MGnest", position player]
_markerObj setMarkerShape "ICON"
"MGnest" setMarkerType "FLAG"
"MGnest" setMarkerText "MGnest Pos"
"MGnest" setMarkerColor "ColorGreen"
_d = direction player
player playmove "AinvPknlMstpSlayWrflDnon_AmovPercMstpSrasWrflDnon"
~2
nest = "WarfareBWestMGNest_M240" Createvehicle getMarkerPos "MGnest"
nest setDir _d;
~0.001
nest addEventHandler ["getin", {_this exec "nestOn.sqs"}];
nest addEventHandler ["getout",{_this exec "nestOff.sqs"}];
titleText ["MG nest deployed...", "Plain Down"]

The nestOn script is what I think is causing the side effect
nestOn.sqs
Code: [Select]
hint "start"
~1
_vehicle = _this select 0
_position = _this select 1
_unit = _this select 2
~0.001
?not (vehicle nest isKindOf "WarfareBWestMGNest_M240") and (_position == "Gunner"): exit
;?not (_position == "Gunner"): exit
~1
_unit setdamage -500; _unit addEventHandler ["HIT",{(_this select 0) setDamage (-500 * damage (_this select 0));}];
hint "you should be bulletproof"
~1
nest setdamage -500; nest addEventHandler ["HIT",{(_this select 0) setDamage (-500 * damage (_this select 0));}];
hint "Nest should be bulletproof"
exit

and the last script
nestOff.sqs
Code: [Select]
hint "loser get back here"
_vehicle = _this select 0
_position = _this select 1
_unit = _this select 2
~1
_unit removeEventHandler ["HIT", 0]
nest removeEventHandler ["HIT", 0]
_unit setdamage 0;
hint "you should be normal"

Anyone got any Ideas on what is happening?

Here is a small example mission

Cheers
Odin
« Last Edit: 20 Aug 2009, 16:24:32 by hoz »

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Strange side effect using EH "HIT"
« Reply #1 on: 03 Nov 2008, 03:04:30 »
What do you mean underneath themselves? 
The nest fires the shells?

Or does the shell explode underneath the nest when it is hit?
Or does the shell explode under the tank firing?
Or does the shell explode underneath the tank firing shells while manning the nest?  :P

What do you mean exactly, Odin?

Luke
Pesky Human!!
Wort Wort Wort.

Offline Odin

  • Members
  • *
Re: Strange side effect using EH "HIT"
« Reply #2 on: 03 Nov 2008, 03:09:03 »
No I mean the firing tank,  Tank fires at target and the fired shell explodes underneath the Tank that fired the shell.
Arty is unaffected, only tanks are affected. :dunno:

Here is a small example mission
« Last Edit: 20 Aug 2009, 16:24:19 by hoz »

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Strange side effect using EH "HIT"
« Reply #3 on: 03 Nov 2008, 21:36:20 »
Sounds odd. I don't personally think this is a result of the script. Does it do it in any other missions? Maybe a mod or something is conflicting ?

Offline Odin

  • Members
  • *
Re: Strange side effect using EH "HIT"
« Reply #4 on: 04 Nov 2008, 05:30:11 »
G'day, I tried it in another mission, samething happens but a few rounds did actualy make it to the nest, The only addons I have is 6thsense editor upgrade, lowflys editor, RTE and the Curatalos_Afghanistan island. In the tests I have done it only starts after I or an AI get in the nest, before that all is normal ??? only seems to affect the T72 and M1A when they use the turret gun, their MG work.

Cheers
Odin

Offline Rommel92

  • Members
  • *
Re: Strange side effect using EH "HIT"
« Reply #5 on: 19 Nov 2008, 21:58:24 »
Code: [Select]
deploy = player addAction ["Deploy MG nest", "mgnest.sqf"]
mgnest.sqf
Code: [Select]
_unit = _this select 1;
_idx = _this select 2;

titleText ["Deploying MG nest...", "Plain Down"];

sleep 1.0;

_markerObj = createMarker ["MGnest", position player];_markerObj setMarkerShape "ICON";
"MGnest" setMarkerType "FLAG";"MGnest" setMarkerText "MGnest Pos";"MGnest" setMarkerColor "ColorGreen";

_d = direction player;
player playmove "AinvPknlMstpSlayWrflDnon_AmovPercMstpSrasWrflDnon";
sleep 2.0;
nest = "WarfareBWestMGNest_M240" createVehicle getPos _unit;
nest setDir _d;

nest addEventHandler ["getIn", {_this execVM "nestOn.sqf"}];
titleText ["MG nest deployed...", "Plain Down"];

nestOn.sqf
Code: [Select]
sleep 2.0;

_vehicle = _this select 0;
_position = _this select 1;
_unit = _this select 2;

while {_unit in (crew nest)} do
{
_unit setdamage -50000;
nest setdamage -50000;
sleep 2.0;
};

_unit setDamage 0;
nest setDamage 0;

Should work, also should get rid-of any nasty bugs, and the constant adding/removal of EH, which is not good practice.

Offline Odin

  • Members
  • *
Re: Strange side effect using EH "HIT"
« Reply #6 on: 22 Nov 2008, 01:54:55 »
G'day, Thx for the script Rommel, It works great appart from the nest and gunner still can be Killed, so I may have to go back to the EH.
 I am only learning SQF now trying to break away from my SQS addiction so it is handy to see your script next to my SQS allowing me to understand SQF syntax better much appreciated :good:

Odin

Offline Ext3rmin4tor

  • Members
  • *
Re: Strange side effect using EH "HIT"
« Reply #7 on: 29 Nov 2008, 16:28:44 »
Learn it as fast as you can. SQF is great compared to SQS, it's like High level programming vs assembly code. Plus you can write functions with a returning value, so if you make a boolean function you can create complex conditions for triggers that can't  normally be put in the condition field.
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!