Weapons Editing? SOLVED (+Tutorial- Newbie Friendly)

Started by Rhynder, October 02, 2011, 06:04:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rhynder

Ok, i'm trying to edit the M16 (AR-16 ingame), to be full auto, instead of burst fire. I searched through the the .xml files looking for stuff related to the weapons fire modes and I finally found it( I think), edited and made the patch file and put it in the Data_Win32 folder. I started the game and tried the weapon, nothing, still burst fire. So I then said "Hey, maybe I just need to start a new game?" Tried that, and it's still the same. "Hey, maybe it's one of the cached values that needs to be reset?" I fired off thousands of rounds, switched weapons, picked up a brand new one off the wall, nothing. :(  I have done all sorts of different things trying to figure this out and nothing is working.


So, i'm just gonna state what I have done and what I changed and maybe you guys can tell me if I did something wrong?


Far Cry 2/modding

Ok, used the bootstrap.bat to create all the files and folders, I then opened "mymod" folder and then the  "patch" folder.

I opened "21_WeaponProperties.xml" to edit the firemode, I used ' Crtl+f ' and searched for " M16 ", which took me to the section needed, scrolled down until I found <value name="iBurstLength" type="UInt32">3</value> This has to be it, it's the only one with 3 as a value, so I checked the rest of the automatic rifles and they have this value set to 0, so I changed it. Ok, now it reads <value name="iBurstLength" type="UInt32">0</value> just like the other assault rifles, I checked the M16 and Ak47 side by side and no other value that should matter is different?

I run the Build_patch.bat, it makes the patch files, just below the two .bat files. I copy the patch files into Data_Win32, overwriting the originals. (Have backs ups of originals)

What am I doing wrong? Is this value hard coded and can't be changed?
I have crappy internet, so don't expect to see me playing any games online.

PZ

Interesting modification idea.  Although I'm no expert in modding just yet, I wonder if it has something to do with the AR-16 animation - perhaps it is only a 3-round burst?

Welcome to OWG by the way - hope you find the information on the site useful  :-X

Rhynder

Okay, I figured it all out. My AR-16 is full auto!

What I was doing before WAS correct, however, there is a second file that needs to be edited and added to the patch file, along with changes to the patch.xml file. I'll spell it all out down below.

You need to also edit the file in libraries/world1/41_WeaponProperties.xml (This one has many "iBurstLength" entries to edit so use the find tool, change them all from 3 to 0)

Once that is done, copy the file into your mymod\patch\ folder. It now needs to added to the patch.

Go back one folder and open the patch.xml file, add <object external="41_WeaponProperties.xml" />  to the list below <object external="22_weapons.xml" /> Save. Run build_patch.bat, copy the patch file over and you're DONE! You now have a  fully auto AR-16.


I've also added a very newbie friendly tutorial, I know most of us here know more than a bit about this stuff, but some might come across this and not know, but want to make the change themselves.

Newbie TUTORIAL

Click the spoiler tag to reveal the newbie friendly version
Spoiler
Newbie friendly tutorial on changing weapon from burst fire to full auto and vice-versa

The AR-16 will be used as the example.


1. Open the ' mymod ' folder and the following  ' patch ' folder

2a. Open " 21_WeaponProperties.xml ", Press Ctrl f,  type M16 in the text field, press " Find Next"

2b. It will have taken you to M16 section, Press Ctrl f again, type Burst in the text field, press " Find Next"

3. You will now be looking at <value name="iBurstLength" type="UInt32">3</value> Change the 3 in between the > < symbols to 0 , Save.

4a. Now, go back to the ' modding ' folder. Open the libraries folder, then open world1, find 41_WeaponProperties.xml.

4b. Copy 41_WeaponProperties.xml to your ' mymod\patch\ '  folder, make the same edits as before. However, there is more than just one this time, keeping searching for "iBurstLength" until you no longer see any 3's and instead see 0's. Save.

5.Go back one folder, you will see a patch.xml file. Open the file. Add this <object external="41_WeaponProperties.xml" /> to the bottom of the list, but before the </object>


EXAMPLE: <object external="21_WeaponProperties.xml" />
  <object external="22_weapons.xml" />
  <object external="41_WeaponProperties.xml" />
</object>



Thanks for the welcome! Also thanks to Gibbed for his modding tools. After the few simple edits I've made this game is actually FUN!
I have crappy internet, so don't expect to see me playing any games online.

PZ

Nicely done!  I enjoy using the AR-16 so this one will be really nice  :-X

Art Blade

Welcome to OWG and "good one" regarding that modification, Rhynder :)  :-X
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

PZ

I applied Rhynder's mod to my game and I must say that the AR-16 is now an amazing weapon.  Thanks again for finding this gem, Rhynder.

Rhynder

You are very welcome, sir. The gun is a beast, my new favorite in Far Cry 2. 

Anyway, now i'm moving onto a new modification. Enemy spawn times, that's it, that's all that is left and this game will be perfect. So far I've looked into the files and found nothing, or maybe I just missed it?

I know this has been looked into before, but that was before so much of the code was even available to edit. So, has anyone since then figured anything out or is this actually a hard coded piece of the game?


UPDATE

I believe I've found the code! The code is not in any of the files the bootstrap program generates, it's in world.fat\ domino\system. There are two files, ' reinforcementregion.lua ', and ' spawnreinforcement.lua '. The code is in here, clear as day. However I am NOT a programmer, I have no idea what to edit or what to add.  But this is what I believe controls the spawns. The entire code is below. Can someone more experienced, please, tell me what this does and if this is it or not?


reinforcementregion.lua
Spoiler
-- DOMINO REFLECTION BOX START
--
-- <Display Category="Missions" Text="ReinforcementRegion"/>
--
-- <ControlIn  Name="ChangeSpawnRate"/>
-- <DataIn     Name="GameRegion"      Type="Nomad|entity"/>
-- <DataIn     Name="MercDensity"     Type="Core|int"/>
-- <DataIn     Name="MercThreshold"   Type="Core|int"/>
--
-- <ControlOut Name="Out"/>
--
--
-- DOMINO REFLECTION BOX END

ReinforcementRegion = {
}

function ReinforcementRegion:Create(cbox)
-- left empty on purpose
end

function ReinforcementRegion:Init(cbox)
-- left empty on purpose
self.MercDensity = -1;
self.MercThreshold = -1;
end

function ReinforcementRegion:ShutDown()
-- left empty on purpose
end

function ReinforcementRegion:ChangeSpawnRate()
    if ( self.GameRegion ~= nil and self.MercDensity ~= nil  and self.MercThreshold) then   
    ChangeReinforcementRegionSpawnRate(self.GameRegion, self.MercDensity,self.MercThreshold);
  return self:Out();
  end
end


export = ReinforcementRegion;
ReinforcementRegion = nil;

______________________________________________________________

spawnreinforcement.lua
Spoiler
-- DOMINO REFLECTION BOX START
--
-- <Display Category="Pawns" Text="Spawn Reinforcement"/>
--
-- <ControlIn  Name="In"/>
-- <DataIn     Name="ReinforcementPoint" Type="Nomad|entity"/>
-- <DataIn     Name="Target"             Type="Nomad|entity"/>
-- <DataIn     Name="ReactOnlyToPlayer"  Type="Core|bool"/>
--
-- <ControlOut Name="Out" Delayed="true"/>
--
-- DOMINO REFLECTION BOX END

SpawnReinforcement = {
}

function SpawnReinforcement:Create(cbox)
-- left empty on purpose
end

function SpawnReinforcement:Init(cbox)
self.callidOnReinforcementPoint = nil;
self.callidOnTarget = nil;
self.counter = 0;
end

function SpawnReinforcement:ShutDown()
self._type.UnregisterCallback(self);
end

function SpawnReinforcement:UnregisterCallback()
  cbSyst = CScriptCallbackSystem_GetInstance();
  if (self.ReinforcementPoint ~= nil and self.callidOnReinforcementPoint ~= nil) then
cbSyst:RemoveCallback(self.ReinforcementPoint, self.callidOnReinforcementPoint);
self.callidOnReinforcementPoint = nil;
end
if (self.Target ~= nil and self.callidOnTarget ~= nil) then
cbSyst:RemoveCallback(self.Target, self.callidOnTarget);
self.callidOnTarget = nil;
end
end

function SpawnReinforcement:In()
if (self.ReactOnlyToPlayer == nil) then
self.ReactOnlyToPlayer = 0;
end
self.counter = 0;

if self.ReinforcementPoint ~= nil and self.Target ~= nil then
if( IsEntityLoaded(self.ReinforcementPoint) ~= 1 ) then
self.callidOnReinforcementPoint = CScriptCallbackSystem_GetInstance():RegisterOnSpawnCallback(self.ReinforcementPoint, self, "TrySpawnReinforcementScenario");
self.counter = self.counter + 1;
end

if (IsEntityLoaded(self.Target) ~= 1) then
self.callidOnTarget = CScriptCallbackSystem_GetInstance():RegisterOnSpawnCallback(self.Target, self, "TrySpawnReinforcementScenario");
self.counter = self.counter + 1;
end

if ( self.counter == 0 ) then
SpawnReinforcementScenario(self.ReinforcementPoint,self.Target,self.ReactOnlyToPlayer);
return self:Out();
end
end
end

function SpawnReinforcement:TrySpawnReinforcementScenario()
if(self.callidOnReinforcementPoint ~= nil) then
if (IsEntityLoaded(self.ReinforcementPoint) == 1) then
self.counter = self.counter - 1;
CScriptCallbackSystem_GetInstance():RemoveCallback(self.ReinforcementPoint, self.callidOnReinforcementPoint);
self.callidOnReinforcementPoint = nil;
end
end

if (self.callidOnTarget ~= nil) then
if (IsEntityLoaded(self.Target) == 1) then
self.counter = self.counter - 1;
CScriptCallbackSystem_GetInstance():RemoveCallback(self.Target, self.callidOnTarget);
self.callidOnTarget = nil;
end
end

if ( self.counter == 0 ) then
SpawnReinforcementScenario(self.ReinforcementPoint,self.Target,self.ReactOnlyToPlayer);
return self:Out();
end
end


-- Export visible for Nomad engine.
export = SpawnReinforcement;
SpawnReinforcement = nil;

I have crappy internet, so don't expect to see me playing any games online.

PZ

Looks promising - not sure but it looks like changing one (or both) of the -1 values might do something.  Might have to do some experimenting.

TheStranger

Great w@&k Rhynder on the AR-16! The 3 round burst was an annoying thing for me all the time so now it's as it should be.  :-X

Maybe we can do something concerning the spawntimes, but als I'm no coder :/

Binnatics

Urhmm, you mean the spawntimes for mercs at guardposts? Good idea.

Actually, I like to think about what can be done by modding, but don't mod anything myself. You think it's possible to change the amount of spawns as well? Should be funny if you can have them spawn by the dosen, knowing that you are at a safe distance with an MGL 140 with extra clip and bigger explosion-range >:D
When you can also adjust the time a dead body will stay in the game, you can start to pile up dead mercs until the whole guardpost is gone, LOL, I'm losing touch with reality again ^-^
"Responsibility is not a matter of giving or taking, responsibility is something you share" -Binnatics

PZ

One other thing that would be nice is to do away with the endless spawn in Pala and Mosate Selao.  That would make those two towns more like Sefapane.

nexor

Thanks for the AR -16 mod Rhynder, works like a dream  :-X

Quote from: Rhynder on October 03, 2011, 08:57:22 PM
You are very welcome, sir. The gun is a beast, my new favorite in Far Cry 2.

Oh and by the way......we almost got PZ and Art domesticated, so please don't call anyone of the two "SIR".........  :o            >:D :-() :-()



[admin]The domesticated Art was so free and edited the messed-up quote for you, nexor  :-()[/admin]

Rhynder

After some testing time, I've come to a conclusion on the enemy re-spawn time matter.  :D  :D  :D

During my testing, I've done a couple things, first off, I edited the script to wait for 5 minutes (just for testing) before it would "respawn" the enemies. It didn't w@&k. So just to test I edited the file again, I removed a key section of the script, which would cause an error and thus crash the game. It didn't w@&k either.

So after a few more hours of testing different stuff out, I've come to the conclusion that patching in the script does not w@&k, it doesn't read the script, it bypasses it and reads the original. Now I don't know if that means that it's just not wanting to read it from the patch file and we would have to find some way to actually replace the original files for it to w@&k or not? I'm also not sure how you would go about repacking world1.fat/world2.fat and common.fat.

But, for now until I get some conformation on the script and if it really is what is controlling the re-spawn (95% sure, btw), i'm just going to give up on this for now.  I wish they would have just released an SDK, so we wouldn't have to use these bypass hacks, life would be so much easier.
I have crappy internet, so don't expect to see me playing any games online.

Art Blade

Nice find.

Unfortunately I currently don't have time for any extended playing or testing so I can't check it out myself.

From what little I gathered, you should be able to pack a new set of files that only have the wrong names. It might be possible to empty the modding folders, put in the luas, pack them to mod files and then rename those.
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

nexor

Quote from: nexor63 on October 04, 2011, 05:17:10 PM
The domesticated Art was so free and edited the messed-up quote for you, nexor  :-()

I'm not with you????

Art Blade

Err.. I was just referring to the fact that you didn't terminate the quote (BBC code error) which resulted in your own text to appear as part of the quote (as if Rhynder had said it). So I terminated the quote after Rhynder's own words and therefore made your text recognisable as a comment which you originally had intended.

:)
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

nexor


Art Blade

[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

shelmez

Good job and great manual! Thank you Phynder!  :-X  Everything turned out right the first time)))) So, step by step game open its secrets))))
rascal, womanizer and eater of pigs))))

shelmez

Maybe someone will be interested in this information. In the game is pretty weak weapon shotgun, I used it a few times and then threw away, because you can only kill the flies. So, everything should be done as written above, Mr.Phynder about M16. For example, consider USAS12. Only need to change the parameter <value name="iBulletsShot" type="UInt32"> 7 </ value> how many bullets it will shoot out of your arms in one shot, that is, in one cartridge 7 bullets. Make <value name="iBulletsShot" type="UInt32"> 20 </ value> and your shotgun will turn into a lawn mower))) But do not forget that your enemy will have the same powerful weapons. But I do not recommend to put more than 20, the game can be very slow.
rascal, womanizer and eater of pigs))))

Art Blade

hehe  :-() I prefer to mod weapons that are not available to mercs so they won't get their grubby mitts on the nukes  :-D
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

nexor


PZ


TheFishlord

I'd like to point out something I've found with the semi auto fix we have here. This adjusting of the burst works, but it is not really meant to be used that way. The way a weapon's firing type is determined is in this section of its code:

Spoiler
<object type="FireRate">
              <value name="fBusyDuration" type="Float">0</value>
              <value name="iFireRate" type="Float">240</value>
              <value name="selFireRateMode" type="UInt32">0</value>
              <object type="enumFireRateMode">
                <object type="enum">
                  <value name="Value" type="String">SingleShot</value>
                </object>
                <object type="enum">
                  <value name="Value" type="String">FullAuto</value>
                </object>
                <object type="enum">
                  <value name="Value" type="String">PrepareShot</value>
                </object>
              </object>
            </object>

Here I have the SPAS12's code. We're looking at the bolded section.

"sel" before a code means that this line is telling the weapon what it is going to do, in this case, "fire rate mode". (Sel is probably short for Select) "enum" before the code means it is giving the weapon its choices, and the first one is numbered as "0", hence the SPAS is single-shot or semi-auto. (Enum probably = Enumeration)

The M1903 and Ithaca are both "PrepareShot", presumably because before each firing an action has to be performed. The MGL140 is "SingleShot" because the action (rotating of the cylinder) comes AFTER the firing.

And all full auto weapons are obviously FullAuto. What piqued my interest here is that the M16 is labeled as full auto, so the "burst" code was apparently actually meant to determine bursts only in full auto. We've worked around it but here is the simplest fix to getting a semi auto gun - change the bolded line's value to 0.

This may solve the problem I pointed out in another thread about the "burst" of sounds. I'll go fix my FAL up with this and see what happens.

EDIT: This silences the weapon entirely (no firing sound at all now). I'll see if I can find any way around that...

PZ

Nice  :-X  Just when I think I've completely played out the game, modding SP comes along.  This will fill in some of the spare game time between now and the time that FC3 comes out.

Tags:
🡱 🡳

Similar topics (5)