View unanswered posts | View active topics It is currently Tue Mar 19, 2024 3:47 am



Reply to topic  [ 6 posts ] 
 Some HDFirearm questions 
Author Message

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post Some HDFirearm questions
Hello, I have three questions about how firearms function. I'll keep them short and sweet.

First off, is there some kind of rateoffire limit? I set my new weapon to 1800 but it seems to be eating up ammo at that rate - not actually firing it that fast. Is that a problem with the velocity of the bullet or something? Does it not go away fast enough for the next bullet? EDIT: It only fires once every 4th shot. How odd. EDIT 2: This problem has been fixed. Rounds to tracer ratio confuses me, as in why its there, but it works now. Other questions still stand.

Next up, I'd like to make a weapon that requires to charge up to full before firing - you can't hold this charge or charge longer for the weapon to be stronger, it's a set time with a set sound effect. So far I've been able to replicate this with spinup, but the problem is that if I charge halfway and let go, the sound still goes, and it also sets off AFTER I've shot the weapon, so it charges up a second time while I'm reloading, which is not what I intended for it to do.

Last off, reload sounds. Is there any way to make the ReloadStart sounds stop if you switch away from the weapon? Some of my bigger, slower weapons have custom sounds and it feels off when I switch away and still hear them.

If it's possible to do any of this without delving into Lua, please say so. I know CC's variable system but next to nothing about Lua.

Thanks

-Hoovy


Wed Dec 23, 2015 9:42 am
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Re: Some HDFirearm questions
Tracer rounds are fired once every [RTTRatio] shots. Set TracerRound to None and RTTRatio to 0 to disable them.

Charge-up weapons can pretty much only be done through either spinup or lua. The Dummy faction has two charge-up weapons but they gain power from longer charges. The Techion faction has one weapon that works through spinup, but it only has one shot per mag. The effect you're looking for shouldn't be too simple to achieve though.

Dynamic reload sounds can be tricky, and they absolutely require lua scripting, e.g. something like having 3 different sfx that each play at certain stages of the reload, or an AEmitter that plays the sound if the weapon is still held. You could combine this with some gfx, too.

Let me know if you want further help with this.


Wed Dec 23, 2015 4:24 pm
Profile

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post Re: Some HDFirearm questions
4zK wrote:
Tracer rounds are fired once every [RTTRatio] shots. Set TracerRound to None and RTTRatio to 0 to disable them.

Charge-up weapons can pretty much only be done through either spinup or lua. The Dummy faction has two charge-up weapons but they gain power from longer charges. The Techion faction has one weapon that works through spinup, but it only has one shot per mag. The effect you're looking for shouldn't be too simple to achieve though.

Dynamic reload sounds can be tricky, and they absolutely require lua scripting, e.g. something like having 3 different sfx that each play at certain stages of the reload, or an AEmitter that plays the sound if the weapon is still held. You could combine this with some gfx, too.

Let me know if you want further help with this.


I do need some help. If I were to want to code all that, where would I start? I've tried looking and sifting through and editing various lua files from mods and the base game alike, but all I can achieve is.. well, nothing. Lua is completely undecipherable to me.


Wed Dec 23, 2015 4:41 pm
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Re: Some HDFirearm questions
Lua scripting can definitely be a lot of trial and error to start with.

I could use some clarification with the charge-up weapon though; from what I understand, you basically want the weapon to have a delay before the round is fired? You could first see if the actor had tried to fire the weapon, then have it wait x amount of milliseconds before the weapon is actually activated.

See if this works. (apply this to the weapon)
Code:
function Create(self)   -- upon creation
   self.chargeDelay = 500;      -- charge time in milliseconds
   self.chargeTimer = Timer();   -- set a timer
   self.charge = false;         -- not charging on creation
end

function Update(self)   -- every frame
   if self.charge == true then            -- are we charging?

      gfx = CreateMOSParticle("Tiny Smoke Ball 1");      -- gfx example
      gfx.Pos = self.MuzzlePos;
      gfx.Vel = self.Vel + Vector(2*math.random(),0):RadRotate(math.random()*(math.pi*2));
      MovableMan:AddParticle(gfx);

      if self.chargeTimer:IsPastSimMS(self.chargeDelay) then   -- are we past the charge delay?
         self:Activate();      -- fire!
         self.charge = false;   -- charge is over
      else            -- charge isn't done
         self:Deactivate();      -- can't fire
      end
   elseif self.Magazine and self:IsActivated() then      -- not yet charging, activated & magazine exists (not reloading)
      if self.triggerPulled == false then         -- trigger isn't already been pulled
         self:Deactivate();            -- can't fire
         self.charge = true;         -- start charge
         self.triggerPulled = true;      -- trigger has been pulled
         self.chargeTimer:Reset();      -- start timer from 0

--[[ charge sound effects

         sfx = CreateAEmitter("Sound Particle Name"); -- make an AEmitter with the sound, example: Dummy.rte/Devices/Weapons/Laser Cannon.ini/"Dummy Laser Cannon Sound Fire"
         sfx.Pos = self.Pos;
         MovableMan:AddParticle(sfx);

remove these when done ]]--

      end
   else      -- not activated
      self.triggerPulled = false;   -- trigger isn't pulled
   end

   if self.Magazine and self.Magazine.RoundCount == 0 then   -- automatic reload at 0 ammo for optimization reasons
      self:Reload();
   end
end


Wed Dec 23, 2015 7:06 pm
Profile

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post Re: Some HDFirearm questions
4zK wrote:
Lua scripting can definitely be a lot of trial and error to start with.

I could use some clarification with the charge-up weapon though; from what I understand, you basically want the weapon to have a delay before the round is fired? You could first see if the actor had tried to fire the weapon, then have it wait x amount of milliseconds before the weapon is actually activated.

See if this works. (apply this to the weapon)

*code*


Thank you so much! It works pretty much perfectly! I have a feeling it'll be a while before I understand lua well enough to do stuff like that on my own, but that is going to help a lot, since I know exactly what it does and can study it closer. Thanks again!


Wed Dec 23, 2015 7:38 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Some HDFirearm questions
Hoovytaurus wrote:
EDIT 2: This problem has been fixed. Rounds to tracer ratio confuses me, as in why its there, but it works now. Other questions still stand.


Tracers have two uses;

1) You can mix stronger bullets in.
2) You can mix brighter, more visible bullets in.

They're mostly used for #2. You generally don't want a gigantic obnoxious spray of bright bullets going everywhere as it can make things very visually-noisy, especially with rapidfire weapons - so what you do is have a more neutral-coloured regular round and a brighter tracer. Several of the vanilla weapons do this already, and their tracers are usually a tiny bit more lethal too.


Wed Dec 23, 2015 10:52 pm
Profile YIM
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.211s | 17 Queries | GZIP : Off ]