Home   Help Search Login Register  

Author Topic: Trying to understand sqf...  (Read 2355 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
Trying to understand sqf...
« on: 29 May 2007, 01:55:06 »
Hello, I've found a script to place the player on the roof of a moving truck. The player is not able to move, but that's not my problem.
I want the script to exit via an addaction, but I don't know how to do this to do in sqf format. Actually... in sqs either  :P

Here is the script:

Quote
_Unit=_This Select 0;
_Vehicle=_This Select 1;

_Unit SetPos (_Vehicle ModelToWorld [0,-3,1.26]);

//STARTTRUCK=True;

WaitUntil
   {
   _Unit SetVelocity (Velocity _Vehicle);
   _Unit SetPos (_Vehicle ModelToWorld [0,-3,1.27]);
   _VUp=VectorUp _Vehicle;
   _VDir=VectorDir _Vehicle;
   _Unit SetvectorUp _VUp;
   _Unit SetvectorDir _VDir;
   };

First question...

Is the line //STARTTRUCK=True; a comment? When I delete this line the script still works.

Second question...

I think the position & vector of player and truck needs to be updated when the truck starts moving, but I don't see a loop here...
Waituntil doesn't create a loop AFAIK. Where is the condition?

Third question...

How can I exit the script via an addaction? I want to create an action "jump of the roof" that exits the script. I would add one of the rollanimations when the player gets of the roof to make it look better.

Left roll =  "amovppnemstpsnonwnondnon_amovppnemevasnonwnondl"
Right roll = "amovppnemstpsnonwnondnon_amovppnemevasnonwnondr"

 
PS: I've read Cheetah's basic sqf tutorial but I still don't get it  :confused:
« Last Edit: 29 May 2007, 02:02:15 by Blanco »
Search or search or search before you ask.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Trying to understand sqf...
« Reply #1 on: 29 May 2007, 02:07:12 »
da exiting part shud b easy.... u just add condition

Code: [Select]
?nameOfVariable : exit
inside ur loop

and in da addaction script u just put

Code: [Select]
nameOfVariable = true
also dont forget 2 init da nameOfVariable 2 false

bout ur function... i 2 cant understand da waitUntill thingy... as it doesnt follow da syntax in COMREF  ???

Quote
_i = 0; waitUntil {_i = _i + 1; _i >= 100}

it doesnt seem 2 have condition attached ?

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Blanco

  • Former Staff
  • ****
Re: Trying to understand sqf...
« Reply #2 on: 29 May 2007, 02:50:13 »


Aha LCD is back :good:
I have to learn my LCDish again  :P

OK, I could fix it.

ontruck.sqf
X = [Name of unit, name of vehicle] ExecVM "onroof.sqf"

Quote
_Unit=_This Select 0;
_Vehicle=_This Select 1;

_Unit SetPos (_Vehicle ModelToWorld [0,-3,1.26]);

onroof = true;WaitUntil
   {
   _Unit SetVelocity (Velocity _Vehicle);
   _Unit SetPos (_Vehicle ModelToWorld [0,-3,1.27]);
   _VUp=VectorUp _Vehicle;
   _VDir=VectorDir _Vehicle;
   _Unit SetvectorUp _VUp;
   _Unit SetvectorDir _VDir;
!(onroof)};
exitWith;

Onroof is the variable to exit the script and is set false in the init and addaction script.

I tried to create the addaction in the onroof.sqf but I got an missing error...

The rolling part doesn't look like I expected and the player got hurt when he jumps of the roof even on a stationairy truck

.


 
Search or search or search before you ask.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Trying to understand sqf...
« Reply #3 on: 29 May 2007, 03:00:55 »
aha blanco que paso ?  :D  ;)

so now it kills da script ?

i dont remember much of da functions but i think dey r more suited 4 math stuff nd da like nd not 2 do stuff like what u do ? but im not sure about dat... so mebe dats y da addaction didnt work in da screen itself ???

as 4 da getting hurt... best u cud do is set his dammage 2 whatever it was b4 dat i guess ? cuz it seems Arma soldiers really dont like heights  :no: also i suggest maybe finding a nice anim 2 play when he jumps down ? or something like that ?

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Blanco

  • Former Staff
  • ****
Re: Trying to understand sqf...
« Reply #4 on: 29 May 2007, 03:13:38 »
Quote
i dont remember much of da functions but i think dey r more suited 4 math stuff nd da like nd not 2 do stuff like what u do ? but im not sure about dat...

I have no idea

Quote
as 4 da getting hurt... best u cud do is set his dammage 2 whatever it was b4 dat i guess ? cuz it seems Arma soldiers really dont like heights

I store his damage in a variable before he jumps of the roof and add again when he's back on the ground. Seems to work.

This is the addacation script right now:

Quote
onroof = false

_dam = getdammage player
player removeaction 0

; from prone to crouch"
player playmove "amovppnemstpsraswrfldnon_amovpknlmstpsraswrfldnon"

;waituntil the player is on the ground
@(getpos player select 2 < 0.5)

~0.2
player setdammage _dam
exit

Quote
also i suggest maybe finding a nice anim 2 play when he jumps down ? or something like that ?

Yeah, i was looking for a good anim, maybe the "climb down ladder" anim?




 





« Last Edit: 29 May 2007, 03:36:08 by Blanco »
Search or search or search before you ask.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Trying to understand sqf...
« Reply #5 on: 29 May 2007, 03:22:24 »
dats da anim tool u need :D

just d/l nd chose what u like ;)  :cool2:

well have 2 wait and see what 1 of da big boys says bout da function vs script tingy

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Blanco

  • Former Staff
  • ****
Re: Trying to understand sqf...
« Reply #6 on: 29 May 2007, 03:48:30 »
Thx, I already have the animviewer.

I have made an excel file with most animnames + a short description. Oranised in 3 worksheets : stand, crouch and prone, but no death or cargo anims.
You can use the list while your scripting instead of switching between the animviewer and the mission your working on..

here it is : http://www.mediafire.com/upload_complete.php?id=iwaizatqzww


 

Search or search or search before you ask.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Trying to understand sqf...
« Reply #7 on: 29 May 2007, 10:24:16 »
I would use a while with sleep inside instead of waitUntil

Code: [Select]
_Unit=_This Select 0;
_Vehicle=_This Select 1;

onroof = true;
_actionidx = player addAction ["Jump", "jump.sqs"];
_Unit SetPos (_Vehicle ModelToWorld [0,-3,1.26]);
while {onroof} do
{
   _Unit SetVelocity (Velocity _Vehicle);
   _Unit SetPos (_Vehicle ModelToWorld [0,-3,1.27]);
   _VUp=VectorUp _Vehicle;
   _VDir=VectorDir _Vehicle;
   _Unit SetvectorUp _VUp;
   _Unit SetvectorDir _VDir;
  Sleep 0.002;
};
player removeAction _actionidx;

Code: [Select]
;jump.sqs
onroof = false

;Whatevet you want to add here


exit