Home   Help Search Login Register  

Author Topic: How to script this?  (Read 3921 times)

0 Members and 1 Guest are viewing this topic.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
How to script this?
« on: 13 Jan 2004, 13:25:50 »
How would one do this in a script:

You define a array of weapons _warr = [wep1,wep2,wep3,etc...]
Then you put one of these weapons to a soldier (let's call'm Sol1) and make the script check if the soldier has one of these weapons in the array...
So basicly a loop of ((primaryWeapon Sol1) in _warr) or similar should do the trick..?

That's easy (for me) compared to the next thing I need the sript to do...
I need the script to assign the unit having one of the weapons in that weapon array to a global variable so that the global variable kind of 'doubles' itself so that if more units carry weapons defined in the weapon array they each get assigned as individual global variable.
And even if two soldiers carry the 'same' weapon, so that i.e Sol1 has wep1 and Sol4 has wep1 they would still each get the individual variable...Example:

Sol1 has weapon wep1, thus becoming globalvariable_1
Sol2 has weapon wep3, thus becoming globalvariable_2
Sol3 has weapon wep24534, thus becoming globalvariable_3
Sol4 has weapon wep1, thus becoming globalvariable_4
And so on...

I'm guessing that the format command would be needed in this but I have no idea how to implement that for this use...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

PsyWarrior

  • Guest
Re:How to script this?
« Reply #1 on: 13 Jan 2004, 18:34:00 »
Greetings.

Clarification: you want to combine 2 variables (soldierName and weapon) into one global variable (sorta like this -> [Sol1, m16])?

Or something different?

-Supreme Commander PsyWarrior
-Psychic Productions.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #2 on: 13 Jan 2004, 21:36:10 »
Nope, something different...  :)

For example something like weaponCarrier_#...


Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

PsyWarrior

  • Guest
Re:How to script this?
« Reply #3 on: 13 Jan 2004, 21:42:20 »
Ah, so you want to combine the soldier and the weapon name/num into a single text string?

Like "Soldier1 has weapon 4"

or "WEST: Alpha Black 1 has M16"

so GlobalVar_1 = "Soldier1 has weapon#4"

or am I shooting randomly in the wrong direction again?  :gunman:

-PsyWarrior

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #4 on: 14 Jan 2004, 03:33:53 »
Ah, so you want to combine the soldier and the weapon name/num into a single text string?

Like "Soldier1 has weapon 4"

or "WEST: Alpha Black 1 has M16"

so GlobalVar_1 = "Soldier1 has weapon#4"

or am I shooting randomly in the wrong direction again?  :gunman:

-PsyWarrior
:D

Almost...  :)

And nope, I don't need any strings... I only need to assign the soldier who carries one of the specific weapons as a global variable...

To clarify, here's an example (not in anyway an actual code):

Code: [Select]
_grp = _this select 0
_wepArr = _this select 1
_check = 0
_nr = 0

#loop
_unit = _grp select _nr
?((primaryWeapon _unit) in _wepArr): _check=_check+1; globVar_#=_unit

?(_nr == (count _grp)): exit
_nr = _nr + 1
goto "loop"

I need to know how to implement that number given by the _check to the global variable... Meaning that the # would be the same as _check...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Unnamed

  • Guest
Re:How to script this?
« Reply #5 on: 14 Jan 2004, 11:01:11 »
I think I know what your after, but a couple of questions:

You want to monitor every guy in a unit, to see when he picks up, or if he is carrying a particular weapon?

What do you want to do once you have a list of all the units carrying those particular wepaons?

Is it for multiplayer or single player?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #6 on: 14 Jan 2004, 11:55:51 »
I think I know what your after, but a couple of questions:

You want to monitor every guy in a unit, to see when he picks up, or if he is carrying a particular weapon?
Yes... Should do both. If the weapon is given to the soldier in the briefing or if he picks it up in the battlefield...

Quote
What do you want to do once you have a list of all the units carrying those particular wepaons?
They are (of course) distributed into the global space to use in other scripts and a few triggers. Too lazy to go through all the details...  :P
I'm looking a way to improve my scripts which I wrote for making the AI deploy portable weapon systems in FDF Mod... If/when I get this particular thing sorted and tested, based on that I'll go deeper into the subject since I'm pretty sure I'll be needing a ton of help...

Anyhoo, I don't think that there's a need to store the global variables in an array or something... They do exist once they are defined... If that's is what you were after?

Quote
or multiplayer or single player?
Single player...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

PsyWarrior

  • Guest
Re:How to script this?
« Reply #7 on: 14 Jan 2004, 12:51:06 »
*ping*

Ah, now I think I see  :D .

So all you want is to check if a soldier has any one of the weapons in the weapArr array, and then assign the soldier to a global variable - which is called globalVar_# (with # being a number that increases every time?

I think you are correct in assuming that the format command could be used here. I have only really used the format command with text strings, so the code below is theoretical at best:

Code: [Select]
_count = 4; comment "example only"
format [globalVar_%1, _count] = _unit

This may or may not work - it's untested I'm afraid, because I'm at college at the minuite (and for some reason, the admin won't let me install OFP on the network. Don't know why...). However, it should be something along those lines, so experiment with it.

If nothing works, I'll do some of my own experiments when I get back.

-PsyWarrior

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #8 on: 14 Jan 2004, 13:20:02 »
*ping*

Ah, now I think I see  :D .

So all you want is to check if a soldier has any one of the weapons in the weapArr array, and then assign the soldier to a global variable - which is called globalVar_# (with # being a number that increases every time?
;D

Yep... BUT  :D as I was going to test that I noticed this needs to be more complicated  :-X
:tomato:  :beat:

If the sol1 carries wep2 -> global variable = globVar_1...
BUT if the sol1 drops/puts down the weapon and picks it up again the global variable should still stay as globvar_1 OR if the sol1 dies and someone else picks up the wep2 that guy would be assigned as globVar_1...

So as the global variable is assigned for the first time it would get 'locked' somehow to sort of match the weapon the soldier was carrying so that the same weapon picked up again wouldn't cause the globVar_# to go up... (you had a bit similar thought in one of your earlier posts...)

I hope you can get my drift from that...
English's not by native language so I may not be as clear as I wanted in explaining myself... ;)
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

PsyWarrior

  • Guest
Re:How to script this?
« Reply #9 on: 14 Jan 2004, 14:43:22 »
Aaaaaaaaaaaaaagh! :noo:

Okay... Here goes:

So if sol1 picks up weap3, globalVariable_1 = sol1.
But if sol1 drops weap3, globalVariable_1 = sol1 still.

dammit!

Right, try this -> After sol1 has been assigned to gV_1 (for short), you need to execute another script using the parameters [gV_#, sol#, _weapArr, num]. In the script:

Code: [Select]
_var = _this select 0
_sol = _this select 1
_weapArr = _this select 2
_num = _this select 3

#primaryLoop
; run a loop to check if primaryWeapon _sol in _weapArr
; If yes, goto primaryLoop. If no goto noWeap

#noWeap
_var = RES; comment "RES for Reserved"
format [globalVar_%1, _num] = _var; comment "if this works at all"
? !(alive _unit): exit

#secondryLoop
; loop to check if unit picks up weapon again
; if yes, reassign globalVar_1 to _unit. If no, loop. Also check if unit is !alive.

You also need to add some code to the original script, removing _unit from the _grp array when this script is executed - otherwise, when the unit picks up the weapon again, the main script will assign them to globalVar_13 or something.

OK?

-PsyWarrior :beat:

PS - did that "format..." thing work? Or do I have to kill myself?

Unnamed

  • Guest
Re:How to script this?
« Reply #10 on: 14 Jan 2004, 17:48:00 »
Code: [Select]
Anyhoo, I don't think that there's a need to store the global variables in an array or something... They do exist once they are defined... If that's is what you were after?

No I was just curious to know what you wanted to do as there are wealth of possible approaches, is it for one guy, 100 hundred guys e.t.c

At least you know you dont need to use arrays or something, thats a start.






Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #11 on: 15 Jan 2004, 01:37:17 »
Quote
PS - did that "format..." thing work? Or do I have to kill myself?
Nope... :(
Just says "Error Unknown Operator"...
So, are you planning to use rope, gun or what… ;)  :D

Quote
Okay... Here goes:

So if sol1 picks up weap3, globalVariable_1 = sol1.
But if sol1 drops weap3, globalVariable_1 = sol1 still.

Yes... BUT if the weapon dropped by the sol1 is picked by another dude, like sol6, then sol1 would get nilled and sol6 would become the globVar_1...
I'm starting to doubt that's this is not even possible to do...  ::)


Quote
No I was just curious to know what you wanted to do as there are wealth of possible approaches, is it for one guy, 100 hundred guys e.t.c
Well, it could be for 100 guys as well...
So, it is for more that 1 dude...


I made a list of what the sript(s) should do (if this clarifies anything...)

1. Check what weapons the soldiers are carrying and cross reference them with the weapon array. Should check only secondaryWeapon since other checks not needed.

2. If a match is found assign the soldier carrying the first match as globalVariable_1, a soldier carrying the second match as globalVariable_2, and so on...

3. If the globalVariable_1 drops/puts down the weapon he still stays as globalVariable_1.
BUT if the weapon he dropped/put down is picked up by another soldier that soldier now becomes the globalVariable_1...
Or the globalVariable_1 dies and someone else picks up the weapon from him that someone would get assigned as globalVariable_1...
So in a sense the weapon matched in the weapon array should sort of be 'toetagged' with the globalVariable_#... (Or maybe the weapon should be assigned as a global variable as well... ???)

I know this must be somewhat confusing and I just can't explain it any better...
All I know is that I have a clear 'vision' in my head what this script should do...


Here's the code I have now, did this a while while back and it's fully functional. Don't care about the global variables, they are defined elsewhere and this is only one part of currently five part script...
Only drawback this has is that you can use it only for one specific weapon and one dude...
(Well actually two as they carry the weapon in two parts...)

Code: [Select]
_nr    = 0
_pArr      = units group player - [player]
_intAmmo   = HTR_depWepAmmo

?(HTR_weaponCarrierSet == 1) && (HTR_tripodCarrierSet == 1): exit

#loopCheck
~.05
_unit = _pArr select _nr

?(alive _unit) && (_unit hasWeapon HTR_wpnToDeploy): HTR_weaponCarrier = _unit; HTR_weaponCarrierSet = 1
?(alive _unit) && (_unit hasWeapon HTR_trpToCarry): HTR_tripodCarrier = _unit; HTR_tripodCarrierSet = 1

?(_nr == (count _pArr)): exit
_nr = _nr + 1

?(HTR_weaponCarrierSet == 1) && (HTR_tripodCarrierSet == 1): goto "ammoRoutine"

goto "loopCheck"

So this checks the players groups AI who might be carrying a specific weapon and tripod and assigns them as global variables...
Why I want that weapon array for is that it would be predefined so the mission maker would not have to define it by him/herself... With this current code the mission maker needs to define the weapon in the init.sqs specificly...
Why I need the globalVariable_# thingy is that I'd like this script to be useable for more than one weapon per group without the weapon to be predefined... Now this script limits the players group to carry only one portable weapon system which needs to be predefined...

I hope this helps u to get a glimpse of what I'm getting at...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

PsyWarrior

  • Guest
Re:How to script this?
« Reply #12 on: 15 Jan 2004, 12:50:33 »
 :noo: :noo:
 :gunman:
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaagh!
Noooooooooooooo...

*bang*.

It could be that the format command only works in conjunction with another scripting command, or only works with text strings (although I think I've seen it used with other data types).

As for monitoring who is in possesion of a given weapon at any one time, I don't know if this is even possible. If there is only one instance of a weapon at any one time, it should be fairly easy to rig up a script that detects who has what weapon at which time. However, if there are multiple instances of a weapon (e.g. 3x M16, 2x M60), I can't see any way of monitoring who has what instance of which weapon at what time  ??? . At least not without getting incredibly 'credibly advanced.

Of course it could be that it is possible for OFP to differentiate between one M16 and another, which would solve most of our problems instantly!

As for the format cmnd, what does it say is the unknown operator? And try this to see if you can get a text string to output:

hint format ["globVar_%1", _nr]

If that doesn't work, then something else is messed up. It's also possible that the understrike (_) is messing it up. Try stuff like "globVar%1" or "globVar-%1".

And next time you add a feature to this script, myself and PsySniper will be knocking on your door. With a 200mm shell...

-PsyWarrior

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #13 on: 15 Jan 2004, 13:53:37 »
It could be that the format command only works in conjunction with another scripting command, or only works with text strings (although I think I've seen it used with other data types).

As for the format cmnd, what does it say is the unknown operator? And try this to see if you can get a text string to output:

hint format ["globVar_%1", _nr]

If that doesn't work, then something else is messed up. It's also possible that the understrike (_) is messing it up. Try stuff like "globVar%1" or "globVar-%1".
Works fine if you use it as hint format but if you use it like format ["globVar_%1",_nr] = _unit you'll get the error... So 'tis the = _unit that causes it...

I think the format needs to be defined separately before using it as the global variable... Not tested yet though...

As for monitoring who is in possesion of a given weapon at any one time, I don't know if this is even possible. If there is only one instance of a weapon at any one time, it should
be fairly easy to rig up a script that detects who has what weapon at which time. However, if there are multiple instances of a weapon (e.g. 3x M16, 2x M60), I can't see any way of monitoring who has what instance of which weapon at what time  ??? . At least not without getting incredibly 'credibly advanced.
I've had it working so that if you use different kinds of weapons like portable TOW, portable Konkurs and portable Heavy Machinegun at the same... Made it work with the current script of mine, only downside being that I had to copy/paste and rename all the global variables and the scripts to make it work... Very very feeble...  >:(

Maybe we need a new section to these forums; 'Incredibly Impossibly Advanced Scripting'  ;D
(Just kiddin'....  ;) )

And next time you add a feature to this script, myself and PsySniper will be knocking on your door. With a 200mm shell...
:D ;D :P
Oh I haven't told you even the half of the features I'd like this (these) scripts to perform...  ;)

Maybe I still should go and buy some Class 4 Armor and Laser shielding...  :D
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

PsyWarrior

  • Guest
Re:How to script this?
« Reply #14 on: 15 Jan 2004, 15:47:29 »
 >:(

Anyway, if you want to use the format command in this way, I think you have to remove the speech marks ["globVar_%1"...] should be [globVar_%1...] or you will end up formating globVar_# as a string rather than as a variable.

excuse me a minuite...

LOAD WEAPONS!

As I was saying, I'm kind of out of ideas at the moment, so I will try some stuff when I get home, and update you then.

AIM!

If you discover a way around this, please post it up or i'll be spending hours trying stuff out for nothing... and that would be bad. Very bad.  >:(

FIRE!

 :gunman:
 :gunman:
 :gunman:
 :gunman:
 :gunman:

-PsyWarrior

Offline MachoMan

  • Honoured
  • Former Staff
  • ****
  • KISS, Keep it Simple Stupid
Re:How to script this?
« Reply #15 on: 15 Jan 2004, 16:26:00 »
OK i think the answer is suprisingly easy:

Code: [Select]
;   -  ECP TEAM -
;=====================
;      MachoMan
;=====================
;WeaponCheck.sqs
;=====================
;Scipt will take 2 arrays
;_this select 0 -> Units
;_this select 1 -> Weapons
;selectedUnits -> Global Variable result

_units = _this select 0
_weapons = _this select 1
selectedUnits = []
_iterator = Count _units

#unitsLoop
_unit = _units select (_iterator-1)
; Iterator -1, because array starts @ null.
"?(_unit hasWeapon _x): selectedUnits = selectedUnit + [_unit]" foreEach _weapons
_iterator = _iterator-1
?(_iterator > 0):goto "unitsLoop"
exit

In essence i rewrote the foreEach function, so that u can use a double foreEach.  ;)

IF u rewrite it into a .sqf u can even have it return the array.
« Last Edit: 15 Jan 2004, 17:42:04 by MachoMan »
Get those missions out there you morons!

Unnamed

  • Guest
Re:How to script this?
« Reply #16 on: 15 Jan 2004, 17:39:05 »
You could use the In command to check against an array of weapon names as strings.

Code: [Select]
If ((SecondaryWeapon _Unit) In _Weapons) Then {selectedUnit=selectedUnit + [_unit]}

You may need to add something to delete a unit from selectedUnit, if it has been killed or has dropped the weapon?

I'm quite interested in this myself, I would like to do the same with Mortars, perhaps with three or four individual components. But this would be limited to mortar crews only.

As I only had a small number of guys in mind, and just need to add the appropriate action menu options. I thought of launching a simple script for every possible mortar crew. It looks like something like:

Code: [Select]
_Unit=_This select 0

_LastWeapon=""
_ActionID=-1

#Loop

~1

_Weapon=SecondaryWeapon _Unit

If (_Weapon!=_LastWeapon) Then {If (_LastWeapon In CheckWeapons) Then {RemoveAction...e.t.c} ; {If (_Weapon In CheckWeapons) Then {AddAction....Deploy.sqs...e.t.c}}

_LastWeapon=_Weapon

If (Alive _Unit) Then {goto "Loop"} Else {RemoveAction...e.t.c}

I'ts basic enough to probably allow quite a few copies running in the background.
« Last Edit: 15 Jan 2004, 17:40:07 by Unnamed »

PsyWarrior

  • Guest
Re:How to script this?
« Reply #17 on: 15 Jan 2004, 17:46:22 »
Wait a moment, I don't get it  ???

I may be slow and stupid, but I don't see how this solves the initial problem of numbering a global variable (globVar_#).

Can someone enlighten me? Please? Before I start losing sleep over this.

 :(

-PsyWarrior

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #18 on: 15 Jan 2004, 21:00:03 »
 :cheers: Thanks to you all for the input...

I can't really tell you guys anything new since I've been very busy today and will be tomorrow so I may not be able to test anything for a couple of days...  :'(


@PsyWarrior: removing the "" from the format thingy does not work... Tested that already...   :-\
Oh, and please do not use all your free time for me...  :D
Or loose your sleep over this... I haven't..  ;)


@MachoMan
Oh, took me a while to see what you were getting at... And I'm still not quite understanding it  :D
"?(_unit hasWeapon _x): selectedUnits = selectedUnit + [_unit]" foreEach _weapons
I have always problems understanding these "_x this and that" those things... :(

It just so sad since I know that once this particular problem gets solved the next one is there waiting and it's propably much more complicated than this... :-\


@Unnamed
Yup... That certainly would be another way...

Sure, your code looks like it should work...
And I'm not meaning that this script of mine should run for 100 guys... That would too much firepower on the battlefield...  :P

Just so that i.e. the players group could have 1-3 portable weapon systems with them... or more, depending on the mission maker...

I have fully working beta of my AI deploy scripts in small circulation so if you're interested I could post a link where to get it... Needs FDF Mod 1.2 though...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline MachoMan

  • Honoured
  • Former Staff
  • ****
  • KISS, Keep it Simple Stupid
Re:How to script this?
« Reply #19 on: 15 Jan 2004, 21:55:03 »
@HateR_Kint

I'm not sure weather this is what u meant (didn't fully understand your first post  ;) ), but i thought u wanted a script that would create an array of units who have a weapon located in another array.

Code: [Select]
"?(_unit hasWeapon _x): selectedUnits = selectedUnit + [_unit]" foreEach _weapons
I'll explain this. It checks weather _unit has _x, where _x is each of the weapons in _weapons.
Get those missions out there you morons!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #20 on: 15 Jan 2004, 23:17:43 »
I'm not sure weather this is what u meant (didn't fully understand your first post  ;) ), but i thought u wanted a script that would create an array of units who have a weapon located in another array.

Code: [Select]
"?(_unit hasWeapon _x): selectedUnits = selectedUnit + [_unit]" foreEach _weapons
I'll explain this. It checks weather _unit has _x, where _x is each of the weapons in _weapons.

Ah...

Well, actually I didn't want any arrays (why, I don't know...) at first but now I'm leaning to the direction that it would be the best solution...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

PsyWarrior

  • Guest
Re:How to script this?
« Reply #21 on: 16 Jan 2004, 10:50:29 »
I suppose in the end it might actually be better to use an array instead of lots of numbered global variables. In an array, all the positions are already numbered (array select 0, 1, etc.).

For instance, instead of
sol1 has weap3, and goes in globVar_0,
you would have:
sol1 has weap3, and goes in globArr select 0.

i.e. (globArr select 0) = _unit

This removes the need for numbered variables completely. ;D

Try it...

-PsyW

Offline MachoMan

  • Honoured
  • Former Staff
  • ****
  • KISS, Keep it Simple Stupid
Re:How to script this?
« Reply #22 on: 16 Jan 2004, 12:15:49 »
I suppose in the end it might actually be better to use an array instead of lots of numbered global variables. In an array, all the positions are already numbered (array select 0, 1, etc.).

For instance, instead of
sol1 has weap3, and goes in globVar_0,
you would have:
sol1 has weap3, and goes in globArr select 0.

i.e. (globArr select 0) = _unit

This removes the need for numbered variables completely. ;D

Try it...

-PsyW


Yep, ofcourse it's better to use arrays, anything else will make using the data kinda hard, since u do not know how many global variables there will be.
If u use an array u always now there is 1 variable, the array itself, and if u want to know how many vars are in the array just use count.
Get those missions out there you morons!

PsyWarrior

  • Guest
Re:How to script this?
« Reply #23 on: 16 Jan 2004, 12:21:55 »
It's just a pity to have expended all that brainpower to try and get the format command to work.
Still arrays are more efficient and will probably do everything that HateR_Kint wants them to do.

I hope... ::)

-PsyW
« Last Edit: 16 Jan 2004, 12:23:01 by PsyWarrior »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #24 on: 16 Jan 2004, 14:02:41 »
Yep, ofcourse it's better to use arrays, anything else will make using the data kinda hard, since u do not know how many global variables there will be.
If u use an array u always now there is 1 variable, the array itself, and if u want to know how many vars are in the array just use count.
I was just about to say the same thing...   :P
Now once you think of it the format thingy would've been useless as you pointed out...

Quote
It's just a pity to have expended all that brainpower to try and get the format command to work.
Agreed...  :(


I hope that I find the time during the weekend to test these things...
I'll report back then...

 :cheers:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #25 on: 19 Jan 2004, 00:07:42 »
 >:(

I'm starting to believe that I'm trying to chew too big a piece with this...

The MachoMans script works fine, and I'm still wondering why in the name of all that is holy I didn't come up with it myself...
------
 
As I'm trying make the AI deploy the portable weapon systems (specially in FDF Mod...) so the weapon takes two guys to carry it; the other carries the weapon part (like Machine Gun or TOW tube) and the other carries the tripod (a 'dummy' weapon), so I had to 're-write' the MachoMans script a bit to get two arrays; units who carry the weapon and units who carry the tripods... This also works like a charm...

The current script 'bundle' I've made does make the AI deploy these weapons, but only with one weapon per group and that weapon needs to be specified by the mission maker...
What I need to achieve now is that the mission makers wouldn't have to specify the weapons him/herself as they would be defined in the scripts already. This would free the mission maker to use any of the portable weapon systems without a worry... This is why I needed that units weapons compared to the weapon array... I also hoped that this would 'enable' the use of more than one weapon of the same kind, in other words you could have two iTOWs, two Konkurs' and so on...
The current scripts do not support that feature...

Can be done so far: with array of weapons and array of tripods I can have the corresponding array of weaponcarriers and array of tripodcarriers... A big thanks to you guys… This does liberate mission maker from the definition process…

The next problems are so complex in a way that I just can't explain them to you… Instead I'll make a numbered list what features the script(s) should have and answer your questions should there rise any. And I'm NOT (bur hey, not stopping you either  ;) )asking you to write any scripts for me, merely just a ‘professional' opinion wether these ‘features' are even possible to code:

1.Check who carries which weapons. If there's portable weapons present  make arrays of the units who carry the weapon part and units who carry the tripod part. DONE.

2.Then check for ‘pairs' so that the weapon carrier and the unit who carries the tripod for that weapon are defined as weaponCarrier and tripodCarrier for that particular weapon. TODO.

3.Add an action per ‘pair' for the player so that the first ‘pair' responds to the first action and so on. Name the action relating the weapons name (maybe I'll need an array of names also…). TODO.

4.When an action for weapon deploy is called the ‘pair' ‘belonging' to that certain action performs the deploy process. TODO.


As said, I'm running out of ‘talent' with this thing  â€¦
So again, I may be up to something too big for me, as usual...  :-\

Here's (save target as…) the current version of the scripts I have working, WITHOUT the array ‘features' and such… The original one specific weapon version…
Needs the FDF Mod 1.2
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline MachoMan

  • Honoured
  • Former Staff
  • ****
  • KISS, Keep it Simple Stupid
Re:How to script this?
« Reply #26 on: 19 Jan 2004, 11:08:34 »
Ok all can be done, and are actually not that hard.

Let's start with script 2:
There are multiple ways to get this thing done, all of them use arrays for storing the names of the weapons and their ammo and tripods in arrays.

The best way (in my opinion), would be to use 2D arrays.
I will give u a simple example:
Code: [Select]
gunsAndAmmo = [ [m16, m16mag], [ak47, ak47mag], [m4, m4mag] ]

I think u'll get my point ;)

Ok now use this kind of an array to check if a unit has a weapon, then u use the second name in the array to see if another unit hase the tripod.

Again it's not really as hard as it looks  ;)

As my title says: KISS  ;D
« Last Edit: 19 Jan 2004, 11:09:41 by MachoMan »
Get those missions out there you morons!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:How to script this?
« Reply #27 on: 19 Jan 2004, 11:41:40 »
The best way (in my opinion), would be to use 2D arrays.
I will give u a simple example:
Code: [Select]
gunsAndAmmo = [ [m16, m16mag], [ak47, ak47mag], [m4, m4mag] ]

I think u'll get my point ;)

Ok now use this kind of an array to check if a unit has a weapon, then u use the second name in the array to see if another unit hase the tripod.

Again it's not really as hard as it looks  ;)

As my title says: KISS  ;D
Again something I never even thought of  >:(

I have no problem in KISS, but I think I'd bee needing TISS, think it simple stupid...  ;D

thnx
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.