Forum Jump :

Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 21
In-game name: Drew

 
#1 Posted at 2012-11-10 13:17        
     
Hi all! At the risk of overstaying my welcome, I need some more help. I am attempting to make a simple zombie where it follows you around la-de-da, and Iv'e run into some trouble. I had it running on the editor, but I want to change it into a sqf. I had (what I thought) to be an okay script, but the chap just stands there, waiting to beoome a lead magnet. It could just be a simple syntax error. Here's what I have in the zombieadvanced.sqf:

_unit = _this select 0

If (isServer) then {

_unit domove getpos player1;

};

With player1 as my character.

And in the init of the victim:

nul = this execVM "zombieadvanced.sqf";
Any help in the slightest would be appreciated :)

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#2 Posted at 2012-11-10 19:57        
     
# Dutchy : At the risk of overstaying my welcome

Not possible if your problem is valid.

_unit = _this select 0; // missing ;
If (isServer) then {
_unit domove getpos player1;
};

null= [this] execVM "zombieadvanced.sqf";

alternatively test
While {alive _unit } do { 
group _unit move (player1 modeltoworld [0,0,0]);
hint "Following";
sleep 10;
};

This post was edited by palyarmerc (2012-11-10 20:09, ago)

....that's all folks....!

Advertisement


Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 43
In-game name: kylania

 
#3 Posted at 2012-11-10 20:18        
     
zombie attachTo[player, [0,0,0]];

]:->


Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 21
In-game name: Drew

 
#4 Posted at 2012-11-11 05:29        
     
Palyarmerc, it works perfectly *THUMBS UP* Except if I run away for a little while they will stop and stare, and won't start up again until I run near them and back away a few times. I also wanted to add another parameter using the If function:

_unit = _this select 0; 

If ([player1 getdistance _unit] < 100) then {
While {alive _unit } do { 
group _unit move (player1 modeltoworld [0,0,0]);
hint "Following";
sleep 0.01;
}};
But after I input it into the code, it renders the whole thing useless. I assumed it was a syntax error, but I double checked most things. And Pirin, What is this madness! =-O

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#5 Posted at 2012-11-11 11:18        
     
Yeah, it takes the AI a while to respond to ModelToWorld since the AI is still actually executing BIS functions for behaviour. Pirin was being obtuse (just a running joke we have going, breaks up the monotony whilst demonstarating other methods of scripting. We learn quite a bit doing it, so it's all good, hehe)
Have you tried DoFollow ? I got it to work once, A bicycle following a Tractor. It's not straightforward, as always but should be the thing to do. I'll have a play around with that and get back to you.

....that's all folks....!

Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 21
In-game name: Drew

 
#6 Posted at 2012-11-11 11:31        
     
Appreciate it, and that script from Pirin actually helped me with something else *DRINK* I'll give Dofollow a go and see where it takes me.

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#7 Posted at 2012-11-11 11:37        
     
Don't guess coding [] () {} or Commands like GetDistance. Use the Scripting Commands Reference
_unit = _this select 0;

If ((player1 distance _unit) < 100) then {
While {alive _unit } do {
group _unit move (player1 modeltoworld [0,0,0]);
sleep 0.01;
}};

DoFollow only works if they are in the same group, so ideal for getting one car to follow another

....that's all folks....!

Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 21
In-game name: Drew

 
#8 Posted at 2012-11-11 11:54        
     
I didn't realise there was a big difference between [] {} (). I havn't been able to find someone explain them, and when to use them. As for the GetDistance, I even used it before and didn't notice it :-|

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#9 Posted at 2012-11-11 15:16        
     
You get to know in time. I don't know the correct terminology, and learnt by example, I just know
[] is an array : [this], [_x], [this select 0,_this select 1,_this select 2,etc]
() is a sum : (count units), (a == b), etc
{} is a condition : {waitUntil}, {_x count units}, etc
It makes sense after a short while :-)
Although it's English it is pre-defined code. You can't just guess the command ;-)
Just think, you'll be able to handle JavaScript when editing ArmA3 soon & it could land you a job in the real world !

Actually I'd just like to say, I have never read any programming language, and owe everything I know to Bohemia for the Arma Series and the people here at Armaholic !

This post was edited by palyarmerc (2012-11-11 15:23, ago)

....that's all folks....!

Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 21
In-game name: Drew

 
#10 Posted at 2012-11-14 14:25        
     
Yeah, appreciate it. I got quite fluent with TES: Oblivion scripting enging, but then, Oblivion became old, so I try to carry over the laungage, and it just doesn't work *NO*

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 43
In-game name: kylania

 
#11 Posted at 2012-11-14 16:46        
     
# palyarmerc : [] is an array : [this], [_x], [this select 0,_this select 1,_this select 2,etc]
() is a sum : (count units), (a == b), etc
{} is a condition : {waitUntil}, {_x count units}, etc

[] is an array, a list of values. [1,2,3,4] (an array of numbers) or ["bob", "mary", "sue"] (an array of strings) or [p1, p2, p3] (presumedly an array of objects assuming p1, p2 and p3 are units on the map).

() is usually used to specify order of operation or to make things more clear instead of sums. (count units group player) and count units group player will both result in the same. Here's a somewhat tricky example of that:

Lets say you have a script that returns what gun a unit has called via: nul = [player] execVM "whichGun.sqf";

The code of whichGun.sqf would be:
_gun = primaryweapon _this select 0;
hint format["The gun is %1", _gun];

You'd expect that to return the classname of the gun of player, but instead you might get an error saying "Expected object; got ARRAY" or something similar because primaryWeapon is expecting the next thing to be an object. So you could fix it like this:

_gun = primaryweapon (_this select 0);
hint format["The gun is %1", _gun];

By putting () around the _this select 0 you tell the scripting engine to evaluate that first, so instead of being primaryWeapon _this it becomes primaryWeapon player. Make sense?

{} denote codeblocks. Such as in the case sections of a switch, or the then and else sections of an if or the code within a waitUntil or an eventHandler or spawn. A condition would be a boolean usually tested by an if statement.

if is a tricky one since it combines two of these.

if (someCondition) then { 
    // code in this block 
};