Jump to content
  • Advertisement
Sign in to follow this  
marc_moy

Real-Time attack on RPG (click-attack) how to:

This topic is 3665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using C++ and Dx9 API.. I just want to ask you guys how to do that method? (click enemy to attack) it would be nice if you point me to a tutorial site or lend me some pseudcodes or some actual coding.. im planning to make a turn-based RPG BUT i really want to do click-attack style.. so i'll give it a try! Thanks a lot in advance! [Edited by - marc_moy on June 10, 2008 5:22:07 AM]

Share this post


Link to post
Share on other sites
Advertisement
What exactly do you want help with? Selecting characters, combat, AI?

What systems are you using (Language, OS, libraries)?

I think you need to ask something more specific to get a meaningful reply.

Also, don't expect a reply straight after you post. Give it a little time.

Share this post


Link to post
Share on other sites
You mean target enemy with mouse pointer, then click attack?

You'd need some way of detecting which object your mousepointer is over (picking), you'd then need to store it as a target, if that's the route you're going. Then you handle your combat logic on it, whichever way you've thought about doing that. There are so many ways to go about and solve this though.

Share this post


Link to post
Share on other sites
yes!! when clicking the enemy, your main character will attack it! my problem is should i use A*? how about when i already clicked the enemy then while moving close the enemy walked away,the main character should follow and attack right??
how?

Share this post


Link to post
Share on other sites
Quote:
Original post by marc_moy
yes!! when clicking the enemy, your main character will attack it! my problem is should i use A*? how about when i already clicked the enemy then while moving close the enemy walked away,the main character should follow and attack right??
how?

Your questions are far too broad. Without knowing how you handle game states, objects and positions, we have no idea whether a character should follow and attack, let alone how to implement that.

I suggest you think about what functionality you want. Identify the individual features; for example, selecting a character when clicked on, running the attack animation, calculating effects of the attack, calculating distance to enemy and determining whether he's close enough etc. Then try to implement that. If you have trouble with a specific feature, then ask for help and we might be able to assist.

Share this post


Link to post
Share on other sites
It sounds like you are trying to implement a basic AI system. As has been said, you need to decide what you want your characters (units?) will do. I would suggest making a flow chart to explain it's behaviour, e.g.

Is enemy within range?
- If yes then fire at enemy
- If no then move towards enemy.

Break down each step until it leads to some code decisions.

Thinking about things like A* algorithms is way to early at this stage. You need to flesh out your game design a little more first.

Share this post


Link to post
Share on other sites
If your using the DirectX sdk check out a function called D3DXIntersect

http://msdn.microsoft.com/en-us/library/bb172882(VS.85).aspx

This is an easy version of picking that works with .x models. If you also need to know how to get an attacking to work when a click has been made you can try looking up states and finite state machines.

E.G when you click on something to attack your entity enters an attack state and runs it's attacking code. You can send in a pointer to the enemy that has been attacked and walk towards it with an A* like you said (Be sure to have a way to check if the enemy is still alive each turn so you don't get a run time break on deletion) Then use vectors (or a Manhattan distance if your using grids) to see how close you are to your target if your in range your A.I should attack.

Hope that helps.

Share this post


Link to post
Share on other sites
Sorry to butt in... but, a Manhattan distance, is it used because the added arithmatic for an actual distance formula is to slow? Or not too slow, but maybe just alot slower?

Share this post


Link to post
Share on other sites
No, it's simply because if you can only move horizontally or vertically along a grid, then the Manhattan distance is more accurate than the Pythagorean distance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!