Magic Targeting System

Issue #10 resolved
Chris Logsdon
created an issue

This system will most likely only apply to the Mage. This should be separate from the Mage's regular ranged attacks, which involve one key press, and which travel independently in a straight line (likely a fireball)

The magic targeting system, likely initiated by the 'S' key, would work like this:

When the key is down, send out some sort of cross-hair-like graphic in a straight line. Put some acceleration on it so it has some sort of "casting time". Starts slow, and gets faster the further it travels.

Continue to move the cross-hair in a straight line until either the key is released or until it hits a wall/goes off-screen. If there is a continuous acceleration on the cross-hair graphic, then if you try to hit something that is very far away, the cross-hair will be moving pretty fast by the time it reaches your target, thus making it more difficult to hit with the attack.

When the key is released, stop moving the cross-hair graphic, and initiate the spell and its animation (likely a lightning bolt). The collision between the spell and the targeted enemy/object should not not occur until their actual pixels come into contact. This will make it so you need to lead the target if it's moving. Not to mention, it'd be pretty goofy to have the enemy die/disappear before the bolt even touches him.

The amount of mana this uses up as compared to the other attacks will probably be better determined once we see it in action.

Comments (23)

  1. Chris Logsdon reporter

    I do believe I could take on this task, but I want to ask you... How would you go about setting it up? That is, where should this system exist in code? The Fireball class (which should be renamed to Projectile)? The Mob class? Game?

  2. Jake Albano repo owner

    I think the lightning attack should be its own special class, since it's not really a projectile. I like your targeting lets the casting become a skill of sorts since it isn't necessarily easy to use. I wouldn't have the acceleration be too fast though...and the spell should fail gracefully (no mana lost) if the targeting thing goes off screen or hits a platform.

    What do you think of something like this as the target beacon? It seems to fit.

    Would it make sense to have the spell fail if there is a platform or other obstacle above the target area? We'd probably want the bolt to end at the platform the target enemy is standing on.

    Assuming only one lightning bolt will be active at once, I'd say add a private variable of type LightningBolt (or whatever you name the class) to the Game class.

    private var boltAttack:LightningBolt = null;

    When you cast the spell, make a new bolt and assign it to that variable. Then check it against enemies in the collision loop, right after the projectiles are checked ( line 133 of in my revision. It should be the same for you.)

    if (boltAttack) // Check if not null
       if (boltAttack.hitTestObject(Mobs[l]) { // Do stuff here }

    You should probably add a timer to the class and set a Boolean if enough time has passed that the bolt is fully extended, and another Boolean that tells the Game class to set it back to null if the animation has finished.

    That's how I would do it, anyway. As long as it works I'm happy though. ;) You should be able to figure out how to make it animated by looking at the Mob class, but as always email me if there are problems.

  3. Jake Albano repo owner

    Just pulled in your latest work and both of the new images look fantastic. Since this is coming along so well, let's focus on the mage as the class to finish up before we submit the work so far this Thursday.

  4. Jake Albano repo owner

    I fixed the bug where the last frame of the animation remains on the stage in revision 2abdc97a6938 .

    Not sure if this was intentional, but you were adding the bolt animation at position 0, causing it to render under everything else. I fixed it in my revision, but if that was intentional it can be changed back.

    Also, in the future, make sure to add display objects directly to the stage (stage.addChild ) instead of to the document class (addChild ). It makes removing objects easier.

  5. Chris Logsdon reporter

    I meant to do it at 0, but I did not want it to be behind everything else. I didn't know that was causing it. I thought 0 was the top. So the way you have it now is how I intended it :P

    Thank you for telling me that, because I really have never felt comfortable with how I added children. I've never known for sure the proper way. Thank you for clearing this up! :) Many of the bugs I've been struggling with were due to that.

  6. Chris Logsdon reporter

    Well, we should figure out what we want to do (and do it) with if there is a platform above where the bolt would hit. Other than that, I think it's pretty good. The collision detection isn't as clean as I'd prefer, but it certainly works.

  7. Jake Albano repo owner

    I was thinking about this, actually...since it's a magic lightning bolt it doesn't have to come out of the sky...what about having some sort of vortex or something open up above the beacon and have the bolt come out of that?

    There should be a frame in the generic enemy animation that shows an x-ray effect when he gets zapped. :D

  8. Chris Logsdon reporter

    This is super close to being done. The only thing is... in it's current state, it's very easy to hit an enemy with this without ever even coming near the enemy. I'm feeling like we should do one or more (or none) of the following:

    • Put a range limit on the wisp
    • Stop the wisp when it collides with an object
    • Stop the bolt if it hits a platform
    • Have the bolt start at the bottom of the nearest above platform (if one exists between the wisp and where the bolt would normally start.

    Maybe it's not too cheap as it is, though? Let me know.

  9. Jake Albano repo owner

    I don't feel like it's all that easy to seems like the collision has to be right on for the attack to connect.Or did you mean you don't have to hit the enemy with the bottom of the bolt? I kind of like it that way. It makes it possible to hit multiple enemies with the same bolt.

    I think the way it works now (coming out of the vortex) makes more sense than if it were to emit from a platform. With the vortex we have the excuse that it came out of a magical dimension or something.

    I do think we should stop the wisp if it goes off the screen, and not charge mana.

  10. Chris Logsdon reporter

    My only reservation is how easy it is to kill the enemies with the attack without ever confronting the enemy. I feel like if we left it exactly as it is, it would put a big restriction on level design. I just don't know how to change it, and I would like to see this get checked off as well.

  11. Jake Albano repo owner
    • changed status to open

    Ah, I see.

    What about making it drain a large amount of mana, and making the health/mana/ammo drops disappear after a fairly short time? It would limit the amount of times the attack could be used, effectively making it more special, and if you're too far away from a mana pickup it would fade away before you could get there.

  12. Jake Albano repo owner

    (Reply via

    Another possibility could be having the wisp fade out after traveling a certain distance, so the spell automatically deactivates after it goes too far. Whatever you want is fine; it's your call.

  13. Log in to comment