Reloading a gun.

HI

So currently I'm trying to have my character use a gun that uses 6 bullets (revolver) before he/she has to reload. What I need help with is how do I make the hero reload (as in he/she can't use the gun during the reload period) when he/she hits zero bullets. The reload will be automatic when it hits exactly zero.

I currently have a self made attribute integer at 6 called ammo.

--Gun (actor receives event)(mouse button) is (down)
--spawn actor (bullet)
--change attribute (self.ammo) to (self.Ammo-1)

How do I make the hero NOT be able to shoot his/her gun while reloading?
How do I make the attribute ammo go back to six after it hits zero? I'm guessing something to do with timers and change attribute.

I'm guessing I need a group or rule that once it hits zero that after X seconds reload change attribute back to six.

If you need more information or better clarity please let me know. Thank you for your time and knowledge.

Comments

  • GnarlyGnarly canadaMember Posts: 840

    Can you make in the fire rule another condition:
    Fire if bullets are => than 1

    It will fire until 0 bullets. It will stop firing because bullet attribute is less than 1.

    When you reload and bullet attribute is 6 again.
    It should allow firing again because that condition is met to fire.

    Make sense?

    if attribute bullet =<0 then
    Change attribute bullet to 6

    If you want a delay.

    Timer After 1 second
    Change bullet attribute to 6

    You can alter time to what's needed.

  • SocksSocks London, UK.Member Posts: 12,822

    @gattoman said:
    Can you make in the fire rule another condition:
    Fire if bullets are => than 1

    It will fire until 0 bullets. It will stop firing because bullet attribute is less than 1.

    When you reload and bullet attribute is 6 again.
    It should allow firing again because that condition is met to fire.

    Make sense?

    if attribute bullet =<0 then
    Change attribute bullet to 6

    If you want a delay.

    Timer After 1 second
    Change bullet attribute to 6

    You can alter time to what's needed.

    Yeah, that's basically how I'd do it too, I'd also stick the reload into the otherwise section.

    When Ammo > 0
    --When mouse button is down
    ----spawn bullet
    ----change Ammo to Ammo-1
    Otherwise
    --Timer: After x seconds
    ----change Ammo to 6

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited April 2016

    You might want to consider putting your ammo in a game attribute instead of a self one on the actor as it'll be easier to show your ammo count elsewhere on the screen as bullets that disappear one by one as they're fired. I'm talking about heads up display here.

  • BinbangBinbang Member Posts: 2

    Awesome. It works with everything I was told. Thank you for the assistance.

Sign In or Register to comment.