Flintlock Firearm ammo system

Discussion in 'JS Plugin Requests' started by Blackjack488, Oct 9, 2016.

  1. Blackjack488

    Blackjack488 Unassuming Veteran

    Messages:
    40
    Likes Received:
    2
    Location:
    Seattle
    First Language:
    English
    So, in the world of the game I'm creating, the only form firearms exist in is in flintlock weaponry. They do a ridiculous amount of damage but have a small failure chance. In addition (the way I have them conceived) shooting one would deprive it of its ammo, forcing the user to either switch to a different one or burn a turn to reload their equipped one. The associated skill type (Firearms skills) of course only work if you have a loaded firearm equipped, and having an unloaded firearm equipped would replace the "Attack" command with a "Reload" command (for ease of access). Reloading itself would likely be a separate skill, which reduces the user's defense and agility (making them vulnerable until the next turn) as well as taking away one of a "Shot and Powder" item from the party's inventory. If you don't have a Shot and Powder, you can't reload, and probably should be switching to your backup weapon. This makes firearms something of a burst-damage weapon that deals a ton of damage, but is less reliable than something like a bow or a sword.


    (tl;dr Every gun has one shot, and when you use it, it's changed to being "empty". At which point you can either swap to a different gun or use a "Reload" skill, which consumes an ammo item and reduces your defense and agility for that turn).


    That's all well and good on paper, but the issue is actually making it work in practice. I've been scanning through dozens of different plugins and tutorials to try and find something functional, and everything could technically work, but not the way I have it designed (as written above). Usually, one of two issues occurs: getting the firearms to use ammo works great, but the "Reload" skill doesn't work the way I imagined (or flat-out can't exist); or it all works great except for switching firearms, at which point, whatever firearm you have in your hand is automatically considered "empty" until you use the Reload skill. The first one is bad because it means that guns are basically just a better version of the Bow, which doesn't make sense for flintlocks. And the second one is equally bad because it removes gun-swapping, which is a core mechanic that makes several firearm-centric skills (and even party-members) viable. (A side-note about gun-swapping and its impact on the intended game is in the Spoiler tag below.)

    One character that relies on the gun-swapping mechanic a lot is a guy named Zafir. He's one of the three core damage-dealers available to the player, alongside Melianne the sword-wielding Duelist and Finch the rifle-toting Soldier. But what makes party-building a fundamental part of gameplay strategy is what each damage-dealer is intended to specialize in: Melianne focuses down single high-health targets, Finch cracks through high-Defense, and Zafir specializes in eliminating a lot of small or low-health enemies. While Zafir technically can use both Blades and Firearms, the Blades are more of a backup for him to deal at least SOME consistent damage between reloads. Instead, he's built to rely a lot on using several pistols to pick off low-health enemies while the party protects him. Nowhere is this more reflected than in his second unique skill: an ability that takes every loaded pistol in the party's inventory and fires them all off in rapid succession, randomly picking targets each time (for the Overwatch players out there, it's a lot like McCree's Deadeye ability, except...slightly different).


    And this is where making the firearm system work properly comes into making him useful. Without the Reload skill present, he's just a Melianne without the reliability. Without the gun-swapping mechanic, he's just a Finch with less survivability. In neither scenario is he viable, and especially not viable for his intended role. In order for him to actually have a place in the party, both the Reload skill and the gun-swapping mechanic need to exist together.



    I've done a lot of research into this subject, but I can't seem to find a way to make this work how I imagined it. So I decided to ask you guys if there are any plugins (or eventing/coding within plugins) that would make this system work as intended. If you know of anything, please let me know! Any help is immensely appreciated!


    ~Blackjack
     
    #1
  2. Jeremy Cannady

    Jeremy Cannady Coldfire Veteran

    Messages:
    449
    Likes Received:
    261
    Location:
    Texas
    First Language:
    English
    The problem I see is having the attack switch over to reload. I guess if you had it detect whether or not you had the gun equipped it would work alright.
    Do you have a some basic script already? 
     
    #2
  3. Blackjack488

    Blackjack488 Unassuming Veteran

    Messages:
    40
    Likes Received:
    2
    Location:
    Seattle
    First Language:
    English
    Sadly, no. When it comes to scripting, I'm woefully inexperienced. :/


    I'm also, due to computer issues, unable to access MV for the near future. But the system I had before my computer exploded was to just have a "Gun Attack" skill replace the equipped gun with an unloaded version of that gun with common events. Not exactly ideal. XD
     
    #3
  4. Blackjack488

    Blackjack488 Unassuming Veteran

    Messages:
    40
    Likes Received:
    2
    Location:
    Seattle
    First Language:
    English
    Okay, I'm back on my game, and I've narrowed down the problem to one that (probably) has an easily-fixed solution.


    Essentially, I've put together a common-event monstrosity that more-or-less covers all the bases I'm after, in addition to yanfly's Weapon Unleash plugin to change the weapon attack skills. Basically, any firearm (let's use the rifle as an example) has a common event in its attack skill that replaces the equipped rifle with an "unloaded rifle". The unloaded version is identical in every way, except that the weapon skill is replaced with a "reload" skill, that costs a shot-and-powder item and replaces the unloaded rifle with a loaded one. And that all works fine and dandy, except for one aspect: the replacement weapons aren't equipped right out of the gate, so the procedure for using a flintlock rifle is currently:


    Fire rifle --> Equip unloaded rifle --> Reload --> Equip loaded rifle --> Repeat


    So all I really need to do now is cut out those "Equip" bits, by tweaking the common events to automatically equip the new firearm to the party member who used it. The good news is that this is now a much more straightforward problem, and probably much easier to solve than it was before. The bad news is that I have no idea how to fix said problem, so I'm forced to ask you guys for help on it (and apologies if there's a completely-noobish solution that I'm just missing here).


    Any help is immensely appreciated! ^^
     
    #4
  5. Blackjack488

    Blackjack488 Unassuming Veteran

    Messages:
    40
    Likes Received:
    2
    Location:
    Seattle
    First Language:
    English
    Bump...
     
    #5
  6. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    486
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    There is an Event Command "Change Equipment" which you could use in the Common Event - that, or its Script Call equivalent, which looks like this:


    $gameActors.actor(actorId).changeEquip(slotId, item);


    Replace actorId with the ID of the actor whose equipment you want to change, slotId with the ID of the equipment slot (Weapon should be either 0 or 1) and item with the new pice of equipment ($dataWeapons[1] for weapon #1, $dataWeapons[2] for weapon #2 and so on).


    The difficulty here might be to get the right actor of more than one can use firearms - one way to do is is applying a dummy state to the user in the damager formula and then check in the common event which actor has that state.


    Before I get too deep into that, however, I think there is an easier way:


    Yanfly's Weapon Unleash can also use Lunatic Mode for Replace Attack. So you can refer to whatever keeps track of that weapon's ammo as a condition for the Shoot/Reload skills. E.g. if you use variables for your ammo system and variable #5 keeps track of the ammo for that weapon, it would look like this:


    <Custom Replace Attack>
    if ($gameVariables.value(5) > 0) {
    id = 1; // change to ID of your "shoot" skill
    } else {
    id = 21; // change to ID of your "reload" skill
    }
    </Custom Replace Attack>


    Depending on how your ammo system works, the condition would look a bit different, but let me know if this method would work for you.
     
    #6
  7. Blackjack488

    Blackjack488 Unassuming Veteran

    Messages:
    40
    Likes Received:
    2
    Location:
    Seattle
    First Language:
    English
    The second one is probably most useful for the one character who exclusively equips a unique rifle, I think. Beyond that, there'd just be too many firearms changing between too many hands to reliably keep track of. Little things like having someone switch to a sword while someone else fires a pistol, then the first guy switches back to his gun to shoot it, only for the variable to be reduced by someone else's shot. Still really helpful to know, though, if only so I don't have to make five copies of that one unique rifle. XD


    That first concept, though...that could be unbelievably useful......


    I'm still working on tweaking and ironing out the dummy-state concept, but I thought of an idea that might be more reliable and wanted to run it by you. Is it possible to store the user's Actor ID as a game variable immediately upon using the skill, then call that game variable in that skills' common event in the script line you wrote up there? So the code would run something like:


    GameVariable(4) = user.ActorID();  <--(or something. I'm bad at code. >.> )
    $gameActors.actor(value.GameVariable(4)).changeEquip(0, WeaponID#);


    I'm not sure if this is even possible, but I figured I'd ask in case it is. In the meantime, I'm still testing out the Dummy State setup, so I'll let you know if that works (probably by tomorrow morning, since it's pretty late here)!


    Thanks so much for the assist! ^^
     
    Last edited by a moderator: Jan 31, 2017
    #7
  8. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    486
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Good idea, I hadn't thought of that! I haven't tried it, but you can probably store the actor ID in a variable in the damage formula and use it in the skill's common event, since the damage is calculated before the common event runs.


    It should look like this (a stands for the user in the damage formula, but can't be used anywhere else):


    $gameVariables.setValue(4, a._actorId)


    and call it with


    $gameVariables.value(4)


    in the Script Call in the common event.


    Or you can just save the entire actor object, that would shorten the Script Call for changing equipment a bit:


    $gameVariables.setValue(4, a)


    and then in the common event


    $gameVariables.value(4).changeEquip(...)
     
    #8
  9. Blackjack488

    Blackjack488 Unassuming Veteran

    Messages:
    40
    Likes Received:
    2
    Location:
    Seattle
    First Language:
    English
    Okay...it's partly working, but I'm running into an unknown bug that's not letting it work. I've narrowed the bug down to somewhere in the Common Event Script call, and I've iterated it in every way I can. So far, nothing's actually changed what the user has equipped. Thought I'd let you know what I'm looking at and see if I'm falling into any little mistakes. I even tried using a constant as the Actor ID, and even that didn't work.


    So, either something's seriously wrong with the script calls in my version of MV, or I'm making some noobish error in the Change Equip call. With that in mind, one last bug-fix is needed. This is the code I'm using:


    $gameActors.actor($gameVariables.value(9)).changeEquip(0,$dataWeapons[41]);


    Otherwise, everything seems to work fantastically! Thanks so much for the assist!
     
    #9
  10. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    486
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    The code itself seems to be correct. Have you given the weapon to the party before that equip command? Apparently it can only change the equipment if the weapon / armor is already in the inventory.
     
    #10
  11. Blackjack488

    Blackjack488 Unassuming Veteran

    Messages:
    40
    Likes Received:
    2
    Location:
    Seattle
    First Language:
    English
    Ahh, THAT would be what's doing it!


    Everything's now fixed and works perfectly! Thanks again so much for the assist! ^^
     
    #11
  12. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    486
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Glad it's working now!
     
    #12

Share This Page