Home   Help Search Login Register  

Author Topic: 2 Q's about conditions and a script  (Read 2974 times)

0 Members and 2 Guests are viewing this topic.

Offline Captain

  • Members
  • *
2 Q's about conditions and a script
« on: 03 Apr 2008, 12:44:36 »
I'm currently making a mission using DAC, I have set up various (deactivated) zones as sort of random encounters in the desert but I require a few things to get it to work as hoped. Firstly, rather than a trigger detecting 'OPFOR', 'Not Present', if possible  I would like a condition that states 'when 80% of OPFOR in the area are 'Not Present' the condition is met.

Secondly I would like to know how to have a script exec 1 of 3 or more possible snippets *roughly below, forgive the crudity* :-[

Code: [Select]
#1st Option
titleCut ["","BLACK OUT",.001]

[z1,Position Logic1,[250,250],0,2,2] call DAC_fChangeZone

[z1] call DAC_Activate

titleCut ["You have encountered a small group of Raiders","BLACK IN",.001]

#2nd Option
titleCut ["","BLACK OUT",.001]

[z1,Position Logic1,[250,250],0,4,2] call DAC_fChangeZone

[z1] call DAC_Activate

titleCut ["You have been surprised by a medium group of Raiders","BLACK IN",.001]

#3rd Option
titleCut ["","BLACK OUT",.001]

[z1,Position Logic1,[250,250],0,5,3] call DAC_fChangeZone

[z1] call DAC_Activate

titleCut ["You have stumbled apon a Raider camp","BLACK IN",.001]

#and so on...

How would such a script go and how would one exec it?

Also in regard to the percentage condition, I'm surprised that after what I believe to be thorough searching there are few mentions of this type of condition on either this or the BI forum.

edit: Looking at it now that is actually only 1 Q about conditions... :whistle:
« Last Edit: 03 Apr 2008, 12:49:24 by Captain »

Offline Rommel92

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #1 on: 04 Apr 2008, 06:23:14 »
This could be done through two triggers.

First up would be the trigger to count the OPFOR inside the area.
Code: [Select]
(East Present)
Condition: This
Activation: OPF_units = Count ThisList

Second would be the 80% dead:
Code: [Select]
(East Present)
Condition: OPF_units * 0.2 > Count ThisList
Activation: <Code Here>

For the one in three chance.

script.sqf
Code: [Select]
private ["_r"];

_r = floor(random 3);

titleCut ["","BLACK OUT",.1];

switch (_r) do
{
     case 0:
     {
          [z1,getPos Logic1,[250,250],0,2,2] call DAC_fChangeZone;
          titleCut ["You have encountered a small group of Raiders","BLACK IN",.1];
     };
     case 1:
     {
          [z1,getPos Logic1,[250,250],0,4,2] call DAC_fChangeZone;
          titleCut ["You have encountered a medium group of Raiders","BLACK IN",.1];
     };
     case 2:
     {
          [z1,getPos Logic1,[250,250],0,5,3] call DAC_fChangeZone;
          titleCut ["You have encountered a large group of Raiders","BLACK IN",.1];
     };
};

[z1] call DAC_Activate;

Or something along that nature, not at me PC so I can't test / cross check with Biki so I'll have to rely on knowledge, hopefully Mando or Spooner or the like will fix any errors I might have made.

Hope this helps,

romm
« Last Edit: 04 Apr 2008, 06:31:32 by rommel92 »

Offline Captain

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #2 on: 04 Apr 2008, 12:04:44 »
Code: [Select]
(East Present)
Condition: This
Activation: OPF_units = Count ThisList

Code: [Select]
(East Present)
Condition: OPF_units * 0.2 > Count ThisList
Activation: <Code Here>

Thanks, works as intended and has been added to my snippets file. :good:

I haven't used your second bit (but will) as I'm altering the way I'm going about it. Which has brought me a new problem, basically what I have now is as follows...

Code: [Select]
Whole map trigger, BLUFOR, Present, Repeatedly, Timeout, 1800/3600/2700
On activation: this exec "rundac.sqs";

so that somewhere between 30 minutes and 1 hour this is exec'd (repeatedly)...

Code: (rundac.sqs) [Select]
titleCut ["","BLACK OUT",.01];
_trg = createTrigger["zone1",getPos player];
_trg setTriggerArea[250, 250, 0, false];
_trg setTriggerActivation["WEST","PRESENT",true];
_trg setTriggerStatements["this","["z1"[1,0,0,250,250],[2,2,25,15],[ ],[ ],[ ],[0,0,0,6,1]]exec "DAC\Scripts\DAC_Init_Zone.sqs"", ""];
titleCut ["You have encountered a small group of Raiders","BLACK IN",.01];

But it gives the following error.

Quote from: RPT
Error in expression <_trg setTriggerStatements["this","["z1"[1,0,0,250,250],[2,2,25,15],[ ],[ ],[>
  Error position: <z1"[1,0,0,250,250],[2,2,25,15],[ ],[ ],[>
  Error Missing ]
Cannot create non-ai vehicle zone1,
Error in expression <_trg setTriggerStatements["this","["z1"[1,0,0,250,250],[2,2,25,15],[ ],[ >
  Error position: <"["z1"[1,0,0,250,250],[2,2,25,15],[ ],[ >
  Error Generic error in expression

Once I can get the script call working then I'll use your second section in the same way I would have before. Rather than having the zones placed manually in the editor they are spawned at the player after a random time.

     ...edited for stupidity
« Last Edit: 04 Apr 2008, 13:27:40 by Captain »

Offline Rommel92

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #3 on: 04 Apr 2008, 14:46:43 »
Found it!

Code: [Select]
["z1"[1,0,0,250,250],[2,2,25,15],[ ],[ ],[ ],[0,0,0,6,1]]exec "DAC\Scripts\DAC_Init_Zone.sqs"", ""];versus:
Code: [Select]
["z1",[1,0,0,250,250],[2,2,25,15],[ ],[ ],[ ],[0,0,0,6,1]]exec "DAC\Scripts\DAC_Init_Zone.sqs"", ""];
The "z1" is missing a comma after it, this is a common mistake when copying out of the DAC Manual, the bastards didn't check their code.
« Last Edit: 04 Apr 2008, 14:53:20 by rommel92 »

Offline Captain

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #4 on: 04 Apr 2008, 15:24:30 »
God dammit! I can't believe I f#&ked that up. I've corrected for that many times.

However that is not the issue here as I still get...

Quote from: RPT
Error in expression <_trg setTriggerStatements["this","["z1",[1,0,0,250,250],[2,2,25,15],[ ],[ ],>
  Error position: <z1",[1,0,0,250,250],[2,2,25,15],[ ],[ ],>
  Error Missing ]
Cannot create non-ai vehicle zone1,
Error in expression <_trg setTriggerStatements["this","["z1",[1,0,0,250,250],[2,2,25,15],[ ],[>
  Error position: <"["z1",[1,0,0,250,250],[2,2,25,15],[ ],[>
  Error Generic error in expression
>:(

Thankyou for your continued assistance on this rommel.

Offline Rommel92

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #5 on: 04 Apr 2008, 15:55:49 »
Hate to be a ball breaker, but did you realise you named the trigger "zone1", not z1?   :P
Code: [Select]
_trg = createTrigger["zone1",getPos player];
_trg setTriggerArea[250, 250, 0, false];
_trg setTriggerActivation["WEST","PRESENT",true];
_trg setTriggerStatements["this","["z1"[1,0,0,250,250],[2,2,25,15],[ ],[ ],[ ],[0,0,0,6,1]]exec "DAC\Scripts\DAC_Init_Zone.sqs"", ""];

However I can't see the problem with the missing ].

Offline Captain

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #6 on: 04 Apr 2008, 23:24:38 »
I hadn't noticed that, but unfortunately my stupidity is not the problem here.

same thing, different spot...
Quote
Error in expression <_trg setTriggerStatements["this","["zone1",[1,0,0,250,250],[2,2,25,15],[ ],[>
  Error position: <zone1",[1,0,0,250,250],[2,2,25,15],[ ],[>
  Error Missing ]
Cannot create non-ai vehicle zone1,
Error in expression <_trg setTriggerStatements["this","["zone1",[1,0,0,250,250],[2,2,25,15],[ >
  Error position: <"["zone1",[1,0,0,250,250],[2,2,25,15],[ >
  Error Generic error in expression

Offline Rommel92

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #7 on: 05 Apr 2008, 00:49:13 »
I hadn't noticed that, but unfortunately my stupidity is not the problem here.

same thing, different spot...

The error is in the script call, it does not like the "DAC\Scripts\DAC_Init_Zone.sqs", how to fix this I dont know, but remove those talking marks and it goes away.

Offline Loyalguard

  • Former Staff
  • ****
Re: 2 Q's about conditions and a script
« Reply #8 on: 05 Apr 2008, 01:02:48 »
Anytime you use "" within a string (such as a within a code string as part of setTriggerStatements) you must use double quotes.  Examples:

""z1""
""DAC\Scripts\DAC_Init_Zone.sqs""

Try this line instead:

Code: [Select]
_trg setTriggerStatements["this","[""z1""[1,0,0,250,250],[2,2,25,15],[ ],[ ],[ ],[0,0,0,6,1]]exec ""DAC\Scripts\DAC_Init_Zone.sqs""", ""];
I suspect that will solve (some) of your problems.

Offline Rommel92

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #9 on: 05 Apr 2008, 10:25:42 »
Anytime you use "" within a string (such as a within a code string as part of setTriggerStatements) you must use double quotes.  Examples:

""z1""
""DAC\Scripts\DAC_Init_Zone.sqs""

Try this line instead:

Code: [Select]
_trg setTriggerStatements["this","[""z1""[1,0,0,250,250],[2,2,25,15],[ ],[ ],[ ],[0,0,0,6,1]]exec ""DAC\Scripts\DAC_Init_Zone.sqs""", ""];
I suspect that will solve (some) of your problems.

Haha, LoyalGuard, damn those DAC bastards, they really have a domino effect, you forgot the comma too.  :clap:

Code: [Select]
_trg setTriggerStatements["this","[""z1"",[1,0,0,250,250],[2,2,25,15],[ ],[ ],[ ],[0,0,0,6,1]]exec ""DAC\Scripts\DAC_Init_Zone.sqs""", ""];

Offline Captain

  • Members
  • *
Re: 2 Q's about conditions and a script
« Reply #10 on: 05 Apr 2008, 11:30:56 »
I've now tried both with and without the comma (having seen LoyalGuard's post first) and the result is the same. I get no error in game but no DAC zone either. All I now get in the RPT is this... (which is an improvement but still no joy).

Quote from: RPT
Cannot create non-ai vehicle zone1,