Это виртуальный метод CEntity для переопределения параметров затенения модели. В CEnemyBase, например, он перегружен (строка 780).
SeriousAlexej, GetLerpedPlacement возвращает усреднённое месторасположение между двумя отсчётами таймера. А у какого объекта неправильно работает GetPlacement? У игрока? У других объектов работает правильно?
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Добавлено (29.12.2012, 10:30) --------------------------------------------- а теперь у меня есть такой вопрос У меня есть радар, но он ловит врагов на близком расстоянии, а мне надо чтобы он их ловил с дальнего расстояния, но при этом не выежая за края радара. вот код радара: это туториал Armern'a. // draw radar {FOREACHINDYNAMICCONTAINER(((CEntity&)*_penPlayer).GetWorld()->wo_cenEntities, CEntity, iten) { // For every entity in the level CEntity *pen = iten; if (IsDerivedFromClass(pen, "Enemy Base")) { // if entity is an Enemy Base CEnemyBase *penEnemy = (CEnemyBase *)pen; // basicly we make a new enemy thing, Hey I may not know how to explain it, but atleast I know what it does.. hehe if (penEnemy->m_penEnemy==NULL) { continue; }
CPlacement3D plEnemy; // we make a new placement thing plEnemy.pl_PositionVector=penEnemy->GetPlacement().pl_PositionVector; // get the position of this enemy ( plEnemy.pl_OrientationAngle=FLOAT3D(0,0,0); // set it to 0,0,0 for now. plEnemy.AbsoluteToRelativeSmooth(((CEntity&)*_penPlayer).GetPlacement()); // get it's position relative to the position of the player. It's a bunch of maths...
FLOAT EnemyOnHudX=plEnemy.pl_PositionVector(1); // X position of the enemy (dot) relative to the player FLOAT EnemyOnHudY=plEnemy.pl_PositionVector(3);// Y position of the enemy (dot) relative to the player FLOAT posX = EnemyOnHudX*2.5+_pDP->GetWidth()-128; // in my radar, the center of my radar is 128 pixels from the side FLOAT posY = EnemyOnHudY*2.5+_pDP->GetHeight()-128;// and 128 pixels from the bottom. Also, you can set the 2.5 to different amounts. A higher number means a wider range the radar will show. I'm not good at explaining maths, so you'll have to take it for granted.. sorry :). FLOAT fRadarRadius = 48.5f; // the radius of the radar in meters (SEd units).. COLOR colRdot = C_WHITE|255; FLOAT m_fEnemyHealth = 0.0f;
m_fEnemyHealth = ((CEnemyBase*)pen)->GetHealth() / ((CEnemyBase*)pen)->m_fMaxHealth; // Get the health of this enemy
if( (penEnemy->GetPlacement().pl_PositionVector - ((CEntity&)*_penPlayer).GetPlacement().pl_PositionVector ).Length() < fRadarRadius ) // if the enemy is less than 24 meters away from the player { colRdot = C_GREEN|255; // give the dot a green colour if( m_fEnemyHealth<0.25f) { colRdot = C_RED|255; } // whoops, he's allmost dead. this is to check if it's health is lower than 25. else if( m_fEnemyHealth<0.60f) { colRdot = C_YELLOW|255; } // if it's a little lower, make it yellow else if( m_fEnemyHealth<0.01f) { colRdot = C_RED|0; } // I added this for my own test, but it appears not to always work. I want the dot to dissapear when an enemy is basicly dead.. for some reason it's health never becomes this low when he's dead? else { colRdot = C_GREEN|255; } // or else, his health is pretty high, so he may stay green. } else { colRdot = C_WHITE|0; // if his position relative to the player is more than 24 meters, make it invisible. }
_pDP->InitTexture(&_rDot); // Here we intialize the dot texture _pDP->AddTexture(posX-8/2,posY-8/2,posX+8/2,posY+8/2, colRdot); // we place it at the correct position. We must tell it to substract half the image size for the left, half at the top, and add half to the bottom and right, or else you wouldn't see a dot (texture) at all. _pDP->FlushRenderingQueue();
} }}
Сообщение отредактировалXFighter - Суббота, 29.12.2012, 12:55
XFighter, в комментариях к коду всё написано, прочитай внимательно. SeriousAlexej, вероятно, GetPlacement у сервера и у клиента вызываются несинхронно, или на чём-то отразилась применённая где-то функция FRnd/Rnd.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Вопрос такой: После смерти игрока мне нужно проверить наличие у всех игроков определенной переменной. Я пробовал делать это так. В Death(EDeath eDeath) я поместил следующее // autoreset game if all players are humans/zombies for(int i = 0; i < CEntity::GetMaxPlayers(); i++) { CPlayer* penPlayer = (CPlayer*)CEntity::GetPlayerEntity(i); if (m_bIAmZombie==TRUE) { penPlayer->SendEvent(EGameReset()); CPrintF(TRANS("ZOMBIES WIN")); } else { CPrintF(TRANS("HUMANS WIN")); penPlayer->SendEvent(EGameReset()); } } Тем не менее, игра почему-то вырубилась.
Также такой вопрос: У меня есть определенная энтити, которая совершает действие (вызывает эвент в игроке). Как можно можно ее активировать кодом, с указанием нужного мне события? (она может как активировать эвент, так и изменить переменную в игроке). И еще - как можно ее активировать после 10 секунд после старта игры? Учтите, триггер с автостартом не прокатит, нужно именно кодом. Был бы очень признателен, если поможете.
Сообщение отредактировалHeming_Hitrowski - Суббота, 05.01.2013, 14:10
CEntity::GetMaxPlayers() - тебе нужно вызывать просто GetMaxPlayers(). И проверяй penPlayer перед тем, как обращаешься к нему через указатель; ты итерируешь от 0 до максимального числа игроков, а их может быть меньше максимального, поэтому penPlayer может быть NULL. Второй вопрос не понял. Вызывает ивент? В игроке? Может, она посылает ивент игроку? Активировать - в смысле, отправить EActivate? И как вообще можно "активировать ивент"? Если нужно послать ивент, используй penPointerToSomeEntity->SendEvent(eSomeEventObject). А чтобы что-то сработало через определённое время, можно использовать wait с задержкой:
Код
wait(10.0f) { on (ETimer) : { stop; } otherwise() : { resume; } } SomeFunction(); // Будет вызвана через 10 секунд
Или (ещё проще и правильнее) - autowait:
Код
autowait(10.0f); SomeFunction();
wait и autowait работают только внутри процедур. autowait не работает внутри wait.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Ты это в Visual C++ 6.0 компилируешь? А не пытался перед этим открывать проекты СДК в более новой версии? Выглядит так, словно пытался. Так или иначе, компилятор говорит, что у тебя в папке с проектом нет папки Engine, а в ней нет файла Engine.h.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Нет, похоже, что ты компилируешь в VC6.0 то, что перед этим было открыто в чём-то другом. Убедись, что Engine\Engine.h существует в правильном месте.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.
Значит, ты не исправил. ) Помести файл (а лучше - всю папку Engine) туда, где её хочет видеть компилятор. Затем, первым делом, откомпилируй (отдельно от всего остального) StdH.cpp.
Where did all the dragons go? We searched in the hills and we searched down the canyons, we even scanned the depths of the caves with our armour, swords and lanterns. Oh, if only had we seen him lurch, from his glorious skull covered perch.
CRACK went his claws and SMACK swipped the tail, a ROAR of might, one big BITE.