Trying to make a new Disc Launcher type weapon....

Sami has expressed his desire for a Disc Launcher that has no splash damage & in the future would inherit the player's velocity. This is my first venture in to modding weapons; I think I have maxxed myself out on making maps 😉

I found the AVM Tutorial database, and it has many examples in it for all types of weapons. However, it seems like the information is maybe a little dated & jumbled up. I have not had 100% success yet with adding a weapon of my own making.

Does anyone know of a weapon Mod that was released with the modified .cs script files intact? I would like to look at an example like that & see how they made it work. I could then have a better chance at making the new Disc Launcher work once I see what all was changed from Base to the Mod. I don't want to "steal" anyones code; I just want to learn from it. I would give full credit in my weapons file to any original coders.

Comments

  • edited August 15

    While I wouldn't say they're always the cleanest, almost every mod that isn't distributed in dso form should have an example of how a weapon being added/modified can work. Some of them do handle things like the inventory listing differently, but it's all the same in principle. Grab that mega pack of mod content and have a look through each one and you should find a few good ones, and a whole bunch of very rough ones that get the job done.

    To add a new alternate spinfusor to alter those factors, you're mainly going to be creating new copies of a set of datablocks, making sure to give them new names:

    • An ItemData block weapon itself, which describes the weapon as a pickup object in the world
    • An ItemData block for the ammo pickup, unless you want it to share the same ammo as the original
    • A LinearProjectileData block to define the projectile and its parameters, where you'll apply the splash damage and velocity inheritance
    • A ShapeBaseImageData block, which describes the weapon in your hand and its behaviours. For a simple change, this will most importantly need to be updated to reference your other new datablocks: item, ammo, projectile.

    The easiest way to get started understanding how this behaves on your own server is just to change out the projectile datablock alone and reload the script, but because these are datablocks, you can't see the changes live without restarting the server unless %client.transmitDataBlocks(0); is being run on your client every time the script is compile/exec'd. Some mods implement a reload("mydisc.cs"); function to do this for every client on a server.

    For more advanced weapon behaviours, you can start to look at state transitions and their script callbacks in the ShapeBaseImageData datablock. "onFire" is the standard included trigger callback, and you'll see ShapeBaseImageData::onFire in projectiles.cs for the default action where the projectile is created. This can be completely overridden by creating a function with the same structure for your specific datablock, e.g. function DiscImage::onFire(%data, %obj, %slot) which can inherit the ShapeBaseImageData::onFire logic by calling %projectile = Parent::onFire(%data, %obj, %slot); You'll see a lot of examples of this if you look at one of the construction mods or something like Meltdown.

    Similarly, the projectile/explosions may have callbacks that are of interest for further advanced behaviours, e.g. having players within range of the impact have some special effect applied to them.


    For actually adding it as a new weapon with how it's handled in the base scripts, you'll want to look at weapons.cs for how reticles are specified to be sent to clients, and inventoryHud.cs for how it gets added to the inventory list for players to select. You'll also need to modify the player datablocks in player.cs to set new max[MyDisc] counts for inventory restrictions.

    If you don't want to bother going that far for testing a new gun, you can directly modify the disc datablocks to just try the changes on the spinfusor itself, or you can use %client.player.setInventory(%datablockName, %count, %force); with the ItemData pickup block names e.g. MyDisc, 1, 1 and MyDiscAmmo, 1000, 1

  • Wow !!! 😎 Thanks for the quick response !!! 😊 I have a ton of reading to do now 😃 I really appreciate the advice !!! 👍️👍️

    I'll go grab the Mega pack now & play around with it 😉

  • Using Krash's input on another thread, this is the function I've been using to reload mod changes. The last call binds the function to `ctrl + ;`. Refreshing the file manager is needed if you add a new .cs file while the game is already running, otherwise exec() will not be able to find it.

    function reloadModScripts(%a0) {
        if (!%a0) {
            return;
        }
    
        // Refresh file manager
        setModPaths(getModPaths());
    
        // ADD YOUR SCRIPT EXECS HERE
        // E.g. exec("scripts/weapons/my_cool_gun.cs");
    
        // Transmit datablocks to non-bots
        for (%i = 0; %i < ClientGroup.getCount(); %i++) {
            %client = ClientGroup.getObject(%i);
            if (!%client.isAIControlled()) {
                %client.transmitDataBlocks(0);
            }
        }
    }
    
    GlobalActionMap.bind("keyboard", "ctrl ;", "reloadModScripts");
    

    -Arg0

  • I just finished extracting the Mega pack to an empty directory. It looks like the Triumph mod has all of the .cs script files & I will be able to use those as how-to-do stuff examples 😃 Many thanks to the guys who put that together !!! 👍️

    I also read thru the scripting FAQ included in the Mega pack...... Very good information & I am glad to have found it ☺️

    Thanks for the advice & direction, guys.... I'll probably be back in about a month or two once I get all of this down pat ☺️

Sign In or Register to comment.