Create xcom like chance of hitting target/missing target?

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • This is probably has a solution beyond my current comprehension of C2 but I would like to know is it possible to create a "chance of hitting target based on certain conditions" style game in C2. Xcom EU is a perfect example where you have a player unit targeting an enemy unit and depending on the distance, weapon, and cover of target, a percent chance of hitting the target is calculated and shown. If so, could someone point me in the right direction of the C2 manual or maybe a tutorial or keyword I should start searching to begin grasping this concept? Im assuming if this is possible that "arrays" would play a large part so Ill start there but a little guidance would be greatly appreciated.

    Thanks in advance.

  • First, are you applying this to an action game or a turn based game? i.e. will there be live game movements to consider?

    Are you talking about the physical act of shooting and missing? i.e animating a bullet and as it travels start to make its accuracy falter? Or do you mean just calculations? If it's just calculations you completely control that with your design.

    Arrays have nothing to do with that really, except a way to loop through data. Seems like you are talking about design.

  • First, are you applying this to an action game or a turn based game? i.e. will there be live game movements to consider?

    Are you talking about the physical act of shooting and missing? i.e animating a bullet and as it travels start to make its accuracy falter? Or do you mean just calculations? If it's just calculations you completely control that with your design.

    Arrays have nothing to do with that really, except a way to loop through data. Seems like you are talking about design.

    Just calculations. Essentially a real time xcom instead of turn based BUT moving objects should not be considered since the units stay still when firing. Instances that would effect the chance of successfully hitting a target would be cover, weapon, and distance. I know this must be very complex so even guiding me on where to start to learn how to begin such a process would be immensly helpful. Its possible it may be easier than I think for someone with advanced understanding of the capabilities of C2. I was considering creating "safe zone" sprites which would simply be invisible squares that would be placed behind "cover" sprites and having an event that would go something like "When unit is colliding with object "safe zone" object "bullet" has 30% chance of hitting target. Or maybe creating a series of % chances that the bullet can hit the target and initiating these depending on the "safe zone" the unit is colliding with. The problem is, I dont know if that is even possible in C2 and if it is, then what section of the tutorial do I start looking into. Im more than willing to put in the time to research this but I dont know where to begin. Thanks for the response.

  • You could use the line-of-sight behavior to check if your units are covered or not, and based on that check apply a modifier.

    A couple of months ago I wrote a tutorial about getting several % of loot drop out of mobs, you could inspire yourself of that tutorial to possibly apply several % of "touch chances" to your shoots.

    It's not straight forward, but I guess it would be a good way to start.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's more of a design issue than if C2 can do it. C2 can pretty much do anything you need it to (in 2D).

    It doesn't sound that hard to do. Especially if the ships are stable like in the game FTL. If you don't care that the weapon physically goes through the target and you flash something on the screen like "MISS" then that's WAY easier to accomplish.

    One way I can think of is when doing the calculation you should have an overall modifier. So weapon1 has a 80% chance of hitting. Give that number a value out of 0-100 (100 means you will always hit, 0 means always a miss). Then check for other modifiers. Distance > 500? -10, distance >1000? -20. Enemy has cover? -20 Player has a gunner with >10 exp? +10

    Figuring this out is a whole process of testing and balancing. Something you will probably modify up until the game is just about done. Meaning, it's going to change a lot!

    Then when you have your final modified number (ToHitNumber), generate a random() number between 0-100 and see if its within your ToHitNumber. If it is, player hit the target, if not, player missed. Then you can do a similar process for how much damage you did.

    basically D&D...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)