Jump to content
Sign in to follow this  
jpinard

Arma Veterans - Help us learn to help ourselves (in this thread)

Recommended Posts

"Give a man a fish he eats for a day. Teach a man to fish and you feed him for a lifetime."

^^That's^^ the idea for this thread. Not just an easy answer, but help guide us in finding and executing the information already available - primarily by using BIS's scripting reference: http://www.arma2.com/comref/comref.html or better: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2

--------------

I'll start things off.

Question #1

I'd like to have a set of units blow up when Blufor hits a specific waypoint. I looked up "damage" and found this:

object setDamage damage
Operand types:
   object: Object
   damage: Number
Compatibility:
   Version 1.50 required.
Type of returned value:
   Nothing
Description:
   Damages / repairs the object. Damage 0 means the object is fully functional, damage 1 means it's completely destroyed / dead. Note: this function is identical to setDammage. It was introduced to fix a spelling error in the original function name. 
Example:
   player setdamage 1 
Category: OFP 

I have 3 units I want to destroy. Based on the Wiki I went the basic route and figured the waypoint action section should look like this:

truck1 setdamage 1 && truck2 setdamage 1 && truck3 setdamage 1

The game won't accept it. When is the && preferable?

Question #2 - Would it be possible, instead of naming each unit to be destroyed, make a trigger that is synchronized to destroy everything in the encircled area once the player hits the waypoint or trigger area? If so can you give me a hint of what to look for in the BIS scripting wiki?

Edited by jpinard

Share this post


Link to post
Share on other sites

1:

{_x setDamage 1} foreach [t1, t2, t3];

2:

Place a Trigger covering the area you want to destroy things in. Set it to Anybody - Present - Repeatedly and name it deathZone.

In your waypoint (or other trigger) onAct put:

{_x setDamage 1} foreach list deathZone;

&& or AND is used to evaluate something, not execute something. This would have worked too:

truck1 setDamage 1; truck2 setDamage 1; truck3 setDamage 1;

You'd use && in a trigger condition, like to make sure that both Mac and Cheese were in a trigger zone you'd put this in it's Condition field:

Mac in thislist && Cheese in thislist

By the way, a much easier to read COMREF is available here: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2

Edited by kylania

Share this post


Link to post
Share on other sites

Thank you! ...and thanks to everyone else who participates with both questions and answers. :)

Now, how you wrote the following:

{_x setDamage 1} foreach [t1, t2, t3];

Is there somewhere in the wiki I would have found that? Or is that standard syntax programmers are already intimately familiar with?

Share this post


Link to post
Share on other sites

Here's some basic getting started resources:

The Bible: Armed Assault Editing Guide - Deluxe Edition - English version by Mr-Murray

SQF Syntax: http://community.bistudio.com/wiki/SQF_syntax

Wonderful SQF Scripting Guide: http://forums.bistudio.com/showthread.php?t=94015

All of that is slightly outdated in that they deal with and show examples from ArmA and ArmA II, but 99.99% of it all should work with Arrowhead.

Share this post


Link to post
Share on other sites

Here's another one I can't figure out. I want a civilian to keep driving his bus through town even though there's a massive war going on all around him. Right now he drives 10 feet, gets out and dives for cover even though we're not a target.

I looked up "danger" and got nothing relevant. Then I looked up "ignore" and didn't see any ignore commands that were relevant. Am I looking in the wrong area?

Share this post


Link to post
Share on other sites
Here's another one I can't figure out. I want a civilian to keep driving his bus through town even though there's a massive war going on all around him. Right now he drives 10 feet, gets out and dives for cover even though we're not a target.

I looked up "danger" and got nothing relevant. Then I looked up "ignore" and didn't see any ignore commands that were relevant. Am I looking in the wrong area?

Just put the following to the unit init line.

this setBehaviour "CARELESS";

_neo_

Share this post


Link to post
Share on other sites

I can't take credit for this (I think originally posted by fasad), but it has been invaluable to me:

Find all objects that do not have classes (e.g. trees, fences, etc.) within a specific radius of the player:

_radius = 100; // Change as desired but the bigger the radius the more potential lag.
nearestObjects [player,[], _radius]) - ((getPos player) nearObjects _radius);

---------- Post added at 05:24 AM ---------- Previous post was at 04:54 AM ----------

Here is a list of machine types (singleplayer, servers, client) and how various condition checks will return if run on that machine. For example, if you wanted to make sure a machine was a MP host and not a dedicated server you could run:

if ((isServer) and (!isDedicated)) then {...);

You don't usually need to check more than two (and sometimes one will do) but here is a list of how all three SP/MP condition checks return for all SP/MP game modes:

EDITOR PREVIEW / SINGLEPLAYER:

isMultiplayer returns false

isServer returns true

isDedicated returns false

MULTIPLAYER (NON-DEDICATED) HOST SERVER

isMultiplayer returns true

isServer returns true

isDedicated returns false

MULTIPLAYER DEDICATED SERVER

isMultiplayer returns true

isServer returns true

isDedicated returns true

MULTIPLAYER CLIENT

isMultiplayer returns true

isServer returns false

isDedicated returns false

Edited by Loyalguard

Share this post


Link to post
Share on other sites
I can't take credit for this (I think originally posted by fasad), but it has been invaluable to me:

Find all objects that do not have classes (e.g. trees, fences, etc.) within a specific radius of the player:

_radius = 100; // Change as desired but the bigger the radius the more potential lag.
nearestObjects [player,[], _radius]) - ((getPos player) nearObjects _radius);

Not to be rude but, why is that useful?

Share this post


Link to post
Share on other sites

It's useful for damaging these items via script. My nuke uses this technique to ensure that trees and fences do not remain standing in the blast zone.

Share this post


Link to post
Share on other sites
Here's another one I can't figure out. I want a civilian to keep driving his bus through town even though there's a massive war going on all around him. Right now he drives 10 feet, gets out and dives for cover even though we're not a target.

I looked up "danger" and got nothing relevant. Then I looked up "ignore" and didn't see any ignore commands that were relevant. Am I looking in the wrong area?

Just put the following to the unit init line.

_neo_

Doesn't work. They still get out and take cover when they draw near to dueling tanks even though citizens are friendly to all.

Share this post


Link to post
Share on other sites

Aside from the above, I'm looking to create a variable that limits the maximum height a jet or helicopter will fly. I know we can set the exact height it will fly at ie.

this flyinheight 100

But how do you set a "maximum"ceiling value? I didn't see anything in the script code that would let me do that.

Edited by jpinard

Share this post


Link to post
Share on other sites
Aside from the above, I'm looking to create a variable that limits the maximum height a jet or helicopter will fly. I know we can set the exact height it will fly at ie.
this flyinheight 100

But how do set a maximum ceiling value? I didn't see anything in the script code that would let me do that.

Yes, I'm very curious about this as well.

Great thread by the way!

Share this post


Link to post
Share on other sites

Hello i have recently started to make my own missions, just basic stuff at the moment. Anyway I am trying to get an OPFOR with an RPG to attack an object.

So i create the OPFOR with RPG launcher and 2 rockets (PG7VL) and give him a destroy waypoint on top of the target which is a power generator trailer from (objects (military) > generator trailer), I put myself as part of his squad so i could determine what he is doing.

The the rpg gunner says 'all attack vehicle' a destroy waypoint comes up, then jumps to a random spot 10m from the tank, then the he starts running around in circles for a bit before stopping. If I run towards the waypoint it starts to correct itself and it is properly marked onto the target once i am right on top of it, then he decides to fire. The rpg gunner won't even attack the generator trailer.

EDIT2: I've now properly linked the waypoint, before I would create the waypoint on empty space and drag it on to the target

Edited by Wraith_V

Share this post


Link to post
Share on other sites

g1 doTarget gen; g1 selectWeapon secondaryWeapon g1; g1 doFire gen;

Tested as working vs a Power Generator.

Share this post


Link to post
Share on other sites
g1 doTarget gen; g1 selectWeapon secondaryWeapon g1; g1 doFire gen;

Tested as working vs a Power Generator.

Thanks, forgive my ignorance but what do I put that on - waypoint, trigger, external file. I'm working off an tutorial I found at OFPEC.com and I haven't quite gotten to the external file bit yet.

Also whats up with the AI and sandbags, they cant seem to shoot or even see while standing or crouching behind them.

Share this post


Link to post
Share on other sites

The above example will work perfectly in a trigger or waypoint. Don't forget to name the AI soldier g1 and the Power Generator gen

Share this post


Link to post
Share on other sites

Well, in my test I put it on a radio trigger, but you can put it most anywhere. When did you want the guy to shoot the generator? That will determine where you put it.

Share this post


Link to post
Share on other sites
Well, in my test I put it on a radio trigger, but you can put it most anywhere. When did you want the guy to shoot the generator? That will determine where you put it.

Im doing a mission where some US troops are defending a small base from attack by insurgents, I wanted to have an objective to keep the generator van from being blown up by enemy rpg's. I wanted to have it so that the AI move close to the base before firing so they don't destroy it from too far away.

Unfortunately it didn't work, I tried it on a waypoint and area trigger that determines if any opfor are in the area with the same result.

Here is what I did (for testing purposes):

- Created a new Generator van with name "gen" (no quotes)

- created an opfor armed with an RPG name "g1" (no quotes)

- set a move waypoint a few metres ahead of the RPG gunner

in the waypoint:

Condition: true

onAct: g1 doTarget gen; g1 selectWeapon secondaryWeapon g1; g1 doFire gen;

He's aiming at it for sure but he won't swap to his secondary weapon or open fire even if I remove the swap weapon bit, ive even tried "swapWeapon "RPG7V"" instead of "g1 selectWeapon secondaryWeapon g1", it does look like he is trying though as the rocket on the end of the RPG launcher appears for a second.

Share this post


Link to post
Share on other sites

Was he out of ammo perhaps? You might want to build in some safeguards, like have the trigger look for an RPG class unit that entered the area, then remove all his weapons, give him back just the RPG and ammo for it, have him target and fire at the location, then maybe give him back his other weapons. Just that way you control what's happening at that point.

Share this post


Link to post
Share on other sites

Very strange, he's perfectly happy swapping to other weapons (pistols, rifles etc) but not any launchers, also tried BLUFOR and Russian guys to see If it wasn't just the Takistani guys. I also tried using it on a radio channel, without luck.

I tried what you suggested, took all his weapons away then gave him a launcher and some rockets but still no change.

EDIT1: Okay so I found the problem, apparently ai can't attack the 'generator trailer' at all, your code works against everything else that I tested (including static generators), so i'll just change it to an uplink humvee.

Thanks alot for your help.

One more question, why don't the AI shoot at anything from behind sandbags, their vision also seems impared

Edited by Wraith_V

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  

×