Home   Help Search Login Register  

Author Topic: sqs chaos  (Read 1713 times)

0 Members and 1 Guest are viewing this topic.

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
sqs chaos
« on: 22 Sep 2010, 08:59:27 »
The situation in mission is this: player have to recon an enemy camp. Before the proper recon (and HQ order to engage) cannot engage (cannot fire). If he do this, the enemy kill the hostages and mission failed. If he recon (knowsAbout) properly the camp, he got order from HQ to engage.

I do it with this way:
There is a prepare script (sqs), what build the enemy camp and create the enemy patrols and hostages... and finally it do this:
Code: [Select]
grp0 setCombatMode "GREEN" 
~2
Hint "Don't engage the enemy, but recon it!"

{_x addEventHandler ["Fired", {playershoot=true;}];} forEach units grp0

[] exec "reconfail.sqs"
[] exec "recon.sqs"

playershoot and lehetguards variables are setted false in the init.sqs
And these are the called two other scripts:

reconfail.sqs
Code: [Select]
@(lehetguards or playershoot)
?(lehetguards) : exit
?(lehetguards) : goto "vege"

[] exec "mass.sqs"

~2
TitleText["- Don't shoot! We have no orders!","PLAIN DOWN"]
~4
TitleText["- Damn!","PLAIN DOWN"]
~2
TitleText[" ","PLAIN DOWN"]
~5

TitleText["M I S S I O N   F A I L E D","PLAIN"]
fail = true

#vege


recon.sqs
Code: [Select]
@({p knowsAbout _x > 0.5} count guards > 2)and({p knowsAbout _x > 0.5} count hostages > 3)
?(playershoot) : exit
lehetguards = true

player sideChat "This is Robber One. We have visual contact with camp. many civilians guarded by Takistani troopers. Over"
~10
hq sideChat "Copy that. That's a pity. Engage them and free the hostages. Over"
~8
player sideChat "Copy that. We engage. I repeat we engage. Out"




The effect of these script is confuse. It - most times - works. But depend of something - maybe save and revert - caused the two last scripts started both after the player recon the camp: the succeas and failed text run paralel and finally the mission failed... (but player - me - didn't shoot...)

Save and revert could cause damage variable values?
This situation is the last task in a VERY long mission, so from the init.sqs to this script spend hours and probably many save and revert...
Fix bayonet!

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: sqs chaos
« Reply #1 on: 22 Sep 2010, 12:47:14 »
Hrmmm...

lehetguards will never be true in reconfail.sqs:

  • lehetguards is set to false on mission start
  • reconfail.sqs is run before recon.sqs
  • But recon.sqs sets lehetguards to true
try { return true; } finally { return false; }

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: sqs chaos
« Reply #2 on: 22 Sep 2010, 13:08:28 »
Yes but both recon... scripts started with @ (wait until) code. So if the player detect the enemy and hostages, the lehetguards will be true. And it will start the fail script, but immediat exit.
Fix bayonet!

Offline Zipper5

  • BIS Team
  • ****
Re: sqs chaos
« Reply #3 on: 22 Sep 2010, 13:48:09 »
Correct me if I'm wrong, but the first thing I noticed is that it really only makes sense if the player is given the fired eventhandler when in audible range of the camp, otherwise he could be on the other side of Takistan, fire, and he'd still fail. :P

I think first of all you should create a trigger on the map. Give it the condition
Code: [Select]
({p knowsAbout _x > 0.5} count guards > 2)and({p knowsAbout _x > 0.5} count hostages > 3)and name the trigger campspotted, or something similar. In the campspotted trigger's activation line, have it execute recon.sqs. Instead of making the playershoot variable true in the fired eventhandler, have it exec reconfail.sqs. In reconfail.sqs, get rid of the trigger by putting deleteVehicle campspotted. That way after the trigger is deleted you can never complete the mission if you fire before the recon of the camp. Finally, remove the fired eventhandler from the player once both reconfail.sqs or recon.sqs are executed, and remove the playershoot and lehetguards variables from the scripts entirely since they're no longer needed. Here are the scripts with these changes to perhaps help you understand better:

In your prepare script:
Code: [Select]
grp0 setCombatMode "GREEN"  
~2
Hint "Recon but do not engage the enemy."

{_x addEventHandler ["fired", {[] exec "reconfail.sqs"}]} forEach units grp0
reconfail.sqs:
Code: [Select]
{_x removeAllEventHandlers "fired"} forEach units grp0
deleteVehicle campspotted

[] exec "mass.sqs"

~2
TitleText["- Don't shoot! Don't shoot!","PLAIN DOWN"]
~4
TitleText["- Damn!","PLAIN DOWN"]
~2
TitleText[" ","PLAIN DOWN"]
~5

TitleText["M I S S I O N   F A I L E D","PLAIN"]
fail = true
recon.sqs
Code: [Select]
{_x removeAllEventHandlers "fired"} forEach units grp0

player sideChat "This is Robber One, we have a visual on the camp; many civilians guarded by Takistani troopers. Over."
~10
hq sideChat "Copy that, engage them and free the hostages. Over."
~8
player sideChat "Roger, engaging all enemy contacts. Out."
Now, I haven't tested that, but from what I can tell it should work. I also included some spelling and grammar changes. Hope you get it working! :D
« Last Edit: 22 Sep 2010, 13:53:51 by Zipper5 »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: sqs chaos
« Reply #4 on: 22 Sep 2010, 14:11:12 »
Hmm. I'm not sure. There might indeed be some kind of variable decay someplace, which would be very unfortunate, but even so this whole setup seems a little awkward. I've also heard someplace that the waitUntil is not never-ending, i.e. it only "waits" so many frames (I think it checks every frame) before it breaks.

First of all, can't you get rid of the whole reconfail.sqs by pasting it into the "preparing" script instead? Or, alternatively, can't you make the eventhandler fire the script instead of just switching a variable? Or, ultimately, why is reconfail tied to firing your weapons, rather than (for instance) being spotted by the enemy? I know that these are just workarounds, since as far as I can tell the scripts SHOULD work as they are.  :(

Let us know how it works out!

(Also, Zipper5 is a NINJA!)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: sqs chaos
« Reply #5 on: 22 Sep 2010, 14:14:53 »
@Zipper:
This task is the last in that mission and EH added when the player is near to the camp. So theoretically it fires the fail script anywhere in Takistan, but normal way, the player is on site.

The design-time trigger (placed in the editor) is not so good, because arrays guards and hostages didn't exists in the first 90% of mission. These units - and the arrays itself - created (spawn) when the player is near (in the same script when I exec the two recon script). I guess a design-time trigger caused error, because array not even exists... but I'm not sure. You have any experience with it?

I'll try your way...


@Wolfrug: Thank you for your "just workarounds". It's very inspirative!

My problem is to place the script into the eventhandler is it's weird to me, because all units in player's squad have the same EH. So if they start shooting almost same time, it triggered the script many times...
I know, I can handle it, if I check a global variable in the begining of this script and if it's true then exit and the second line set this variable true. And this way the scripot run only once... But IMHO, it's the same way if I set this variable in the EH...




Anyway - as I said - the most times, it works... But sometimes didn't.
« Last Edit: 22 Sep 2010, 14:21:58 by bardosy »
Fix bayonet!

Offline Zipper5

  • BIS Team
  • ****
Re: sqs chaos
« Reply #6 on: 22 Sep 2010, 14:32:49 »
If the player isn't within eyesight of the guards and hostages you could spawn the units and create the arrays earlier in the mission, perhaps?
« Last Edit: 22 Sep 2010, 14:35:05 by Zipper5 »

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: sqs chaos
« Reply #7 on: 22 Sep 2010, 14:44:55 »
It's a very long and massive assault mission with possibly lag problems. So I create the enemies front of player and delete them behind him. I don't really want to create the characters of this task before the player is near.
Fix bayonet!

Offline Zipper5

  • BIS Team
  • ****
Re: sqs chaos
« Reply #8 on: 22 Sep 2010, 15:15:54 »
Okay then, if you're in the mood for spawning, then place the campspotted trigger on the map, leave the condition and activation lines blank, and then change your preparation script to the following:
Code: [Select]
grp0 setCombatMode "GREEN"  
~2
Hint "Recon but do not engage the enemy."

{_x addEventHandler ["fired", {[] exec "reconfail.sqs"}]} forEach units grp0

campspotted setTriggerStatements ["({p knowsAbout _x > 0.5} count guards > 2)and({p knowsAbout _x > 0.5} count hostages > 3)", "[] exec "recon.sqs""]
That will change, via script, the condition and activation of the trigger when you want it to. For the rest of the mission it will just sit there waiting. You may need two " around recon.sqs, i.e. the line will become
Code: [Select]
campspotted setTriggerStatements ["({p knowsAbout _x > 0.5} count guards > 2)and({p knowsAbout _x > 0.5} count hostages > 3)", "[] exec ""recon.sqs"""]due to how it's written there, but I'm not sure. Is that a better solution?
« Last Edit: 22 Sep 2010, 15:19:46 by Zipper5 »

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: sqs chaos
« Reply #9 on: 22 Sep 2010, 15:27:46 »
Yeah! It's sound great. Thanks!

(Unfortunately I cannot try it tonight, because visiting friends... but tommorrow night...)


EDIT:

I want to test what you adviced yesterday, but I was SO frutrated because of a bug, what players found in my two older campaign... I search and search for it...  :dunno: It was very weird: with base ArmA2 everything works fine. But Combined Operation CRASHED TO DESKTOP... :(

Finally I found it: I used extra pilots in vehicles, when I want the player team in the cargo area and not the cocpit. But the vehicle has TR UNLOAD waypoint and it drop the extra pilots too and it was weird, so I delete them before unload. It works for ArmA2, but CO is crashed. So I have to trick it out and then pack the two campiagns. When I finished, I have no inspiration to work on my new campaign...


EDIT2:

By your advices, I modify the structure... I left the playershoot=true in the EH, but the main script remain active and wait for (by @-sign) the recon OR the playershoot variable. And when it's happened, an IF check the playershoot and if it's true, run the reconfail script and EXIT. If it's not true, then script continues as the recon script... 

So there is no paralel scripts, in the same moment, only one script run and it's impossible to happened some timing hazard.

THANKS!
« Last Edit: 28 Sep 2010, 11:46:08 by bardosy »
Fix bayonet!