View unanswered posts | View active topics It is currently Mon Jul 08, 2024 4:10 pm



Reply to topic  [ 13 posts ] 
 A Flintlock Musket - Code, not sprite. 
Author Message
User avatar

Joined: Thu Apr 23, 2009 6:35 pm
Posts: 71
Reply with quote
Post A Flintlock Musket - Code, not sprite.
So basically, all I would like to see is how to code a Musket so that the weapon fires with a delay of about 0.1 seconds. This is best explained with how a Musket actually works :

Wikipedia wrote:
The gun is leveled and the trigger is pulled, releasing the cock holding the flint.
The flint strikes the frizzen, a piece of steel on the priming pan lid, opening it and exposing the priming powder.
The contact between flint and frizzen produces a shower of sparks (buring pieces of the metal) that is directed into the gunpowder in the flashpan.
The powder ignites, and the flash passes through a small hole in the barrel (called a vent or touchhole) that leads to the combustion chamber where it ignites the main powder charge, and the gun discharges.


I'd also like to know how to code the bullet as a MOSParticle. From what I see the only way for a MOSParticle to cause any damage is for it to either explode on impact or have an emitter attached to it. I'm not entirely certain on how it works, either way.

If you noted from my thread title, I don't ask for a sprite, however, if you are willing to try and beat my sprite, the weapon in question is a Charleville .69 Caliber French Musket.

As my avatar suggests, I am a dummy, especially in regards to coding, but I'm willing to learn. I'd appreciate it if you didn't code an entire weapon, but rather a small portion of it, ex.

Code:
StartTime = 100
EndTime = 100


Not sure if that is the actual parameters for wind up time, but I've checked and tried for the musket and it doesn't work well at all.

Another thing I would definitely like is a large amount of smoke to come out of the lock of the gun, but that is aesthetics and I tend to care about those the least (meaning, don't do it if you don't want to.)


Tue Oct 11, 2011 3:08 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
I can help you out.

But to begin with, MOSParticles work exactly the same as a MOPixel, the difference is that this one has a sprite that doesn't rotate.

You probably mean a MOSRotating or an AEmitter.

To have the aesthectics effects you want, you'd have to make the weapon fire an AEmitter that emits the particles you want to be fired (this method is used to reduce recoil, for example, in the Coalition's Revolver Cannon, but it can also be used to fire multiple type of particles at the same time, for example, the Coalition's Flamer).

Well so, the wind up and down code can be copied from the Coalition's Gatling Gun and tweaked to your likings.


Tue Oct 11, 2011 4:37 am
Profile
User avatar

Joined: Fri Aug 20, 2010 4:45 am
Posts: 911
Location: No Comment.
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
i'll maby try and sprite this, not to sure at this point. Busy


Tue Oct 11, 2011 8:22 am
Profile
User avatar

Joined: Thu Apr 23, 2009 6:35 pm
Posts: 71
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
Not sure if this is possible without Lua, actually.
I don't think I stated that in my main post.


Tue Oct 18, 2011 1:51 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
Bud.
Did you read my post?

If I got it right, it's perfectly possibly with ini, and it's pretty easy.


Tue Oct 18, 2011 2:13 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
The problem with a wind up is it would seem unrealistic since you would be able to fire and then cancel the shot.

If you want to go the realistic direction then lua would be the way to go. Making it fire an Emitter would make some nasty muzzle stray without it following the weapon's muzzle properly.


Tue Oct 18, 2011 2:18 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
Instead of windup it could just have a slow ROF. Let's say 30, it should fire after 2 second of holding click.


Tue Oct 18, 2011 2:28 am
Profile
User avatar

Joined: Thu Apr 23, 2009 6:35 pm
Posts: 71
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
So holding down a click as opposed to just clicking?
I'm playing this with friends, so If you can lua something up really small and tell me what the params do I'd be grateful.


Wed Oct 19, 2011 2:07 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
Code:
function Create(self)
   self.fireTimer = Timer();
   self.fireTime = 3; --seconds
   self.firing = false;
   self.bullet = CreateMOPixel("Bullet"); --presetname and type of bullet here
   self.speedmultiplier = 2; --adjust this to alter bullet speed, muzzleoffset also affects this
end

function Update(self)
   if self.parent then
      if self.parent:GetController():IsState(Controller.WEAPON_FIRE) == true and self.firing == false then
         self.fireTimer:Reset()
         self.firing = true;
      end
      if self.firing == true and self.fireTimer:IsPastSimS(self.fireTime) then
         self.bullet.Pos = self.Pos + Gun:RotateOffset(self.MuzzlePos);
         self.bullet.Vel = Vector(self.MuzzlePos.X * self.speedmultiplier,self.MuzzlePos.Y * self.speedmultiplier);
         MovableMan:AddParticle(self.bullet);
      end
   else
      self.parentID = MovableMan:GetMOFromID(self.RootID);
      if MovableMan:IsActor(self.parentID) then
         self.parent = ToAHuman(self.parent);
      end
   end
end

Seriously untested code. If anyone sees any corrections do make them noticed.


Last edited by Roast Veg on Wed Oct 19, 2011 7:47 pm, edited 1 time in total.



Wed Oct 19, 2011 7:06 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
Instead of defininf the Muzzle position you could have used self.MuzzlePos.


Wed Oct 19, 2011 7:26 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
I wasn't entirely sure if that worked. If you're sure it does then I'll rewrite it.


Wed Oct 19, 2011 7:39 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
It's used in Charged Weaponry mod.
A mod that I coded.
And works.


Wed Oct 19, 2011 7:42 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: A Flintlock Musket - Code, not sprite.
Thanks for clarifying, and fixed.


Wed Oct 19, 2011 7:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 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.030s | 13 Queries | GZIP : Off ]