Home   Help Search Login Register  

Author Topic: House Patrol Script (need help!)(arma scripts)  (Read 4091 times)

0 Members and 2 Guests are viewing this topic.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
House Patrol Script (need help!)(arma scripts)
« on: 14 Jul 2009, 14:07:40 »
Can someone convert the following to .sqf format(version) :D
I indeed need that format because .sqs is annoying the fps when over 20 of that scripts was used in a single mission!
Code: [Select]
#loop
tourguide setbehaviour "safe"
tourguide setspeedmode "limited"
{_x domove getpos (hotel1 buildingpos random 256)} foreach units travellers;
~15
?!(alive tourguide):hint "The tourguide is dead";exit
?tourguide distance helipad1 > 25 :goto "loop"

tourguide=name of the leader of the group "travellers"

helipad1=used an invisilbe helipad.(script will continue looping if tourguide is more than 25 meters far away from helipad1

hotel1=name of the hotel (get this by using "hotel1=nearestbuilding gamelogic1")

This script makes the group of travellers to roam in the hotel.
The hotel has 256 max available pos for the roamers so you will get a complete active hotel. :)
Just need to know that it can be converted to .sqf or not?? ???
« Last Edit: 19 Jul 2009, 17:09:22 by haroon1992 »
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: House Patrol Script (need help!)(arma scripts)
« Reply #1 on: 08 Aug 2009, 18:15:36 »
Here ya go!!

Code: [Select]
_dist = tourguide distance helipad1;
while {((tourguide distance helipad1) < 25)&&(alive tourguide)} do
   {
   tourguide setbehaviour "safe";
   tourguide setspeedmode "limited";
   {_x domove getpos (hotel1 buildingpos random 256)} foreach units travellers;
   sleep 15;
   };

Hope that helps!

Luke
Pesky Human!!
Wort Wort Wort.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: House Patrol Script (need help!)(arma scripts)
« Reply #2 on: 09 Aug 2009, 07:02:19 »
Thank you for the help!.....
Long time no reply....! hUh....!
At least i got it now!

Thank you :clap:
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: House Patrol Script (need help!)(arma scripts)
« Reply #3 on: 09 Aug 2009, 14:55:24 »
Just for the sake of my sanity,( I am not very comfortable with SQF either) but shouldn't the local variable "_dist" replace the full line of text inside the braces on the second line? Otherise, why declare that variable? Just trying to understand is all.
Example:
Code: [Select]
while {((_dist) < 25)&&(alive tourguide)} do

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: House Patrol Script (need help!)(arma scripts)
« Reply #4 on: 09 Aug 2009, 17:56:12 »
No. The loop would check an outdated value on every iteration. The only purpose of _dist is to confuse you... :)
try { return true; } finally { return false; }

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: House Patrol Script (need help!)(arma scripts)
« Reply #5 on: 10 Aug 2009, 00:19:48 »
{S}houldn't the local variable "_dist" replace the full line of text inside the braces on the second line? Otherise, why declare that variable? Just trying to understand is all.

No. The loop would check an outdated value on every iteration. The only purpose of _dist is to confuse you... :)

Nice, WE!  :D

No, Grace is right, my bad.

New Script:
Code: [Select]
_dist = tourguide distance helipad1;
while {(_dist < 25)&&(alive tourguide)} do
   {
   tourguide setbehaviour "safe";
   tourguide setspeedmode "limited";
   {_x domove getpos (hotel1 buildingpos random 256)} foreach units travellers;
   _dist = tourguide distance helipad1;
   sleep 15;
   };

Sorry about that!

Luke
Pesky Human!!
Wort Wort Wort.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: House Patrol Script (need help!)(arma scripts)
« Reply #6 on: 10 Aug 2009, 11:38:37 »
Yes , i have got the correct one,,,,but how do i call that from the game?

script=[] exec "housepatrol.sqf" , is this right ?
Or
script = [] execVM "housepatrol.sqf"?????
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: House Patrol Script (need help!)(arma scripts)
« Reply #7 on: 10 Aug 2009, 11:45:55 »
I believe the latter one for sqf.

@Luke
Thanks for clearing that up Luke.

@Worldeater
What are you refering to when you say outdated value? A condition satisfied already?

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: House Patrol Script (need help!)(arma scripts)
« Reply #8 on: 11 Aug 2009, 05:44:28 »
Yes , i have got the correct one,,,,but how do i call that from the game?

That might require some modification to the script,
at least, in my eyes.

All right One Final Effort. (Because its so uplifting)

Code: (Housepatrol.sqf) [Select]
tourguide= _this select 0;
helipad1 = _this select 1;
hotel1 = _this select 2;
travellers = _this select 3;

_dist = tourguide distance helipad1;
while {(_dist < 25)&&(alive tourguide)} do
   {
   tourguide setbehaviour "safe";
   tourguide setspeedmode "limited";
   {_x domove getpos (hotel1 buildingpos random 256)} foreach units travellers;
   _dist = tourguide distance helipad1;
   sleep 15;
   };


Can be called in one of the two following ways;
[tourguide, helipad1, hotel1, travellers] execvm "Housepatrol.sqf";

or if you want specific units in the group 'travellers' rather than a set group use this:
[tourguide, helipad1, hotel1, [traveller1, traveller2, ... travellerN]] execvm "Housepatrol.sqf";

Where traveller1 through travellerN are the names of individual.

So if Dan and Dave are the travellers then:
[tourguide, helipad1, hotel1, [Dan, Dave]] execvm "Housepatrol.sqf";

or if its Dan, Dave, & Phil then:
[tourguide, helipad1, hotel1, [Dan, Dave, Phil]] execvm "Housepatrol.sqf";

Hope this helps.

Luke
Pesky Human!!
Wort Wort Wort.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: House Patrol Script (need help!)(arma scripts)
« Reply #9 on: 11 Aug 2009, 08:33:42 »
What are you refering to when you say outdated value? A condition satisfied already?

No, the value of _dist would not have been updated. So the script would have used the initial(!) distance for the check until the end of the mission. Luke's current version almost solves this problem:
Quote
   ...
   _dist = tourguide distance helipad1;
   sleep 15;
   };
In this version the value of _dist is updated regularly. The problem is that the value in _dist is still 15s old when while checks it. ;)

To solve this you could switch the bold line and the sleep (so _dist is updated right before while checks it again). But if you do this and look at the code again then you might realize that all this _dist stuff looks pretty confusing and that the first while construct was the most readable... :)
try { return true; } finally { return false; }

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: House Patrol Script (need help!)(arma scripts)
« Reply #10 on: 11 Aug 2009, 16:06:12 »
Thank all of you for the replies....but i saw something like PRELOADING the .sqf script or STORING it in the CACHE before use
Is this done automatically? Or do i need something to do that?
I've seen many examples,including Mr.Murray's and got confused by what they mean!  :weeping:


Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: House Patrol Script (need help!)(arma scripts)
« Reply #11 on: 11 Aug 2009, 17:39:47 »
No, the value of _dist would not have been updated. So the script would have used the initial(!) distance for the check until the end of the mission. Luke's current version almost solves this problem:
Quote
   ...
   _dist = tourguide distance helipad1;
   sleep 15;
   };
In this version the value of _dist is updated regularly. The problem is that the value in _dist is still 15s old when while checks it. ;)

Good God, You're Right!

Oops. :dry:

Sorry! :whistle:

Code: (housepatrol.sqf) [Select]
]
tourguide= _this select 0;
helipad1 = _this select 1;
hotel1 = _this select 2;
travellers = _this select 3;

_dist = tourguide distance helipad1;
while {(_dist < 25)&&(alive tourguide)} do
   {
   tourguide setbehaviour "safe";
   tourguide setspeedmode "limited";
   {_x domove getpos (hotel1 buildingpos random 256)} foreach units travellers;
   _dist = tourguide distance helipad1;
   sleep 1;
   };

Thanks for catching that.

Luke
Pesky Human!!
Wort Wort Wort.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: House Patrol Script (need help!)(arma scripts)
« Reply #12 on: 07 Sep 2009, 13:22:47 »
Sorry for replying so lately [I may be even digging my old - thread! :D]

When its :
sleep 1;
Then how do i make the unit wait for a random time(eg  ~2 +random 10)in .sqf???
And also, can loops be created with .sqf?

And this may be a little OFFTOPIC :

 ???what is :
private ["_thisisone","_thisistwo","_thisisthree"]
Is that used to define the local variables?
Also,I don't see them in your script????
Haroon1992..........
« Last Edit: 07 Sep 2009, 13:25:10 by haroon1992 »
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(