Jump to content
Sign in to follow this  
READTHESCROLL

Scripting noob needs assistance!

Recommended Posts

Hey guys, I am currently trying to adapt the EtV script for the Exile mod. I have it 90% done as far as integration with the mod but need to figure out 1 thing.. I am trying to figure out how to do a check if the explosive is in an array of predefined coordinates with a radius (safe zones) to prevent the explosive from being detonated. If someone tries to detonate the charge in the safe zone I want the explosive to be deleted. This is what I have so far.. It is not 100% done so if you see something funny in there that's why lol Any help is greatly appreciated. Thanks!

EtV_TouchOff =
{
	_array = _this select 3;
	_unit = _array select 0;
	_explosives = _unit getVariable ["charges",[]];
	{
		if(alive _x && !ExilePlayerInSafezone && _explosives !(SAFE ZONE COORDS) then //NEED HELP ADDING COORDS HERE
		{
			_nearVehicle = (nearestObjects [_x,["Air","Ship","LandVehicle","Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"],5]) select 0;
			"HelicopterExploSmall" createVehicle (position _x);
			deleteVehicle _x;
			_existingDamage = damage _nearVehicle;
			if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"]) then 
				{
					_nearVehicle setDamage _existingDamage + 0.10;
				}
				else
				{
					_nearVehicle setDamage _existingDamage + 1;
				};

			_destroyed = damage _nearvehicle > 0.99;
			if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"] == (_destroyed)) then //if (_destroyed) then
				{
					_nearVehicle call ExileServer_object_construction_database_delete;
				}
				else
				{
					_nearVehicle call ExileServer_object_vehicle_remove;
				};
		}
		else
		{
			deleteVehicle _explosives;
		};
	} forEach _explosives;
	_unit setVariable ["charges",[]];

};

Share this post


Link to post
Share on other sites

You could do something like 

//A simple array of positions
safeZones = [
    [7719.89,1605.51,0.001434433],
    [7783.26,1642.77,0.00143433]  
]; 

//An arbitrary distance
safeZoneDistance = 25;

//I would recommend using the fired event handler as it should trigger the moment a unit places an explosive (ofc triggers on weapon fire)
player addEventHandler ["Fired", {
    if ({player distance _x < safeZoneDistance} count safeZones > 0) then {
        //delete the projectile and whatever else you want  
    };  
}];  

Share this post


Link to post
Share on other sites

Thanks for the reply! I'll mess around with that and see what I can come up with. I would like to use the check to see if the explosive is in one of those areas instead of the player himself. The other thing is that I remembered that there are markers defined in the mission.sqm. How would I add a check to see if the location of the demo charge is in the marker area instead?

 

Also havent really messed around with eventHandlers yet. Would this work?

//A simple array of positions
safeZones = [
    [7719.89,1605.51,0.001434433],
    [7783.26,1642.77,0.00143433]  
]; 

//An arbitrary distance
safeZoneDistance = 25;

//I would recommend using the fired event handler as it should trigger the moment a unit places an explosive (ofc triggers on weapon fire)
_explosives addEventHandler ["Fired", {
    if ({_explosives distance _x < safeZoneDistance} count safeZones > 0) then {
        //delete the projectile and whatever else you want  
    };  
}];

Share this post


Link to post
Share on other sites

 

Thanks for the reply! I'll mess around with that and see what I can come up with. I would like to use the check to see if the explosive is in one of those areas instead of the player himself. The other thing is that I remembered that there are markers defined in the mission.sqm. How would I add a check to see if the location of the demo charge is in the marker area instead?

 

Also havent really messed around with eventHandlers yet. Would this work?

//A simple array of positions
safeZones = [
    [7719.89,1605.51,0.001434433],
    [7783.26,1642.77,0.00143433]  
]; 

//An arbitrary distance
safeZoneDistance = 25;

//I would recommend using the fired event handler as it should trigger the moment a unit places an explosive (ofc triggers on weapon fire)
_explosives addEventHandler ["Fired", {
    if ({_explosives distance _x < safeZoneDistance} count safeZones > 0) then {
        //delete the projectile and whatever else you want  
    };  
}];

You can certainly do this with markers. You'd simply need to create an array of markers(similar to the array of positions)

safeZones = [
    "marker1",
    "marker2",
    "marker3"
];

and then modifying the count to check the distance from the player to the marker's position using getMarkerPos.

if ({player distance getMarkerPos _x < safeZoneDistance} count safeZones > 0) then {
   //Do whatever you want to the projectile or player
};

As far as event handlers go, I'd suggest reading through the list Event Handlers to see if there's perhaps a handler which would be better suited for the task.

Event handlers can be added to object but I don't think the Fired event handler would be triggered by the explosive but would instead be triggered by the player.

 

I'm unfortunately not familiar with Exile so I'm not sure what kind of explosive/explosions you are trying to protect from but if you'd like to go into further details, I may be able to come up with a better solution.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot for the help. I really do appreciate it. This is what I have now after using your suggestions. Havent had a chance to test it yet though. I'll try add it to the server later tonight and see if it works.

EtV_TouchOff =
{
	_array = _this select 3;
	_unit = _array select 0;
	_explosives = _unit getVariable ["charges",[]];
	SZ_Markers = [
	    "TraderCityMarker",
	    "TraderZoneSilderas",
	    "TraderZoneFolia"
	];
	SZ_Radius = 300;
	if(alive _x && !ExilePlayerInSafezone) then { //Checks if player is not in safe zone
		if ({_explosives distance getMarkerPos _x < SZ_Radius} count SZ_Markers > 0) then {	//Checks if demo charge is in sz marker
			deleteVehicle _explosives; //Deletes explosive if it is in sz
			call ExileClient_gui_safezone_fired; //Hint message
		}
		else //Demo charge is not in safe zone & player is not in safe zone. Proceed...
		{
			_nearVehicle = (nearestObjects [_x,["Air","Ship","LandVehicle","Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"],5]) select 0;
			"HelicopterExploSmall" createVehicle (position _x);
			deleteVehicle _x;

			_existingDamage = damage _nearVehicle;
			if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"]) then
				{
					_nearVehicle setDamage _existingDamage + 0.08;
				}
				else
				{
					_nearVehicle setDamage _existingDamage + 1;
				};

			_destroyed = damage _nearvehicle > 0.99;
			if ((typeOf _nearVehicle) in ["Exile_Construction_WoodGate_Static","Exile_Construction_WoodDoor_Static"] == (_destroyed)) then //if (_destroyed) then
				{
					_nearVehicle call ExileServer_object_construction_database_delete;
				}
				else
				{
					_nearVehicle call ExileServer_object_vehicle_remove;
				};
			};
		};
	} forEach _explosives;
	_unit setVariable ["charges",[]];

};

Here's a link to my Pastebin if you'd like to see the whole code. Most of the original EtV script is untouched aside from the EtV_TouchOff section.

 

http://pastebin.com/MaWksYDa

 

Also I've been working on an adaptation of EtV called S2V, or , Strobes 2 Vehicles which is similar to EtV but allows players to attach IR strobes to vehicles if you'd like to see my progress on that so far.

 

http://pastebin.com/samfy1gf

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×