Jump to content

"When this weapon is equipped, zoom in and press E to fire Projectile2" - How do I code this into a mod?


Epsilon725

Recommended Posts

Let's say I'm making a mod that adds a custom weapon that fires normally fires a certain projectile when fired normally, and that's 10mm bullets. But if you zoom in with Right Mouse Button and press E, the gun instead shoots Projectile2, a Dragon's Breath Shotgun Round. And each use of this feature costs 10 bullets of 10mm ammo. This is just an example of what the alt-fire mechanic could be used for.

 

How would I go about coding in a feature like that, or if that doesn't work, a "Press K while this custom 10mm gun is equipped to fire Dragon's Breath ammo for free" feature?

Link to comment
Share on other sites

Seems to me you need a couple of event handlers that become active when you have the weapon "equipped" event: one which would handle the "zoom" and set a flag; and within that another that would detect the "trigger" button and check that the necessary pre-conditions (correct weapon equipped and triggered, zoomed, sufficient ammo and type, etc.) are met.

 

"OnActorEquip" is a standard event. "IsEquippedWeaponScoped" is a standard function. The others would need to be custom handlers you program yourself. See the links 'TIP Do not overlook EventHandlers' and 'Tip EventHandler for HotKey' under the "Scripting" section of the wiki "Getting started creating mods using GECK" article for articles on that process.

 

-Dubious-

Link to comment
Share on other sites

Made this for you, learn from it:

https://drive.google.com/open?id=1cPvYwioDGVllO7a5D3Fv2HXBx8DUHV9f

 

Makes a 10mm pistol fire a missile projectile at the cost of 10 bullets when the following requirements are met:

  • Player is aiming (IsControlPressed 6 == 1)
  • Player has atleast 10 rounds loaded (Player.GetCurrentAmmoRounds >= 10)
  • Player is pressing the 'e' key (IsKeyPressed 18 == 1)

I'll answer any questions you have.

 

Edit: Requires NVSE & JIP LN NVSE Plugin

Edited by IntenseMute
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...