OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Odin on 27 Nov 2008, 02:47:26

Title: Deployable IED with scoring system [testing]
Post by: Odin on 27 Nov 2008, 02:47:26
G'day,
 I have just completed my Roving IED scripts, this is my first foray in SQF scripting so I hope my syntax is correctly written.

What these scripts allow is a player to deploy an IED anywhere they want and receive a score for the vehicles destroyed by that IED. Also the player can defuse the IED then redeploy it in another Location.

At the moment these scripts are only set up for single player use, but I have all intentions of converting it to MP, once I get my head around the intricacies of MP scripting, So I am hoping for feedback  on this version so I can make it better and use that to convert with.

Also the score system is only working on LandVehicles, Not sure whether to add Infantry in to the scoring yet? And not much point in scoring for Aircraft or ships as it is designed as a roadside bomb.

USAGE:
Code: [Select]
R o v i n g - I.E.D. with score system. Single Player only.
(Version1)

Description; These scripts allow the player to deploy an IED and Detonate it either Remotely
Or by a trigger which can be created via the script. Player will receive scores for all destroyed vehicles, positive for enemy and Negative for friendly and civilian.

Installation:
Extract the folder RovingIED.Intro into the mission folder:

C:\Documents and Settings\XXXXXX\My Documents\ArmA Other
Profiles\YourName\missions\

------------------------------------------------------------------

Usage:

INIT: in your init.sqf/sqs add this code

deployIED = player addAction ["Deploy IED", "rovingIED.sqf",[],-1, false, false, ""];

Description.ext and Dialogs: Requires a small dialog to be added for the progress bar to work.
In your Description you need to add these lines;

#include "Dialogs\Common\DialogColorConstants.hpp"
#include "Dialogs\Common\DialogColorScheme.hpp"
#include "Dialogs\Common\DialogControlClasses.hpp"
#include "Dialogs\rovingIED.hpp"

------------------------------------------------------------------

DIALOGS:

Create or copy the Dialogs folder, and include all files within.

- ProgressBar.sqf
- DefuseProgressBar.sqf
- rovingIED.hpp

Common folder-
- DialogColorConstants.hpp
- DialogColorScheme.hpp
- DialogControlClasses.hpp

NOTE! if you are using other Dialogs and already are using the three .hpp files from the Common folder there is no need to ADD or DEFINE these three files again! This Dialog was originally made by Dr Eyeball modified by myself for use with the IED scripts so they are usualy used with all Dialogs made by the good Dr ;) Also If you have your own Dialog and have defined RscStructuredText, you may not have to add the three .hpp files from the Common folder.

------------------------------------------------------------------

SCRIPTS:

rovingIED.sqf

USAGE:
 This script is called upon using the action added in the INIT from the menu In-game
 To change the way it detonates from either, the Trigger or Remote (addaction)
 Remove the /* */ Comments from the unactive Block and use the same comments on the
 active Block. eg;

 //Trigger
 sleep 0.001;
 _trg = createTrigger["EmptyDetector",getPos IED];
 _trg setTriggerArea[30,30,0,true];
 _trg setTriggerActivation["EAST","PRESENT",false];
 _trg setTriggerStatements["this", "execVM ""findIED.sqf""", ""];
 _trg setTriggerType "NONE";
 
 /*
 // Remote
 remoteIED = player addAction ["DETONATE IED", "findIED.sqf"];
 */
 
 If using the trigger method, be sure to change which side is to activate the Trigger, eg.

 trgz setTriggerActivation["EAST","PRESENT",false];
 
 This is set to EAST, to change to WEST, use.

 trgz setTriggerActivation["WEST","PRESENT",false];
------------------------------------------------------------------

findIED.sqf

USAGE:
 This script is called through the rovingIED.sqf.
 The _shelltype list starts from the weakest down to strongest Blasts, remove the // comments
 from the size blast (_shelltype), you want. Then place the same // comments infront of the
 previously used _shelltype.
 
------------------------------------------------------------------

killerz.sqf

USAGE:
 Use the "Templates" Located in the Score Templates folder
 to change the score settings from Friendly to Enemy, dependeing on your mission.
 
 If you do not have version 1.14 remove the warfare vehicles from the score Blocks,
 Warfare Vehicles have this comment //(comes with patch 1.14 (Warfare)) after the Classname.
 
------------------------------------------------------------------

defuse.sqf

USAGE:
This script will delete all actions, the IED object, the created trigger and the marker, then readd the Deploy IED action again.

------------------------------------------------------------------

OTHER:

Score Templates folder: This folder contains the score templates for all side's, both Enemy and Friendly as well as a Blank Score Template, if the user wishes to add different classes (addons). Also the official ARMA: ratings values, in a .txt document.

------------------------------------------------------------------

THANX:

Dr Eyeball(dialogs), CSL, Gigian, Mandoble and ZoneKiller for breaking the ground with good wholesome explosive effects and the entire ARMA community for contributions made in Forums and the WIKI, that make life a whole lot easier.

Thanx
Odin
Title: Re: Deployable IED with scoring system [testing]
Post by: hoz on 14 Dec 2008, 22:55:45
this is pretty cool. I wondered though why you used equal signs for progression. Also the ied explosion was cool, it seemed like there was a lot of red dust or smoke.
Title: Re: Deployable IED with scoring system [testing]
Post by: Odin on 15 Dec 2008, 00:49:02
Thanx hoz, I mucked around with a few different symbols for the progress bar and in the end the = signs seemed to fit the the smoothest without dissapearing off the box alltogeter, I have thought about adding different colored .jpg instead, but I have had limited time lately. I am glad you liked the explosion  :D the red is meant to be dust it looks a bit funny. I was haveing trouble getting it to spread evenly.
Thanx for the reply
Odin
Title: Re: Deployable IED with scoring system [testing]
Post by: Ironman on 16 Dec 2008, 06:16:39
Nothing is spread "evenly" when it explodes.
Title: Re: Deployable IED with scoring system [testing]
Post by: Knight Trane on 22 Dec 2008, 22:54:15
Did a quick test of the demo mission, + a few more player spots, on dei server.  Worked great. 

Need to be able to set multiple "IEDs", like satchles.

Very nice. :D
Title: Re: Deployable IED with scoring system [testing]
Post by: Mandoble on 08 Feb 2009, 11:39:20
Odin, good work there.
I've applied some small modifications to make the effects MP compatible as follows:
From findIED.sqf, extract all the code related to effects and move it to an independent script:
Code: [Select]
// rovingIEDeffects.sqf

private["_i", "_posx", "_posy", "_posz"];
_posx = _this select 0;
_posy = _this select 1;
_posz = _this select 2;

for [{_i = 0},{_i < 5},{_i = _i + 1}] do
{

drop [["\Ca\Data\ParticleEffects\Pstone\Pstone.p3d", 8, 3, 1], "", "SpaceObject", 1, 10,[_posx,_posy,_posz -10],[0,0,-2],1,10,1,0.2,[2,2],[[1,1,1,1],[1,1,1,1],[1,1,1,1]],[0,1],1,0,"","",""];

drop ["\ca\data\cl_basic","","Billboard",120,5,[_posx,_posy,_posz - 10],[1.8,2.8,0],1,2,1.55,1,[2.5,6],[[0.35,0.3,0.25,0.5],[0.35,0.35,0.25,0.4],[0.35,0.3,0.25,0.2],[0.4,0.35,0.3,0]],[0],0.2,0.2,"","",""];

drop ["\ca\data\cl_basic","","Billboard",120,5,[_posx,_posy,_posz - 10],[1.5,2.5,0],1,2,1.55,1,[1.5,5.7],[[0.35,0.3,0.25,0.5],[0.35,0.35,0.25,0.4],[0.35,0.3,0.25,0.2],[0.4,0.35,0.3,0]],[0],0.2,0.2,"","",""];

drop ["\ca\data\cl_basic","","Billboard",120,5,[_posx,_posy,_posz - 10],[1.2,2.5,0],1,2,1.55,1,[1.5,5.4],[[0.35,0.3,0.25,0.5],[0.35,0.35,0.25,0.4],[0.35,0.3,0.25,0.2],[0.4,0.35,0.3,0]],[0],0.2,0.2,"","",""];

drop [["\Ca\Data\ParticleEffects\Pstone\Pstone.p3d", 8, 3, 1], "", "SpaceObject", 1, 10,[_posx,_posy,_posz - 10],[0, 0, -2],1,10,1,0.2,[2,2],[[1,1,1,1],[1,1,1,1],[1,1,1,1]],[0,1],1,0,"","",""];

drop ["\Ca\Data\kouleSvetlo.p3d","","Billboard",1,1.0,[_posx,_posy,_posz - 10],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];
sleep 0.001;
drop [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d",8,5,0],"","Billboard",1,10.0,[_posx,_posy,_posz -30],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];
sleep 0.001;
drop ["\Ca\Data\kouleSvetlo.p3d","","Billboard",1,5.0,[_posx,_posy,_posz - 20],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];
sleep 0.001;
drop [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 20, 6], "", "Billboard",1,200.0,[_posx,_posy,_posz - 10],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];
sleep 0.001;
drop ["\Ca\Data\cl_fireD","","Billboard",1,3.0,[_posx,_posy,_posz - 10],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];
sleep 0.001;
drop [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\FireAnim.p3d", 8, 1, 8], "", "Billboard",1,1.0,[_posx,_posy,_posz -50],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];
sleep 0.001;
drop ["\Ca\Data\cl_fireD","","Billboard",1,1.0,[_posx,_posy,_posz - 10],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];
sleep 0.001;
drop [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d",8,5,0],"","Billboard",1,40.0,[_posx,_posy,_posz -50],[0,0,0],1,1.3,1.0,0.0,[100],[[1.0,0.7,0.4,1.0],[1.0,0.6,0.4,0.001]],[0],0.0,0.0,"","",""];

};

Now, in findIED.sqf, at the position where effects code was removed add the following:
Code: [Select]
// effects for IED ====>
[_posx, _posy, _posz] spawn
{
   private["_posx", "_posy", "_posz", "_trigger"];
   _posx = _this select 0;
   _posy = _this select 1;
   _posz = _this select 2;
   _trigger = createTrigger ["EmptyDetector", [0, 0, 0]];
   _trigger setTriggerActivation ["NONE", "PRESENT", false];
   _trigger setTriggerArea [0, 0, 0, false];
   _trigger setTriggerType "NONE";
   _trigger setTriggerTimeout [0, 0, 0, false ];
   _trigger setTriggerStatements ["true", format ["res = [%1,%2,%3]execVM""rovingIEDeffects.sqf""", _posx, _posy, _posz], ""];
   Sleep 6;
   deleteVehicle _trigger;
};

Still have some doubts about your scoring system, if Killed event is not broadcasted then it should work fine, else you might be adding score even to the enemy players.
Title: Re: Deployable IED with scoring system [testing]
Post by: Curatalo on 09 Feb 2009, 05:29:01
Sounds like a great idea!
Ive been hoping for this for a while.
I would say yes to the player getting points for killing Infantry, and vehicles, but theres no reason for Aircraft and Ships, because that will be prety rare!

Wish you luck!
Title: Re: Deployable IED with scoring system [testing]
Post by: johnnyboy on 09 Feb 2009, 17:34:20
Mando: 

So I can understand MP programming better, please explain the following regarding your changes to this script:

1.  By moving the effects to a script called by a trigger, you guarantee the code is executed on each client.  Correct?

2. In the last step of the code creating the trigger, you "deleteVehicle _trigger;".  How does the trigger fire before it is deleted?

Gracias in advance!
Title: Re: Deployable IED with scoring system [testing]
Post by: Mandoble on 09 Feb 2009, 20:06:53
1 - yes.
2 - The trigger fires at creation time, as its condition is just "true". The trigger is executed only once, and then it is worthless, so I delete it just after few seconds.
Title: Re: Deployable IED with scoring system [testing]
Post by: Odin on 12 Mar 2009, 23:14:24
Thanx Mando for the edit  :good: this has helped me better understand the use of "Private". Sorry for such a late reply RL has really been keeping me away from my little projects and the putor. I had shelved this project just befor Xmas as I am having alot of trouble getting a reliable score system implemented for MP use, I can get it to work but it will not work on a Dedicated server. But your post has given me renewed insperation.

Thank-you to all that have commented and tried this out, I am just not sure on how to make Multiple IED's, KT.
The posted version is for SP use and the score system works fine for that, well I guess I best resume work on the MP version, so if anyone knows a good score method I am all eyes :yes:

Thanx
Odin
Title: Re: Deployable IED with scoring system [testing]
Post by: Mandoble on 15 Mar 2009, 14:16:08
You can check the one present in mando missile for warheads detonations which use mando_scorefunc. To study that way, you may use mando_missiles\warheads\mando_missilehead1a.sqf and mando_missiles\mando_score.sqf