Forum Devil OTS'a.

Opis forum

  • Nie jesteś zalogowany.
  • Polecamy: Gry

  • Index
  •  » C++
  •  » Mastery chodza na skos by me :]

#1 2007-01-19 20:30:24

Devil

Administrator

Zarejestrowany: 2006-12-22
Posty: 152
Punktów :   
WWW

Mastery chodza na skos by me :]

Kod jest w 100% by me !

W map.cpp nad:

Kod:

std::list<Position> Map::getPathTo(Creature *creature, Position start, Position to,

dodaj

Kod:

std::list<Position> Map::getPathToEx(Creature *creature, Position start, Position to,
bool creaturesBlock /*=true*/, bool ignoreMoveableBlockingItems /*= false*/, int maxNodSize /*= 100*/){
std::list<Position> path;
/* if(start.z != to.z)
return path;
*/
AStarNodes nodes;
AStarNode* found = NULL;
int z = start.z;

AStarNode* startNode = nodes.createOpenNode();
startNode->parent = NULL;
startNode->h = 0;
startNode->x = start.x;
startNode->y = start.y;

while(!found && nodes.countClosedNodes() < (unsigned long)maxNodSize){
AStarNode* current = nodes.getBestNode();
if(!current)
return path; //no path

nodes.closeNode(current);

for(int dx=-1; dx <= 1; dx++){
for(int dy=-1; dy <= 1; dy++){   
if(1 == 1/*std::abs(dx) != std::abs(dy)*/){

int x = current->x + dx;
int y = current->y + dy;

if(dx == -1 && dy == -1)
{
Tile *ctest1 = getTile(x+1, y, z); 
Tile *ctest2 = getTile(x, y+1, z);
if(ctest1 && ctest2) {

ReturnValue ctest1er = ctest1->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);
ReturnValue ctest2er = ctest2->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);

if(ctest1er == RET_CREATUREBLOCK && ctest1->getCreature() == creature && ctest1->creatures.size() == 1)
ctest1er = RET_NOERROR;
if(ctest2er == RET_CREATUREBLOCK && ctest2->getCreature() == creature && ctest2->creatures.size() == 1)
ctest2er = RET_NOERROR;

if(ctest1er == RET_NOERROR || ctest2er == RET_NOERROR) {
continue;
}
} 

}

if(dx == 1 && dy == -1)
{
Tile *ctest1 = getTile(x-1, y, z); 
Tile *ctest2 = getTile(x, y+1, z);
if(ctest1 && ctest2) {

ReturnValue ctest1er = ctest1->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);
ReturnValue ctest2er = ctest2->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);

if(ctest1er == RET_CREATUREBLOCK && ctest1->getCreature() == creature && ctest1->creatures.size() == 1)
ctest1er = RET_NOERROR;
if(ctest2er == RET_CREATUREBLOCK && ctest2->getCreature() == creature && ctest2->creatures.size() == 1)
ctest2er = RET_NOERROR;

if(ctest1er == RET_NOERROR || ctest2er == RET_NOERROR) {
continue;
}
} 

}

if(dx == 1 && dy == 1)
{
Tile *ctest1 = getTile(x-1, y, z); 
Tile *ctest2 = getTile(x, y-1, z);
if(ctest1 && ctest2) {

ReturnValue ctest1er = ctest1->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);
ReturnValue ctest2er = ctest2->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);

if(ctest1er == RET_CREATUREBLOCK && ctest1->getCreature() == creature && ctest1->creatures.size() == 1)
ctest1er = RET_NOERROR;
if(ctest2er == RET_CREATUREBLOCK && ctest2->getCreature() == creature && ctest2->creatures.size() == 1)
ctest2er = RET_NOERROR;

if(ctest1er == RET_NOERROR || ctest2er == RET_NOERROR) {
continue;
}
} 

}

if(dx == -1 && dy == 1)
{
Tile *ctest1 = getTile(x-1, y, z); 
Tile *ctest2 = getTile(x, y+1, z);
if(ctest1 && ctest2) {

ReturnValue ctest1er = ctest1->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);
ReturnValue ctest2er = ctest2->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);

if(ctest1er == RET_CREATUREBLOCK && ctest1->getCreature() == creature && ctest1->creatures.size() == 1)
ctest1er = RET_NOERROR;
if(ctest2er == RET_CREATUREBLOCK && ctest2->getCreature() == creature && ctest2->creatures.size() == 1)
ctest2er = RET_NOERROR;

if(ctest1er == RET_NOERROR || ctest2er == RET_NOERROR) {
continue;
}
} 

}

Tile *t = getTile(x, y, z);
if(t) {
ReturnValue ret = t->isBlocking(BLOCK_SOLID | BLOCK_PATHFIND, !creaturesBlock, ignoreMoveableBlockingItems);
if(ret == RET_CREATUREBLOCK && t->getCreature() == creature && t->creatures.size() == 1)
ret = RET_NOERROR;

if(ret != RET_NOERROR) {
continue;
}
}
else
continue;

if(!nodes.isInList(x,y)){
AStarNode* n = nodes.createOpenNode();
if(n){
n->x = x;
n->y = y;
n->h = abs(n->x - to.x)*abs(n->x - to.x) + abs(n->y - to.y)*abs(n->y - to.y);
n->parent = current;
if(x == to.x && y == to.y){
found = n;
}
}
}
/* else{
if(current->g + 1 < child->g)
child->parent = current;
child->g=current->g+1;
}*/
}
}
}
}
//cleanup the mess
while(found){
Position p;
p.x = found->x;
p.y = found->y;
p.z = z;
path.push_front(p);
found = found->parent;
}

return path;
}

Map.h pod:

Kod:

std::list<Position> getPathTo(Creature* creature, Position start, Position to,
bool creaturesBlock = true, bool ignoreMoveableBlockingItems

dodaj

Kod:

std::list<Position> getPathToEx(Creature* creature, Position start, Position to,
bool creaturesBlock = true, bool ignoreMoveableBlockingItems

w monster.cpp zamień:

Kod:

route = game->map->getPathTo(this, this->pos, moveToPos, true, mType->canPushItems);

na

Kod:

route = game->map->getPathToEx(this, this->pos, moveToPos, true, mType->canPushItems);

Offline

 

#2 2007-01-20 15:12:38

Cinek

Zielony

Zarejestrowany: 2007-01-18
Posty: 16
Punktów :   

Re: Mastery chodza na skos by me :]

Heh Dobry Jestes


"Co Masz To Mów,Ja Nie Cofam Słów"

Offline

 

#3 2007-01-21 19:02:10

Devil

Administrator

Zarejestrowany: 2006-12-22
Posty: 152
Punktów :   
WWW

Re: Mastery chodza na skos by me :]

Thx :]

Offline

 

#4 2007-03-04 20:44:46

Grubass Zioom

Zielony

Zarejestrowany: 2007-01-29
Posty: 19
Punktów :   

Re: Mastery chodza na skos by me :]

ja tez zaczolem pisac w c++ tylko nie mam kompilatora napiszcie jakas stronke gdzie mozna go sciagnac

Offline

 

#5 2007-03-12 17:08:45

867037

Zielony

Zarejestrowany: 2007-03-11
Posty: 28
Punktów :   

Re: Mastery chodza na skos by me :]

Good zrobione dzieki devil jestes ziom ^^

Offline

 

#6 2007-03-12 17:31:40

Fox

Moderator

Zarejestrowany: 2007-02-18
Posty: 216
Punktów :   

Re: Mastery chodza na skos by me :]

Grubass Zioom napisał:

ja tez zaczolem pisac w c++ tylko nie mam kompilatora napiszcie jakas stronke gdzie mozna go sciagnac

Grubass nie to, że cię wyśmiewam, ale ty nawet nie umiesz zrobić prostej gierki to napewno piszesz w c++?

Offline

 

#7 2007-03-12 20:03:02

Devil

Administrator

Zarejestrowany: 2006-12-22
Posty: 152
Punktów :   
WWW

Re: Mastery chodza na skos by me :]

@up
Pheh jak mozna pisac bez kompilatora?

Offline

 

#8 2007-03-15 20:09:14

Monia

Moderator

Zarejestrowany: 2007-01-13
Posty: 128
Punktów :   

Re: Mastery chodza na skos by me :]

spoko bedzie 1000 razy lepiej jak monsty chodza na skos


"Jestem Więc pisze nie ma mnie to nie pisze"
Name :Monia               Level:505             Prof:Master Sorcerer

Offline

 

#9 2007-03-15 20:55:59

Fox

Moderator

Zarejestrowany: 2007-02-18
Posty: 216
Punktów :   

Re: Mastery chodza na skos by me :]

Dla mnei tam nei będzie różnicy

Offline

 

#10 2007-03-16 13:42:26

Pikachu

Zielony

Zarejestrowany: 2007-03-13
Posty: 44
Punktów :   

Re: Mastery chodza na skos by me :]

Grubass Zioom napisał:

ja tez zaczolem pisac w c++ tylko nie mam kompilatora napiszcie jakas stronke gdzie mozna go sciagnac

Buahahahahahaha Grybass ściemniać to ja też potrafie

Hmm... Ja nie chce potworów na skos!! Bo będą szybko chdozić

Offline

 

#11 2007-03-16 21:31:11

Devil

Administrator

Zarejestrowany: 2006-12-22
Posty: 152
Punktów :   
WWW

Re: Mastery chodza na skos by me :]

@Monia
Jak mi wynajdziesz dobry sposub na train roomy to niema sprawy ;p

Offline

 

#12 2007-03-17 13:16:51

Fox

Moderator

Zarejestrowany: 2007-02-18
Posty: 216
Punktów :   

Re: Mastery chodza na skos by me :]

@Devil
A gdzie monia pisała o train roomach?

Offline

 
  • Index
  •  » C++
  •  » Mastery chodza na skos by me :]

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora