Home   Help Search Login Register  

Author Topic: CTI_SectorLink Help  (Read 7731 times)

0 Members and 1 Guest are viewing this topic.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CTI_SectorLink Help
« Reply #30 on: 14 Jul 2008, 12:26:18 »
So you already have a list of triggers covering the areas which power balance you want to check?
Code: [Select]
_balance = [tr_1, 10, 20, 1, 2, 1] call mando_getbalancefirst parameter is the name of a trigger or directly a trigger object.

// Parameters:
//    trigger name which units will be tested (usually ANYBODY present type).
//    Added power value per armoured type unit present
//    Added power value per flying type unit present
//    Added power value per ship type unit present
//    Heights control bonus (who controls the heights has its power value muntiplied by this, only with an advantage of more than 5m over other sides).
//    Strategic bonus (all power values for this trgger are multiplied by this, the power presence in some triggers may be
//    more important than in other triggers).

//    This function returns an array with the following format:
//    [BLUFOR power, OPFOR power, Independent power, Civilian power, BLUFOR ratio, OPFOR ratio, Independent ratio, civ ratio, winner sides]
//    ratios are like % of total power present in the trigger's area.
//    winner sides is an array with the side with more power, or more than one side in case of draw

For your case:
Code: [Select]
// check_global_balance.sqf
private["_balance", "_total_balance", "_markers_ranges", "_i"];
_positions_ranges = [["mk_paraiso", 2000],["mk_rahmadi", 1500], ["mk_airport", 1500]];
_trigger = createTrigger ["EmptyDetector", [0,0]];   
_trigger setTriggerActivation ["ANY", "PRESENT", false];
_trigger setTriggerArea [1, 1, 0, false];
_trigger setTriggerType "NONE";
_trigger setTriggerStatements ["this", "", ""];
_trigger setTriggerTimeout [0, 0, 0, false ];

while {true} do
{
   _i = 1;
   {
      _trigger setTriggerArea [_x select 1,  _x select 1, 0, false];
      _trigger setPos getMarkerPos (_x select 0);
      Sleep 1;
      _balance = [_trigger, 10, 20, 1, 2, 1] call mando_getbalance;
      _total_balance = [((_total_balance select 0) + (_balance select 4))/_i, ((_total_balance select 1) + (_balance select 5))/_i, ((_total_balance select 2) + (_balance select 6))/_i,((_total_balance select 3) + (_balance select 7))/_i];
      _i = _i + 1;
   } forEach _positions_ranges;
   
   /* Here _total_balance contains the global % of power for west, east, resistance and civilian sides
      _total_balance select 0: West % of power in the map
      _total_balance select 1: East % of power in the map
      _total_balance select 2: Resistance % of power in the map
      _total_balance select 3: Civilian % of power in the map
   */

   Sleep 1;
};

Code: [Select]
// init.sqf

if (isServer) then
{
   mando_getbalance = compile (preprocessFileLineNumbers "mando_getbalance.sqf");
   Sleep 1;
   []execVM"check_global_balance.sqf";
};

This way you dont need to define any trigger in the map, just some markers and the radius to be checked from each one (_positions_ranges array).
« Last Edit: 14 Jul 2008, 14:12:35 by Planck »

Offline USM-CPT.Dyson

  • Members
  • *
Re: CTI_SectorLink Help
« Reply #31 on: 26 Jul 2008, 00:01:11 »
Yes I have pre-placed triggers, but could delete them and only place markers. I really dont understand what I need to change in order to do this.

Here is what I want in the objective script. Could you highlight where I would place the marker names please. Also I didn't follow still what I was changing the post before your last.

__________________________________________________

Here is what I am looking to do

Settings

Min players to start capture: 6 Points
Time to capture: 5 Minutes

Objectives MUST be taken in order

Both linking objectives MUST be taken

No enemy can be present or timer is reset
________________________________________________________________________________

Objective Layout

BLUFOR START | OPFOR END

   Parasio Airport (PA)

      PA1
      PA2
      PA3
      PA4
      PA5
      PA6
      PA7

      Links:
      PA_SM1
      PA_SM2

   Sierra Madre (SM)

      SM1
      SM2
      SM3
      SM4
      SM5
      SM6
      SM7

      Links:
      SM_CZ1
      SM_CZ2

   Corazol (CZ)

      CZ1
      CZ2
      CZ3
      CZ4
      CZ5
      CZ6
      CZ7

      Links:
      CZ_OG1
      CZ_OG2

   Obregan (OG)

      OG1
      OG2
      OG3
      OG4
      OG5
      OG6
      OG7

      Links:
      OG_VC1
      OG_VC2

   Valle De Carmen (VC)

      VC1
      VC2
      VC3
      VC4
      VC5
      VC6
      VC7

OPFOR START | BLUFOR END
« Last Edit: 26 Jul 2008, 00:03:59 by USM-CPT.Dyson »
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CTI_SectorLink Help
« Reply #32 on: 26 Jul 2008, 00:09:18 »
The marker names and the range to check from each marker are into
Code: [Select]
_positions_ranges = [["mk_paraiso", 2000],["mk_rahmadi", 1500], ["mk_airport", 1500]];

Offline USM-CPT.Dyson

  • Members
  • *
Re: CTI_SectorLink Help
« Reply #33 on: 28 Sep 2008, 05:39:28 »
Was wondering about this. I am looking to replace the BIS smoke grenade with smoke particles of my own. Instead of constantly bugging Spooner and before he blocks me, I was wondering if anyone can point me in the right direction.

okay here is an update made by DaChevs (who wrote the whole thing for me :yes:)!!!

Code: [Select]
//===================================

// Smoke_Check.sqf - Sep 28, 2008
// Created By: DaChevs
// Particle Effects Selected By: USM-CPT.Dyson
// Thanks To: CSL Particle Parameter Utility V2
//     By: ColonelSandersLite

//===================================

while {alive player} do
{
_smoke = nearestObject [player, "SmokeShell"];

if (!(isNull _smoke)) then
{
_log = "Logic" createVehicle (getPos _smoke);


//Put your particle effects here.
//Spawn it using the _xpos,_ypos and _zpos


_particleSource = "#particlesource" createVehicle (getPos player);

_particleSource setParticleCircle [10, [2, 0, 0]];
_particleSource setParticleRandom [0, [0, 0, 0], [0.54, 0.54, 0], 0, 0.25, [1e-005, 1e-006, 1e-006, 0.2], 0, 0];
_particleSource setParticleParams [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 1], "", "Billboard", 1, 15, [0, 0, 0], [2, 0, 0], 1, 12, 10, 0.2, [5, 10, 25, 35, 45, 50], [[0.9, 0.9, 0.9, 0.4], [0.9, 0.9, 0.9, 0.2], [0.9, 0.9, 0.9, 0], [0.9, 0.9, 0.9, 0]], [2, 1], 0, 0, "", "", SmokeLogic];
_particleSource setDropInterval 0.08;
_particleSource setPos (getPos _log);


//Delete the smokegrenade.
deleteVehicle _smoke;

Sleep 2;
};
Sleep 1;
};

Except it doesn't work. Anyone?

Just kidding, works awesome. Only thing missing now is when the smoke grenades speed reaches 0, it THEN needs to be deleted. Still be help with that bit.

Thanks to DaChevs!
« Last Edit: 28 Sep 2008, 10:16:02 by USM-CPT.Dyson »
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: CTI_SectorLink Help
« Reply #34 on: 30 Sep 2008, 01:59:39 »
Hmmm, it's odd to use a neverending loop for this purpose....but as you say DaChevs wrote the script......no comment, at least it worked so far.  ;)

IMHO an Eventhandler "fired" would fit better for this purpose. I wrote something that may work, give it a try:

Code: (smoker.sqf) [Select]
//////////////////////////////////////////////////////////////////
// player addEventHandler ["fired", {_this execVM "smoker.sqf"}]
// Created by: [GLT]Myke
//////////////////////////////////////////////////////////////////
_unit = _this select 0;
_weapon = _this select 1;
_stopped = false;
_timestamp = 0;
if (_weapon == "Throw") then {
_shell = nearestObject [_unit, "SmokeShell"];
if (isnull _shell) exitwith {};
_timestamp = time;
while {!_stopped} do {
_velX = velocity _shell select 0;
_velY = velocity _shell select 1;
if ((_velX == 0) && (_velY == 0)) then {
_stopped = true;
};
if (time > (_timestamp + 2)) then {
_stopped = true;
};
sleep 0.1;
};
_smokepos = getpos _shell;
deletevehicle _shell;
_particleSource = "#particlesource" createVehicle _smokepos;
_particleSource setParticleCircle [10, [2, 0, 0]];
_particleSource setParticleRandom [0, [0, 0, 0], [0.54, 0.54, 0], 0, 0.25, [1e-005, 1e-006, 1e-006, 0.2], 0, 0];
_particleSource setParticleParams [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 1], "", "Billboard", 1, 15, [0, 0, 0], [2, 0, 0], 1, 12, 10, 0.2, [5, 10, 25, 35, 45, 50], [[0.9, 0.9, 0.9, 0.4], [0.9, 0.9, 0.9, 0.2], [0.9, 0.9, 0.9, 0], [0.9, 0.9, 0.9, 0]], [2, 1], 0, 0, "", "", SmokeLogic];
_particleSource setDropInterval 0.08;
};

Should work pretty well although it surely needs to be tested for MP.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: CTI_SectorLink Help
« Reply #35 on: 30 Sep 2008, 03:00:27 »
Yes, using event handlers is 100% better than using the original method, which was CPU intensive and wouldn't really work anyway.

Still, the event-handler version won't work for MP, since FIRED events are only local for thrown weapons (for weapons that shoot, they seem to be global). No idea why, but that is how it is. Even if the handler was global, you'd have a nasty race-state, in that the local version would sometimes delete the thrown grenade before the remote versions did, so they wouldn't know where to put the particles.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline USM-CPT.Dyson

  • Members
  • *
Re: CTI_SectorLink Help
« Reply #36 on: 30 Sep 2008, 06:32:28 »
Thanks myke! So what I want to know is if fired event handlers are better, but not for MP, is there something the server can to that would better sync it self with the player?
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: CTI_SectorLink Help
« Reply #37 on: 30 Sep 2008, 11:16:06 »
@Spooner

Sorry if i ask stupid questions but in this case, does it matter if the EH is only locally triggered? I know that this method wont work for AI thrown smokeshells but as they use pretty rarely the smokeshells (unless a script tell them to do so) it is manly for players.

As a player throws a smokeshell, the "fired" EH would launch the script locally on players client. But as "deletevehicle" and "createvehicle" are global commands, the smokeshell should be deleted everywhere and also the particlesource should be created everywhere.

Or am i missing a point somewhere?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: CTI_SectorLink Help
« Reply #38 on: 30 Sep 2008, 14:06:07 »
"#ParticleSource" is a local-only object, so even if you attempt to create it globally with createVehicle, it will just exist locally (it is usual to create it with createVehicleLocal to avoid confusion). Thus, all particle effects, whether generated by a "#ParticleSource" object or the drop command, need to be created locally.

You are still a lot better just using the local fired event, but then broadcasting the location at which you wish to produce the smoke (I do something like this for my Molotov script, which needs to be broadcast anyway, so it can damage people locally as well as produce local particle effects).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: CTI_SectorLink Help
« Reply #39 on: 30 Sep 2008, 15:26:01 »
Ah ok, i see the matter. So to make this MP compatible it would need first the "fired" EH to catch the thrown smokeshell and the place where it landed. then packing these coords into an public array which is broadcasted with publicvariable and finally a publicVariableEventhandler initiated script which creates the particelsource on all other clients.

No big deal as far as i can judge.

@USM-CPT.Dyson

if you need this done, say a word. I guess it will take 10 mins to write it.

Offline USM-CPT.Dyson

  • Members
  • *
Re: CTI_SectorLink Help
« Reply #40 on: 30 Sep 2008, 20:12:01 »
Sure Myke if you don't mind. Thanks guys for all the help. I want so much in this CTI that BIS should have added in.
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: CTI_SectorLink Help
« Reply #41 on: 30 Sep 2008, 22:29:47 »
Ok, here i wrote a little thing for you. To activate the whole thing, just insert this line into your init.sqf script.

Code: (smoker_init.sqf) [Select]
if (isServer && (!local player)) exitwith {};
glt_smoker_position = [];
"glt_smoker_position" addPublicVariableEventHandler {nul = this execVM "smoker_updater.sqf"};
player addEventHandler ["fired", {_this execVM "smoker.sqf"}];

As you see, this will add the EH to the player and will also prepare the clientscript to make the smoke appear on all clients.

Code: (smoker.sqf) [Select]
_unit = _this select 0;
_weapon = _this select 1;
_stopped = false;
_timestamp = 0;
if (_weapon == "Throw") then {
_shell = nearestObject [_unit, "SmokeShell"];
if (isnull _shell) exitwith {};
_timestamp = time;
while {!_stopped} do {
_velX = velocity _shell select 0;
_velY = velocity _shell select 1;
if ((_velX == 0) && (_velY == 0)) then {
_stopped = true;
};
if (time > (_timestamp + 2)) then {
_stopped = true;
};
sleep 0.1;
};
glt_smoker_position = getpos _shell;
publicvariable "glt_smoker_position";
deletevehicle _shell;
_particleSource = "#particlesource" createVehicle glt_smoker_position;
_particleSource setParticleCircle [10, [2, 0, 0]];
_particleSource setParticleRandom [0, [0, 0, 0], [0.54, 0.54, 0], 0, 0.25, [1e-005, 1e-006, 1e-006, 0.2], 0, 0];
_particleSource setParticleParams [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 1], "", "Billboard", 1, 15, [0, 0, 0], [2, 0, 0], 1, 12, 10, 0.2, [5, 10, 25, 35, 45, 50], [[0.9, 0.9, 0.9, 0.4], [0.9, 0.9, 0.9, 0.2], [0.9, 0.9, 0.9, 0], [0.9, 0.9, 0.9, 0]], [2, 1], 0, 0, "", "", SmokeLogic];
_particleSource setDropInterval 0.08;
};
glt_smoker_position = [];
Code: (smoker_updater.sqf) [Select]
_particleSource = "#particlesource" createVehicle glt_smoker_position;
_particleSource setParticleCircle [10, [2, 0, 0]];
_particleSource setParticleRandom [0, [0, 0, 0], [0.54, 0.54, 0], 0, 0.25, [1e-005, 1e-006, 1e-006, 0.2], 0, 0];
_particleSource setParticleParams [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 1], "", "Billboard", 1, 15, [0, 0, 0], [2, 0, 0], 1, 12, 10, 0.2, [5, 10, 25, 35, 45, 50], [[0.9, 0.9, 0.9, 0.4], [0.9, 0.9, 0.9, 0.2], [0.9, 0.9, 0.9, 0], [0.9, 0.9, 0.9, 0]], [2, 1], 0, 0, "", "", SmokeLogic];
_particleSource setDropInterval 0.08;
glt_smoker_position = [];

As you see, the smoker.sqf does manage the smoke on the client that has thrown the smokeshell and also does update the publicvariable glt_smoker_position which will then launch the smoker_updater.sqf on the other clients so they will also get the new smoke.

As always, test it as much as you can to make sure it work as expected.

Offline USM-CPT.Dyson

  • Members
  • *
Re: CTI_SectorLink Help
« Reply #42 on: 30 Sep 2008, 23:20:24 »
I will test as soon as I get to my house in a few minutes. Thanks Myke you rock!
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: CTI_SectorLink Help
« Reply #43 on: 30 Sep 2008, 23:28:17 »
Naw.....Spooner rocks....Mandoble rocks....i am just an Intermezzo.  :D

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: CTI_SectorLink Help
« Reply #44 on: 01 Oct 2008, 00:22:47 »
Well, buttering me up often encourages me to help out...(but don't lay it on too thickly ;P).

In MP (unless you are the host), the player object won't exist right away when init.sqf is run, thus you need to wait a little while, or you will add the handler to objNull (which is the value of player until it is created):
Code: (smoker_init.sqf (extract)) [Select]
waitUntil { alive player };
player addEventHandler ["fired", {_this execVM "smoker.sqf"}];

You get more info from the fired handler, which means you can avoid accidentally picking up a smoke grenade that has already been thrown 40m away, when you are firing off your AK:
Code: (smoker.sqf (extract)) [Select]
_unit = _this select 0;
_weapon = _this select 1;
_muzzle = _this select 2;
_mode = _this select 3;
_roundClass = _this select 4;
if (roundClass  == "SmokeShell") then
{
    _shell = nearestObject [_unit, "SmokeShell"]; // Guaranteed to find something, since we know we just threw one.

Objects often don't have 0 velocity when they have apparently stop moving, which you probably noticed. Thus, you might try:
Code: (smoker.sqf (extract)) [Select]
    // Using distance from [0, 0, 0] is a cheat way to find out the magnitude of a velocity vector (i.e. its speed).
    waitUntil { ((velocity _shell) distance [0, 0, 0]) < 0.1 };

EDIT: Had written _velocity when I meant velocity
« Last Edit: 01 Oct 2008, 03:17:40 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)