Home   Help Search Login Register  

Author Topic: Detecting non-BIS units.  (Read 1067 times)

0 Members and 1 Guest are viewing this topic.

Offline Nemesis6

  • Members
  • *
Detecting non-BIS units.
« on: 02 Oct 2004, 14:16:41 »
Here's what I'm trying to do - In my mod, I want to add Kammak's JamToTact script, so the JAM guns have smoke effects and all that stuff, too. Now, it works if I execute the script, play as a BIS soldier, shoot a JAM unit, take his gun, and shoot it off, but the problem is - I want the JAM units to just defaultly(new word! :)) have the TactEvents effects. Now, bear in mind that the TACTEvents scripts are already activated for all default BIS units, so that's not a problem. I just need to detect if a unit isn't a default BIS one/if it's a JAM one.
I am actually flying into a star... this is incredible!

Kammak

  • Guest
Re:Detecting non-BIS units.
« Reply #1 on: 02 Oct 2004, 19:37:05 »
I'm on my way out, so this is a quickie:

Try the following condition to see if its a JAM unit:

 "JAM_WBSoldierbase" countType [_x]==1

or

"JAM_EBSoldierbase" countType [_x]==1

That covers most of the units that JAM adds, the others would be a few "crew" types and pilot types, which you could check for manually, ie:

"JAM_SoldierECrew" || "JAM_SoldierEHDCrew"

and so on.

So for example:

_isJam=false
?  "JAM_WBSoldierbase" countType [_x]==1:_isJam=true;goto "jamGuy"
"JAM_EBSoldierbase" countType [_x]==1;_isJam=true;goto "jamGuy"
? (typeOf _x) in ["JAM_SoldierECrew","JAM_SoldierEHDCrew",...]:_isJam=true;goto"jamGuy"

Where _x is an object var that you are checking.




Kammak

  • Guest
Re:Detecting non-BIS units.
« Reply #2 on: 02 Oct 2004, 20:47:37 »
I forgot the Resistance guys:

"JAM_GBSoldierbase" countType [_x]==1


Kammak

  • Guest
Re:Detecting non-BIS units.
« Reply #3 on: 02 Oct 2004, 21:21:08 »
Here's one line to check if a unit is a JAM2 unit:

Code: [Select]
if (("JAM_WBSoldierbase" countType [_x]==1) || ("JAM_EBSoldierbase" countType [_x]==1) || ("JAM_GBSoldierbase" countType [_x]==1) || (typeOf _x in ["JAM_SoldierWPilot","JAM_SoldierWHDPilot","JAM_SoldierWCrew","JAM_SoldierWHDCrew","JAM_WOfficerHD","JAM_SoldierEPilot","JAM_SoldierEHDPilot", "JAM_SoldierECrew","JAM_SoldierEHDCrew","JAM_SoldierGPilot","JAM_SoldierGHDPilot","JAM_SoldierGCrew","JAM_SoldierGHDCrew","JAM_GSniper","JAM_GMosNagSniper"])) then {<whatever code here>}

Where _x is the object variable to check.


I put the line below in a radio trigger to test it:

Code: [Select]
lCount=0;{if (("JAM_WBSoldierbase" countType [_x]==1) || ("JAM_EBSoldierbase" countType [_x]==1) || ("JAM_GBSoldierbase" countType [_x]==1) || (typeOf _x in ["JAM_SoldierWPilot","JAM_SoldierWHDPilot","JAM_SoldierWCrew","JAM_SoldierWHDCrew","JAM_WOfficerHD","JAM_SoldierEPilot","JAM_SoldierEHDPilot",  "JAM_SoldierECrew","JAM_SoldierEHDCrew","JAM_SoldierGPilot","JAM_SoldierGHDPilot","JAM_SoldierGCrew","JAM_SoldierGHDCrew","JAM_GSniper","JAM_GMosNagSniper"])) then {lCount=lCount+1}} foreach units group player;hint format["%1 Jam Units",lCount]

Make an empty mission, then create a player group and add in both JAM and non-JAM units, then use Radio 1/Alpha and the code above will tell you how many of the group members are JAM.

This will be a handy snippet for me, hope it helps you too!  :)

If you find any missing ones, please let me know.
« Last Edit: 03 Oct 2004, 06:41:52 by Kammak »

Offline Nemesis6

  • Members
  • *
Re:Detecting non-BIS units.
« Reply #4 on: 06 Oct 2004, 07:23:57 »
Makes sense, but I wonder - Are the JAM unist considered part of the "Class: men" section? Cause even if I add those scripts, it's like they just aren't executed for the said unit.
I am actually flying into a star... this is incredible!

Kammak

  • Guest
Re:Detecting non-BIS units.
« Reply #5 on: 06 Oct 2004, 07:32:41 »
I don't understand,  when you run that script above it doesn't work?  It has caught all the JAM units that I've tested it with.

I believe any human in OFP has to ultimately be derived from "Man".  Most of the JAM units are derived from a JAM-specific base class, which is different for each "side".

The remaining units that aren't derived from those JAM meta-units, are caught by the " in [<array list>]" clause, which checks the actual typeOf string against those specific class names.

What is not working?
« Last Edit: 06 Oct 2004, 07:33:34 by Kammak »

Kammak

  • Guest
Re:Detecting non-BIS units.
« Reply #6 on: 06 Oct 2004, 07:40:11 »
Remember that if you are using TACTEvents, and the player unit is *not* a Marine Assault Pack unit, you have to manually init TACTEvents for the player unit before any weapon fire effects will show up - even if you have added the "fired" EH to every unit.

Is that the issue you are having?


Offline KTottE

  • Former Staff
  • ****
Re:Detecting non-BIS units.
« Reply #7 on: 06 Oct 2004, 08:46:52 »
It's probably smarter to stick all the types in an array and check against that.

So

Code: [Select]
JAMUnitArray = ["JAM_WSoldierBase","JAM_ESoldierBase","JAM_GSoldierBase"]

if (_x in JAMUnitArray) then {<whatever code here>}

And just add in the rest of the classnames into the array.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Kammak

  • Guest
Re:Detecting non-BIS units.
« Reply #8 on: 06 Oct 2004, 09:02:34 »
No, its not smarter.  Just adds more typing and more chances to introduce typos.

There are a heck of a lot of classes in JAM2.  Far simpler to use the countType to catch 90% of them, and just iterate the ones that aren't derived from JAM meta-classes.

The script works.  I'm not sure what issue Nemesis is having.

And unless you've got a different OFP version than everyone else, that example won't work.  A string comparison won't backtrack through a class heirarchy, so checking for

_x in ["JAM_WBSoldierBase"]

will never return true, as no JAM unit is of that class type.  Its a meta class, that most other JAM units are derived from.
« Last Edit: 06 Oct 2004, 09:10:50 by Kammak »