Ghost Song (back on Stencyl -- Warning, big GIFs ahead!)

twotimingpete

  • *
  • Posts: 1667
Thank you so much! I really appreciate you responding so quickly to my question. I do have a follow up, though, since I'm pretty worthless with code. Is there a way to set the scroll factor to a Number Game Attribute? Or is that asking too much?

It might be, but I'm not much of a coder either! Anyone know?

rob1221

  • *
  • Posts: 9424
Code functions can be made into custom blocks that make them much easier to use in design mode.  See attached behavior containing a global custom block for setScrollFactor().

Thanks Rob. Can you try re-attaching that picture? Doesn't seem to be a code block.

Code functions can be made into custom blocks that make them much easier to use in design mode.  See attached behavior containing a global custom block for setScrollFactor().

rob1221

  • *
  • Posts: 9424
Behaviors in Stencyl are exported as images that have the code embedded.  To import, go to File > Import Resource.

twotimingpete

  • *
  • Posts: 1667
Since some of you guys have shown interest in what I'm doing under the hood, I had the idea to post what I did tonight concerning finishing up the "Scatterburst" weapon (which is like a shotgun).



I had the look pretty much how I wanted, but it was still "static" in its damage calculation. The bullet would hit the enemy and do X damage regardless of range. My criteria to finish up the behavior of this weapon, though, was that each bullet would have higher damage and crit chance the closer the target is to you -- Ideally have it so damage is really high if the range is point blank, and rather very low if at the furthest reaches of the bullet's range. The other part of the criteria is it needs to, like all of my other secondary weapons, have its damage tied to the global attribute "special damage modifier", which begins the game at 100. This is so that as you level up, all of your acquired secondary weapons have their characteristics improve just from that one number. They all tie into it in different ways.

To begin, what I did was within the shotgun bullet behavior, create an attribute that goes up by 1 each frame. I then did some tests with the print to see what this number is at at each point in its range to an enemy.

Next it was time to figure out how to incorporate that number into the damage calculation within the enemy's behavior. Upon impact with the bullet, the enemy will get that attribute from the bullet and then tie it into its damage calculation.



As usual, I roll a crit attribute between 1 and 100. I wanted to incorporate the shotgun's range modifier into the crit chance. Through print statement testing I'd determined that the furthest reaches of the bullet would have a modifier of about 25-30, and at point blank it's 1-3 or so. So I multiply that number by 10, such that a point blank impact has a 70% - 100% chance to crit, and the furthest ranges having little or no chance.

Moving on down, we see now that we divide the global special damage mod (which begins the game at 100 and can be raised as you level up) by the range modifier. A non-crit is halved (it's typical for crits to be about double damage in my weapons). For good measure, just so there's always a bit of randomness, I add a small amount at the end of the calculation. Not every damage calculation is the same, but in this case I just wanted a chance to add 0 to 5 damage to the calculation, this makes the max range shots a bit less useless and also keeps the numbers from all being identical when the shotgun blast hits, which makes it more.. fun, I guess.

End result:

http://gfycat.com/SanePitifulCentipede.webm

we see that we get glancing damage at far ranges, and tons of damage and crits at point blank. while the specific number amounts may be edited, and in fact are likely to be as balancing goes, the basic functionality feels pretty good.

Let me know if you have any questions :D

« Last Edit: May 31, 2014, 12:55:05 am by twotimingpete »

Hectate

  • *
  • Posts: 4643
Off topic posts were split per the request of the users; the new topic can be found at the link below.

http://community.stencyl.com/index.php/topic,32580.0.html
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

MeToo

  • Posts: 338
What if you record the coordinates of our hero as an attribute upon firing, then upon impact compare that to the coordinates of the enemy, determining the shot pellets' distance travelled? Seems like that would be less resource intensive than counting off frames, but maybe it's negligible. I like your solution though, and the game is continuing to look beautiful.

twotimingpete

  • *
  • Posts: 1667
you're quite possibly right, but when you consider the amount of things I'm doing and tracking in the game this one attribute going up, and only going up during a shotgun blast, seems pretty negligible. it's not like I see a frame dip when I shoot the shotgun. from my experience, merely setting an attribute to something, even if it's every frame, is not resource intensive.

Alexin

  • *
  • Posts: 3132
Since the amount of damage is (inversely) proportional to the distance travelled by the bullet, the correct approach would be a function (custom block) that, given a vector, returns the corresponding damage.
Matt's solution is a quick and good approximation for all purposes. I would stick with it as long as it works.
"Find the fun"
alexin@stencyl.com

Hectate

  • *
  • Posts: 4643
I can't help but think that the damage is being increased more than necessary for the range. If each projectile does more damage up close AND more of them hit because you're close, there can be a significant variance. Intended perhaps, but to that degree?
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

NobodyX

  • *
  • Posts: 1228
I can't help but think that the damage is being increased more than necessary for the range. If each projectile does more damage up close AND more of them hit because you're close, there can be a significant variance. Intended perhaps, but to that degree?
Probably better to make the weapon, compared to the other weapons, more different instead of more similar.

MeToo

  • Posts: 338
it's not like I see a frame dip when I shoot the shotgun.

Matt's solution is a quick and good approximation for all purposes. I would stick with it as long as it works.

Sure you guys are right, I believe I am fairly often guilty of "premature optimization".  I'll think of baseball  and cold showers....

snake13

  • Posts: 126
Wait, I'm confused. Is this game already released  or still in progress. If still in progress when is this game going  to be released?
Will it cost money?
Ludum Dare Game: Connected Worlds
URL:http://www.stencyl.com/game/play/27958

MadManAdam

  • Posts: 371
Wait, I'm confused. Is this game already released  or still in progress. If still in progress when is this game going  to be released?
Will it cost money?
http://www.ghostsonggame.com

snake13

  • Posts: 126
Wait, I'm confused. Is this game already released  or still in progress. If still in progress when is this game going  to be released?
Will it cost money?
http://www.ghostsonggame.com
Didn't answer my question
Ludum Dare Game: Connected Worlds
URL:http://www.stencyl.com/game/play/27958