Jump to content
Sign in to follow this  
shammy2010

New to hostage scripting

Recommended Posts

Hi, I'm making a mission where you rescue a hostage but what I need is how to use the dofollow script because I named:

the player "p1"

and the hostage "hos"

and I put it on act in a trigger:

"hos dofollow p1"

but the hostage doesn't seem to follow me.

I also need a trigger to go off only when that hostage is inside the trigger, but i have no idea what the script may be for that.

anyone think they can help?

Share this post


Link to post
Share on other sites

and I put it on act in a trigger:

"hos dofollow p1"

but the hostage doesn't seem to follow me.

The hostage first needs to join your/the players group. You can't interpret the arma commands too literally most of the time. If you're unsure about a command, read the comref. Carefully.

I also need a trigger to go off only when that hostage is inside the trigger, but i have no idea what the script may be for that.

Well, how about a trigger? Then synch it to the hostage and try the trigger activation "ANY", "NOT PRESENT". That should do it.

Share this post


Link to post
Share on other sites

hmm, you can create a sqs and write this inside

hostage.sqs [activate with [this] exec "hostage.sqs"

[Hos] join grpNull;

~2

[Hos] join Player;

~1

Hos setcaptive false;

With this, the hostage is joining the players group.

And for leaving with a trigger

condition

hos in thislist

on activation

[Hos] join grpNull;

But i´m sure, somebody has a better solution for this.

Regards Intruder

Share this post


Link to post
Share on other sites

Isn't there a way of setting it up in a trigger where when you are a certain distance away (2 or 5 metres or so) then the hostage goes into your group? I myself am interested in an answer to the OP question.

Share this post


Link to post
Share on other sites
Isn't there a way of setting it up in a trigger where when you are a certain distance away (2 or 5 metres or so) then the hostage goes into your group? I myself am interested in an answer to the OP question.

condition

5 > (player distance hostage)

Regards Intruder

Share this post


Link to post
Share on other sites

Actually I'd write a short fsm for such a hostage thing. Run it on the hostage(or hostage-group for multiple hostages) and have all in there such as joining the players group or failing the mission in case the hostage dies, etc... for really, such a thing is a flow of happenings with some different routes/reactions and ends to it. Modelling this as a finite state machine is definitely much more comfortable than any other control flow, whether you use a loop or triggers and little scripts scattered all over your filesystem. :)

But for sure, you should stop using the old sqs syntax as well as exec. Make yourself comfortable with sqf/execVM instead.

Share this post


Link to post
Share on other sites

Ruebe, you have misunderstood what i asked, I asked if it was possible to have a script or code that would detect only the hostage when entered but thanks for your time

Share this post


Link to post
Share on other sites

Intruder told you how to trigger when just the hostage was in the zone:

hos in thislist

Share this post


Link to post
Share on other sites

So what is the line in activation which makes the unit go in your group and fight just like a normal soldier in the group? I've tried "pilot dofollow delta1", "pilot joinassilent ["Savior"]", "pilot join ["Savior"]" amd "pilot in ["Savior"]".

What would it be? "5 > (delta1 distance pilot)" activates everything else in the trigger except making the hostage go in my group.

Share this post


Link to post
Share on other sites

join and joinSilent format is: [array] join group; so:

Condition =

pilot distance delta1 < 5

OnAct =

[pilot] joinSilent delta1;

Share this post


Link to post
Share on other sites

Well that works out all nice but it wasn't exactly what i was looking for though, I was actually hoping for the hostage to not join the player at all but only follow him when given the sudden order to through the action menu and stop when not

Share this post


Link to post
Share on other sites

Another option is AddAction with "Come with me!" and he joins the "Hostage Rescue" team group along with saying

captivename sidechat "Pheew, I'm so glad to see you guys!"

Share this post


Link to post
Share on other sites
Well that works out all nice but it wasn't exactly what i was looking for though, I was actually hoping for the hostage to not join the player at all but only follow him when given the sudden order to through the action menu and stop when not

And your problem is where exactly?

Share this post


Link to post
Share on other sites

Shammy: once he joins your command you can order anything - to stop (1-3), move into a vehicle, move to a new place on map, etc.

Share this post


Link to post
Share on other sites

Well the problem is I dont know how to make the hostage follow me without joining my group. If you remember the mission manhattan in red harvest, you should remember Antonia following you but not joining your group, She just followed you. I want to know how to do that

---------- Post added at 07:11 PM ---------- Previous post was at 06:51 PM ----------

Another Problem I encounter is when the hostage leaves the player's group and joins a group back in base so the player's group can go off doing other objectives is that the group that the hostage joins; the commander always orders the hostage to go into the vehicle that was used to transport him back to base, but the player needs that vehicle to continue the rest of the mission, is there anyway for the other group to not order the hostage to go into that vehicle? maybe a leave group script?

Share this post


Link to post
Share on other sites

Here's some silly code I used for a "Creepy Stalker" mod. :)

// null = [poorgirl, stalker] execVM "brains.sqf";

_brains = _this select 0;
_chompy = _this select 1;

while {alive _brains} do {
_chompy doMove position _brains;
sleep 0.5;
};

the commander always orders the hostage to go into the vehicle that was used to transport him back to base, but the player needs that vehicle to continue the rest of the mission

Why isn't the player leading the group? You might be making this too complicated really. Personally I'd make the player the group leader, have the hostage join the group.

Then, if the player is leader or not, just delete the hostage when she's in the "escape vehicle". Name it something like e1 and the girl something like hos1 then make a trigger with Condition of: hos1 in e1 and onAct of: hos1 setPos [1,1,1]; deleteVehicle hos1; So you'll get the effect of the hostage following you and getting into the escape vehicle, but as soon as she does she's teleported into the middle of nowhere and destroyed. :) You get to save the girl and keep your vehicle!

Edited by kylania

Share this post


Link to post
Share on other sites
Well the problem is I dont know how to make the hostage follow me without joining my group. If you remember the mission manhattan in red harvest, you should remember Antonia following you but not joining your group, She just followed you. I want to know how to do that

That's actually not all that hard. Make sure the hostage(s) are stopped (doStop) so they won't follow any group formation if there are multiple hostages or part of a greater civilian group. Then I'd suggest you write the follow-logic/flow in a fsm (if you've got time to learn it), but you can write a little script too. Basically it's something like this:

doStop _theHostage;

while {alive _theHostage) do
{
  _theHostage doMove (position player);
  waitUntil{(!(alive _theHostage) || (unitReady _theHostage))};

  if (!(alive player) || ((_theHostage distance player) > 30)) exitWith {};
};

Something along these lines. Of course you need to think about what happens if the player is too far away (if anything), or any other influences something might have on this situation. Maybe you need a manual way to exit the loop, in which case you could work with a token on the hostage by set(-ing)Variable and get(-ing)Variable... It's up to you.

But again, it's much nicer to model such flows as fsm. It's easy and really worth it.

Share this post


Link to post
Share on other sites
But again, it's much nicer to model such flows as fsm. It's easy and really worth it.

An example of this would be really great! :) All the fsm stuff I've found makes my brain curdle.

Share this post


Link to post
Share on other sites
An example of this would be really great! :) All the fsm stuff I've found makes my brain curdle.

An example? :rolleyes: Why don't you unpbo the missions(_e).pbo and pick one of the smaller ones, starting from there. They are everywhere and usually easy to read and understand (which is one of the strengths of finit state machines and why they are so comfortable to work with).

There isn't really much you need to understand to be able to use and write fsm in Arma. There are states, normal ones and special states such as the start/init-state and the (or multiple) endstates. These states are linked by conditions (which may be ordered by priorities). And then you may execute code as you enter a new state or condition... And that's it pretty much. Here: FSM_Editor_Manual.

Sure, there are some other things to account for, such as no sleep/waitUntil in fsm since they are basically compiled code. But instead you may model delay-loops for example, by having a condition that fires only after a certain amount of mission-time has passed (time - _timeAtLastState) or you may just spawn your code (and easily wait in fsm with scriptDone _handle to continue)... But you'll learn these things as you go. It's really easy and the FSM Editor is fine too, except for the tiny font-size in it's built in editor which you can't change... (though there's an option to use an external editor, so...)

Just jump into the cold water and you will realize that the water is only knee-deep, warm and comfy.

Fear not my friend. :D

Edit: ok, here is a screenshot of one of my own fsm. I'm pretty sure you may figure out what it's all about without even having seen one line of code. Also, this should show, why it's a good idea to model such flows in fsm. GoTo constructs, while-loops or armas jump/exit to named scoped methods are ugly as heck in comparison:

fsm1.png

Edited by ruebe

Share this post


Link to post
Share on other sites
Here's some silly code I used for a "Creepy Stalker" mod. :)

// null = [poorgirl, stalker] execVM "brains.sqf";

_brains = _this select 0;
_chompy = _this select 1;

while {alive _brains} do {
_chompy doMove position _brains;
sleep 0.5;
};

Why isn't the player leading the group? You might be making this too complicated really. Personally I'd make the player the group leader, have the hostage join the group.

Then, if the player is leader or not, just delete the hostage when she's in the "escape vehicle". Name it something like e1 and the girl something like hos1 then make a trigger with Condition of: hos1 in e1 and onAct of: hos1 setPos [1,1,1]; deleteVehicle hos1; So you'll get the effect of the hostage following you and getting into the escape vehicle, but as soon as she does she's teleported into the middle of nowhere and destroyed. :) You get to save the girl and keep your vehicle!

Ok I'm sorry but I'm not too good at explaining myself, but basically now I'm making a mission where you have to capture a warlord, (not saving a girl):rolleyes: and you have to bring him back to base for questioning. The player is also the leader here but when they reach the base, there's an interrogating officer who's group the warlord will join so the warlord isn't following the player but the officer always commands the warlord to board my car and ride with me! :mad: that's my problem. Now there's another objective where you have to save a female reporter who got caught for looking too much into the takistani's business. now I am trying to make this pretty realistic so the hostage can't just disappear right after she gets rescued. Plus I have to make sure that if the hostage dies the mission fails so I put the !alive hos trigger in there and now if she is destroyed in the middle of nowhere like you say then the trigger will go off and end the whole mission.

Share this post


Link to post
Share on other sites

Maybe not actually have the Warlord join the officer's group? Just kick him from your players group, tell him to move to the officer and stop?

Share this post


Link to post
Share on other sites

Well what would be the script for that because I'm still a noob to this scripting stuff.

Share this post


Link to post
Share on other sites
Well what would be the script for that because I'm still a noob to this scripting stuff.

Dude.. :rolleyes: I really doubt anyone in here is willing to write scripts for your personal pleasure. That's your friggin job! We're glad to help if you're having a problem, if you're in need of a push in the correct direction or just out for a funny discussion, whatever... But beeing a "noob" is no excuse for beeing lazy.

And second, for beeing a "noob", maybe you should start with something that doesn't involve too much headaches for you. And maybe you should lower your expectations or goals just a little. It's nice to have concrete/special mission ideas, but nobody came up with a masterpiece of a mission while just starting out.. ever.

Share this post


Link to post
Share on other sites
Well what would be the script for that because I'm still a noob to this scripting stuff.

I'd posted the script before actually. :)

Just [warlord] joinSilent grpNull; then my creepy script above called as null = [officer, warlord] execVM "brains.sqf"; :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×