Home   Help Search Login Register  

Author Topic: triggers as counts instead of individual events.  (Read 1346 times)

0 Members and 1 Guest are viewing this topic.

Offline Quagmire

  • Members
  • *
triggers as counts instead of individual events.
« on: 17 Dec 2009, 11:04:09 »
Hi,

I was wondering if there's a way that I can set a trigger to go off after a certain count has been reached, and if there's some way I can make several triggers contribute toward increasing this count when each of them is triggered.

For example, I have an idea for a mission in which players form a small band of guerrillas with the objective of destroying a certain amount of enemy units, rather than what most missions have, which is the objective of destroying particular enemy units and structures. So I'd want one trigger which increases a "count" when an enemy unit is destroyed, and another trigger which registers an objective as having been complete once this counts reaches a certain level.

It'd be great if anyone could help out, thanks.

edit: also, I'm wondering how I can equip units with gear by a script, rather than having "removeallweapons" etc.. in the init field of each unit which I want to have a defined kit. Particularly, I'd like to equip large numbers of units with the same gear.
« Last Edit: 17 Dec 2009, 11:39:05 by Quagmire »

Offline Shuko

  • Members
  • *
Re: triggers as counts instead of individual events.
« Reply #1 on: 17 Dec 2009, 15:15:45 »
TRIGGER, condition
Code: [Select]
KillCountReached
INIT.SQF, change amount of kills when the trigger should fire and side of enemy
Code: [Select]
[100,EAST] execvm "counter.sqf";

COUNTER.SQF
Code: [Select]
KillCount = 0;
KillCountReached = false;
if (isserver) then {
  _c = _this select 0;
  _s = _this select 1;
  {
    if (side _x == _s) then {
      _x addEventHandler ["killed", {KillCount = KillCount + 1}];
    };
  } foreach allunits;
  waituntil {KillCount >= _c};
  KillCountReached = true;
  publicvariable "KillCountReached";
};

For gear, copy/write all the removeallweapons, addweapon etc command into a file. Example:

GEAR.SQF
Code: [Select]
removeallweapons _this;
_this addweapon "NVGoggles";
_this addweapon "Binocular";
_this addmagazine "30Rnd_556x45_Stanag";
_this addmagazine "30Rnd_556x45_Stanag";
_this addmagazine "30Rnd_556x45_Stanag";
_this addmagazine "30Rnd_556x45_Stanag";
_this addmagazine "30Rnd_556x45_Stanag";
_this addmagazine "30Rnd_556x45_Stanag";
_this addmagazine "SmokeShell";
_this addmagazine "SmokeShell";
_this addmagazine "SmokeShell";
_this addmagazine "SmokeShell";
_this addmagazine "SmokeShellOrange";
_this addmagazine "SmokeShellRed";
_this addweapon "M4A1_Aim_camo";

Then you can just do this in the units init:
Code: [Select]
nul = this execvm "gear.sqf"
Or you can do this from init.sqf. unitname1 etc are the name of units you want to change gear.
Code: [Select]
{_x execvm "gear.sqf"} foreach [unitname1,unitname2,unitname3]

Offline Quagmire

  • Members
  • *
Re: triggers as counts instead of individual events.
« Reply #2 on: 19 Dec 2009, 10:09:51 »
both of those solutions work fine, thanks.

Offline Quagmire

  • Members
  • *
Re: triggers as counts instead of individual events.
« Reply #3 on: 21 Jan 2010, 10:59:03 »
Even though that gear solution worked fine in single player, I find it doesn't work in multiplayer (at least, not for playable troops). Is there something special I have to do to make this kind of gear script work in multiplayer?

Offline Fincuan

  • Members
  • *
Re: triggers as counts instead of individual events.
« Reply #4 on: 22 Jan 2010, 10:44:54 »
Init.sqf:
Code: [Select]
if (not isDedicated) then
{
waitUntil{(not isNull player) and (player == player)};
};
/*
Whatever other stuff you need to run BEFORE mission starts
*/
if (local player) then
{
sleep 0.01;
player execVM "gear.sqf";
};

The little sleep is there to prevent the gear script from running before the mission actually starts, as it won't work otherwise. When the mission starts it'll do the sleep, then run the gear script. A slightly cleaner way would imho be to add the sleep to the beginning of the gear script and remove it from there.

You could also wrap the whole gear script to this:
Code: [Select]
sleep 0.01;
if (local _this) then
{

};
and just run it form the unit's initline:
Code: [Select]
this execVM "gear.sqf";
« Last Edit: 22 Jan 2010, 11:20:52 by Fincuan »

Offline Quagmire

  • Members
  • *
Re: triggers as counts instead of individual events.
« Reply #5 on: 25 Jan 2010, 02:44:24 »
great, thanks

edit: actually, using this, will units have the gear listed in the gear.sqf after respawning?

edit2: never mind, problem solved by using Universal Weapons Respawn Script v1.04
« Last Edit: 25 Jan 2010, 06:44:26 by Quagmire »