void _drawActor(character *actor) { if (actor->hp <= 0 || (isTransitionInProgress() && actor->itemLight && actor->itemLight->sizeMod == 0)) { return; } _actorOnDraw(actor); TCOD_color_t foreColor = actor->foreColor; int nx, ny, occupiedPosition = 0, chr = actor->chr; float healthPercentage = (float)actor->hp / (float)actor->hpMax; character *actorPtr = getActors(), *player = getPlayer(); if (getAnimateFrame() / 60.f >= .5) { if (actor->stanceFlags & IS_STUCK_WITH_LODGED_WEAPON) { foreColor.r = 255; foreColor.g = 0; foreColor.b = 0; chr = getItemLodgedInActor(actor)->chr; } else if (actor->stanceFlags & IS_CRAWLING && actor->stanceFlags & IS_STUNNED) { chr = 25; } else if (actor->stanceFlags & IS_STUNNED) { chr = (int)'*'; } else if (actor->stanceFlags & IS_CASTING) { chr = (int)'!'; } } if (healthPercentage <= .75) { if ((getAnimateFrame() % (int)(60 * ((healthPercentage / .75)))) == 0) { foreColor.r = 255; foreColor.g = 0; foreColor.b = 0; } } drawChar(ACTOR_CONSOLE, actor->x, actor->y, chr, foreColor, actor->backColor); if ((actor->vx || actor->vy) && (!player || actor->delay < getMovementCost(player) - 1)) { nx = actor->x + actor->vx; ny = actor->y + actor->vy; while (actorPtr) { if (actorPtr->x == nx && actorPtr->y == ny) { occupiedPosition = 1; break; } actorPtr = actorPtr->next; } if (!occupiedPosition || getAnimateFrame() / 60.f >= .5) { drawChar(ACTOR_CONSOLE, nx, ny, 176, foreColor, actor->backColor); } } }
void moveActor(character *actor, int vx, int vy) { if (actor->delay) { return; } actor->vx = vx; actor->vy = vy; setDelay(actor, getMovementCost(actor)); }
bool Character::move(direction dir, bool active) { _world->TriggerFieldMove(this,false); // if we move we look into that direction... if (dir != dir_up && dir != dir_down) { faceto = (Character::face_to)dir; } // check if we can move to our target field position newpos = pos; newpos.move(dir); bool fieldfound = false; Field *cfnew, *cfold; // get the old tile... we need it to update the old tile as well as for the walking cost _world->GetPToCFieldAt(cfold, pos); // we need to search for tiles below this level for (size_t i = 0; i < RANGEDOWN + 1 && !fieldfound; ++i) { fieldfound = _world->GetPToCFieldAt(cfnew, newpos); // did we hit a targetfield? if (!fieldfound || cfnew->getTileId() == TRANSPARENTDISAPPEAR || cfnew->getTileId() == TRANSPARENT) { fieldfound = false; --newpos.z; } } // did we find a target field? if (fieldfound && moveToPossible(cfnew)) { uint16_t movementcost = getMovementCost(cfnew); int16_t diff = (P_MIN_AP - actionPoints + movementcost) * 10; uint8_t waitpages; // necessay to get smooth movement in client (dunno how this one is supposed to work exactly) if (diff < 60) { waitpages = 4; } else { waitpages = (diff * 667) / 10000; } actionPoints -= movementcost; // mark fields as (un)occupied cfold->removeChar(); cfnew->setChar(); // set new position setPosition(newpos); // send word out to all chars in range if (active) { _world->sendCharacterMoveToAllVisibleChars(this, waitpages); } else { _world->sendPassiveMoveToAllVisiblePlayers(this); } // check if there are teleporters or other special flags on this field _world->checkFieldAfterMove(this, cfnew); // ggf Scriptausfhrung nachdem man sich auf das Feld drauf bewegt hat _world->TriggerFieldMove(this,true); return true; } return false; }