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,
deploy = player addAction ["Deploy MG nest", "mgnest.sqs"]
mgnest.sqs
_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
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
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