Jump to content
nomadd

how do you make a script into a mod?

Recommended Posts

My searching has not really yielded what I am looking for.

I have made quite a few missions and enjoy playing missions made by others, but on certain mission AI running out of ammo can be a problem. Example: I have a fun base defend , coop with respawn, the enemy spawns in waves and tries to overwhelm the base. Me and friends have played it alot, I noticed however the AI would sometimes run out of ammo and just stand there. So I made a simple script that runs over all the enemy AI (players still have to go get/find ammo). If they get down to 1 mag on the primary weapon 4 more mags spawn in their inventory.

I am using ASR_AI mod (makes AI find ammo and weapons) but for some reason in a large firefight the AI tend to just stand around once out of ammo. It is not a problem of the mod not working, I think it is the AI are just slow to rearm in a large firefight(I host and play so could be a processing power limit). So I just give them the ammo, seems to work well.

My friends and I have started playing with the I44 mod and perfect example of the AI running out of ammo is the D-Day invasion mission. It starts out great , very intense, but as you keep playing you soon notice the AI just standing around. It gets to the point you can actually walk up to the AI and shoot them point blank. I don't want to open the mission and change someones elses hard work.

So I was wondering how hard would it be to take the scripts I use and turn them into a mod so it would work for any mission? Can I turn the mod off and on in the mission? Some missions mine or others do not need this and may actually break the mission. Also, can I make it just needed for the server not clients.

I am probably biting off more than I can chew, but if someone points me in the right direction I will try and figure it out.

Nomadd

Share this post


Link to post
Share on other sites

Fear not, it is not too difficult to create a script only addon. I am not at my computer currently to post an example, but to get you started you should look at the documenation for extended event handlers (which is part of CBA) at dev heaven. Init extended event handlers are the easiest way to launch a script as part of an addon. So, you would need to use CBA as well as your addon, but it is the best way to ensure compatibility with other missions and addons.

If you can wait a few hours I can post an example if someone does not beat me to it.

Share this post


Link to post
Share on other sites

@Loyalguard

Thanks for the help. I will take a look at the CBA extended eventhandlers at dev heven. I have never messed around with them before, but if you can supply an example I can probably figure out how to do what I want.

Nomadd

All my years of gaming, never thought I would become addicted to learning how to script for AMRA2.

Share this post


Link to post
Share on other sites

Here's a cheaty mod that shows how to do this. It's essentially based on InstantViewDistance and requires CBA since I wasn't able to get the script to start on it's own. :)

But you can break it apart and see all the parts it needed.

Share this post


Link to post
Share on other sites

@Kylania

Thanks, I was able to open it up and take a look at the mod. I don't understand everything but it definitely has helped me get started. I am going to take some time and study what you have shown me. I will most likely post back with questions , but first need to figure out what questions to ask.

Nomad

Share this post


Link to post
Share on other sites

Here are the instructions I promised. You can use Kylania's example as a basis using the instructions below. There are only a few differences (the type of XEH, $PBOPREFIX$, mod folder icon, etc.)

1. Create a new folder that begins with the @ symbol and has your unique tag (and if you use your tag for more than one project a description. Example:

@TAG_myAddon

2. Inside your @ folder, make a new folder called "Addons".

3. Inside your Addons folder, create another folder that is the same as your @ folder BUT WITHOUT the @. Example:

TAG_myAddon

4. Now you will create a config.cpp file inside "@TAG_myAddon\Addons\TAG_myAddon". This is just a text file with the .cpp extension. This file fill contain a CfgPatches section and an XEH section. The CfgPatches section adds a new class to the game (your addon). The XEH section creates a new instance of XEHs to execute your script at the beginning of every mission automatically. You will have to consult the XEH documentation to determine which type of XEH is best for your project. The below example is for a post-init XEH that will run after all other init EHs and mission editor init lines have been processed. You can name your actual script whatever you want (below it is init.sqf). Just be sure the name and folder structure are correct if you will have multiple folders inside TAG_myAddon. The below assumes there are no subfolders. Example:

class CfgPatches
{
class TAG_myAddon
{
	units[] = {};
	weapons[] = {};
	requiredVersion = 1.0;
	requiredAddons[] = {"Extended_EventHandlers"};

};
};

class Extended_PostInit_EventHandlers
{
 TAG_myAddon_Post_Init = "TAG_myAddon_Post_Init_Var = [] execVM ""\TAG_myAddon\init.sqf""";
};

5. Create a $PBOPREFIX$ file. The reason can be found here: http://community.bistudio.com/wiki/PBOPREFIX. This is just a txt file with the name $PBOPREFIX$ and no file extention. Inside of it is a single line without whitespace or lines before or after. In the case of this example "TAG_myAddon" (no quotes).

6. Pack your TAG_myAddon folder. Use BinPBO or another PBO tool to pack your TAG_myAddon folder. Do not pack the @ folder, just the folder inside the Addons folder. You can remove the unpacked folder now (or leave it if still testing or for your own use) but don't delete it in case you need to revise, just keep it safe somewhere. Do not move or delete the pbo file You should also sign your addon if you plan on releasing it outside your own use.

7. put your @TAG_myAddon folder where you normally place addons and install it with the -mod parameter or your addon manager.

I hope this helps...good luck!

Edited by Loyalguard
pbo file note
  • Like 5

Share this post


Link to post
Share on other sites

Can't believe the guy never thanked you.

Anyways thanks for the info. I am attempting to also create a addon that uses both a INIT script and calls for a description.ext file that uses both RscTitles and CfgFunctions classes.

I can't seem to get these functions to work inthe config.cpp file. Is there a way to do this?

The addon structure has both a INIT and Description.ext, and then a folder that has other files it will use.

Thank you!

Share this post


Link to post
Share on other sites

Hi Loyalguard !

 

Thanks for these explanations.

I just tried to do this thing, but I think there is something I missed or do wrong.

 

Can I contact you by PM to have some help and explain you what I'm trying to do ?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×