void CharacterCreation::render() { arx_assert(ARXmenu.mode() == Mode_CharacterCreation); GRenderer->Clear(Renderer::ColorBuffer); //------------------------------------------------------------------------- arx_assert(BookBackground); { UseRenderState state(render2D()); EERIEDrawBitmap(Rectf(Vec2f(0, 0), g_size.width(), g_size.height()), 0.9f, BookBackground, Color::white); g_playerBook.stats.manageNewQuest(); bool DONE = (player.Skill_Redistribute == 0 && player.Attribute_Redistribute == 0); Color color = Color::none; Rectf book = g_playerBook.getArea(); Vec2f spacing = Vec2f(20.f, 30.f) * minSizeRatio(); Vec2f quickGenerateButtonSize(hFontMenu->getTextSize(str_button_quickgen).size()); Rectf quickGenerateButton(book.bottomLeft() + Vec2f(0.f, spacing.y), quickGenerateButtonSize.x, quickGenerateButtonSize.y); Vec2f doneButtonSize(hFontMenu->getTextSize(str_button_done).size()); Rectf doneButton(book.bottomRight() + Vec2f(-doneButtonSize.x, spacing.y), doneButtonSize.x, doneButtonSize.y); Vec2f skinButtonSize(hFontMenu->getTextSize(str_button_skin).size()); Rectf skinButton((quickGenerateButton.centerRight() + doneButton.centerLeft() - skinButtonSize) / 2.f, skinButtonSize.x, skinButtonSize.y); if(quickGenerateButton.right > skinButton.left - spacing.x) { quickGenerateButton.move(skinButton.left - spacing.x - quickGenerateButton.right, 0.f); } if(doneButton.left < skinButton.right + spacing.x) { doneButton.move(skinButton.right + spacing.x - doneButton.left, 0.f); } // Button QUICK GENERATION if(quickGenerateButton.contains(Vec2f(DANAEMouse))) { cursorSetInteraction(); if(!eeMousePressed1() && eeMouseUp1()) { m_cheatQuickGenButtonClickCount++; int iSkin = player.skin; ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); if(bQuickGenFirstClick) { ARX_PLAYER_MakeAverageHero(); bQuickGenFirstClick = false; } else { ARX_PLAYER_QuickGeneration(); } player.skin = checked_range_cast<char>(iSkin); } characterCreationAddDescription(m_desc_quickgen); color = Color::white; } else { color = Color(232, 204, 143); } ARX_UNICODE_DrawTextInRect(hFontMenu, quickGenerateButton.topLeft(), 999999, str_button_quickgen, color); // Button SKIN if(skinButton.contains(Vec2f(DANAEMouse))) { cursorSetInteraction(); if(eeMouseUp1()) { m_cheatSkinButtonClickCount++; ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); player.skin++; if(player.skin > 3) { player.skin = 0; } ARX_PLAYER_Restore_Skin(); } characterCreationAddDescription(m_desc_skin); color = Color::white; } else { color = Color::rgb(0.91f, 0.8f, 0.56f); } ARX_UNICODE_DrawTextInRect(hFontMenu, skinButton.topLeft(), 999999, str_button_skin, color); // Button DONE if(doneButton.contains(Vec2f(DANAEMouse))) { if(DONE) cursorSetInteraction(); if(DONE && eeMouseUp1()) { if(m_cheatSkinButtonClickCount == 8 && m_cheatQuickGenButtonClickCount == 10) { m_cheatSkinButtonClickCount = -2; } else if(m_cheatSkinButtonClickCount == -1) { ARX_PLAYER_MakeSpHero(); player.skin = 4; ARX_PLAYER_Restore_Skin(); m_cheatSkinButtonClickCount = 0; SP_HEAD = 1; } else { if(SP_HEAD) { player.skin = 4; ARX_PLAYER_Restore_Skin(); SP_HEAD = 0; } ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); MenuFader_start(Fade_In, Mode_InGame); } } else { if(DONE) { color = Color::white; } else { color = Color::gray(0.75f); } } characterCreationAddDescription(m_desc_done); } else { if(DONE) { color = Color(232, 204, 143); } else { color = Color::gray(0.75f); } } if(m_cheatSkinButtonClickCount < 0) { color = Color::magenta; } ARX_UNICODE_DrawTextInRect(hFontMenu, doneButton.topLeft(), 999999, str_button_done, color); } EERIE_LIGHT * light = lightHandleGet(torchLightHandle); light->pos.x = 0.f + GInput->getMousePosition().x - (g_size.width() >> 1); light->pos.y = 0.f + GInput->getMousePosition().y - (g_size.height() >> 1); if(pTextManage) { pTextManage->Update(g_platformTime.lastFrameDuration()); pTextManage->Render(); } ARX_INTERFACE_RenderCursor(true); if(MenuFader_process()) { if(iFadeAction == Mode_InGame) { ARX_MENU_NEW_QUEST_Clicked_QUIT(); MenuFader_reset(); if(pTextManage) { pTextManage->Clear(); } } } }
void ManageCombatModeAnimations() { arx_assert(entities.player()); Entity * const io = entities.player(); AnimLayer & layer1 = io->animlayer[1]; ANIM_HANDLE ** alist=io->anims; WeaponType weapontype = ARX_EQUIPMENT_GetPlayerWeaponType(); if(weapontype == WEAPON_BARE && LAST_WEAPON_TYPE != weapontype) { if(layer1.cur_anim != alist[ANIM_BARE_WAIT]) { changeAnimation(io, 1, alist[ANIM_BARE_WAIT]); AimTime = 0; } } switch(weapontype) { case WEAPON_BARE: // BARE HANDS PLAYER MANAGEMENT if(layer1.cur_anim == alist[ANIM_BARE_WAIT]) { AimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_BARE_STRIKE_LEFT_START + CurrFightPos * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT_START+j*3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_BARE_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); AimTime = (unsigned long)(arxtime); } else if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT_CYCLE+j*3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_BARE_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(io, SM_STRIKE, "bare"); PlayerWeaponBlocked = -1; CurrFightPos = 0; AimTime = 0; } else if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT+j*3]) { if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_BARE_WAIT], EA_LOOP); CurrFightPos = 0; AimTime = (unsigned long)(arxtime); PlayerWeaponBlocked = -1; } else if(layer1.ctime > layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.2f && layer1.ctime < layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.8f && PlayerWeaponBlocked == -1 ) { long id = -1; if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT]) { id = io->obj->fastaccess.left_attach; } else { // Strike Right id = io->obj->fastaccess.primary_attach; } if(id != -1) { Sphere sphere; sphere.origin = io->obj->vertexlist3[id].v; sphere.radius = 25.f; EntityHandle num; if(CheckAnythingInSphere(sphere, PlayerEntityHandle, 0, &num)) { float dmgs = (player.m_miscFull.damages + 1) * STRIKE_AIMTIME; if(ARX_DAMAGES_TryToDoDamage(io->obj->vertexlist3[id].v, dmgs, 40, PlayerEntityHandle)) { PlayerWeaponBlocked = layer1.ctime; } ARX_PARTICLES_Spawn_Spark(sphere.origin, int(dmgs), 2); if(ValidIONum(num)) { ARX_SOUND_PlayCollision(entities[num]->material, MATERIAL_FLESH, 1.f, 1.f, sphere.origin, NULL); } } } } } } break; case WEAPON_DAGGER: // DAGGER PLAYER MANAGEMENT // Waiting and receiving Strike Impulse if(layer1.cur_anim == alist[ANIM_DAGGER_WAIT]) { AimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_DAGGER_STRIKE_LEFT_START + CurrFightPos * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_DAGGER_STRIKE_LEFT_START+j*3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_DAGGER_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); AimTime = (unsigned long)(arxtime); } else if(layer1.cur_anim == alist[ANIM_DAGGER_STRIKE_LEFT_CYCLE+j*3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_DAGGER_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(io, SM_STRIKE, "dagger"); CurrFightPos = 0; AimTime = 0; } else if(layer1.cur_anim == alist[ANIM_DAGGER_STRIKE_LEFT+j*3]) { if(layer1.ctime > layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.3f && layer1.ctime < layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.7f) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; if(PlayerWeaponBlocked == -1 && ARX_EQUIPMENT_Strike_Check(io, weapon, STRIKE_AIMTIME, 0)) { PlayerWeaponBlocked = layer1.ctime; } } if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_DAGGER_WAIT], EA_LOOP); layer1.flags &= ~(EA_PAUSED | EA_REVERSE); CurrFightPos = 0; AimTime = (unsigned long)(arxtime); PlayerWeaponBlocked = -1; } if(PlayerWeaponBlocked != -1 && layer1.ctime < layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.9f) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; ARX_EQUIPMENT_Strike_Check(io, weapon, STRIKE_AIMTIME, 1); } } } break; case WEAPON_1H: // 1HANDED PLAYER MANAGEMENT // Waiting and Received Strike Impulse if(layer1.cur_anim == alist[ANIM_1H_WAIT]) { AimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_1H_STRIKE_LEFT_START + CurrFightPos * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_1H_STRIKE_LEFT_START+j*3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_1H_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); AimTime = (unsigned long)(arxtime); } else if(layer1.cur_anim == alist[ANIM_1H_STRIKE_LEFT_CYCLE+j*3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_1H_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(io, SM_STRIKE, "1h"); CurrFightPos = 0; AimTime = 0; } else if(layer1.cur_anim == alist[ANIM_1H_STRIKE_LEFT+j*3]) { if(layer1.ctime > layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.3f && layer1.ctime < layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.7f) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; if(PlayerWeaponBlocked == -1 && ARX_EQUIPMENT_Strike_Check(io, weapon, STRIKE_AIMTIME, 0)) { PlayerWeaponBlocked = layer1.ctime; } } if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_1H_WAIT], EA_LOOP); layer1.flags &= ~(EA_PAUSED | EA_REVERSE); CurrFightPos = 0; AimTime = 0; PlayerWeaponBlocked = -1; } if(PlayerWeaponBlocked != -1 && layer1.ctime < layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.9f) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; ARX_EQUIPMENT_Strike_Check(io, weapon, STRIKE_AIMTIME, 1); } } } break; case WEAPON_2H: // 2HANDED PLAYER MANAGEMENT // Waiting and Receiving Strike Impulse if(layer1.cur_anim == alist[ANIM_2H_WAIT]) { AimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_2H_STRIKE_LEFT_START + CurrFightPos * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_2H_STRIKE_LEFT_START+j*3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_2H_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); AimTime = (unsigned long)(arxtime); } else if(layer1.cur_anim == alist[ANIM_2H_STRIKE_LEFT_CYCLE+j*3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_2H_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(io, SM_STRIKE, "2h"); CurrFightPos = 0; AimTime = 0; } else if(layer1.cur_anim == alist[ANIM_2H_STRIKE_LEFT+j*3]) { if(layer1.ctime > layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.3f && layer1.ctime < layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.7f) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; if(PlayerWeaponBlocked == -1 && ARX_EQUIPMENT_Strike_Check(io, weapon, STRIKE_AIMTIME, 0)) { PlayerWeaponBlocked = layer1.ctime; } } if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_2H_WAIT], EA_LOOP); layer1.flags &= ~(EA_PAUSED | EA_REVERSE); CurrFightPos = 0; AimTime = 0; PlayerWeaponBlocked = -1; } if(PlayerWeaponBlocked != -1 && layer1.ctime < layer1.cur_anim->anims[layer1.altidx_cur]->anim_time * 0.9f) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; ARX_EQUIPMENT_Strike_Check(io, weapon, STRIKE_AIMTIME, 1); } } } break; case WEAPON_BOW: // MISSILE PLAYER MANAGEMENT if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_CYCLE]) { if(GLOBAL_SLOWDOWN != 1.f) BOW_FOCAL += Original_framedelay; else BOW_FOCAL += framedelay; if(BOW_FOCAL > 710) BOW_FOCAL = 710; } // Waiting and Receiving Strike Impulse if(layer1.cur_anim == alist[ANIM_MISSILE_WAIT]) { AimTime = (unsigned long)(arxtime); if(eeMousePressed1() && Player_Arrow_Count() > 0) { changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE_PART_1]); io->isHit = false; } } if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_PART_1] && (layer1.flags & EA_ANIMEND)) { AimTime = 0; changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE_PART_2]); EERIE_LINKEDOBJ_LinkObjectToObject(io->obj, arrowobj, "left_attach", "attach", NULL); } // Now go for strike cycle... if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_PART_2] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE_CYCLE], EA_LOOP); AimTime = (unsigned long)(arxtime); } else if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_CYCLE] && !eeMousePressed1()) { EERIE_LINKEDOBJ_UnLinkObjectFromObject(io->obj, arrowobj); changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE]); SendIOScriptEvent(io, SM_STRIKE, "bow"); StrikeAimtime(); STRIKE_AIMTIME = (float)(BOW_FOCAL)/710.f; Entity * quiver = Player_Arrow_Count_Decrease(); float poisonous = 0.f; if(quiver) { poisonous = quiver->poisonous; if(quiver->poisonous_count > 0) { quiver->poisonous_count--; if(quiver->poisonous_count <= 0) quiver->poisonous = 0; } ARX_DAMAGES_DurabilityLoss(quiver, 1.f); // TODO is this needed ?, quivers seem to self destruct via script, but maybe not all if(ValidIOAddress(quiver) && quiver->durability <= 0.f) { ARX_INTERACTIVE_DestroyIOdelayed(quiver); } } float aimratio = STRIKE_AIMTIME; if(sp_max && poisonous < 3.f) poisonous = 3.f; Vec3f orgPos = player.pos + Vec3f(0.f, 40.f, 0.f); if(io->obj->fastaccess.left_attach >= 0) { orgPos = io->obj->vertexlist3[io->obj->fastaccess.left_attach].v; } Anglef orgAngle = player.angle; PlayerLaunchArrow_Test(aimratio, poisonous, orgPos, orgAngle); if(sp_max) { Anglef angle; Vec3f pos = player.pos + Vec3f(0.f, 40.f, 0.f); angle.setYaw(player.angle.getYaw()); angle.setPitch(player.angle.getPitch() + 8); angle.setRoll(player.angle.getRoll()); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); angle.setYaw(player.angle.getYaw()); angle.setPitch(player.angle.getPitch() - 8); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); angle.setYaw(player.angle.getYaw()); angle.setPitch(player.angle.getPitch() + 4.f); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); angle.setYaw(player.angle.getYaw()); angle.setPitch(player.angle.getPitch() - 4.f); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); } AimTime = 0; } else if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE]) { BOW_FOCAL -= Original_framedelay; if(BOW_FOCAL < 0) BOW_FOCAL = 0; if(layer1.flags & EA_ANIMEND) { BOW_FOCAL = 0; changeAnimation(io, 1, alist[ANIM_MISSILE_WAIT], EA_LOOP); AimTime = 0; PlayerWeaponBlocked = -1; EERIE_LINKEDOBJ_UnLinkObjectFromObject(io->obj, arrowobj); } } break; } LAST_WEAPON_TYPE = weapontype; }
void AddFlare(const Vec2s & pos, float sm, short typ, Entity * io, bool bookDraw) { int oldest = 0; size_t i; for(i = 0; i < MAX_FLARES; i++) { if(!magicFlares[i].exist) { break; } if(magicFlares[i].tolive < magicFlares[oldest].tolive) { oldest = i; } } if(i >= MAX_FLARES) { removeFlare(magicFlares[oldest]); i = oldest; } FLARES * fl = &magicFlares[i]; fl->exist = 1; flarenum++; if(!bookDraw) fl->bDrawBitmap = 0; else fl->bDrawBitmap = 1; fl->io = io; if(io) { fl->flags = 1; io->flarecount++; } else { fl->flags = 0; } fl->pos.x = float(pos.x) - rnd() * 4.f; fl->pos.y = float(pos.y) - rnd() * 4.f - 50.f; fl->tv.rhw = fl->v.rhw = 1.f; if(!bookDraw) { EERIE_CAMERA ka = *Kam; ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle; EERIE_CAMERA * oldcam = ACTIVECAM; SetActiveCamera(&ka); PrepareCamera(&ka, g_size); fl->v.p += ka.orgTrans.pos; EE_RTP(fl->tv.p, &fl->v); fl->v.p += ka.orgTrans.pos; float vx = -(fl->pos.x - subj.center.x) * 0.2173913f; float vy = (fl->pos.y - subj.center.y) * 0.1515151515151515f; if(io) { fl->v.p = io->pos; fl->v.p += angleToVectorXZ(io->angle.getPitch() + vx) * 100.f; fl->v.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getYaw() + vy))) * 100.f - 150.f; } else { fl->v.p.x = 1.0f * float(pos.x - (g_size.width() / 2)) * 156.f / (640.f * g_sizeRatio.y); fl->v.p.y = 0.75f * float(pos.y - (g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y); fl->v.p.z = 75.f; ka = *oldcam; SetActiveCamera(&ka); PrepareCamera(&ka, g_size); float temp = (fl->v.p.y * -ka.orgTrans.xsin) + (fl->v.p.z * ka.orgTrans.xcos); fl->v.p.y = (fl->v.p.y * ka.orgTrans.xcos) - (-fl->v.p.z * ka.orgTrans.xsin); fl->v.p.z = (temp * ka.orgTrans.ycos) - (-fl->v.p.x * ka.orgTrans.ysin); fl->v.p.x = (temp * -ka.orgTrans.ysin) + (fl->v.p.x * ka.orgTrans.ycos); fl->v.p += oldcam->orgTrans.pos; } fl->tv.p = fl->v.p; SetActiveCamera(oldcam); PrepareCamera(oldcam, g_size); } else { fl->tv.p = Vec3f(fl->pos.x, fl->pos.y, 0.001f); } switch(PIPOrgb) { case 0: { fl->rgb = Color3f(.4f, 0.f, .4f) + Color3f(2.f/3, 2.f/3, 2.f/3) * randomColor3f(); break; } case 1: { fl->rgb = Color3f(.5f, .5f, 0.f) + Color3f(.625f, .625f, .55f) * randomColor3f(); break; } case 2: { fl->rgb = Color3f(.4f, 0.f, 0.f) + Color3f(2.f/3, .55f, .55f) * randomColor3f(); break; } } if(typ == -1) { float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? rnd() : 1.f); if(zz < 0.2f) { fl->type = 2; fl->size = rnd() * 42.f + 42.f; fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL; } else if(zz < 0.5f) { fl->type = 3; fl->size = rnd() * 52.f + 16.f; fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL; } else { fl->type = 1; fl->size = (rnd() * 24.f + 32.f) * sm; fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL; } } else { fl->type = (rnd() > 0.8f) ? 1 : 4; fl->size = (rnd() * 38.f + 64.f) * sm; fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL; } fl->dynlight = LightHandle::Invalid; for(long kk = 0; kk < 3; kk++) { if(rnd() < 0.5f) { continue; } PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } if(!bookDraw) { pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; if(!io) { pd->special |= PARTICLE_NOZBUFFER; } } else { pd->special = FADE_IN_AND_OUT; } pd->ov = fl->v.p + randomVec(-5.f, 5.f); pd->move = Vec3f(0.f, 5.f, 0.f); pd->scale = Vec3f(-2.f); pd->tolive = 1300 + kk * 100 + Random::get(0, 800); pd->tc = fire2; if(kk == 1) { pd->move.y = 4.f; pd->siz = 1.5f; } else { pd->siz = 1.f + rnd(); } pd->rgb = Color3f(fl->rgb.r * (2.f/3), fl->rgb.g * (2.f/3), fl->rgb.b * (2.f/3)); pd->fparam = 1.2f; if(bookDraw) pd->is2D = true; } }
//----------------------------------------------------------------------------- // ARX Menu Rendering Func // returns false if no menu needs to be displayed //----------------------------------------------------------------------------- bool ARX_Menu_Render() { if(ARXmenu.currentmode == AMCM_OFF) return false; bool br = Menu2_Render(); if(br) return br; if(ARXmenu.currentmode == AMCM_OFF) return false; GRenderer->Clear(Renderer::ColorBuffer | Renderer::DepthBuffer); FLYING_OVER = 0; //------------------------------------------------------------------------- if(ARXmenu.currentmode == AMCM_NEWQUEST && ARXmenu.mda) { GRenderer->SetRenderState(Renderer::Fog, false); GRenderer->SetRenderState(Renderer::AlphaBlending, false); if(ARXmenu.mda->BookBackground != NULL) { GRenderer->SetRenderState(Renderer::AlphaBlending, false); GRenderer->SetRenderState(Renderer::Fog, false); GRenderer->SetRenderState(Renderer::DepthWrite, false); GRenderer->SetRenderState(Renderer::DepthTest, false); EERIEDrawBitmap2(Rectf(Vec2f(0, 0), g_size.width(), g_size.height()), 0.9f, ARXmenu.mda->BookBackground, Color::white); } BOOKZOOM = 1; ARX_INTERFACE_ManageOpenedBook(); if(ARXmenu.mda) { long DONE = 0; if(player.Skill_Redistribute == 0 && player.Attribute_Redistribute == 0) DONE = 1; if(!ARXmenu.mda->flyover[FLYING_OVER].empty() ) //=ARXmenu.mda->flyover[FLYING_OVER]; { if(FLYING_OVER != OLD_FLYING_OVER) { float fRandom = rnd() * 2; int t = checked_range_cast<int>(fRandom); pTextManage->Clear(); OLD_FLYING_OVER = FLYING_OVER; UNICODE_ARXDrawTextCenteredScroll(hFontInGame, (g_size.width() * 0.5f), 12, (g_size.center().x) * 0.82f, ARXmenu.mda->flyover[FLYING_OVER], Color(232 + t, 204 + t, 143 + t), 1000, 0.01f, 2); } } else { OLD_FLYING_OVER = -1; } Vec2f pos; pos.x = 0; pos.y = 313 * g_sizeRatio.y + (g_size.height() - 313 * g_sizeRatio.y) * 0.70f; Vec2f size = g_sizeRatio; size *= 100; Color color = Color::none; //--------------------------------------------------------------------- // Button QUICK GENERATION pos.x = (g_size.width() - (513 * g_sizeRatio.x)) * 0.5f; const Rectf quickGenerateButtonMouseTestRect( pos, size.x, size.y ); if(quickGenerateButtonMouseTestRect.contains(Vec2f(DANAEMouse))) { SpecialCursor = CURSOR_INTERACTION_ON; FLYING_OVER = BUTTON_QUICK_GENERATION; if(eeMousePressed1()); else if (eeMouseUp1()) { QUICK_MOD++; int iSkin = player.skin; ARX_SOUND_PlayMenu(SND_MENU_CLICK); if(bQuickGenFirstClick) { ARX_PLAYER_MakeAverageHero(); bQuickGenFirstClick = false; } else { ARX_PLAYER_QuickGeneration(); } player.skin = checked_range_cast<char>(iSkin); } color = Color(255, 255, 255); } else color = Color(232, 204, 143); pTextManage->AddText(hFontMenu, ARXmenu.mda->str_button_quickgen, static_cast<long>(pos.x), static_cast<long>(pos.y), color); //--------------------------------------------------------------------- // Button SKIN pos.x = g_size.width() * 0.5f; const Rectf skinButtonMouseTestRect( pos, size.x, size.y ); if(skinButtonMouseTestRect.contains(Vec2f(DANAEMouse))) { SpecialCursor = CURSOR_INTERACTION_ON; FLYING_OVER = BUTTON_SKIN; if(eeMouseUp1()) { SKIN_MOD++; BOOKZOOM = 1; ARX_SOUND_PlayMenu(SND_MENU_CLICK); player.skin++; if(player.skin > 3) player.skin = 0; ARX_PLAYER_Restore_Skin(); } color = Color(255, 255, 255); } else color = Color(232, 204, 143); pTextManage->AddText(hFontMenu, ARXmenu.mda->str_button_skin, static_cast<long>(pos.x), static_cast<long>(pos.y), color); //--------------------------------------------------------------------- // Button DONE pos.x = g_size.width() - (g_size.width() - 513 * g_sizeRatio.x) * 0.5f - 40 * g_sizeRatio.x; const Rectf doneButtonMouseTestRect( pos, size.x, size.y ); if(doneButtonMouseTestRect.contains(Vec2f(DANAEMouse))) { if(DONE) SpecialCursor = CURSOR_INTERACTION_ON; FLYING_OVER = BUTTON_DONE; if(DONE && eeMouseUp1()) { if(SKIN_MOD == 8 && QUICK_MOD == 10) { SKIN_MOD = -2; } else if(SKIN_MOD == -1) { ARX_PLAYER_MakeSpHero(); player.skin = 4; ARX_PLAYER_Restore_Skin(); SKIN_MOD = 0; SP_HEAD = 1; } else { if(SP_HEAD) { player.skin = 4; ARX_PLAYER_Restore_Skin(); SP_HEAD = 0; } ARX_SOUND_PlayMenu(SND_MENU_CLICK); bFadeInOut = true; //fade out bFade = true; //active le fade iFadeAction = AMCM_OFF; } } else { if(DONE) color = Color(255, 255, 255); else color = Color(192, 192, 192); } } else { if(DONE) color = Color(232, 204, 143); else color = Color(192, 192, 192); } if(SKIN_MOD < 0) color = Color(255, 0, 255); pTextManage->AddText(hFontMenu, ARXmenu.mda->str_button_done, static_cast<long>(pos.x), static_cast<long>(pos.y), color); } } EERIE_LIGHT * light = lightHandleGet(torchLightHandle); light->pos.x = 0.f + GInput->getMousePosAbs().x - (g_size.width() >> 1); light->pos.y = 0.f + GInput->getMousePosAbs().y - (g_size.height() >> 1); if(pTextManage) { pTextManage->Update(framedelay); pTextManage->Render(); } if(ARXmenu.currentmode != AMCM_CREDITS) ARX_INTERFACE_RenderCursor(true); if(ARXmenu.currentmode == AMCM_NEWQUEST) { if(ProcessFadeInOut(bFadeInOut, 0.1f)) { switch(iFadeAction) { case AMCM_OFF: arxtime.resume(); ARX_MENU_NEW_QUEST_Clicked_QUIT(); iFadeAction = -1; bFade = false; fFadeInOut = 0.f; if(pTextManage) pTextManage->Clear(); break; } } } return true; }
void ManageCombatModeAnimations() { arx_assert(entities.player()); if(player.m_aimTime > 0) { player.m_aimTime += g_platformTime.lastFrameDuration(); } Entity * const io = entities.player(); AnimLayer & layer1 = io->animlayer[1]; ANIM_HANDLE ** alist = io->anims; WeaponType weapontype = ARX_EQUIPMENT_GetPlayerWeaponType(); if(weapontype == WEAPON_BARE && LAST_WEAPON_TYPE != weapontype) { if(layer1.cur_anim != alist[ANIM_BARE_WAIT]) { changeAnimation(io, 1, alist[ANIM_BARE_WAIT]); player.m_aimTime = 0; } } switch(weapontype) { case WEAPON_BARE: { // BARE HANDS PLAYER MANAGEMENT if(layer1.cur_anim == alist[ANIM_BARE_WAIT]) { player.m_aimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_BARE_STRIKE_LEFT_START + player.m_strikeDirection * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT_START + j * 3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_BARE_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); player.m_aimTime = PlatformDuration::ofRaw(1); } else if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT_CYCLE + j * 3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_BARE_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(NULL, io, SM_STRIKE, "bare"); player.m_weaponBlocked = AnimationDuration::ofRaw(-1); // TODO inband signaling AnimationDuration player.m_strikeDirection = 0; player.m_aimTime = 0; } else if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT + j * 3]) { if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_BARE_WAIT], EA_LOOP); player.m_strikeDirection = 0; player.m_aimTime = PlatformDuration::ofRaw(1); player.m_weaponBlocked = AnimationDuration::ofRaw(-1); } else if( layer1.ctime > layer1.currentAltAnim()->anim_time * 0.2f && layer1.ctime < layer1.currentAltAnim()->anim_time * 0.8f && player.m_weaponBlocked == AnimationDuration::ofRaw(-1)) { ActionPoint id = ActionPoint(); if(layer1.cur_anim == alist[ANIM_BARE_STRIKE_LEFT]) { id = io->obj->fastaccess.left_attach; } else { // Strike Right id = io->obj->fastaccess.primary_attach; } if(id != ActionPoint()) { Sphere sphere; sphere.origin = actionPointPosition(io->obj, id); sphere.radius = 25.f; EntityHandle num; if(CheckAnythingInSphere(sphere, EntityHandle_Player, 0, &num)) { float dmgs = (player.m_miscFull.damages + 1) * player.m_strikeAimRatio; if(ARX_DAMAGES_TryToDoDamage(actionPointPosition(io->obj, id), dmgs, 40, EntityHandle_Player)) { player.m_weaponBlocked = layer1.ctime; } ParticleSparkSpawnContinous(sphere.origin, unsigned(dmgs), SpawnSparkType_Success); if(ValidIONum(num)) { static PlatformInstant lastHit = 0; PlatformInstant now = g_platformTime.frameStart(); if(now - lastHit > toPlatformDuration(layer1.ctime)) { ARX_SOUND_PlayCollision(entities[num]->material, MATERIAL_FLESH, 1.f, 1.f, sphere.origin, NULL); lastHit = now; } } } } } } } break; } case WEAPON_DAGGER: { // DAGGER PLAYER MANAGEMENT // Waiting and receiving Strike Impulse if(layer1.cur_anim == alist[ANIM_DAGGER_WAIT]) { player.m_aimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_DAGGER_STRIKE_LEFT_START + player.m_strikeDirection * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_DAGGER_STRIKE_LEFT_START + j * 3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_DAGGER_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); player.m_aimTime = PlatformDuration::ofRaw(1); } else if(layer1.cur_anim == alist[ANIM_DAGGER_STRIKE_LEFT_CYCLE + j * 3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_DAGGER_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(NULL, io, SM_STRIKE, "dagger"); player.m_strikeDirection = 0; player.m_aimTime = 0; } else if(layer1.cur_anim == alist[ANIM_DAGGER_STRIKE_LEFT + j * 3]) { if( layer1.ctime > layer1.currentAltAnim()->anim_time * 0.3f && layer1.ctime < layer1.currentAltAnim()->anim_time * 0.7f ) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; if(player.m_weaponBlocked == AnimationDuration::ofRaw(-1) && ARX_EQUIPMENT_Strike_Check(io, weapon, player.m_strikeAimRatio, 0)) { player.m_weaponBlocked = layer1.ctime; } } if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_DAGGER_WAIT], EA_LOOP); layer1.flags &= ~(EA_PAUSED | EA_REVERSE); player.m_strikeDirection = 0; player.m_aimTime = PlatformDuration::ofRaw(1); player.m_weaponBlocked = AnimationDuration::ofRaw(-1); } if( player.m_weaponBlocked != AnimationDuration::ofRaw(-1) && layer1.ctime < layer1.currentAltAnim()->anim_time * 0.9f ) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; ARX_EQUIPMENT_Strike_Check(io, weapon, player.m_strikeAimRatio, 1); } } } break; } case WEAPON_1H: { // 1HANDED PLAYER MANAGEMENT // Waiting and Received Strike Impulse if(layer1.cur_anim == alist[ANIM_1H_WAIT]) { player.m_aimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_1H_STRIKE_LEFT_START + player.m_strikeDirection * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_1H_STRIKE_LEFT_START + j * 3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_1H_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); player.m_aimTime = PlatformDuration::ofRaw(1); } else if(layer1.cur_anim == alist[ANIM_1H_STRIKE_LEFT_CYCLE + j * 3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_1H_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(NULL, io, SM_STRIKE, "1h"); player.m_strikeDirection = 0; player.m_aimTime = 0; } else if(layer1.cur_anim == alist[ANIM_1H_STRIKE_LEFT + j * 3]) { if( layer1.ctime > layer1.currentAltAnim()->anim_time * 0.3f && layer1.ctime < layer1.currentAltAnim()->anim_time * 0.7f ) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; if(player.m_weaponBlocked == AnimationDuration::ofRaw(-1) && ARX_EQUIPMENT_Strike_Check(io, weapon, player.m_strikeAimRatio, 0)) { player.m_weaponBlocked = layer1.ctime; } } if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_1H_WAIT], EA_LOOP); layer1.flags &= ~(EA_PAUSED | EA_REVERSE); player.m_strikeDirection = 0; player.m_aimTime = 0; player.m_weaponBlocked = AnimationDuration::ofRaw(-1); } if( player.m_weaponBlocked != AnimationDuration::ofRaw(-1) && layer1.ctime < layer1.currentAltAnim()->anim_time * 0.9f ) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; ARX_EQUIPMENT_Strike_Check(io, weapon, player.m_strikeAimRatio, 1); } } } break; } case WEAPON_2H: { // 2HANDED PLAYER MANAGEMENT // Waiting and Receiving Strike Impulse if(layer1.cur_anim == alist[ANIM_2H_WAIT]) { player.m_aimTime = 0; if(eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_2H_STRIKE_LEFT_START + player.m_strikeDirection * 3]); io->isHit = false; } } // Now go for strike cycle... for(long j = 0; j < 4; j++) { if(layer1.cur_anim == alist[ANIM_2H_STRIKE_LEFT_START + j * 3] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_2H_STRIKE_LEFT_CYCLE + j * 3], EA_LOOP); player.m_aimTime = PlatformDuration::ofRaw(1); } else if(layer1.cur_anim == alist[ANIM_2H_STRIKE_LEFT_CYCLE + j * 3] && !eeMousePressed1()) { changeAnimation(io, 1, alist[ANIM_2H_STRIKE_LEFT + j * 3]); strikeSpeak(io); SendIOScriptEvent(NULL, io, SM_STRIKE, "2h"); player.m_strikeDirection = 0; player.m_aimTime = 0; } else if(layer1.cur_anim == alist[ANIM_2H_STRIKE_LEFT + j * 3]) { if( layer1.ctime > layer1.currentAltAnim()->anim_time * 0.3f && layer1.ctime < layer1.currentAltAnim()->anim_time * 0.7f ) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; if(player.m_weaponBlocked == AnimationDuration::ofRaw(-1) && ARX_EQUIPMENT_Strike_Check(io, weapon, player.m_strikeAimRatio, 0)) { player.m_weaponBlocked = layer1.ctime; } } if(layer1.flags & EA_ANIMEND) { changeAnimation(io, 1, alist[ANIM_2H_WAIT], EA_LOOP); layer1.flags &= ~(EA_PAUSED | EA_REVERSE); player.m_strikeDirection = 0; player.m_aimTime = 0; player.m_weaponBlocked = AnimationDuration::ofRaw(-1); } if( player.m_weaponBlocked != AnimationDuration::ofRaw(-1) && layer1.ctime < layer1.currentAltAnim()->anim_time * 0.9f ) { Entity * weapon = entities[player.equiped[EQUIP_SLOT_WEAPON]]; ARX_EQUIPMENT_Strike_Check(io, weapon, player.m_strikeAimRatio, 1); } } } break; } case WEAPON_BOW: { // MISSILE PLAYER MANAGEMENT if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_CYCLE]) { player.m_bowAimRatio += bowZoomFromDuration(toMs(g_platformTime.lastFrameDuration())); if(player.m_bowAimRatio > 1.f) player.m_bowAimRatio = 1.f; } // Waiting and Receiving Strike Impulse if(layer1.cur_anim == alist[ANIM_MISSILE_WAIT]) { player.m_aimTime = PlatformDuration::ofRaw(1); if(eeMousePressed1() && Player_Arrow_Count() > 0) { changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE_PART_1]); io->isHit = false; } } if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_PART_1] && (layer1.flags & EA_ANIMEND)) { player.m_aimTime = 0; changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE_PART_2]); EERIE_LINKEDOBJ_LinkObjectToObject(io->obj, arrowobj, "left_attach", "attach", NULL); } // Now go for strike cycle... if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_PART_2] && (layer1.flags & EA_ANIMEND)) { changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE_CYCLE], EA_LOOP); player.m_aimTime = PlatformDuration::ofRaw(1); } else if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE_CYCLE] && !eeMousePressed1()) { EERIE_LINKEDOBJ_UnLinkObjectFromObject(io->obj, arrowobj); changeAnimation(io, 1, alist[ANIM_MISSILE_STRIKE]); SendIOScriptEvent(NULL, io, SM_STRIKE, "bow"); StrikeAimtime(); player.m_strikeAimRatio = player.m_bowAimRatio; Entity * quiver = Player_Arrow_Count_Decrease(); float poisonous = 0.f; if(quiver) { poisonous = quiver->poisonous; if(quiver->poisonous_count > 0) { quiver->poisonous_count--; if(quiver->poisonous_count <= 0) quiver->poisonous = 0; } ARX_DAMAGES_DurabilityLoss(quiver, 1.f); // TODO is this needed ?, quivers seem to self destruct via script, but maybe not all if(ValidIOAddress(quiver) && quiver->durability <= 0.f) { ARX_INTERACTIVE_DestroyIOdelayed(quiver); } } float aimratio = player.m_strikeAimRatio; if(sp_max && poisonous < 3.f) poisonous = 3.f; Vec3f orgPos = player.pos + Vec3f(0.f, 40.f, 0.f); if(io->obj->fastaccess.left_attach != ActionPoint()) { orgPos = actionPointPosition(io->obj, io->obj->fastaccess.left_attach); } Anglef orgAngle = player.angle; PlayerLaunchArrow_Test(aimratio, poisonous, orgPos, orgAngle); if(sp_max) { Anglef angle; Vec3f pos = player.pos + Vec3f(0.f, 40.f, 0.f); angle.setPitch(player.angle.getPitch()); angle.setYaw(player.angle.getYaw() + 8); angle.setRoll(player.angle.getRoll()); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); angle.setPitch(player.angle.getPitch()); angle.setYaw(player.angle.getYaw() - 8); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); angle.setPitch(player.angle.getPitch()); angle.setYaw(player.angle.getYaw() + 4.f); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); angle.setPitch(player.angle.getPitch()); angle.setYaw(player.angle.getYaw() - 4.f); PlayerLaunchArrow_Test(aimratio, poisonous, pos, angle); } player.m_aimTime = 0; } else if(layer1.cur_anim == alist[ANIM_MISSILE_STRIKE]) { player.m_bowAimRatio -= bowZoomFromDuration(toMs(g_platformTime.lastFrameDuration())); if(player.m_bowAimRatio < 0) player.m_bowAimRatio = 0; if(layer1.flags & EA_ANIMEND) { player.m_bowAimRatio = 0; changeAnimation(io, 1, alist[ANIM_MISSILE_WAIT], EA_LOOP); player.m_aimTime = 0; player.m_weaponBlocked = AnimationDuration::ofRaw(-1); EERIE_LINKEDOBJ_UnLinkObjectFromObject(io->obj, arrowobj); } } break; } } LAST_WEAPON_TYPE = weapontype; }
void AddFlare(const Vec2f & pos, float sm, short typ, Entity * io, bool bookDraw) { size_t oldest = 0; size_t i; for(i = 0; i < g_magicFlaresMax; i++) { if(!g_magicFlares[i].exist) { break; } if(g_magicFlares[i].tolive < g_magicFlares[oldest].tolive) { oldest = i; } } if(i >= g_magicFlaresMax) { removeFlare(g_magicFlares[oldest]); i = oldest; } MagicFlare & flare = g_magicFlares[i]; flare.exist = 1; g_magicFlaresCount++; flare.bDrawBitmap = bookDraw; flare.io = io; if(io) { flare.flags = 1; io->flarecount++; } else { flare.flags = 0; } flare.pos.x = pos.x - Random::getf(0.f, 4.f); flare.pos.y = pos.y - Random::getf(0.f, 4.f); if(!bookDraw) { if(io) { float vx = -(flare.pos.x - g_size.center().x) * 0.2173913f; float vy = (flare.pos.y - g_size.center().y) * 0.1515151515151515f; flare.p = io->pos; flare.p += angleToVectorXZ(io->angle.getYaw() + vx) * 100.f; flare.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getPitch() + vy))) * 100.f - 150.f; } else { Vec3f screenPos(1.0f * (pos.x - float(g_size.width() / 2)) * 156.f / (640.f * g_sizeRatio.y), 0.75f * (pos.y - float(g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y), 75.f); flare.p = Vec3f(glm::inverse(g_preparedCamera.m_worldToView) * Vec4f(screenPos, 1.0f)); } } else { flare.p = Vec3f(flare.pos.x, flare.pos.y, 0.001f); } switch(g_magicFlareCurrentColor) { case 0: { flare.rgb = Color3f(0.4f, 0.f, 0.4f) + Color3f(2.f / 3, 2.f / 3, 2.f / 3) * randomColor3f(); break; } case 1: { flare.rgb = Color3f(0.5f, 0.5f, 0.f) + Color3f(0.625f, 0.625f, 0.55f) * randomColor3f(); break; } case 2: { flare.rgb = Color3f(0.4f, 0.f, 0.f) + Color3f(2.f / 3, 0.55f, 0.55f) * randomColor3f(); break; } default: arx_unreachable(); } static const float FLARE_MUL = 2.f; if(typ == -1) { float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? Random::getf() : 1.f); if(zz < 0.2f) { flare.type = 2; flare.size = Random::getf(42.f, 84.f); flare.tolive = PlatformDurationMsf(Random::getf(800.f, 1600.f) * FLARE_MUL); } else if(zz < 0.5f) { flare.type = 3; flare.size = Random::getf(16.f, 68.f); flare.tolive = PlatformDurationMsf(Random::getf(800.f, 1600.f) * FLARE_MUL); } else { flare.type = 1; flare.size = Random::getf(32.f, 56.f) * sm; flare.tolive = PlatformDurationMsf(Random::getf(1700.f, 2200.f) * FLARE_MUL); } } else { flare.type = (Random::getf() > 0.8f) ? 1 : 4; flare.size = Random::getf(64.f, 102.f) * sm; flare.tolive = PlatformDurationMsf(Random::getf(1700.f, 2200.f) * FLARE_MUL); } flare.dynlight = LightHandle(); for(unsigned int kk = 0; kk < 3; kk++) { if(Random::getf() < 0.5f) { continue; } PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } if(!bookDraw) { pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING; if(!io) { pd->m_flags |= PARTICLE_NOZBUFFER; } } else { pd->m_flags = FADE_IN_AND_OUT; } pd->ov = flare.p + arx::randomVec(-5.f, 5.f); pd->move = Vec3f(0.f, 5.f, 0.f); pd->scale = Vec3f(-2.f); pd->tolive = 1300 + kk * 100 + Random::getu(0, 800); pd->tc = fire2; if(kk == 1) { pd->move.y = 4.f; pd->siz = 1.5f; } else { pd->siz = Random::getf(1.f, 2.f); } pd->rgb = flare.rgb * (2.f / 3); pd->m_rotation = 1.2f; if(bookDraw) { pd->is2D = true; } } }
void AddFlare(const Vec2f & pos, float sm, short typ, Entity * io, bool bookDraw) { size_t oldest = 0; size_t i; for(i = 0; i < g_magicFlaresMax; i++) { if(!g_magicFlares[i].exist) { break; } if(g_magicFlares[i].tolive < g_magicFlares[oldest].tolive) { oldest = i; } } if(i >= g_magicFlaresMax) { removeFlare(g_magicFlares[oldest]); i = oldest; } MagicFlare & flare = g_magicFlares[i]; flare.exist = 1; g_magicFlaresCount++; if(!bookDraw) flare.bDrawBitmap = 0; else flare.bDrawBitmap = 1; flare.io = io; if(io) { flare.flags = 1; io->flarecount++; } else { flare.flags = 0; } flare.pos.x = pos.x - Random::getf(0.f, 4.f); flare.pos.y = pos.y - Random::getf(0.f, 4.f) - 50.f; flare.tv.rhw = flare.v.rhw = 1.f; if(!bookDraw) { EERIE_CAMERA ka = *g_magicFlareCamera; ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle; EERIE_CAMERA * oldcam = ACTIVECAM; SetActiveCamera(&ka); PrepareCamera(&ka, g_size); flare.v.p += ka.orgTrans.pos; EE_RTP(flare.tv.p, flare.v); flare.v.p += ka.orgTrans.pos; float vx = -(flare.pos.x - subj.center.x) * 0.2173913f; float vy = (flare.pos.y - subj.center.y) * 0.1515151515151515f; if(io) { flare.v.p = io->pos; flare.v.p += angleToVectorXZ(io->angle.getYaw() + vx) * 100.f; flare.v.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getPitch() + vy))) * 100.f - 150.f; } else { flare.v.p.x = 1.0f * float(pos.x - (g_size.width() / 2)) * 156.f / (640.f * g_sizeRatio.y); flare.v.p.y = 0.75f * float(pos.y - (g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y); flare.v.p.z = 75.f; ka = *oldcam; SetActiveCamera(&ka); PrepareCamera(&ka, g_size); float temp = (flare.v.p.y * -ka.orgTrans.xsin) + (flare.v.p.z * ka.orgTrans.xcos); flare.v.p.y = (flare.v.p.y * ka.orgTrans.xcos) - (-flare.v.p.z * ka.orgTrans.xsin); flare.v.p.z = (temp * ka.orgTrans.ycos) - (-flare.v.p.x * ka.orgTrans.ysin); flare.v.p.x = (temp * -ka.orgTrans.ysin) + (flare.v.p.x * ka.orgTrans.ycos); flare.v.p += oldcam->orgTrans.pos; } flare.tv.p = flare.v.p; SetActiveCamera(oldcam); PrepareCamera(oldcam, g_size); } else { flare.tv.p = Vec3f(flare.pos.x, flare.pos.y, 0.001f); } switch(g_magicFlareCurrentColor) { case 0: { flare.rgb = Color3f(.4f, 0.f, .4f) + Color3f(2.f/3, 2.f/3, 2.f/3) * randomColor3f(); break; } case 1: { flare.rgb = Color3f(.5f, .5f, 0.f) + Color3f(.625f, .625f, .55f) * randomColor3f(); break; } case 2: { flare.rgb = Color3f(.4f, 0.f, 0.f) + Color3f(2.f/3, .55f, .55f) * randomColor3f(); break; } } static const float FLARE_MUL = 2.f; if(typ == -1) { float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? Random::getf() : 1.f); if(zz < 0.2f) { flare.type = 2; flare.size = Random::getf(42.f, 84.f); flare.tolive = Random::getf(800.f, 1600.f) * FLARE_MUL; } else if(zz < 0.5f) { flare.type = 3; flare.size = Random::getf(16.f, 68.f); flare.tolive = Random::getf(800.f, 1600.f) * FLARE_MUL; } else { flare.type = 1; flare.size = Random::getf(32.f, 56.f) * sm; flare.tolive = Random::getf(1700.f, 2200.f) * FLARE_MUL; } } else { flare.type = (Random::getf() > 0.8f) ? 1 : 4; flare.size = Random::getf(64.f, 102.f) * sm; flare.tolive = Random::getf(1700.f, 2200.f) * FLARE_MUL; } flare.dynlight = LightHandle(); for(unsigned int kk = 0; kk < 3; kk++) { if(Random::getf() < 0.5f) { continue; } PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } if(!bookDraw) { pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING; if(!io) { pd->m_flags |= PARTICLE_NOZBUFFER; } } else { pd->m_flags = FADE_IN_AND_OUT; } pd->ov = flare.v.p + randomVec(-5.f, 5.f); pd->move = Vec3f(0.f, 5.f, 0.f); pd->scale = Vec3f(-2.f); pd->tolive = 1300 + kk * 100 + Random::getu(0, 800); pd->tc = fire2; if(kk == 1) { pd->move.y = 4.f; pd->siz = 1.5f; } else { pd->siz = Random::getf(1.f, 2.f); } pd->rgb = Color3f(flare.rgb.r * (2.f/3), flare.rgb.g * (2.f/3), flare.rgb.b * (2.f/3)); pd->m_rotation = 1.2f; if(bookDraw) pd->is2D = true; } }