OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Celeriac on 18 Aug 2004, 16:21:12

Title: Rearming Kozlice without spacebar at start
Post by: Celeriac on 18 Aug 2004, 16:21:12
Hey people and folks.  :)

I am trying to add kozlice to a unit via a reload script, and done everything that works on all other weapons. Still you have to press space to "activate" the shotgun every time you get a new one. I know the selectweapon command, but kozlice doesnÂ't want to co-operate.

Is there any way to rearm a unit with the shotgun so it will have one of the 2 ammo types active at startup? Any help will be appreciated.  :P
Title: Re:Selectweapon dilemma
Post by: Tyger on 18 Aug 2004, 16:39:22
did you add one of the magazines before you added the weapon?

if you added all the mags after you added the weapon, you'll have to press space, or somthin like that

e.x.
Code: [Select]
this AddMagazine "KozliceShell"; this AddWeapon "Kozlice"
try dat
Title: Re:Selectweapon dilemma
Post by: DBR_ONIX on 18 Aug 2004, 17:05:04
Yup, thats the way
;)
- Ben
Title: Re:Selectweapon dilemma
Post by: Celeriac on 18 Aug 2004, 17:50:14
No, I have checked everything.

This is how the rearm.sqs looks like.

Code: [Select]
_Unit=_this;
RemoveAllWeapons _Unit;

_Unit AddMagazine "KozliceShell";
_Unit AddMagazine "KozliceShell";
_Unit AddMagazine "KozliceShell";
_Unit AddMagazine "KozliceShell";
_Unit AddMagazine "KozliceShell";
_Unit AddMagazine "KozliceBall";
_Unit AddMagazine "KozliceBall";
_Unit AddMagazine "KozliceBall";
_Unit AddMagazine "KozliceBall";
_Unit AddMagazine "KozliceBall";
_Unit AddWeapon "Kozlice";
_Unit SelectWeapon "Kozlice";

exit

It works on all single ammo weapons I know of, but this one is a toughie.  :-\
Title: Re:Selectweapon dilemma
Post by: macguba on 18 Aug 2004, 20:50:57
What happens if you add the weapon after one ammo type, but before the other ammo type?
Title: Re:Selectweapon dilemma
Post by: General Barron on 18 Aug 2004, 22:14:06
I remember doing this a while back, but it was on AI guys, not a player, so I'm not sure if it will work right or not. Basically, you can use a 'fired' event-handler to detect when they shoot a shell, and then add another shell to their inventory:

this addeventhandler ["fired", {if (_this select 4 == "kozliceShell) then {(_this select 0) addmagazine "kozliceShell"}}]

Not sure if "kozliceShell" is the name of the ammo fired by the gun though, but you can check it using this:

this addeventhandler ["fired", {hint format ["%1", _this select 4]}]

As long as they still have ammo in their weapon when you give them more ammo, there shouldn't be a problem. I'm guessing you are waiting until they are out of ammo to give them more.
Title: Re:Selectweapon dilemma
Post by: Celeriac on 19 Aug 2004, 15:18:53
Actually, IÂ'm making a script for a deathmatch to rearm a guy when he respawns. The weapon works fine but by a long shot itÂ's tedious to press space every time to activate the weapon.


@mac
The same as adding the weapon before, after or in middle of the whole script: no weapon active.  :-\
Title: Re:Rearming Kozlice without spacebar at start
Post by: Tyger on 20 Aug 2004, 00:08:02
is it just me or don't u have 2 do that in all mp missions

check the bis mp missions and see what they do. they're actually helpful if you can figure out the variables :)
Title: Re:Rearming Kozlice without spacebar at start
Post by: Celeriac on 20 Aug 2004, 00:22:19
@Tyger
No, you have to do it only in very poorly scripted ones because the selectweapon command helps in most cases. Try arming a non-hunter guy with kozlice, so the gun is active at start and you know what I mean.

The problem is that I know how to do this script with all other weapons. There are no info or references on a double ammo weapon like kozlice though. BIS uses shotties with AI in some missions but the bots donÂ't have to bother pressing spacebar.
Title: Re:Rearming Kozlice without spacebar at start
Post by: Tyger on 20 Aug 2004, 00:24:51
well, then im stumped. havent actully ran into this prob before, so i cant help much :P

good luck m8 :)
Title: Re:Rearming Kozlice without spacebar at start
Post by: Celeriac on 21 Aug 2004, 00:18:04
Could there be a command to make a unit change its weapon mode once, to possibly replace the spacebar "manual override"?
Title: Re:Rearming Kozlice without spacebar at start
Post by: Bluelikeu on 21 Aug 2004, 10:25:01
    I've ran into your problem several times, Celeriac. I've tried many ways to fix this problem ???. Apparently the only way to make it work is to already have the unit with the kozlice, and a Kozlice magazine on him. Then add the magazines afterwards. In your case, you were using a script to add both magazines and the weapon, you would always have to press spacebar. If you already have the weapon on him, with no magazines you still have to press spacebar. However, I've come up with a very lengthy idea. ::)

        First, add all the magazines that your entire game will be using into the init field of a unit. Then add all the weapons possible. Then activate your script and use removeallweapons _Unit. When your script activates, and the new weapon, and extra ammo is given to the unit. You will not need to press spacebar, plus your gun will be fully loaded. ;D It's that simple :o, but depending on the number of weapons you are using, it will take some time to finish.

this addmagazine "m16"; This addweapon "m16"; This addmagazine "kozliceball"; this addweapon "kozliceball"; this addmagazine "m21"; this addweapon "m21"; Hint "Does it end?"

#removed scrolling text - this is supposed to be a helpful forum, not one full of effects....
Title: Re:Rearming Kozlice without spacebar at start
Post by: Celeriac on 21 Aug 2004, 10:49:23
I appreciate it, but the idea is still blurry to me. Can you explain it step by step please?
Title: Re:Rearming Kozlice without spacebar at start
Post by: Bluelikeu on 21 Aug 2004, 12:18:10
Sorry about being vague.

Step1:
Double Click on the unit you wish to use

Step2:
Click in the init field of the unit and write the following:
This addmagazine "kozliceBall"; This addmagazine "kozliceshell"; this addweapon "kozlice"

Repeat step 2 for all weapons that you wish to use

Step3:
Initiate the script on the unit. Should remove all weapons of the unit.

Step4
Preview the mission. You should see that you don't have to press spacebar.


Notes:
You should add all the weapons and ammunition that you will be using in the mission to the init field of the unit
EX: This addweapon "m16"; this addweapon "Kozlice"
You should also add the ammunition before the weapons.

When you remove a weapon to add another, the weapons should have at least one magazine in it; you can add more ammunition if you like. And every time you remove another weapon and switch it with a different one, you will always be able to add more magazines to the weapon without having to press spacebar to select the ammo.

Basically, you declared all the ammunition and weapons you can use. And the game will think that you have all weapons and magazines one you. Disabling the problem of having to press spacebar every time you switch a weapon or start the game.

I'm not sure if it works for respawning, but it's good as a one time deal, if you know what I mean.
Title: Re:Rearming Kozlice without spacebar at start
Post by: Celeriac on 21 Aug 2004, 14:02:18
Sorry, doesnÂ't work for me.  :(
Title: Re:Rearming Kozlice without spacebar at start
Post by: Bluelikeu on 21 Aug 2004, 19:52:38
Did you remove all the magazines. If you did that it won't work, or it could be something else.

What exactly are you doing with the unit ???
Title: Re:Rearming Kozlice without spacebar at start
Post by: Celeriac on 21 Aug 2004, 21:49:07
Ah works now, had to erase the remove commands from the script, only adding mags and the shotty!  :P

Thank you, I will continue working on it on my own now.  :-*

(http://www.ofpec.com/yabbse/YaBBImages/smilies/cool2.gif)