What scripting code/command allows the Engineer to collect?

Ask questions, discuss ideas, get answers
professor_smith
Posts: 133
Joined: Thu Dec 13, 2012 7:45 am

What scripting code/command allows the Engineer to collect?

Post by professor_smith »

Hello,
Recently, while play testing my mod HTroop, I ran across a slight problem I just cannot seem to figure out. My engineer cannot collect mines as they have always been able to do. I select the repair pack/wrench item, crouch over the mine and "start repairing it", and it will not pick it up/collect it. It will however, collect/pickup explosive packs. Can someone tell me what scripting command line controls the engineer's ability to collect/pickup mines, and what file(s) it would be in?

Thank You,

Professor Smith
Lets make war games, not war.
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: What scripting code/command allows the Engineer to colle

Post by Apache Thunder »

The mines in question need to have network info enabled. Take a look at the vanilla landmine code as an example. ;)

Trying this on mines set by PCOs instead of soldiers may cause a crash hence why some mods may have removed the net code from the mines. Mines fired from handweapons should still have the net code.

Also the game may be hardcoded so that only the "RepairPack" can pick up mines. If you got a custom handweapon that uses a different name and try to use it as a wrench, it may not work for picking up mines. The behavior of the C4/TNT is also hardcoded thus the "detonator" handweapon only works on the ExpPack and visa versa.
ImageImageImage
I have cameras in your head!
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: What scripting code/command allows the Engineer to colle

Post by Vilespring »

Just asking this while it is semi-relevant, what allows the expack and detonator to be in the same slot, cycled by right click? Because I'm thinking of making a weapon being able to change from semi-auto to automatic by this method.
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: What scripting code/command allows the Engineer to colle

Post by Apache Thunder »

The "detonator" uses a hardcoded index number. It's index 11. Since it's not used on the keyboard anywhere (vanilla BF1942 only has up to 6 normal weapons on a kit, though meme file edits to the ingame HUD can unlock up to 8 or 9 if you are willing to move the parachute key) The game always expects the detonator to use index 11. So the ExpPack is hardcoded to "switch" to the detonator on index 11 when you right click or when you use up all the ammo.

So it seems as if there is two weapons on the same slot when in fact the detonator is on a special index that the ExpPack switches to after depleting ammo or right clicking.
ImageImageImage
I have cameras in your head!
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: What scripting code/command allows the Engineer to colle

Post by Swaffy »

So I can put a pistol in slot 4 and a knife on slot 11 and I can switch between them? Or do you mean the weapon's name is hard coded?
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: What scripting code/command allows the Engineer to colle

Post by Apache Thunder »

I am pretty sure the game is hardcoded for those specific handweapon names to have that functionality.

I at one point tried to use a custom handweapon with the detonator, but got a CTD about the detonator not being able to find the "ExpPack". So being able to use something like you said in this system isn't likely to work unfortunately. :(
ImageImageImage
I have cameras in your head!
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: What scripting code/command allows the Engineer to colle

Post by Vilespring »

couldn't I use the names of Expack and Detonator and then edit their names in the Lexcon.all to edit the kill names, to do the semi/auto battle rifle?
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: What scripting code/command allows the Engineer to colle

Post by Apache Thunder »

Yeah if you want replace the expack/detonator without renaming them, then yes doing it from the Lexicon should work. It's the object template names that must be the same. The Lexicon could have it show up with whatever name you want in the in kill messages/GUI.
ImageImageImage
I have cameras in your head!
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: What scripting code/command allows the Engineer to colle

Post by Vilespring »

hehe. I would just loose explosives, so I do not know if it is a good trade off...
probably good for custom maps. I just need to figure out how to make animations work in my new guns... :|
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
professor_smith
Posts: 133
Joined: Thu Dec 13, 2012 7:45 am

Re: What scripting code/command allows the Engineer to colle

Post by professor_smith »

Vilespring,
I am going to copy and past a tutorial I found that helped me a lot with creating custom weapons and editing their animations:

STEP 4: Animations Scripting
The animations directory contains the scripting files, the animation files and the skeleton file which the game engine uses to animate every object in BF: 1942.
The “SG44.ske” file will define how the skeletal structure of the animations will work in-game (how the arms holding the gun will move while running, reloading, firing, etc.)
• Enter the “animations” directory.
• Copy the “SG44.ske” file

• Rename the new file to “M16.ske”.

The BF: 1942 engine has built-in support for adding new weapons. This support allows you to put your additions and changes into new files instead of modifying and potentially ruining the existing game files. Instead of requiring you to edit the original files, the BF: 1942 engine allows you to make the following new files as additions: (“singleShotWeaponsmod.inc”, “multiShotWeaponsmod.inc”, and “AnimationStatesmod.con”).
**NOTE: The game engine will only recognize these three new filenames.
Because this weapon we are adding is a machine gun, we will use the “multiShotWeaponsmod.inc” file and not the “singleShotWeaponsmod.inc” file.
• Create a new text file called “multiShotWeaponsmod.inc”.
• Open “multiShotWeaponsmod.inc”.
• Add the following line: “AnimationStateMachine.copyState2 M16 v_arg1”.

• Close and save this file.
This line tells the BF: 1942 engine that a weapon named “M16” has animations.
The next step will take a few minutes because you need to gather lines of text that tweak the animations and how the camera will shake for this weapon.
• Create a text file named “AnimationStatesMod.con”.
• Open this file.
• Copy every line that has “Sg44” in it from the following files: “1pAnimationsTweaking.con”, “3pAnimationsTweaking.con”, “MiscAnimationsTweaking.con”.
The lines that you are copying are speed adjustments to the default speed of the animations that the M16 will use. For example, by changing these values you change the speed at which the reload animation will occur. Paste the copied lines into the “AnimationStatesMod.con” file you just created.

• Open the “AnimationStatesCameraShakes.con” and search for “Sg44”.

This particular file contains settings which define how the camera will shake when particular weapon is fired. There will be two lines with “Sg44” in them, but you need the 5 lines under each of those instances (for a total of 12 lines in this file).
• Copy the 12 lines of text into the new file “AnimationStatesMod.con”.
• Replace every “Sg44” with “M16” in the “AnimationStatusMod.con” file.

**NOTE: This can be done easily with a text editor’s find/replace function.
• Close the “AnimationStatesMod.con” file.
STEP 5: Animation Files
Having finished the animation scripting, the next item to complete is the setup of the animation files that the game will use to bring the new weapon to life. This task entails copying directories and renaming files. The animation files are split up into different directories. Each directory name denotes the type of animations that are held inside.
**NOTE: In this tutorial we will work with the existing “SG44” animations. You are able to make new animations for your weapon using the Mod Development Animation Tool.
There are five main directories that you will need to work on: “Crouch”, “Lie”, “StandWalkRun”, “WeaponHandling”, and “Weapons”.

Four of these directories (all except the “Weapons” directory) have a subdirectory named “3P” (only the “StandWalkRun” and “WeaponHandling” directories have both the “1P” and “3P” subdirectories). Follow these steps for each main directory:
• Find the “Sg44” directory.

• Copy the “Sg44” directory.

• Rename the new file to “M16”and enter the new directory.

• Replace the “Sg44” in each filename with “M16” (ex. “3PCrouchBreathUpperSg44.baf” would be changed to “3PCrouchBreathUpperM16.baf”).

Follow the steps above for each of the main directories (“Crouch”, “Lie”, etc). Once these steps have been completed, you have created all the files necessary to animate your new weapon.
• Go back to the “Battlefield 1942” directory (base install directory).
STEP 6: Adding the New Weapon to a Kit
The weapons in BF: 1942 are added into the game via kits. Each kit defines the weapons with which a particular class of soldier will start the game.
• Enter the “objects\Items” directory.

You will see a list of directories. These directory names are made up of the country they represent and the word “kit”. Pick the country (directory) to which the new weapon will be added. We will use “USKit” for this example.
• Enter the “USKit” directory.
There is another set of directories named for each class of soldier. We will add the new M16 to the Assault class.
• Enter the “Assault” directory.
• Open the “objects.con” file.
• Find the line that has “Bar1918” in it (the main machine gun for the US Assault class).

• Replace “Bar1918” with “M16”.

• Save and close the file.
You have now added a new weapon into BF: 1942. Once you put the “objects”, “animations” and “standardMesh” directories back into .rfa format, you can start BF: 1942 and test out the new weapon.
Lets make war games, not war.
Post Reply