Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Megamek custom weapons
#1
Hello all. I've done a lot of searching and from what I've read the only way to make custom weapons is to code it into the game. I've successfully figured out how to compile the program but I'm having problems with my custom weapons not appearing in the jar file. As a test, I copied and modified the IS LB 10-X AC file and named it as a new weapon. Also what determines the UniqueID? Anyone have any ideas? Thanks.
Reply
#2
Are you on the Slack?
https://megamek-public.slack.com/
Reply
#3
In addition to adding a new weapon class file, you also need to ensure that the weapon gets added to the list of known weapons in MM.  Look at WeaponType.initializeTypes().
Reply
#4
(03-30-2017, 08:00 AM)Arlith link Wrote: In addition to adding a new weapon class file, you also need to ensure that the weapon gets added to the list of known weapons in MM.  Look at WeaponType.initializeTypes().
Hmm, so far I've made a customweapon.java (that extends LBXACWeapon) file and added it to WeaponType.initializeTypes() like you said but I still do not see it in the jar file when I compile it. Sorry if the answer is obvious but I only have a little experience with coding in java.
Reply
#5
You asked about the unique id before.  Are you referring to the internal name?  Each piece of equipment has an internal name, which is a unique string that identifies that piece of equipment.  It must be unique because that's how the game refers to that piece of equipment.  If it's not unique, it will get overwritten.

I haven't added a weapon in a while, and I can't really see exactly what you've done, so I'm kind of giving you vague responses.  In theory, all you "need to do" is create a new weapon.java file like you've done and then ensure it gets added in WeaponType.initializeTypes().  It seems like you're doing this already.

Did you checkout the source code with git?  If so, if you could create a diff to see what changes you've made, that might help.  It's been a while since I've added a weapon, so there may be a step I'm missing.
Reply
#6
Here's the example .java file. I was asking about the serialVersionUID line actually. In the picture I just randomly put in numbers and a letter.
http://i.imgur.com/uxt8sqp.png

I got this error as soon as I type "EquipmentType."
http://i.imgur.com/sHnjfEn.png

Quote:Did you checkout the source code with git?  If so, if you could create a diff to see what changes you've made, that might help.
I'm not sure what you mean here. I did grab the files from git using an Eclipse addon though.
Reply
#7
Where and why are you typing Equipment type?

As for hte serialVersionUID, generally I generate that with Eclipse.  If you don't have the serial ID defined, Eclipse will warn you, and that warning has a quick fix of  generating the ID.  the actual value isn't super important, it just needs to be unique to that version of the file.  It shouldn't be the same as any other source file, and it should change if the source file changes.

Git allows you to generate a diff file, which is a file that shows the differences in a code, so that someone else could apply those diffs and get your version of the code.  The Eclipse Egit add-on should be able to do it, but I don't use it so I'm not sure how to do it offhand.  The hope would be that by having your code changes, I could figure out where you're going wrong.

Alternatively, GitHub allows you to fork a repository, so you get your own local copy that you can commit changes to and push back to GitHub, and I could then checkout your repository.  If this doesn't make sense to you, it may be too much for me to describe how to do it to you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Custom Weapons? Docwade 1 328 02-25-2019, 10:04 PM
Last Post: Hammer
  How do i add new weapons to megamek source? cementblade 2 403 12-19-2017, 01:17 AM
Last Post: cementblade
  Custom weapons? Koniving 6 2,109 10-27-2015, 06:19 PM
Last Post: Koniving
  Having trouble with custom infantry using multiple weapons Victor Morson 6 1,365 12-18-2014, 03:42 PM
Last Post: scJazz
  Adding custom units so they are available in MegaMek darkwolf 3 2,065 10-02-2011, 10:46 AM
Last Post: Crazy S

Forum Jump:


Users browsing this thread: 1 Guest(s)