OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Johan_D on 22 Feb 2004, 16:19:22

Title: Group sounds.. need a start and help!
Post by: Johan_D on 22 Feb 2004, 16:19:22
Looking into the scripts I dont know how to start. Can someone point me in the right direction?
This is what I would like to have.
- script that runs in a loop for each group, and plays sounds on certain events.

Sample:

#start

; get leader of group

; check leader speed, if running then play "gogogo"

; check leader if position up/down, if down play "takecover"

; check leader if fireing, if so then play "attack!"

; check leader if enemy is spottet, if so then play "enemyahead"

; check leader if fleeing, if so play "fallback"

; check leader if wounded, play "medic"

; check leader if he knows if enemy is wiped out, then play "area-secure"

; check leader for giving formations command, line="stick together", vee="spreadout" etc

; ---whole group/each unit

; check unit if wounded, play "medic"

; check unit if detecting heavy armour, then play "tank!!"

; check unit if detecting mortar, then play "incomming!"

; check group size, if below 5 then play "needreinforcements"


#loop


; more sophiticated:

; get position of detected enemy relative to the group, and play "behind us", "watch flanks" etc


Can some guru help me starting?

Johan
Title: Re:Group sounds.. need a start and help!
Post by: macguba on 22 Feb 2004, 22:48:10
:D That's about 50 questions in one.

OK, where to start ...

_leader = leader grp1

The general form of syntax you need is this

? condition: result if condition is true

For example

? fleeing _leader: play "runaway"

Read the command reference from front to back, like a book, to discover the commands you need.   Don't forge the extra sections like "Scripting topics"  Here are a few commands to help get you started.

speed
getUnitPos
getDammage
count
knowsAbout

For an introduction to scripting read:-

snYpir's Friendly Intro to code snippets
Johan Gustafsson's Scripting Guide
Title: Re:Group sounds.. need a start and help!
Post by: Johan_D on 23 Feb 2004, 16:00:45
Thanks for your time. Ill try to make a start, and let you know.. probably with a load of other questions :-)

Johan
Title: Re:Group sounds.. need a start and help!
Post by: Johan_D on 23 Feb 2004, 21:31:20
Okay, had some moderate sucesses. Thanks Maguba.
Now on to a certain problem:

Is there a way in a script to have the leader a knowsabout about whatever enemy he has spotted?

Like this:

? (_leader knowsabout _enemy > 0): playsound "aenemyspot";_knows = 1

How do I fill the _enemy array? Preferrable not with any trigger. Can a script grab somewhere any enemies, or all?

Johan
Title: Re:Group sounds.. need a start and help!
Post by: macguba on 23 Feb 2004, 22:23:28
This is harder than it looks:   you need a unit for the knowsAbout command, not an array, so you need to combine it with a count command in some way:-

? ("_leader knowsAbout _x > 0.5" count _enemy) > 3: whatever

Syntax not guaranteed at all.

If you want to grab an array of all enemies currently on the map, you'll need a trigger.    However, if you want an array of all enemies on the map at the mission start you can either use a trigger or, if you have named all the enemy groups, just define it in your init.sqs.