AmpedRobot's Forum Posts

  • That is intriguing. And you're right, for all intents and purposes it does look like they have different fire rates, even though there is a slight chance of duplication (about which I don't care).

    The timer is interesting too. Never used, so would've had no idea how to code.

  • Hey, plinkie.

    Believe it or not I tried a few things, but I was wondering what the best programmer's method would be as all of mine seem bloated.

    For example, I thought I could consistently vary the fire rate for each one of those objects

    http://www.darksunpictures.com/public/SAME INSTANCE FIRE DIFFERENTLY.zip

    by making them separate objects (just same animation) and then you can give them different fire rates, but you'd have to track spawns via an array to make sure they spawn in a pretty unique sequence. That seems a bit bloated.

    You could load up one of those red objects (in capx) with a lot of different fire rate variables and then potentially on spawn set each instance to a unique fire rate? Not sure if that would work, but again seems a bit bloated or not sure if the code would work (I try a lot of different things for hours, but most of them end up not working).

    Without that I thought maybe you could set the fire rate value on spawn, but that just changes it for all the ships.

    Isn't there a nifty programmer way that would make this easy?

    Again, all I'm trying to do is make different instances of the same object fire at consistently different rates I could set.

    I believe this is what you suggested initially, different but consistent fire rates for each ship or ship type (not to put you on the spot or anything).

    I went back to this because the problem with all the other solutions is an inconsistent fire rate based on how many ships have spawned or been killed etc which becomes a bit problematic.

    Plus it becomes boring if all ships of the same type always fire the same, and it looks fake.

    So..... is there a programmer's solution to this?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How would I set a variable fire rate for the same sprite? (without switching instances)

    So Instance 1 of ship X fires at 0.1 (same bullet for all)...

    So Instance 2 of ship X fires at 0.5...

    So Instance 3 of ship X fires at 0.25...

    I thought this would be easy to do, but it's giving me a devil of a time. I mean they all have the same cd or fire rate variable (and you can't set it to random inside the instance variable), so how the heck do you vary it without affecting all? Is there something like pick current or last instance or some equivalent?

  • OMG, Miraab his sails unfurled!

    <------You're dealing with a 40 year old brain here, so I guess it gets foggy sometimes when I have to deal with new concepts, plus so little brain space left after I had to learn all the other stuff to make this game.

    This is great, thanks.

  • Plinkie, am I wrong, but is this assigning random numbers to the ship types via "choose" and "pick", so they are only sometimes the same?

    I actually wanted the same firing pattern for each different ship type consistently. So say ship type 1 or t1 would only fire green shots, ship type 2 or t2 would only fire red shots.

    Is that possible?

    I guess the question is; how can one compare a specific object type picked via random instance in a family?

    Or is the only or better way of doing this via specific family instance variables setting everything up separately for each ship in terms of firing pattern?

    I guess I was looking for a convenient shortcut if one exists.

    Also, not really sure how to avoid each ship of a specific type from firing the same, some sort of random roller for the cooldown instance variable?

    It gets pretty hairy 'cause I have a lot of different ship types and if you start using similar logic without one all encompassing algorithm things break down.

    That's sort of the boat I am in right now. I designed a lot of different shot spawners, but it's similar logic, so they malfunction when there's multiple ship types on screen.

  • Hey, guys.

    Just wanted to confirm something.

    I've done some cool things with turret behavior, some unexpected, which turned out to be very cool, but one thing I wanted to confirm.

    Initially, I was trying to set up turret behavior/predictive aim for a family of different sprites/objects, but that never worked.

    The setup seems to work individually per sprite type and then you can group it to a family for other things.

    Is this correct?

    I mean I couldn't get these to do anything as a family behavior.

    Scratch this. I was able to modify plinkie's code to make turrets work as a family behavior also.

    Yei!!

  • Hey, guys or plinkie specifically!

    Alright, here's that capx.

    I'm trying to set up separate ship firing patterns.

    If you'll notice in the capx, there's 4 different ship types - based on color (t1, t2, t3, t4).

    I can't figure out or find on Google/Scirra how to code when a specific ship type (t1, t2...) is picked as a random instance and then link it up to the firing pattern instead of "ship_type" which obviously makes no sense in there right now.

    Only coded 1 firing pattern for now, but pretty easy to change with just copy and paste.

    You mentioned something that "picked instance" exists somewhere I believe, but I've never done it before so no idea how to code.

    http://www.darksunpictures.com/public/R ... _MODIF.zip

    I did this publicly because the pm system is weird. Some of my messages sit in outbox for days.

  • Thank you, plinkie.

    That works great.

  • Could you demonstrate? I had it done with sub-events only, based on logic a layman should think would work. The only difference was the Firing Group was a subevent of System -> Every x Seconds (second condition Pick Random Ships Instance), but it wasn't even picking the instance correctly in terms of timing.

  • Hey, guys.

    There's something I'm having trouble with.

    Trying to make a random instance of a ship in a family fire 2 shots of 1 type, then 1 shot of another type, then switch instance.

    I tried it various ways with sub-events where it should have worked and for some reason it doesn't.

    The attached capx is the final version where I fell back on groups as a last resort, but that just made all the ships fire at once.

    http://www.darksunpictures.com/public/A ... _SHOTS.zip

  • Addendum

    I figured this out with a multi-line function calling from the For X loop, but if anybody has any cool code they want to share, let's go for it!

    Basically, my current spawn ratios rely on randomness which means the correct spawn ratio does not always get called.

    I did controlled chaos before (within a range).

    I'd probably want a call to an array for exact spawn ratios and it'd be nice if the sequencing was random.

    But this post is solved for all intents and purposes for now.

  • Hey, guys.

    Got a question.

    How would I code something in a single line to be able to control various percentages of the ships which spawn on screen?

    Currently I have this set up as:

    set type (local variable) to choose (1,1) or choose (1,2,3,4,5...) etc, but no idea how to even set this up to accurately control spawn ratios of different ships on screen.

    Basically I have a lot of different ship types, but rather than just revealing them all at once in a random version, I found that a slower timed reveal works better, feels

    way more video gamy.

    There's generally about 10 ships total on screen at a time with the spawner I have set up.

    I have a time variable TimeCount

    so let's say TimeCount>5

    spawn just 1 ship type

    --

    TimeCount>200

    spawn 1 ship of Ship Type 2 for every 9 ships of Ship Type 1

    TimeCount>400

    say spawn 3 ships of Ship Type 5 for every 7 ships of Ship Type 3 etc etc

    Basically, it gets pretty hard to do with the choose expression.

    Something with percentages that's very compact that could fit in a single line of code (maybe with calls, functions, etc.) that works well with a For Each X element of an array loop would be great here.

    ?

    Any ideas?

  • Scratch this.

    It does actually work!

    Just made a simple capx from scratch, so no idea what happened ha ha.

    Thanks for all the replies.

    This concludes tonight's presentation.

  • 99Instances2Go

    Thanks, man. You obviously know what you're doin, but I've already implemented my ROJO modified code for this. I will process your solution at some point because it seems to be a long time programmer's solution.

    99Instances2Go

    Still tryin to do the shooting though with multiple image points. Not hard to setup with instance variables for each ship type, but gets complicated trying to control the rate of fire of many different ships.

    The simplest solution I had before, which worked very well, was:

    Every x seconds

    Pick a random instance Sprite -> Sprite - spawn bullet

    Replacing Sprite with a Family of say 20 sprites did not work (think they all fire simultaneously).

    Is System ->Pick Random Instance equivalent to Pick a Random Family Instance? Where is the family random instance picking or is it the same?

    Maybe I'm just not seeing that option anywhere.

    Found a Scirra tutorial on picking family instances and it will take hours to test absorb, but I do not believe I want to mess with UIDs or anything that fancy.

  • Thanks a million!!!