Home   Help Search Login Register  

Author Topic: Trigger Based Objective System  (Read 1525 times)

0 Members and 1 Guest are viewing this topic.

Offline USM-CPT.Dyson

  • Members
  • *
Trigger Based Objective System
« on: 07 Jan 2009, 01:58:09 »
Code: [Select]
//////////////////////////////////////////////////////////////////
// File: init.sqf
// By: TF5-SGM.Spyder
// Version: 0-0-8
//////////////////////////////////////////////////////////////////

[] execVM "scripts\objective_sys\init_objectives.sqf";

[] execVM "scripts\ticket_sys\ticket_count.sqf";

[] execVM "scripts\ticket_sys\player_death.sqf";

Code: [Select]
//////////////////////////////////////////////////////////////////
// File: objective_status.sqf
// By: TF5-SGM.Spyder
//////////////////////////////////////////////////////////////////

Sleep 1;

// ==================== BLUFOR Constant ====================
BLUFOR_Constant = createTrigger ["EmptyDetector", getMarkerPos "Objective_1"];
BLUFOR_Constant setTriggerArea [300, 200, 0, true];
BLUFOR_Constant setTriggerActivation ["WEST", "PRESENT", true];
BLUFOR_Constant setTriggerTimeout [0, 0, 0, true];
BLUFOR_Constant setTriggerStatements ["this", "BLUFOR_ConstantB = true", "BLUFOR_ConstantB = false"];
// ==================== End BLUFOR Start ====================



// ==================== REDFOR Constant ====================
REDFOR_Constant = createTrigger ["EmptyDetector", getMarkerPos "Objective_1"];
REDFOR_Constant setTriggerArea [300, 200, 0, true];
REDFOR_Constant setTriggerActivation ["EAST", "PRESENT", true];
REDFOR_Constant setTriggerTimeout [0, 0, 0, true];
REDFOR_Constant setTriggerStatements ["this", "REDFOR_ConstantB = true", "REDFOR_ConstantB = false"];
// ==================== End REDFOR Start ====================



// ==================== BLUFOR addTicket ====================
BLUFOR_addTicket = createTrigger ["EmptyDetector", getMarkerPos "Objective_1"];
BLUFOR_addTicket setTriggerArea [300, 200, 0, true];
BLUFOR_addTicket setTriggerActivation ["WEST", "PRESENT", true];
BLUFOR_addTicket setTriggerTimeout [1, 1, 1, true];
BLUFOR_addTicket setTriggerStatements ["this && (BLUFOR_ConstantB) && ((count list BLUFOR_addTicket) < 0)", "BLUFOR_addTicketB = true", "BLUFOR_addTicketB = false"];
// ==================== End BLUFOR Addticket ====================



// ==================== REDFOR addTicket ====================
REDFOR_addTicket = createTrigger ["EmptyDetector", getMarkerPos "Objective_1"];
REDFOR_addTicket setTriggerArea [300, 200, 0, true];
REDFOR_addTicket setTriggerActivation ["EAST", "PRESENT", true];
REDFOR_addTicket setTriggerTimeout [1, 1, 1, true];
REDFOR_addTicket setTriggerStatements ["this && (REDFOR_ConstantB) && ((count list REDFOR_addTicket) > 0)", "REDFOR_addTicketB = true", "REDFOR_addTicketB = false"];
// ==================== End REDFOR Addticket ====================

Code: [Select]
//////////////////////////////////////////////////////////////////
// File: init_objectives.sqf
// By: TF5-SGM.Spyder
//////////////////////////////////////////////////////////////////

Sleep 1;

// ==================== Initialize Objectives ====================
If (isnil "BLUFOR_ConstantB") then { BLUFOR_ConstantB = false; };
If (isnil "REDFOR_ConstantB") then { REDFOR_ConstantB = false; };
If (isnil "BLUFOR_PresentB") then { BLUFOR_PresenttB = false; };
If (isnil "REDFOR_PresentB") then { REDFOR_PersentB = false; };
If (isnil "BLUFOR_addTicketB") then { BLUFOR_addTicketB = false; };
If (isnil "REDFOR_addTicketB") then { REDFOR_addTicketB = false; };
// ==================== End Initialize Objectives ====================

[] execVM "scripts\objective_sys\objective_status.sqf";

Code: [Select]
//////////////////////////////////////////////////////////////////
// File: ticket_count.sqf
// By: TF5-SGM.Spyder and Spooner
//////////////////////////////////////////////////////////////////

while {true} do
{
sleep 5;
   
if (BLUFOR_addTicketB) then
{
BLUFOR_TicketsB = BLUFOR_TicketsB +1; hint format ["BLUFOR_TicketsB = %1", BLUFOR_TicketsB];
};

if (REDFOR_addTicketB) then
{
REDFOR_TicketsB = REDFOR_TicketsB +1; hint format ["REDFOR_TicketsB = %1", REDFOR_TicketsB];
};
};

Code: [Select]
//////////////////////////////////////////////////////////////////
// File: player_death.sqf
// By: Beta (Beita)
//////////////////////////////////////////////////////////////////

// infinite loop
for [{_i=0}, {_i<1}, {_i=0}] do
{
waitUntil {!alive player};  //player has died
waitUntil {alive player};  //player has respawned

if (side player == WEST) then
  {     
      BLUFOR_tickets = BLUFOR_tickets - 1; publicVariable "BLUFOR_tickets"; 
      hint format["%1 BLUFOR Tickets remaining", BLUFOR_tickets];   
  }
  else
  {     
      REDFOR_tickets = REDFOR_tickets - 1; publicVariable "REDFOR_tickets";         
      hint format["%1 REDFOR Tickets remaining", REDFOR_tickets];
  };

};

The constant boolean is needed to ensure the team controlling the zone must be in the zone with no exceptions to gain tickets.

A Present boolean will replace

Code: [Select]
((count list BLUFOR_addTicket) < 0)
his is required to make sure that the enemy doesn't stop the controling team from gaining points by jumping in the zone. "Present will be added tomorrow when i have a free second"

Thanks again to Spooner, Mando, Vipermaul, Beta (beita), and BarmyArmy!
« Last Edit: 09 Jan 2009, 06:21:36 by USM-CPT.Dyson »
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Problems with &&
« Reply #1 on: 07 Jan 2009, 11:45:20 »
Code: [Select]
BLUFOR_Start setTriggerStatements ["this", "BLUFOR_Start == true", ""];Remove == true there, do boolean checks simply placing the name of the variable for true checks or !name of variable for false checks.

Code: [Select]
BLUFOR_Start setTriggerStatements ["this && (BLUFOR_Start)", "BLUFOR_Present == true", "BLUFOR_Present == false"];in the activation and deactivation code you are using == instead of =

Offline USM-CPT.Dyson

  • Members
  • *
Re: Problems with &&
« Reply #2 on: 08 Jan 2009, 21:14:31 »
Heh yeah thanks mando, of course there was a whole lot more wrong here but with the help of you, Vipermaul, beta (beita), Spooner, and BarmyArmy I got it just about done. I just need to learn about public variables and JIP now.

I also updated the 1st post with the new code.

EDIT: Updated will fully working script (values will be tweaked and one more mentioned thing must be added).
« Last Edit: 09 Jan 2009, 05:51:17 by USM-CPT.Dyson »
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/