Home   Help Search Login Register  

Author Topic: CSL Weapon Switching - Updated V1.3 (ACCEPTED)  (Read 8348 times)

0 Members and 1 Guest are viewing this topic.

CSL Weapon Switching - Updated V1.3 (ACCEPTED)
« on: 03 Sep 2007, 13:22:50 »
*** Updated V1.3 ***


This script allows you to easilly have a unit carry 2 primary weapons. For
example, it will allow you to equip a sniper with both an M24 and an MP5SD5.
It was originally made for the mission titled CO 1-2 Operation Shining Anvil to
enable the player sniper to carry an MP5 as well as the sniper rifle.  I
thought that it would prove to be very useful for some people.  As always,
feedback, bug reports, etc are welcome.
 
Features:
     This script will work regardless of addons used.

     Using this script will not give the players free rounds if they switch
     weapons before a magazine is empty.  They will retain the magazine with
     the spent rounds.

     Animation and sound played when the player switches weapons.

     This script does not give the players extra ammo space, requiring them to
     carefully balance their ammunition selections.

     The player can pick up and drop weapons in either weapon slot at will.

     Supports Join in progress, teamswitching, and all respawning modes.

Compatibility:
     Tested Armed Assault v1.08 compatible.  Older Versions not tested. It
     should work on any later version.

Multiplayer:
     100% MP compatible.

Issues:
     There are 3 known issues that can not or will not be corrected due to arma
     limitations.

     1: The secondary weapon slot cannot be accessed inside the gear dialog on
     mission start.  This is completely unchangable.  I attempted to make an
     optional modified gear dialog for v1.1, but could not get arma to populate
     it.  If you figure out a way to fix this somehow, be sure and let me know.

     2: If you use the scripts on a very unusually sized unit, the algorithm to
     detect what posture the unit is in may fail.  For example, a 50 foot giant
     would always return standing, and a 2 foot midget would always return
     prone.  I consider this to be a minor issue.

     3: It is possible to equip a large weapon (such a pk or m240) and an AT
     weapon at the same time using the following process.
          A: Switch to weapon slot you wish to arm with both heavy weapons.
          B: Pick up a machinegun or any weapon weapon considered to be large.
          C: Switch to the other weapon slot.
          D: Pick up the AT or AA weapon.
          E: Upon switching to the weapon slot with the large weapon, both
          the heavy weapons will be available.
     While this is a potential cheat, it is at least counterbalanced by the
     fact that these weapons have large bulky ammo.  Since this script does not
     give the player extra ammo space, it will actually place a heavy handicap
     on the player that attempts to do this.  The only way to fix this problem
     would be to require that all weapons be defined, which would make this
     script much less flexible.

Download:
     CSL Weapon Switching V1.3 Courtesy Of Armaholic.com

Hosting:
     You can host this anywhere you want, but if you let me know via PM on the
     BIS forums, I'll add a link in the download thread and let you know if I
     patch it.  I'd also prefer if you included a link back to the home page,
     as this is where I'll be posting updates, answering questions etc.

Usage:
     It is strongly reccomended you view the demo missions before attempting to
     use this.

     Full instructions are found in the readme.

Version History:
V1.3:
     Fixed a save game related bug that slipped in probably in v1.1 but
     remained undetected for reasons unknown.  Thanks to undeceived for
     reporting it.

     Fixed a small bug that nobody had yet reported.  Would have caused
     problems when using the script on multiple units with teamswitching on.

V1.2:
     Fixed a small mp bug involving running the script on a unit that doesn't
     exist due to the unit being disabled either by the player or the mission
     designer.

     Parameters simplified slightly.

V1.1:
     Units now play the correct reloading animation per their stance thanks to
     Mandoble's function to detect it.

     A couple of scripts are now built in to handle respawning, so you don't
     have to do it yourself.  One preserves the unit's current equipment on
     death, and respawns him with it.  The other, resets his equipment to
     starting every time he respawns.

V1.0:
     Release

License:
     Unlimited rights (including editing and rereleasing) so long as it's non-
     commercial and adheres to the BIS terms of use.  Any derivative work
     cannot be more restrictive than this with respect to what rights an end
     user has.

     Note that use of Mandoble's function must conform to his requirements, not
     mine.

Credits:
     Special Ed for prompting me to write this script in the first place and
     helping with the MP testing.
     Mandoble - Wrote the function to get the unit's posture.
     Tack Of The 10th Mountain Division - Testing
     Super - Six Of The 10th Mountain Division - Testing
     Matt Rochelle - Bug Report, error when run on a disabled unit.
     Undeceived - Bug Reprt, save game related.
« Last Edit: 21 Feb 2008, 20:13:23 by ColonelSandersLite »
Everything I have released for ARMA can be found here.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: CSL Weapon Switching (TESTING)
« Reply #1 on: 03 Sep 2007, 15:06:50 »
Quote
2: Due to inability to determine if a unit is prone, crouched, or
     standing, this script always uses the crouched animation when changing
     weapons.  The prone animation has been tried, but it honestly looked
     pretty bad.  Crouching seems to be a fair compromise all around.  Note
     that this animation is here in the first place to prevent the player from
     being able to instantly reload their weapons so removing it would be sort
     of a cheat.

http://www.ofpec.com/forum/index.php?topic=29174.0

 :D Looks great - maybe a pic to demonstrate? (I guess you won't actually see both weapons at the same time, right?)

Wolfrug out.

"When 900 years YOU reach, look as good you will not!"

Re: CSL Weapon Switching (TESTING)
« Reply #2 on: 03 Sep 2007, 15:21:20 »
Thanks, I'll have to look into his method.

Yeah, a pic wouldn't actually show much.  It would require a video, and frankly,  I don't have a clue what I'm doing with that.
Everything I have released for ARMA can be found here.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: CSL Weapon Switching (TESTING)
« Reply #3 on: 03 Sep 2007, 15:40:17 »
I was going to also suggest looking at mandobles getpos function.

This is just a general question but is it possible replace the gear screen with your own gear dialog and have it act in the same fashion as your script?
Xbox Rocks

Re: CSL Weapon Switching (TESTING)
« Reply #4 on: 03 Sep 2007, 22:18:47 »
That's a definate maybe, but probably not.  :D

To be more precise, I could probably modify the gear UI itself to do it with little difficulty.  The thing is that it'll be populated by arma game code that I couldn't touch or even see.  It's worth a try I guess, but I wouldn't put my hopes into it.

Also, it would have the dramatic downside of making any mission that use it require it as an addon, which is a real problem for mp.
Everything I have released for ARMA can be found here.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CSL Weapon Switching (TESTING)
« Reply #5 on: 07 Sep 2007, 21:29:11 »
Have a question, why do you need a user defined global var name for each unit? why dont you use a common variable per each soldier, for example CLS_Multyweapon? You only need to handle it as a vehicle internal variable (unit setVariable ["varname", value] and unit getVariable varname.

Aside of that detail, the script works well. Do you plan to add anything new to it?

Re: CSL Weapon Switching (TESTING)
« Reply #6 on: 07 Sep 2007, 21:38:23 »
Ah, that's because setVariable is local to the machine it's set on, and I needed a variable that would transmit across machines to support various MP functions.

I'm not sure of the preservative behaviours of a variable set by the setVariable command when a unit changes locality through various methods, and for one reason or another, I just didn't test it out.  You know the old saying, stick with the devil you know?  That was pretty much my logic.  Maybe before I update it to include decting the posture of the units correctly, I'll check it out to be sure.  Unless someone here can tell me the behaviour of that off hand?


Edit:
Oh, by the way, I did play with modding the gear screen to handle multiple weapons, and I couldn't get the game to populate it as I expected.
« Last Edit: 07 Sep 2007, 21:40:50 by ColonelSandersLite »
Everything I have released for ARMA can be found here.

Offline MattiusRochelle

  • Members
  • *
Re: CSL Weapon Switching (TESTING)
« Reply #7 on: 08 Sep 2007, 14:12:23 »
very nice.

Offline MattiusRochelle

  • Members
  • *
Re: CSL Weapon Switching (TESTING)
« Reply #8 on: 08 Sep 2007, 23:01:27 »
Ive added this to a BASE Respawn map and im having trouble when the player dies. Ive looked at your readme and i made this trigger.


Repeadly
Condition: !(Alive Multi1)
Activation: _scriptHandle = [[Multi1, "M24", "CSL_ReloadSound", "Multi1_CSLWeaponSwitchingSwap"]] execVM "CSL_WeaponSwitching\CSL_WeaponSwitching_V1.0_Main.sqf";

but doesnt work on the server so i tried

Condition: !(Alive Multi1) && Local Server

Which gives errors

Which way do/would you use to make this work :)

Offline MattiusRochelle

  • Members
  • *
Re: CSL Weapon Switching (TESTING)
« Reply #9 on: 09 Sep 2007, 00:44:23 »
Each time i get this

Quote
Error in expression <_scriptHandle = [[Multi2, "M24", "CSL_ReloadSound", "M>
  Error position: <= [[Multi2, "M24", "CSL_ReloadSound", "M>
  Error Local variable in global space
Creating debriefing
Error in expression <_scriptHandle = [[Multi3, "M24", "CSL_ReloadSound", "M>
  Error position: <= [[Multi3, "M24", "CSL_ReloadSound", "M>
  Error Local variable in global space


Re: CSL Weapon Switching (TESTING)
« Reply #10 on: 09 Sep 2007, 10:12:21 »
Ok,

I'll see about rigging up a demo with respawning stuff enabled.

3 points to consider in the meantime.

1: isLocal server is antiquated, and should be replaced with isServer.  The old works, but the new is genuinely better.

2: The script should be run on all machines, not just on the server.

3: The error message is caused by you using a local variable in the on activation field.

Specifically, _scriptHandle should be some global variable, not a local.






V1.1 will be released as soon as it's tested in a true mp environment.
Changes:
Units now play the correct reloading animation per their stance thanks to Mandoble's script to detect it.

A couple of scripts built in to handle respawning, so the user doesn't have to do it himself.  One preserves the unit's current equipment on death, and respawns him with it.  The other, resets his equipment to starting every time he respawns.  Retrospectively, that should have been in there to begin with.
« Last Edit: 09 Sep 2007, 13:36:13 by ColonelSandersLite »
Everything I have released for ARMA can be found here.

Offline MattiusRochelle

  • Members
  • *
Re: CSL Weapon Switching (TESTING)
« Reply #11 on: 09 Sep 2007, 17:04:54 »
Excelent, ill add it into my map when its done and also test it.  :good:

you have done a great job though it works perfectly.  :good:

Re: CSL Weapon Switching - Updated V1.1 (TESTING)
« Reply #12 on: 13 Sep 2007, 05:39:57 »
Updated V1.1.  See top post for details.
Everything I have released for ARMA can be found here.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: CSL Weapon Switching - Updated V1.1 (TESTING)
« Reply #13 on: 13 Sep 2007, 10:02:32 »
@MattiusRochelle
Double posting is not allowed here.
If you have something to add to your post after a short period of time modify it instead of replying to yourself...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: CSL Weapon Switching - Updated V1.1 (TESTING)
« Reply #14 on: 13 Sep 2007, 13:07:26 »
Nice job on this. I found it a very useful feature in your mission. :good:
Would be good though if you could change the secondary weapon, eg. on the gear selection list, but that would require making a new addon with some config stuff. Anyway, it's very useful script.