Kay dudes, I need some advice.
EQ Is a party based RPG and up until now it been really fucked up because I'm trying to clone Chrono Triggers following system where you controle one party member and the rest of them follow your every footstep.
At first I didn't mind if it wasn't 100% exact but the issue is that if they don't retrace your every step then they can get stuck behind walls and stuff.
So does anybody know how I should go about implementing somthing like this?
Handling a party system
Moderator: PC Supremacists
Re: Handling a party system
Its rather ugly but works, also this does shortest path following and not actual path.
Code: Select all
#ifndef _cCharacter_h
#define _cCharacter_h
#include <stdlib.h>
#include <GLUT/GLUT.h>
#include "cEntity.h"
class cCharacter : cEntity
{
public:
cCharacter()
{
this->col[0] = 1;
this->col[1] = 1;
this->col[2] = 1;
this->follow = NULL;
}
cCharacter(cPoint loc)
: cEntity(loc)
{
this->col[0] = 1;
this->col[1] = 1;
this->col[2] = 1;
this->follow = NULL;
}
void chase(cEntity *p)
{
this->follow = p;
}
void update()
{
if(this->follow != NULL)
{
cPoint vec = cPoint(follow->loc.getX() - this->loc.getX(),follow->loc.getY() - this->loc.getY());
if(vec.length() > 10)
{
vec.normalize();
this->loc.setX(this->loc.getX() + vec.getX()*0.01);
this->loc.setY(this->loc.getY() + vec.getY()*0.01);
}
}else {
}
}
void draw()
{
glPushMatrix();
glTranslatef(this->loc.getX(), this->loc.getY(), 0);
glColor3f(0, 1, 0);
glutSolidSphere(2, 6, 6);
glPopMatrix();
}
private:
cEntity *follow;
float col[3];
};
#endif
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: Handling a party system
Certainly not the ugliest code i've ever seenavansc wrote:Its rather ugly but works
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
Re: Handling a party system
Ok know i feel retarded
Thanks avansc I'll see how it goes
EDIT: The only thing I can see that is ugly is glut
EDIT EDIT:
Whats the cPoint class? I don't think its delcared anywhere is it just a vector?
Thanks avansc I'll see how it goes
EDIT: The only thing I can see that is ugly is glut
EDIT EDIT:
Whats the cPoint class? I don't think its delcared anywhere is it just a vector?
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Handling a party system
The actual method used in Chrono Trigger is to have a simple static buffer of the last 30 or so previous locations of the party leader and bump each position down a notch when the next position is pushed in (like a queue). Then each of the party members will be positioned at index 15 and 30 (assuming a 30 node queue).
Re: Handling a party system
yeap cPoint is just a 2 dim vector, its actually misnamed, I added stuff to it, it really should be called cVec2 or something of that nature. but all the function names should be fairly self explanatory.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
Re: Handling a party system
I'd considered this but it seemed like it would only end out a mess but I'll defnitly try it thenGyroVorbis wrote:The actual method used in Chrono Trigger is to have a simple static buffer of the last 30 or so previous locations of the party leader and bump each position down a notch when the next position is pushed in (like a queue). Then each of the party members will be positioned at index 15 and 30 (assuming a 30 node queue).
Thanks.
Thanks I was confused because you were normalizing lol.avansc wrote:yeap cPoint is just a 2 dim vector, its actually misnamed, I added stuff to it, it really should be called cVec2 or something of that nature. but all the function names should be fairly self explanatory.
Thanks again.
EDIT: Holy shit working asif its straight from chrono trigger, your a fucking genius Falco! I must have walked around aimlessly in chrono trigger for houres trying to figure it out.