FAQ
Character Event Basics:Create event creates all the variables the weapon uses, like max ammo count, reload speed, refire rate, xoffset and yoffset (these are so the weapon aligns with the sprite properly), and anything else you need for the weapon to function correctly.
Alarms are usually for reloading ammo, and determining when you can fire again. Alarm[0], which is part of the 'Weapon' parent object, determines when the weapon is ready to fire (arbitrarily chosen in gg2).
Step events are run through every step (frame). Usually for regenerating ammo, or charging up meter.
Destroy event is activated when the weapon is destroyed. Use it to resolve and destroy any projectiles that belong to the weapon.
User Defined Event 1 is M1 press (arbitrarily chosen in gg2).
User Defined Event 2 is M2 press (arbitrarily chosen in gg2).
User Defined Event 3 is M1 release (arbitrarily chosen in gg2).
User Defined Event 12 is the serialize event. Whenever this is called in the serializeState script (which serializes each player and their character objects), it sends data to the server. Put important weapon variable stuff here that you don't want to get desynced. Just copy the format of the other weapon's code (arbitrarily chosen in gg2).
User Defined Event 13 is the deserialize event. This is when you set all the variables to the data received by the server (arbitrarily chosen in gg2).
Just go explore around in the code and make small changes and see what that does. When you feel like it, you can start to create new classes with new weapons (duplicating existing objects is the easiest route).
Font Issues:
If you do this your mod will automaticcaly use the gg2 font.
Installing Extensions:Extensions are compiled dlls made in other languages you can add to Game Maker.
You need to install a few extensions to be able to compile gg2, not doing so will follow errors, like this one:
___________________________________________
COMPILATION ERROR in Script: CustomMapInit
Error in code at line 9:
leveldata = GG2DLL_extract_PNG_leveldata(argument0, tempfile);
^
at position 16: Unknown function or script: GG2DLL_extract_PNG_leveldata
To install them, open Game Maker, and select "Resources", then "Select Extension Packages".
Then, keep clicking "Install" until a small window appears, asking you for a file. Navigate to your "Gang Garrison 2/Source" folder, and click on everything that ends with ".gex". These are all extensions.
Lastly, go back to the first "Extension Packages" window. Add every option in the right column into the left one by clicking on them and on the blue arrow.
Also, keep in mind that this needs the full version of Game Maker, so lite won't suffice. If you really want to mod, but can't/don't want to get Pro, you can probably post the source and ask for someone to compile it for you.
Using the Mod Lobby:You might have seen once that mods have their own tag in the lobby, as well as a download link if they are not compatible.
Here is the code that sends all your information to the lobby:
var noOfPlayers;
noOfPlayers = ds_list_size(global.players);
if(global.dedicatedMode)
noOfPlayers -= 1;
var lobbyBuffer;
lobbyBuffer = buffer_create();
set_little_endian(lobbyBuffer, false);
parseUuid("b5dae2e8-424f-9ed0-0fcb-8c21c7ca1352", lobbyBuffer); // Message Type "register"
write_buffer(lobbyBuffer, GameServer.serverId);
write_buffer(lobbyBuffer, global.gg2lobbyId);
write_ubyte(lobbyBuffer, 0); // TCP
write_ushort(lobbyBuffer, global.hostingPort);
write_ushort(lobbyBuffer, global.playerLimit);
write_ushort(lobbyBuffer, noOfPlayers);
write_ushort(lobbyBuffer, 0); // Number of bots
if(global.serverPassword != "")
write_ushort(lobbyBuffer, 1);
else
write_ushort(lobbyBuffer, 0);
write_ushort(lobbyBuffer, 7); // Number of Key/Value pairs that follow
writeKeyValue(lobbyBuffer, "name", global.serverName);
writeKeyValue(lobbyBuffer, "game", "Gang Garrison 2");
writeKeyValue(lobbyBuffer, "game_short", "gg2");
writeKeyValue(lobbyBuffer, "game_ver", GAME_VERSION_STRING);
writeKeyValue(lobbyBuffer, "game_url", "http://www.ganggarrison.com/");
writeKeyValue(lobbyBuffer, "map", global.currentMap);
write_ubyte(lobbyBuffer, string_length("protocol_id"));
write_string(lobbyBuffer, "protocol_id");
write_ushort(lobbyBuffer, 16);
write_buffer(lobbyBuffer, global.protocolUuid);
udp_send(lobbyBuffer, LOBBY_SERVER_HOST, LOBBY_SERVER_PORT);
buffer_destroy(lobbyBuffer);
This may look daunting, but don't worry. It's actually pretty simple.
The only code that interests you is this:
writeKeyValue(lobbyBuffer, "game", "Gang Garrison 2");
writeKeyValue(lobbyBuffer, "game_short", "gg2");
writeKeyValue(lobbyBuffer, "game_ver", GAME_VERSION_STRING);
writeKeyValue(lobbyBuffer, "game_url", "http://www.ganggarrison.com/");
In there you can write any string you wish.
writeKeyValue(lobbyBuffer, "game", "My Awesome Mod");
writeKeyValue(lobbyBuffer, "game_short", "MAM");
writeKeyValue(lobbyBuffer, "game_ver", GAME_VERSION_STRING);
writeKeyValue(lobbyBuffer, "game_url", "http://www.ganggarrison.com/forums/index.php?topic=18089.msg41529#msg41529");
Notice the link for "game_url". This is only used if the mod is incompatible with Vanilla, so people who click on the server will get redirected to that link.
So put your mod thread link there.
Next, open the "Resources" menu, and select "Define Constants". Constants are names for strings or numbers you can't change in the code, and are global.
For example, there you will find the "GAME_VERSION_STRING" constant. You might want to change that to the version of your mod.
Finally, if your mod is incompatible, you have to get another UUID. For this go into the Source folder, and click on the "UUIDgenerator.html" file. Copy-paste the resulting UUID string into the constant PROTOCOL_UUID,
not the GG2_LOBBY_UUID.
This will make your server greyed out in the lobby, and if anyone clicks on it, it'll direct the user to whatever link you specified.
How to Add New Classes:First you have to add another variable in the constants for the new class [Look that up yourself. I'm lazy, piss off]
Then, you have to open the getCharacterObject script and add another string for the new class
Example:
//this goes under the blue team's half of the code
case (TEAM_BLUE*16 + CLASS_QUOTE):
return QuoteBlue;
//That will bring up Curly in the current client
//So, all you have to do is change CLASS_QUOTE to whatever you named the constant
//For example, if the constant was named CLASS_NEW
case (TEAM_BLUE*16 + CLASS_NEW):
return NewBlue;
//Rinse and repeat for the Red team
"return NewBlue", or whatever you name it, it doesn't really matter, calls upon an object. That controls what color it comes up as, like a red scout, or Quote and Curly. Remember to make that object.
After you've done that, make a Parent object for them. In the source, they're the ones that are just named after the classes. "Scout", "Spy", "Sniper" etc.
That's where you add all the variables to the class, which controls their speed and whatnot. Set this object as the parent for the NewRed, NewBlue, or whatever you decide to name it. Look up how to do that, too. I'm really fucking lazy.
Now stop asking. ~Sani
Contributors and previous versions of this post: mrfredman, cspotcode, BassieEnAdriaan, BassMakesPaste, Wareya, Sani, Orpheon
ps sprite mods tend to make the game worse, BUT NOT ALWAYS SO LOOK OUT