Home   Help Search Login Register  

Author Topic: second weapon option  (Read 2007 times)

0 Members and 1 Guest are viewing this topic.

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
second weapon option
« on: 18 Oct 2011, 21:20:49 »
Hi,

Im trying to make a script who add the second weapon option, I don't know if you can understand me. Well I've tried severals way but no one work for me, I'd want to know if there's some script for that...

My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: second weapon option
« Reply #1 on: 18 Oct 2011, 21:47:28 »
I believe this script works:

Code: [Select]
_guy = _this select 0
_pos = getpos _guy select 2
~1
_holder = "weaponholder" createvehicle getpos _guy
~1
;------------Edit Weapon Here-----------------
_holder addmagazinecargo ["HK",3]
_holder addweaponcargo ["HK",1]
;-------------------------------------------------

#loop
?vehicle _guy !=_guy: goto "loop2"
_holder setpos [(getpos _guy select 0),(getpos _guy select 1),(getpos _guy select 2)-0.5]
~0.1
goto "loop"

#loop2
?vehicle _guy ==_guy: goto "loop"
_holder setpos [(getpos _guy select 0),(getpos _guy select 1),(getpos _guy select 2)+500]
~0.1
goto "loop2"
exit

This basically creates a weapon holder (like a crate) directly below the player, allowing him to access another weapon. In this script the second weapon is an HK, but you replace it with any weapon of your choice.

I believe SBG made a script similar to this in his Kolgujev Contract mission, which I hear is more efficient (though I think the disadvantage with it is that the crate cannot be accessed when the player is in a guard tower)
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: second weapon option
« Reply #2 on: 20 Oct 2011, 02:15:53 »
Ok thanks I'll try it, but another question... we say: "if I want to shoot with a ak47 30/4 and then it has 14/4, well, now I change it by a m16, m16 has 30/4 magazine. Now my question is Can My unit or me have the ak47 with 14/4 magazines with the second option?
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: second weapon option
« Reply #3 on: 20 Oct 2011, 13:27:06 »
Do you mean that when you access the second weapon you want it to have 14/4? I'm not sure about that. If the AK was the main weapon then it might work.

"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: second weapon option
« Reply #4 on: 21 Oct 2011, 02:23:04 »
You can list which primary weapon type  the player possesses, what magazine types and then count how many of the type you seeking, but there is no command in existence to count bullets or rounds per magazine that I am aware of.

Offline Aldo15

  • OFP-addict
  • Former Staff
  • ****
    • My OFP missions
Re: second weapon option
« Reply #5 on: 25 Oct 2011, 22:04:17 »
I want tomake like some warfare games for example... Modern Warfare or medal of honor. You can use two weapons, we say aM14 and a ak47 or some onther weapon. As you can see we can use those two weapons, and you cahnge them they always appear wit the last magazines. I don't know if you guys are understanding but I don't know how to say you it.
My OFP stuff
FMF Project by Aldo15. Coming soon.
If in the high school or university, Teachers add a new subject about how to make scripts, missions, for ofp. I'd be number one of my classroom

Walter_E_Kurtz

  • Guest
Re: second weapon option
« Reply #6 on: 26 Oct 2011, 01:50:14 »
The script Gruntage quoted is by Blip. The problem you are having stems from the 'crate-like' behaviour of objects where magazines are automatically reloaded when weapons are taken. You can test it for yourself on crates, vehicles, or, as shown in the script, weaponholders. BUT IT DOES NOT APPLY TO DEAD BODIES!


Place a soldier far out of the way. Name him ColdDeadHands and set his health to zero. Remove all his weapons. IF YOU WANT, edit his Init line to load him with a weapon and magazines that the player can swap with straight away, for example:
      removeAllWeapons this
      removeAllWeapons this; this addMagazine "HK"; this addMagazine "HK"; this addMagazine "HK"; this addWeapon "HK"


In the init line of the player write:
      player addAction ["Switch Weapons", "WEK_SwitchWeapons.sqs"]


Code: (WEK_SwitchWeapons.sqs) [Select]
if (primaryWeapon ColdDeadHands == "") then {goto "PutWeapon"}

; Swap Weapons
player action ["Take Weapon", ColdDeadHands, 0,0, (primaryWeapon ColdDeadHands)]
exit

; Put Weapon (because there was nothing to swap)
#PutWeapon
if (primaryWeapon player == "") then {hint "No weapons to swap between."; exit}
player action ["Drop Weapon", ColdDeadHands, 0,0, (primaryWeapon player)]
~1
ColdDeadHands action ["Take Weapon", player, 0,0, (primaryWeapon player)]
exit

Edit: updated the script for situations when the player has discarded one weapon and hence has nothing to swap with - in this circumstance the weapon is transferred to ColdDeadHands and the player is free to pick up something else. Although you can take weapons from dead bodies, you can't put them; they have to go via the empty crate.

Edit 2: But then again, dead bodies can take weapons directly from you. Spooky! This means an intervening crate is no longer required.

Edit 3: Realised that using a civilian with only 4 magazine slots might cause a problem - use a soldier instead.

Edit 4: Used primaryWeapon to select ColdDeadHands' weapon as well as the player's - now more consistent and hopefully a smidgen faster.
« Last Edit: 26 Oct 2011, 13:52:16 by Walter_E_Kurtz »