Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Is it possible to modify which proj a weapon fires during combat  (Read 523 times)

rogerbacon

  • Commander
  • ***
  • Posts: 151
    • View Profile
Is it possible to modify which proj a weapon fires during combat
« on: December 11, 2022, 06:11:46 AM »

I want to make a weapon that has two modes, call them slug and shotgun. All the differences between them are in the proj class that the weapon fires. Is it possible to bind a hotkey that changes what proj a weapon fires and be able to call it during combat?
I see in the WeaponSpecAPI there is a GetProjectileSpec() but I don't see any setter method.
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Is it possible to modify which proj a weapon fires during combat
« Reply #1 on: December 11, 2022, 02:27:42 PM »

you can have the weapon's base projectile's onFireEffect script delete the original projectile before spawning the projectile(s) that you actually want it to use.
as for swapping the mode, I'd limit that to a system or so to make it easier to manage, though you could also set up a BaseEveryFrameCombatPlugin & use that script's processInputPreCoreControls() method to detect & intercept key presses.
« Last Edit: December 11, 2022, 02:32:28 PM by Ruddygreat »
Logged

rogerbacon

  • Commander
  • ***
  • Posts: 151
    • View Profile
Re: Is it possible to modify which proj a weapon fires during combat
« Reply #2 on: December 13, 2022, 05:05:49 AM »

Hi. Thank you for your help. I've partly implemented it. Right now it just uses a random number to switch between the two projectiles. Before I move to the final step of making it deterministic I have a few questions.

I'm using engine.removeEntity(projectile); to get rid of the original projectile. Is this thepreferred way?
This is how I'm spawning a new projectile engine.spawnProjectile(projectile.getSource(), weapon , "plasma_R_torpedo", "plasma_R_torpedo_shot", projectile.getSpawnLocation(), projectile.getSource().getFacing(), projectile.getVelocity());
How do I get it to have an initial travel direction toward my mouse like the original projectile? Also, it comes out a little slower that the original.

Finally, the original projectile has a flight time of 10 seconds, as defined in the CSV. Any projectile I spawn dynamically has a flight time of just 6 seconds. Any idea what could be causing this?
Thanks in advance for any light anyone can shine on these questions.
Logged