OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: CptBravo on 28 Jan 2004, 05:16:41

Title: Anyone out there?????? :)
Post by: CptBravo on 28 Jan 2004, 05:16:41
Hello everyone,

I just need maybe a an easy simple way of knowing when of my groups starts firing on enemy. So everytime a group engages the enemy their leader would report back that they are engaging the enemy.

Thank you for your help.

Title: Re:Detecting Engagment
Post by: General Barron on 28 Jan 2004, 06:19:33
You could add a "fired" eventhandler to the group members, which would then run the appropriate report script (but only have one script run for each group, so you don't get 12 reports from the same squad).

You'd also have to set up some system so that there is a delay between each report, for obvious reasons.
Title: Re:Detecting Engagment
Post by: Chris Death on 28 Jan 2004, 08:20:53
General Barron is right with the "fired" eventhandler,
but you still can use it on every single unit.

How?

give everyone a "fired" eventhandler, and let everyone
start the same script by that.

Now in this script all you have to do is:

set a variable (best done by a boolean - variable = true)
and remove alleventhandlers "fired" for each of those
guys you have given it before.

Now when: variable is true, engagement did start, and nobody
is carrying an eventhandler anymore, so there's a good chance
that the script will only run once (in case that not everyone
started firing at the very same second).

~S~ CD
Title: Re:Detecting Engagment
Post by: deaddog on 28 Jan 2004, 13:48:15
Another way is to use the behaviour command:

?behaviour unitname == "COMBAT":blah blah.....

No matter what mode you set them in "setbehaviour", their behaviour will change to combat once engaged, and then change back once the fight is over.

Title: Re:Detecting Engagment
Post by: Chris Death on 28 Jan 2004, 14:18:34
The only problem could then occur, if you've set them manually
to combat  from the beginning :D

Also note that some players (not saying noobs), sometimes
do random shots, even before they see a bush, which looked
like an enemy by the distance of 50 meters  ;D

Hell even i caught me sometimes yet with pulling the trigger by
accident  :-[

Troops would also turn into combat behaviour for a few secs,
and the whole thingy could become messed up.

~S~ CD
Title: Re:Detecting Engagment
Post by: deaddog on 28 Jan 2004, 14:51:30
That's a good point.  I didn't think about being manually set to combat.  And I know I've taken some shots by mistake :)
Title: Re:Detecting Engagment
Post by: CptBravo on 28 Jan 2004, 17:57:28
Thanks guys for the quick help. Only thing is .. could you please for nooobs sake illustrate exactly what is to be done?  ;D

DO I place it in a trig? Script? Init field? Indivdual unit or group?
Placing it for each unit .. will that increase lag if I have about 120 units on map .. and they all start firing and using script same time?

Thanks for the help.  
Title: Re:Detecting Engagment
Post by: CptBravo on 28 Jan 2004, 17:58:59
and I am not that familiar with eventhandlers .. could you give exact command?

Thanks
Title: Re:Detecting Engagment
Post by: Harkonin on 29 Jan 2004, 00:54:02
You can also use the knowsabout command.

I.E ....

unitname knowsabout enemyunitname  >= 0.5:
Title: Re:Detecting Engagment
Post by: CptBravo on 30 Jan 2004, 04:21:43
Hi,

That command is giving me errors when I place it in a trig.
Could someone pleaaase give a simple step by step way to get feed back from different groups everytime they fire their weapons/engage the enemy   ???

Thanks
Title: Re:Detecting Engagment
Post by: CptBravo on 31 Jan 2004, 21:16:34
Umm .. "cough cough" .. anyone with any hints please?!  :-\
Title: "Naked women, beer and Football" :)
Post by: CptBravo on 02 Feb 2004, 17:36:48
Maybe I should add "Naked women, beer and Football" to subject line .. then I might get morre responses   ;D
Title: Re:Anyone out there?????? :)
Post by: macguba on 02 Feb 2004, 19:38:43
Quote
and I am not that familiar with eventhandlers .. could you give exact command?

As you've already gathered, no.   ;D

The point is that your question boils down to "would somebody please write my script for me", which is probably why nobody has answered.    If you're not familiar with eventhandlers, then it's your responsibility to get familiar.   There's some good stuff in the Ed Depot and the forum search function sometimes comes up with very helpful threads.    

If there's a particular aspect of eventhandlers that is confusing you, then we'd be glad to help.  ;)


Quote
?behaviour unitname == "COMBAT":blah blah.....

If you don't understand roughly what this line is getting at then read

- snYpir's Friendly Intro to code snippets
- Johan Gusafsson's Scripting Guide
- online version of the command reference, particularly the "Scripting topics" section
- unofficial command reference guide
- macguba's guide to mission editing for beginners
- snYpir's OFPEC Guide: making missions



Title: Re:Anyone out there?????? :)
Post by: CptBravo on 02 Feb 2004, 23:12:29
Hi,

I guess I did not realize a script was needed. I thought there was a basic game command that let you know when someone fired thier weapon.

Scripts are not my strongest point so if that is what needed here I'd have to forget about it.

I guess my question is ..

is there any EASY SIMPLE way of detecting group firing their weapons without a script. If not .. is there a method for spotting the enemy. So if any group member spot an enemy his group leader will report back? I will use that as an alternative.

Thanks for the help.  
Title: Re:Anyone out there?????? :)
Post by: Chris Death on 03 Feb 2004, 02:39:02
Quote
is there any EASY SIMPLE way of detecting group firing their weapons without a script

Yes - all you need has already been mentioned here.

As Macguba said, do you want to make the mission by yourself,
or do you want to get a mission by someone else?

Eventhandler "HIT" is the key, and you don't need a script
for that.

Now before i continue posting here, i want you at least to
copy/past that part of the comref, where this command is
explained over here.

Then tell us what you don't understand, and you'll receive
further help.

btw - comref u find in the editors depot (click on Macguba signature)

@Macca - i wonder how you could read my thoughts when
you posted that reply  ;D

~S~ CD
Title: Re:Anyone out there?????? :)
Post by: CptBravo on 03 Feb 2004, 05:21:34
Event handlers
    Event handlers can be defined in unit config or by function addEventHandler. Multiple handlers can be attached at one time. Event handler types are defined below. Each handler receives arguments in _this, argument types and meaning are defined below.
   
      "Hit" object:causedBy,scalar:howMuch


This was the first thing I looked up when I started. It made no sense what so ever! It looks Japanese to me as far as I am concerned.

Anyway the editor does not really explain it well enough in "plain" English to us commoners.

Not all OFP players are Guru Scripters as some have assumed. Some are accountants, lawyers and strippers! Your usual midwest mix!  ;D

So not everyone is going to understand the above that I "copied and pasted"!

Have a great day!



 
Title: Re:Anyone out there?????? :)
Post by: Chris Death on 03 Feb 2004, 15:47:57
Just for info: i also wasn't born as an OFP scripter  :)

OK, you've copied and pasted what i told you and now
i'm goin to do what i've promised to you.

First off: i just noticed that i've been talking about the
wrong eventhandler (i said "HIT", but meant "FIRED")   :-[  ;D

However that's no prob for now:

Just one more thing:

if you scroll down to the bottom in the comref, where there
are the eventhandlers, you will also find a nice entry by
General Barron: more info about eventhandlers

http://www.ofpec.com/editors/resource_view.php?id=543

Also if you do not understand a command in the comref, at least
you know then how it's correct spelling, so that you could click
on the "search" button, just to have a look if somebody else may have been asking the about the same stuff yet (believe
me, there were already plenty of them).

There are also unofficial comrefs, where you will find even
more informations about commands, based upon experiences
by others.


OK, now to your problem:

First you need to create an array of all units, you want to
monitor, wether they fired or not, and then you need to add
them the mentioned eventhandler. Also you need to initialize
a variable, which you will set to true, once somebody started
firing.

You could do that by placing a trigger:


Size: as big as it covers all those units at the start of the mission.

Activation: anybody present - once

condition: this

onActivation:  shotfired = false; shooters = thislist; {_x AddEventHandler ["fired",{shotfired = true; publicVariable {shotfired}}] forEach shooters


Now you need one more trigger, that will be waiting for the variable, and will remove all eventhandlers from these guys.
This is also the trigger, which you should use to do whatever
you wanted to do, once they started firing:


Size: 0/0

Activation: none - once

condition: shotfired

onActivation: {_x removeAlleventhandlers "fired"} forEach shooters; hint "oh no the box of Pandora has been opened"

:note - the second command (the hint message) in the onActivation field represents what you want to do there - just exchange it by whatever you.

That's it  :)

~S~ CD
Title: Re:Anyone out there?????? :)
Post by: CptBravo on 03 Feb 2004, 23:30:06
Thanks Chris for the help. It works now!
Only question is .. well I am trying to get each group leader to report firing "seperatly" "every time" he fires. So I am assuming I'll do 20 trigs for the 10 groups. Now how do you make the trig report only that specific group instead of Anybody or West side?

Thanks
Title: Re:Anyone out there?????? :)
Post by: Chris Death on 04 Feb 2004, 16:00:31
Well Captain Crunch, looks like you can't get enough  ;D

As you could see, that thingy about detecting the first few
shots wasn't really that complicated to be solved.

What you want to do now, won't be easy, and to be honest
it will require using scripts aswell.

Also it will require more variables than only one.

If you want to go further now, let me know - but as i already
said: it might happen that the solution will not fit onto only
one single A4 page.

The need for scripts here comes from the fact that you need
to avoid getting a message for each single shot, or your
screen in OFP will be filled with a lot of messages.

Also using a lot of triggers may cause your game to slow down
a little bit.

As i said: let me know if you want to go further, but don't
expect this to be solved after 5 minutes of work.

~S~ CD
Title: Re:Anyone out there?????? :)
Post by: CptBravo on 04 Feb 2004, 19:03:01
Captain Crunch??????????? Care to explain? lol

Anyway this looks to be a bit more complicated than I thought and I hate complications!! :)

And honestly the one thing I hate more is LAAAAG and with 10-15 groups it will cause a bit of lag I think.

I wonder is there an easyway around it to know when a groupd at least spots an enemy or something so as a commander you get some sort of feed back from your different groups.

Anyway thanks for the help.

CAPTAIN BRAVO (Crunch Free!)  ;)
Title: Re:Anyone out there?????? :)
Post by: Chris Death on 05 Feb 2004, 03:49:24
 :o off course you're Captain Bravo - soz - been answering
summit for Captain Crunch also somewhere, so i've mixed
that part a bit then  ;D

Yeah, as i said: it's possible, even without lag, but also it's
gonna be complicated then. It will not work by just simply
duplicating a trigger, as you want that to be seperately happen
for each group and it's leader.

~S~ CD
Title: Re:Anyone out there?????? :)
Post by: CptBravo on 05 Feb 2004, 16:10:11
Hi Chris,

It would have been been nice to have it but not crucial to the mission design. Maybe there is another way to get reprots back from groups..

Anyway how is your MOTAG going? Almost finished??! Is it going to be more than 2 players compatible?

Also did you get a chance to look at the tamplate I sent you? Anyway you can show me how to make it 2 players compatible?

Thanks again.