Jump to content
Generalfeldmarschall Niessen

Terminating sqf with !alive Trigger

Recommended Posts

Guten Tag,

 

Ok, so i have tried getting this to work since five hours or so but basically I'm trying to set up the following scenario : I got a perfect Loop with the executioner animations for a executioner and animations for someone that is about to be executed. So far so good, the player however has a chance of interrupting the execution by shooting the executioner. After the player does so however, the .sqf with the animations for both still plays out. I tried playing around with a terminate handler to prevent that from happening but to no avail. Any ideas how to stop the animations from happening midway through the script?

 

Cheers.

 

 

Share this post


Link to post
Share on other sites

Welcome, wilkommen at the forum.

something like:

waitUntil {sleep 0.1; !alive _executioner}; _executioner switchMove "";

in a scheduled scope (execVMed , spawned) of course .

  • Like 1

Share this post


Link to post
Share on other sites

If you are using a trigger, just:

on condition:   !alive theExecutionnerNameHere

on activation: theExecutionerNameHere switchMove "";

 

I don't know how did you name this unit.

 

Note: if your sqf loops an animation, so you need to "handle" this execVM, for example:

yourHandleVariable = [] execVM "yourSQF";

 

Then the on activation becomes:

terminate yourHandleVariable;

theExecutionerNameHere switchMove "";

  • Like 1

Share this post


Link to post
Share on other sites

 

 

My sqf does not loop an animation per se but it has multiple animations that perfectly sync together, and my handle would be terminate right? So it would look like something like this :  

 

Condition

 

yourHandleVariable = [] execVM "mySQF";

 

on activation

 

terminate yourHandleVariable;

 

What would my handleVariable look like? The exact same name as my SQF ? 

Share this post


Link to post
Share on other sites

Can you walk me through what to do one by one? I still do not understand, excuse my lack of scripting understanding but i dont know where to put the "yourHandleVariable = [] execVM "mySQF". I also dont know what it should say, i guess something like "terminatescript = execVM "mySQF" ? Also I dont know where to put this " terminate yourHandleVariable;" ? In my !alive trigger for the executioner?  And if yes, what is it supposed to say? 

Share this post


Link to post
Share on other sites
1 hour ago, Generalfeldmarschall Niessen said:

the player however has a chance of interrupting the execution by shooting the executioner.
After the player does so however, the .sqf with the animations for both still plays out. I tried playing around with a terminate handler to prevent that from happening but to no avail.

 

So, it's on your side to explain what is your sqf and what did you try with "terminate handler".

  • Like 1

Share this post


Link to post
Share on other sites

I have two .sqf files, one for the animations for the executioner and one for the one to be shot. The player enters a trigger with a 60sec delay, if the player fails to interrupt the execution in these 60 seconds, the hostage dies. However, if the player shoots the executioner the animations for the hostage still play out e.g he gets hit and dies in the end. I want to terminate said sqf (the one responsible for the hostage animations) so the animations dont play out if i shoot the executioner.

Edited by Generalfeldmarschall Niessen
typo

Share this post


Link to post
Share on other sites

Exactly how do you execute/run the .sqf files? Please provide your complete solution in order for people to be able to provide corrections/improvements.

Share this post


Link to post
Share on other sites

I run the sqf files in a trigger, which the player enters in a specific area. My current goal is to set up a !alive condition (with the executioners name) that (on activation) prevents the animation sqf files for both AI units from further proceeding.

Share this post


Link to post
Share on other sites

Did you add the trigger (no area needed) with the simple condition : !alive guguss  where guguss is the executioner? That can be a separate trigger, so read what I wrote.

Your first trigger must have something on condition, like : handleThat = [] execVm "ansqf"; so what is difficult to understand here?

If, by any chance, you directly wrote a script (this is not an sqf), the solution is same: handleThatAlso = [] spawn {your trigger code for anim to be blocked}

Share this post


Link to post
Share on other sites
17 minutes ago, pierremgi said:

Did you add the trigger (no area needed) with the simple condition : !alive guguss  where guguss is the executioner? That can be a separate trigger, so read what I wrote.

Your first trigger must have something on condition, like : handleThat = [] execVm "ansqf"; so what is difficult to understand here?

If, by any chance, you directly wrote a script (this is not an sqf), the solution is same: handleThatAlso = [] spawn {your trigger code for anim to be blocked}

Well , im not really experienced with scripting and english is not my first language so trying to understand and implement something that I have no clue of and is in a foreign language is honestly tedious. Alright so now i have a trigger with the condition of said executioner to be alive and what is to be written in the activation part? This:  handleThat = [] execVm "anysqf"?

Share this post


Link to post
Share on other sites

It's just an example. Choose what you want as handle name (so you did for the executioner, I presume). anySqf is yours. I can't guess what you're scripting or copying/pasting at this stage. I don't have any Kristal ball. Truly, you mentioned first an sqf... (see your first post).

 

sqf is a language.

blabla.sqf is a file you can execute by execVM "blabla.sqf" (with or without arguments to be passed. See the link). You can add it in your mission folder, at root (where mission.sqm is) or in a sub-folder (if you mention it inside the string:  execVM "aSubFolderName\blabla.sqf";)

some sqf are event scripts. That means, they run automatic on start or on condition like respawn behavior. They are at root.

Share this post


Link to post
Share on other sites

What pierremgi is trying to say here is that after you call execVM you get back a script handler (this is what the command execVM gives you back) and you keep that inside a variable (the thing on the left-hand side of the equal sign). You can name the variable whatever you want. Make sure you make so that it does not start with an underscore.

 

So in the activation field of the trigger you run the animation scripts there should be something like (not necessarily identical since the names I give may not coincide with the ones you gave to the variables) the following

execAnimHandle = [executioner] execVM "executionerAnimationScript.sqf"; // You call the script with the animation for the executioner
vicAnimHandle = [victim] execVM "victimAnimationScript.sqf"; // You call the script with the animation for the "victim"

Where executioner and victim are the names of the units that represent the executioner and the one to be executed respectively. They are set in the name field of the object in the editor and please keep in mind that you may have named them differently. Now, in your version, you may pass some more arguments to the execVM inside the preceding (square) brackets but this doesn't change something since what we are interested in here are the execAnimHandle and vicAnimHandle. Those are the script handlers you can use to prematurely terminate the scripts.

 

So, in another trigger you make you can set the condition to

!alive executioner;

This will trigger as soon as the executioner dies and in the activation field you can run (copying pierremgi's code)

terminate execAnimHandle; // Terminate the script so that animation will not be executed
executioner switchMove ""; // Set the animation of the executioner to "nothing"

I hope this clarifies things a bit. If this solution does not work for you, or you face more issues please let us know about it, providing some specifics about the different result you want to achieve or the problem that arised.

  • Like 1

Share this post


Link to post
Share on other sites
8 minutes ago, ZaellixA said:

What pierremgi is trying to say here is that after you call execVM you get back a script handler (this is what the command execVM gives you back) and you keep that inside a variable (the thing on the left-hand side of the equal sign). You can name the variable whatever you want. Make sure you make so that it does not start with an underscore.

 

So in the activation field of the trigger you run the animation scripts there should be something like (not necessarily identical since the names I give may not coincide with the ones you gave to the variables) the following


execAnimHandle = [executioner] execVM "executionerAnimationScript.sqf"; // You call the script with the animation for the executioner
vicAnimHandle = [victim] execVM "victimAnimationScript.sqf"; // You call the script with the animation for the "victim"

Where executioner and victim are the names of the units that represent the executioner and the one to be executed respectively. They are set in the name field of the object in the editor and please keep in mind that you may have named them differently. Now, in your version, you may pass some more arguments to the execVM inside the preceding (square) brackets but this doesn't change something since what we are interested in here are the execAnimHandle and vicAnimHandle. Those are the script handlers you can use to prematurely terminate the scripts.

 

So, in another trigger you make you can set the condition to


!alive executioner;

This will trigger as soon as the executioner dies and in the activation field you can run (copying pierremgi's code)


terminate execAnimHandle; // Terminate the script so that animation will not be executed
executioner switchMove ""; // Set the animation of the executioner to "nothing"

I hope this clarifies things a bit. If this solution does not work for you, or you face more issues please let us know about it, providing some specifics about the different result you want to achieve or the problem that arised.

I think I finally understood now, im not at home rn so i let you know the results later. Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

Alright so my triggers look like this :

 

https://ibb.co/1KBGWL1
https://ibb.co/4fCGF1y

 

The "executioner.sqf" and the "victim.sqf" are for the animations, can i name the animHandle simply thisy and thisx? Cuz when i get ingame, it tells me script "victim.sqf" not found.

 

Edit :I also broke the Mission, i deleted all the triggers and moved the sqfs out of the Folder, but when i spawn as a character no unit moves and the unit controlled by the player also cant move all i can do is lie down and look around.

 

Edit edit : Scrap that, it was due to a mod conflict (?) I think, removing said mod fixed the no move problem, the original "problem" still exists.

Share this post


Link to post
Share on other sites

Please do go ahead and do some searching. You can consult the BIKI about variables to see how they work if you are not familiar with the concept (or actually any programming textbook really).

 

Additionally, do consult the BIKI on the syntax of the commands you use. For example (from the BIKI) terminate accepts a script handle as an argument and not a string like what you provide in the triggers. So you should do something like

terminate thisx; // Terminate the executioner animation script
terminate thisy; // Terminate the victim animation script

Furthermore, the variable this is a "magic variable" that holds the boolean returned by the trigger's condition check (see BIKI for more info). You should avoid like hell the assignment to magic variables as well as creating ambiguous, or uninformative variable names. You could very well use the thisx and thisy variables but note that returning to the script (or mission) after a month (or even less) they will provide absolutely no information as to what they hold or what the purpose of their existence is. This is bad coding and it is very hard to be maintained by either you or someone else. You could do something like

/*
 * Activation field of first trigger
 */
execAnimHandle = execVM "executioner.sqf";
vicAnimHandle = execVM "victim.sqf";

/*
 * Activation field of second trigger
 */
hostHandle = execVM "hostagesafe.sqf"; // If you don't need the handle you could something like: execVM "hostagesafe.sqf"

terminate execAnimHandle; // Terminate the executioner animation script
executioner switchMove ""; // Switch the move of the executioner to "nothing" (not sure this is needed but pierremgi has provided for it so I will assume it should be there)

terminate vicAnimHandle; // Terminate the victim animation script
victim switchMove ""; // Same as above

Now the code is clearer, you (or anyone who tries to modify/maintain the code) will easily understand what each variable holds and you have minimised the chances of using or overwriting variables that contain something else (and maybe needed/used elsewhere or further below) like this.

 

================================================================================

EDIT

================================================================================

 

Regarding the "victim.sqf" not found, make sure you don't have any typos (either in the script where you call the file, or the name of the file is not written differently) and that said script is either in the same folder as the mission .sqm or you call it correctly. For example, if you have the scripts inside a folder named script then you should call them like

execVM "scripts\victim.sqf";

Please let us know if you encounter more issues.

Edited by ZaellixA
  • Thanks 1

Share this post


Link to post
Share on other sites

Holy shit, I finally got it to work, looking back it was the problem with the scripts inside a folder, as the "on activation" didn't detect that. God bless you, and forgive me for my inconvenience of  not mentioning that in the beginning.Although I did some bad coding, unknowingly but  I fixed that too.

 

Cheers.

  • Like 1

Share this post


Link to post
Share on other sites

You shouldn't apologize. This forum here is to help people and if you see some rather "overwhelming" posts pointing many "incorrect"/bad practices is to help in the long-run.

 

As I said, the fact that ArmA scripting is not something many people would call coding or programming does not mean that we could not benefit from good programming practices (such as the informative variable naming, code structuring and a lot more). So, please take those points as an extra (not aksed-for but nonetheless a piece of) help with the sole purpose to help you avoid troubles in the future (some of them before you even encountering them).

 

Glad it worked for you and hope to see you again around here (not because you'll have a problem but helping others too).

 

Take care, have fun, stay safe and ArmA a lot.

  • Like 1

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

×