//----------------------------------------------------------------------------- float CMultiPoisonProjectile::Render(LPDIRECT3DDEVICE7 m_pd3dDevice) { for (UINT i = 0 ; i < uiNumber ; i++) { float fa = pTab[i]->Render(m_pd3dDevice); CPoisonProjectile * pPoisonProjectile = (CPoisonProjectile *) pTab[i]; if (pPoisonProjectile->lLightId != -1) { long id = pPoisonProjectile->lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 2.3f * fa; DynLight[id].fallend = 250.f; DynLight[id].fallstart = 150.f; DynLight[id].rgb.r = 0.f; DynLight[id].rgb.g = 1.0f; DynLight[id].rgb.b = 0.f; DynLight[id].pos.x = pPoisonProjectile->eCurPos.x; DynLight[id].pos.y = pPoisonProjectile->eCurPos.y; DynLight[id].pos.z = pPoisonProjectile->eCurPos.z; DynLight[id].time_creation = ARXTimeUL(); DynLight[id].duration = 200; } long t = ARX_DAMAGES_GetFree(); AddPoisonFog(&pPoisonProjectile->eCurPos, spells[spellinstance].caster_level + 7); if ((t != -1) && (spells[pTab[i]->spellinstance].timcreation + 1600 < ARXTimeUL())) { damages[t].pos.x = pPoisonProjectile->eCurPos.x; damages[t].pos.y = pPoisonProjectile->eCurPos.y; damages[t].pos.z = pPoisonProjectile->eCurPos.z; damages[t].radius = 120.f; float v = spells[spellinstance].caster_level; v = 4.f + v * DIV10 * 6.f ; damages[t].damages = v * DIV1000 * _framedelay; damages[t].area = DAMAGE_FULL; damages[t].duration = ARX_CLEAN_WARN_CAST_LONG(FrameDiff); damages[t].source = spells[spellinstance].caster; damages[t].flags = 0; damages[t].type = DAMAGE_TYPE_MAGICAL | DAMAGE_TYPE_POISON; damages[t].exist = TRUE; } } return 1; }
//----------------------------------------------------------------------------- float CMultiMagicMissile::Render(LPDIRECT3DDEVICE7 m_pd3dDevice) { long nbmissiles = 0; if (pTab) { for (UINT i = 0 ; i < uiNumber ; i++) { if (pTab[i]) { float fa = pTab[i]->Render(m_pd3dDevice); CMagicMissile * pMM = (CMagicMissile *) pTab[i]; if (pMM->lLightId != -1) { EERIE_LIGHT * el = &DynLight[pMM->lLightId]; el->intensity = 0.7f + 2.3f * fa; el->pos.x = pMM->eCurPos.x; el->pos.y = pMM->eCurPos.y; el->pos.z = pMM->eCurPos.z; el->time_creation = ARXTimeUL(); } if (pMM->bMove) nbmissiles++; } } } if (nbmissiles == 0) return -1; return 1; }
//----------------------------------------------------------------------------- // Spawns a Projectile using type, starting position/TargetPosition void ARX_MISSILES_Spawn(INTERACTIVE_OBJ *io, const long &type, const EERIE_3D *startpos, const EERIE_3D *targetpos) { long i(ARX_MISSILES_GetFree()); if (i == -1) return; missiles[i].owner = GetInterNum(io); missiles[i].type = type; missiles[i].lastpos.x = missiles[i].startpos.x = startpos->x; missiles[i].lastpos.y = missiles[i].startpos.y = startpos->y; missiles[i].lastpos.z = missiles[i].startpos.z = startpos->z; float dist; dist = 1.0F / Distance3D(startpos->x, startpos->y, startpos->z, targetpos->x, targetpos->y,targetpos->z); missiles[i].velocity.x = (targetpos->x - startpos->x) * dist; missiles[i].velocity.y = (targetpos->y - startpos->y) * dist; missiles[i].velocity.z = (targetpos->z - startpos->z) * dist; missiles[i].lastupdate = missiles[i].timecreation = ARXTimeUL(); switch (type) { case MISSILE_FIREBALL: { missiles[i].tolive = 6000; missiles[i].velocity.x *= 0.8f; missiles[i].velocity.y *= 0.8f; missiles[i].velocity.z *= 0.8f; missiles[i].longinfo = GetFreeDynLight(); if (missiles[i].longinfo != -1) { DynLight[missiles[i].longinfo].intensity = 1.3f; DynLight[missiles[i].longinfo].exist = 1; DynLight[missiles[i].longinfo].fallend = 420.f; DynLight[missiles[i].longinfo].fallstart = 250.f; DynLight[missiles[i].longinfo].rgb.r = 1.f; DynLight[missiles[i].longinfo].rgb.g = 0.8f; DynLight[missiles[i].longinfo].rgb.b = 0.6f; DynLight[missiles[i].longinfo].pos.x = startpos->x; DynLight[missiles[i].longinfo].pos.y = startpos->y; DynLight[missiles[i].longinfo].pos.z = startpos->z; } ARX_SOUND_PlaySFX(SND_SPELL_FIRE_WIND, &missiles[i].startpos, 2.0F); ARX_SOUND_PlaySFX(SND_SPELL_FIRE_LAUNCH, &missiles[i].startpos, 2.0F); } } }
//----------------------------------------------------------------------------- CMultiPoisonProjectile::~CMultiPoisonProjectile() { for (UINT i = 0 ; i < uiNumber ; i++) { if (pTab[i]->lLightId != -1) { DynLight[pTab[i]->lLightId].duration = 2000; DynLight[pTab[i]->lLightId].time_creation = ARXTimeUL(); pTab[i]->lLightId = -1; } delete pTab[i]; } delete [] pTab; }
//--------------------------------------------------------------------- void CRuneOfGuarding::Update(unsigned long _ulTime) { ulCurrentTime += _ulTime; float fa = 1.0f - rnd() * 0.15f; if (lLightId != -1) { long id = lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 0.7f + 2.3f * fa; DynLight[id].fallend = 350.f; DynLight[id].fallstart = 150.f; DynLight[id].rgb.r = 1.0f; DynLight[id].rgb.g = 0.2f; DynLight[id].rgb.b = 0.2f; DynLight[id].time_creation = ARXTimeUL(); DynLight[id].duration = 200; } }
//----------------------------------------------------------------------------- // Spawns a Projectile using type, starting position/TargetPosition void ARX_MISSILES_Spawn(INTERACTIVE_OBJ * io, ARX_SPELLS_MISSILE_TYPE type, const Vec3f * startpos, const Vec3f * targetpos) { long i(ARX_MISSILES_GetFree()); if (i == -1) return; missiles[i].owner = GetInterNum(io); missiles[i].type = type; missiles[i].lastpos = missiles[i].startpos = *startpos; float dist; dist = 1.0F / fdist(*startpos, *targetpos); missiles[i].velocity = (*targetpos - *startpos) * dist; missiles[i].lastupdate = missiles[i].timecreation = ARXTimeUL(); switch (type) { case MISSILE_NONE: break; case MISSILE_FIREBALL: { missiles[i].tolive = 6000; missiles[i].velocity *= 0.8f; missiles[i].longinfo = GetFreeDynLight(); if (missiles[i].longinfo != -1) { DynLight[missiles[i].longinfo].intensity = 1.3f; DynLight[missiles[i].longinfo].exist = 1; DynLight[missiles[i].longinfo].fallend = 420.f; DynLight[missiles[i].longinfo].fallstart = 250.f; DynLight[missiles[i].longinfo].rgb = Color3f(1.f, .8f, .6f); DynLight[missiles[i].longinfo].pos = *startpos; } ARX_SOUND_PlaySFX(SND_SPELL_FIRE_WIND, &missiles[i].startpos, 2.0F); ARX_SOUND_PlaySFX(SND_SPELL_FIRE_LAUNCH, &missiles[i].startpos, 2.0F); } } }
//----------------------------------------------------------------------------- void CRuneOfGuarding::Create(EERIE_3D _eSrc, float _fBeta) { SetDuration(ulDuration); SetAngle(_fBeta); eSrc.x = _eSrc.x; eSrc.y = _eSrc.y; eSrc.z = _eSrc.z; eTarget.x = eSrc.x; eTarget.y = eSrc.y; eTarget.z = eSrc.z; fSize = 1; bDone = true; lLightId = GetFreeDynLight(); if (lLightId != -1) { long id = lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 0.7f + 2.3f; DynLight[id].fallend = 500.f; DynLight[id].fallstart = 400.f; DynLight[id].rgb.r = 1.0f; DynLight[id].rgb.g = 0.2f; DynLight[id].rgb.b = 0.2f; DynLight[id].pos.x = eSrc.x; DynLight[id].pos.y = eSrc.y - 50; DynLight[id].pos.z = eSrc.z; DynLight[id].time_creation = ARXTimeUL(); DynLight[id].duration = 200; } }
//----------------------------------------------------------------------------- // Updates all currently launched projectiles void ARX_MISSILES_Update() { long framediff, framediff2, framediff3; EERIE_3D orgn, dest, hit; TextureContainer * tc = TC_fire; EERIEPOLY *tp = NULL; unsigned long tim = ARXTimeUL(); for (unsigned long i(0); i < MAX_MISSILES; i++) { if (missiles[i].type == MISSILE_NONE) continue; framediff = missiles[i].timecreation + missiles[i].tolive - tim; if (framediff < 0) { ARX_MISSILES_Kill(i); continue; } framediff2 = missiles[i].timecreation + missiles[i].tolive - missiles[i].lastupdate; framediff3 = tim - missiles[i].timecreation; switch (missiles[i].type) { case MISSILE_FIREBALL : { EERIE_3D pos; pos.x = missiles[i].startpos.x + missiles[i].velocity.x * framediff3; pos.y = missiles[i].startpos.y + missiles[i].velocity.y * framediff3; pos.z = missiles[i].startpos.z + missiles[i].velocity.z * framediff3; if (missiles[i].longinfo != -1) { DynLight[missiles[i].longinfo].pos.x = pos.x; DynLight[missiles[i].longinfo].pos.y = pos.y; DynLight[missiles[i].longinfo].pos.z = pos.z; } if (USE_COLLISIONS) { orgn.x = missiles[i].lastpos.x; orgn.y = missiles[i].lastpos.y; orgn.z = missiles[i].lastpos.z; dest.x = pos.x; dest.y = pos.y; dest.z = pos.z; EERIEPOLY *ep; EERIEPOLY *epp; EERIE_3D tro; tro.x = 70.0F; tro.y = 70.0F; tro.z = 70.0F; CURRENTINTER = NULL; ep = GetMinPoly(dest.x, dest.y, dest.z); epp = GetMaxPoly(dest.x, dest.y, dest.z); if (Distance3D(player.pos.x, player.pos.y, player.pos.z, pos.x, pos.y, pos.z) < 200.0F) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&pos); Add3DBoom(&pos, NULL); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if (ep && ep->center.y < dest.y) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest, NULL); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if (epp && epp->center.y > dest.y) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest, NULL); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if (EERIELaunchRay3(&orgn, &dest, &hit, tp, 1)) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&hit); Add3DBoom(&hit, NULL); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if ( !EECheckInPoly(&dest) || EEIsUnderWaterFast(&dest) ) //ARX: jycorbel (2010-08-20) - rendering issues with bGATI8500: optimize time to render; { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest, NULL); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } long ici = IsCollidingAnyInter(dest.x, dest.y, dest.z, &tro); if (ici != -1 && ici != missiles[i].owner) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest, NULL); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } } long j = ARX_PARTICLES_GetFree(); if (j != -1 && !ARXPausedTimer) { ParticleCount++; particle[j].exist = TRUE; particle[j].zdec = 0; particle[j].ov.x = pos.x; particle[j].ov.y = pos.y; particle[j].ov.z = pos.z; particle[j].move.x = missiles[i].velocity.x + 3.0f - 6.0F * rnd(); particle[j].move.y = missiles[i].velocity.y + 4.0F - 12.0F * rnd(); particle[j].move.z = missiles[i].velocity.z + 3.0F - 6.0F * rnd(); particle[j].timcreation = tim; particle[j].tolive = 500 + (unsigned long)(rnd() * 500.f); particle[j].tc = tc; particle[j].siz = 12.0F * (float)(missiles[i].tolive - framediff3) * DIV4000; particle[j].scale.x = 15.0F + rnd() * 5.0F; particle[j].scale.y = 15.0F + rnd() * 5.0F; particle[j].scale.z = 15.0F + rnd() * 5.0F; particle[j].special = FIRE_TO_SMOKE; } missiles[i].lastpos.x = pos.x; missiles[i].lastpos.y = pos.y; missiles[i].lastpos.z = pos.z; break; } } missiles[i].lastupdate = tim; } }
//************************************************************************************* //************************************************************************************* void ARX_FOGS_Render(long init) { if (ARXPausedTimer) return; int iDiv = 2; if (pMenuConfig) { iDiv += 2 - pMenuConfig->iLevelOfDetails; } float flDiv = ARX_CLEAN_WARN_CAST_FLOAT(1 << iDiv); for (long i = 0; i < MAX_FOG; i++) { if (fogs[i].exist) { unsigned long offs; float fval; offs = 0; ARX_CHECK_LONG(FrameDiff / flDiv); long count = ARX_CLEAN_WARN_CAST_LONG(FrameDiff / flDiv); if (count < 1) count = 1; while (count) { count--; long j = ARX_PARTICLES_GetFree(); if ((j != -1) && (rnd() * 2000.f < (float)fogs[i].frequency)) { ParticleCount++; particle[j].special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; particle[j].exist = TRUE; particle[j].zdec = 0; if (fogs[i].special & FOG_DIRECTIONAL) { particle[j].ov.x = fogs[i].pos.x; particle[j].ov.y = fogs[i].pos.y; particle[j].ov.z = fogs[i].pos.z; fval = fogs[i].speed * DIV10; particle[j].move.x = (fogs[i].move.x * fval); particle[j].move.y = (fogs[i].move.y * fval); particle[j].move.z = (fogs[i].move.z * fval); } else { particle[j].ov.x = fogs[i].pos.x + 100.f - 200.f * rnd(); particle[j].ov.y = fogs[i].pos.y + 100.f - 200.f * rnd(); particle[j].ov.z = fogs[i].pos.z + 100.f - 200.f * rnd(); fval = fogs[i].speed * DIV5; particle[j].move.x = (fogs[i].speed - rnd() * 2.f) * fval; particle[j].move.y = (fogs[i].speed - rnd() * 2.f) * DIV15; particle[j].move.z = (fogs[i].speed - rnd() * 2.f) * fval; } particle[j].scale.x = particle[j].scale.y = particle[j].scale.z = fogs[i].scale; particle[j].timcreation = lARXTime; particle[j].tolive = fogs[i].tolive + (unsigned long)(rnd() * fogs[i].tolive); particle[j].tc = TC_smoke; particle[j].siz = (fogs[i].size + rnd() * fogs[i].size * 2.f) * DIV3; particle[j].r = fogs[i].rgb.r; particle[j].g = fogs[i].rgb.g; particle[j].b = fogs[i].rgb.b; particle[j].fparam = fogs[i].rotatespeed; } fogs[i].lastupdate = ARXTimeUL(); } } } }
//--------------------------------------------------------------------- void CCurePoison::Update(unsigned long aulTime) { ulCurrentTime += aulTime; if (ulCurrentTime >= ulDuration) { return; } eSrc.x = inter.iobj[spells[spellinstance].target]->pos.x; eSrc.y = inter.iobj[spells[spellinstance].target]->pos.y; if (spells[spellinstance].target == 0) eSrc.y += 200; eSrc.z = inter.iobj[spells[spellinstance].target]->pos.z; unsigned long ulCalc = ulDuration - ulCurrentTime ; ARX_CHECK_LONG(ulCalc); long ff = ARX_CLEAN_WARN_CAST_LONG(ulCalc); if (ff < 1500) { pPS->uMaxParticles = 0; pPS->ulParticleSpawn = PARTICLE_CIRCULAR; pPS->p3ParticleGravity.x = 0; pPS->p3ParticleGravity.y = 0; pPS->p3ParticleGravity.z = 0; list<CParticle *>::iterator i; for (i = pPS->listParticle.begin(); i != pPS->listParticle.end(); ++i) { CParticle * pP = *i; if (pP->isAlive()) { pP->fColorEnd[3] = 0; if (pP->ulTime + ff < pP->ulTTL) { pP->ulTime = pP->ulTTL - ff; } } } } pPS->SetPos(eSrc); pPS->Update(aulTime); if (pPS->lLightId == -1) pPS->lLightId = GetFreeDynLight(); if (pPS->lLightId != -1) { long id = pPS->lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 2.3f; DynLight[id].fallstart = 200.f; DynLight[id].fallend = 350.f; DynLight[id].rgb.r = 0.4f; DynLight[id].rgb.g = 1.f; DynLight[id].rgb.b = 0.4f; DynLight[id].pos.x = eSrc.x; DynLight[id].pos.y = eSrc.y - 50.f; DynLight[id].pos.z = eSrc.z; DynLight[id].duration = 200; DynLight[id].time_creation = ARXTimeUL(); DynLight[id].extras = 0; } }
//--------------------------------------------------------------------- float CRepelUndead::Render(LPDIRECT3DDEVICE7 m_pd3dDevice) { if (ulCurrentTime >= ulDuration) { return 0.f; } SETZWRITE(m_pd3dDevice, FALSE); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); SETALPHABLEND(m_pd3dDevice, TRUE); //---------------------------- EERIE_3D eObjAngle; EERIE_3D eObjPos; EERIE_3D eObjScale; EERIE_RGB rgbObjColor; eObjAngle.b = fBeta; eObjAngle.a = 0; eObjAngle.g = 0; eObjPos.x = eSrc.x; eObjPos.y = eSrc.y - 5.f; eObjPos.z = eSrc.z; rgbObjColor.r = 0.6f; rgbObjColor.g = 0.6f; rgbObjColor.b = 0.8f; float vv = 1.f + (EEsin(ARX_TIME_Get() * DIV1000)); vv *= DIV2; vv += 1.1f; eObjScale.z = vv; eObjScale.y = vv; eObjScale.x = vv; if (ssol) DrawEERIEObjEx(m_pd3dDevice, ssol, &eObjAngle, &eObjPos, &eObjScale, &rgbObjColor); vv *= 100.f; for (int n = 0; n < 4; n++) { int j = ARX_PARTICLES_GetFree(); if ((j != -1) && (!ARXPausedTimer)) { ParticleCount++; particle[j].exist = 1; particle[j].zdec = 0; particle[j].ov.x = eSrc.x - EEsin(frand2() * 360.f) * vv; particle[j].ov.y = eSrc.y; particle[j].ov.z = eSrc.z + EEcos(frand2() * 360.f) * vv; particle[j].move.x = 0.8f * frand2(); particle[j].move.y = -4.f * rnd(); particle[j].move.z = 0.8f * frand2(); particle[j].scale.x = -0.1f; particle[j].scale.y = -0.1f; particle[j].scale.z = -0.1f; particle[j].timcreation = lARXTime; particle[j].tolive = 2600 + (unsigned long)(rnd() * 600.f); particle[j].tc = tex_p2; particle[j].siz = 0.3f; particle[j].r = 0.4f; particle[j].g = 0.4f; particle[j].b = 0.6f; } } if (this->lLightId == -1) this->lLightId = GetFreeDynLight(); if (this->lLightId != -1) { long id = this->lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 2.3f; DynLight[id].fallend = 350.f; DynLight[id].fallstart = 150.f; DynLight[id].rgb.r = 0.8f; DynLight[id].rgb.g = 0.8f; DynLight[id].rgb.b = 1; DynLight[id].pos.x = eSrc.x; DynLight[id].pos.y = eSrc.y - 50.f; DynLight[id].pos.z = eSrc.z; DynLight[id].duration = 200; DynLight[id].time_creation = ARXTimeUL(); } return 1; }
//----------------------------------------------------------------------------- void CCurePoison::Create() { SetAngle(0); eSrc.x = inter.iobj[spells[spellinstance].target]->pos.x; eSrc.y = inter.iobj[spells[spellinstance].target]->pos.y; if (spells[spellinstance].target == 0) eSrc.y += 200; eSrc.z = inter.iobj[spells[spellinstance].target]->pos.z; pPS->SetPos(eSrc); CParticleParams cp; cp.iNbMax = 350; cp.fLife = 800; cp.fLifeRandom = 2000; cp.p3Pos.x = 100; cp.p3Pos.y = 0; cp.p3Pos.z = 100; cp.p3Direction.x = 0; cp.p3Direction.y = -10; cp.p3Direction.z = 0; cp.fAngle = DEG2RAD(5); cp.fSpeed = 120; cp.fSpeedRandom = 84; cp.p3Gravity.x = 0; cp.p3Gravity.y = -10; cp.p3Gravity.z = 0; cp.fFlash = 0; cp.fRotation = 80; cp.fStartSize = 8;//6; cp.fStartSizeRandom = 8; cp.fStartColor[0] = 20; cp.fStartColor[1] = 205; cp.fStartColor[2] = 20; cp.fStartColor[3] = 245; cp.fStartColorRandom[0] = 50; cp.fStartColorRandom[1] = 50; cp.fStartColorRandom[2] = 50; cp.fStartColorRandom[3] = 10; cp.fEndSize = 6; cp.fEndSizeRandom = 4; cp.fEndColor[0] = 5; cp.fEndColor[1] = 20; cp.fEndColor[2] = 5; cp.fEndColor[3] = 0; cp.fEndColorRandom[0] = 0; cp.fEndColorRandom[1] = 40; cp.fEndColorRandom[2] = 0; cp.fEndColorRandom[3] = 0; cp.bTexInfo = FALSE; pPS->SetParams(cp); pPS->ulParticleSpawn = PARTICLE_CIRCULAR | PARTICLE_BORDER; pPS->SetTexture("graph\\particles\\cure_poison.bmp", 0, 100); //5 pPS->lLightId = GetFreeDynLight(); if (pPS->lLightId != -1) { long id = pPS->lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 1.5f; DynLight[id].fallstart = 200.f; DynLight[id].fallend = 350.f; DynLight[id].rgb.r = 0.f; DynLight[id].rgb.g = 1.f; DynLight[id].rgb.b = 0.0f; DynLight[id].pos.x = eSrc.x; DynLight[id].pos.y = eSrc.y - 50.f; DynLight[id].pos.z = eSrc.z; DynLight[id].time_creation = ARXTimeUL(); DynLight[id].duration = 200; DynLight[id].extras = 0; } fSize = 1; }
//----------------------------------------------------------------------------- void CMultiPoisonProjectile::Create(EERIE_3D _eSrc, float _afBeta = 0) { float afAlpha = 0.f; float afBeta = 0.f; spells[spellinstance].hand_group = inter.iobj[spells[spellinstance].caster]->obj->fastaccess.primary_attach; if (spells[spellinstance].hand_group != -1) { spells[spellinstance].hand_pos.x = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.x; spells[spellinstance].hand_pos.y = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.y; spells[spellinstance].hand_pos.z = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.z; } if (spells[spellinstance].caster == 0) // player { afBeta = player.angle.b; afAlpha = player.angle.a; if (spells[spellinstance].hand_group != -1) { _eSrc.x = spells[spellinstance].hand_pos.x - EEsin(DEG2RAD(afBeta)) * 90; _eSrc.y = spells[spellinstance].hand_pos.y; _eSrc.z = spells[spellinstance].hand_pos.z + EEcos(DEG2RAD(afBeta)) * 90; } else { _eSrc.x = player.pos.x - EEsin(DEG2RAD(afBeta)) * 90; _eSrc.y = player.pos.y; _eSrc.z = player.pos.z + EEcos(DEG2RAD(afBeta)) * 90; } } else { afBeta = inter.iobj[spells[spellinstance].caster]->angle.b; if (spells[spellinstance].hand_group != -1) { _eSrc.x = spells[spellinstance].hand_pos.x - EEsin(DEG2RAD(afBeta)) * 90; _eSrc.y = spells[spellinstance].hand_pos.y; _eSrc.z = spells[spellinstance].hand_pos.z + EEcos(DEG2RAD(afBeta)) * 90; } else { _eSrc.x = inter.iobj[spells[spellinstance].caster]->pos.x - EEsin(DEG2RAD(afBeta)) * 90; _eSrc.y = inter.iobj[spells[spellinstance].caster]->pos.y; _eSrc.z = inter.iobj[spells[spellinstance].caster]->pos.z + EEcos(DEG2RAD(afBeta)) * 90; } } long lMax = 0; for (UINT i = 0 ; i < uiNumber ; i++) { pTab[i]->Create(_eSrc, afBeta + frand2() * 10.0f); long lTime = ulDuration + (long) rnd() * 5000; pTab[i]->SetDuration(lTime); lMax = max(lMax, lTime); CPoisonProjectile * pPP = (CPoisonProjectile *) pTab[i]; pPP->SetColor(0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f); pPP->SetColor1(0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f); pPP->SetColor(0, 1, 0); pPP->SetColor1(0.3f, 0.8f, 0); pPP->lLightId = GetFreeDynLight(); if (pPP->lLightId != -1) { long id = pPP->lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 2.3f; DynLight[id].fallend = 250.f; DynLight[id].fallstart = 150.f; DynLight[id].rgb.r = 0; DynLight[id].rgb.g = 1; DynLight[id].rgb.b = 0; DynLight[id].pos.x = pPP->eSrc.x; DynLight[id].pos.y = pPP->eSrc.y; DynLight[id].pos.z = pPP->eSrc.z; DynLight[id].time_creation = ARXTimeUL(); DynLight[id].duration = 200; } pTab[i]->spellinstance = this->spellinstance; } SetDuration(lMax + 1000); }
void ARXDRAW_DrawPolyBoom(LPDIRECT3DDEVICE7 pd3dDevice) { D3DTLVERTEX ltv[4]; long i,k; float tt; SetZBias(pd3dDevice,8); GDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR,0); unsigned long tim = ARXTimeUL(); SETALPHABLEND(pd3dDevice,TRUE); for ( i = 0 ; i < MAX_POLYBOOM ; i++ ) { if ( polyboom[i].exist ) { if ( polyboom[i].type & 128 ) { if (polyboom[i].timecreation - FrameDiff > 0) { float fCalc = polyboom[i].timecreation - FrameDiff; ARX_CHECK_ULONG( fCalc ); polyboom[i].timecreation = ARX_CLEAN_WARN_CAST_ULONG( fCalc ); } if (polyboom[i].timecreation - FrameDiff > 0) { float fCalc = polyboom[i].timecreation - FrameDiff; ARX_CHECK_ULONG( fCalc ); polyboom[i].timecreation = ARX_CLEAN_WARN_CAST_ULONG( fCalc ); } } float t = (float)polyboom[i].timecreation + (float)polyboom[i].tolive - (float)tim; if ( t <= 0 ) { polyboom[i].exist=0; BoomCount--; continue; } if (Project.hide & HIDE_BACKGROUND) continue; else { long typp = polyboom[i].type; typp &= ~128; switch (typp) { case 0: tt = (float)t / (float)polyboom[i].tolive * 0.8f; IncrementPolyWithNormalOutput(polyboom[i].ep,2.f,ltv); EE_RT2(<v[0],<v[0]); EE_RT2(<v[1],<v[1]); EE_RT2(<v[2],<v[2]); for (k=0;k<polyboom[i].nbvert;k++) { ltv[k].tu=polyboom[i].u[k]; ltv[k].tv=polyboom[i].v[k]; if (Project.improve) ltv[k].color=EERIERGB(tt*DIV2,0.f,0.f); else ltv[k].color=_EERIERGB(tt); ltv[k].specular=0xFF000000; } if (Project.improve) { SETBLENDMODE(pd3dDevice,D3DBLEND_ONE,D3DBLEND_ONE); } else { SETBLENDMODE(pd3dDevice,D3DBLEND_ZERO,D3DBLEND_INVSRCCOLOR); } SETTC(pd3dDevice,Boom); ARX_DrawPrimitive_SoftClippZ( <v[0], <v[1], <v[2]); if(polyboom[i].nbvert&4) { EE_RT2(<v[3],<v[3]); ARX_DrawPrimitive_SoftClippZ( <v[1], <v[2], <v[3]); } break; case 1: // Blood { float div=1.f/(float)polyboom[i].tolive; tt=(float)t*div; float tr = tt * 2 - 0.5f; if (tr<1.f) tr=1.f; D3DCOLOR col=EERIERGB(polyboom[i].rgb.r*tt,polyboom[i].rgb.g*tt,polyboom[i].rgb.b*tt); for (k=0;k<polyboom[i].nbvert;k++) { ltv[k].tu=(polyboom[i].u[k]-0.5f)*(tr)+0.5f; ltv[k].tv=(polyboom[i].v[k]-0.5f)*(tr)+0.5f; ltv[k].color=col; ltv[k].specular=0xFF000000; } IncrementPolyWithNormalOutput(polyboom[i].ep,2.f,ltv); EE_RT2(<v[0],<v[0]); EE_RT2(<v[1],<v[1]); EE_RT2(<v[2],<v[2]); if(polyboom[i].nbvert&4) { EE_RT2(<v[3],<v[3]); } { SETTEXTUREWRAPMODE(pd3dDevice,D3DTADDRESS_CLAMP); SETBLENDMODE(pd3dDevice,D3DBLEND_ONE,D3DBLEND_ONE); SETTC(pd3dDevice, polyboom[i].tc); ARX_DrawPrimitive_SoftClippZ( <v[0], <v[1], <v[2]); if(polyboom[i].nbvert&4) { ARX_DrawPrimitive_SoftClippZ( <v[1], <v[2], <v[3]); } col=_EERIERGB(tt); ltv[0].color=ltv[1].color=ltv[2].color=ltv[3].color=col; SETBLENDMODE(pd3dDevice,D3DBLEND_ZERO,D3DBLEND_INVSRCCOLOR); ARX_DrawPrimitive_SoftClippZ( <v[0], <v[1], <v[2]); if(polyboom[i].nbvert&4) { ARX_DrawPrimitive_SoftClippZ( <v[1], <v[2], <v[3]); } SETTEXTUREWRAPMODE(pd3dDevice,D3DTADDRESS_WRAP); } } break; case 2: // WATER { float div=1.f/(float)polyboom[i].tolive; tt=(float)t*div; float tr = (tt * 2 - 0.5f); if (tr<1.f) tr=1.f; float ttt=tt*0.5f; D3DCOLOR col=EERIERGB( polyboom[i].rgb.r*ttt, polyboom[i].rgb.g*ttt, polyboom[i].rgb.b*ttt); for (k=0;k<polyboom[i].nbvert;k++) { ltv[k].tu=(polyboom[i].u[k]-0.5f)*(tr)+0.5f; ltv[k].tv=(polyboom[i].v[k]-0.5f)*(tr)+0.5f; ltv[k].color=col; ltv[k].specular=0xFF000000; } if ( (ltv[0].tu<0.f) && (ltv[1].tu<0.f) && (ltv[2].tu<0.f) && (ltv[3].tu<0.f) ) break; if ( (ltv[0].tv<0.f) && (ltv[1].tv<0.f) && (ltv[2].tv<0.f) && (ltv[3].tv<0.f) ) break; if ( (ltv[0].tu>1.f) && (ltv[1].tu>1.f) && (ltv[2].tu>1.f) && (ltv[3].tu>1.f) ) break; if ( (ltv[0].tv>1.f) && (ltv[1].tv>1.f) && (ltv[2].tv>1.f) && (ltv[3].tv>1.f) ) break; IncrementPolyWithNormalOutput(polyboom[i].ep,2.f,ltv); EE_RT2(<v[0],<v[0]); EE_RT2(<v[1],<v[1]); EE_RT2(<v[2],<v[2]); SETTEXTUREWRAPMODE(pd3dDevice,D3DTADDRESS_CLAMP); SETBLENDMODE(pd3dDevice,D3DBLEND_INVDESTCOLOR,D3DBLEND_ONE); SETTC(pd3dDevice, polyboom[i].tc); ARX_DrawPrimitive_SoftClippZ( <v[0], <v[1], <v[2]); if(polyboom[i].nbvert&4) { EE_RT2(<v[3],<v[3]); ARX_DrawPrimitive_SoftClippZ( <v[1], <v[2], <v[3]); } SETTEXTUREWRAPMODE(pd3dDevice, D3DTADDRESS_WRAP); } break; } } } } SetZBias(pd3dDevice,0); GDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR,ulBKGColor); }
//----------------------------------------------------------------------------- // Updates all currently launched projectiles void ARX_MISSILES_Update() { long framediff, framediff3; Vec3f orgn, dest, hit; TextureContainer * tc = TC_fire; EERIEPOLY *tp = NULL; unsigned long tim = ARXTimeUL(); for (unsigned long i(0); i < MAX_MISSILES; i++) { if (missiles[i].type == MISSILE_NONE) continue; framediff = missiles[i].timecreation + missiles[i].tolive - tim; if (framediff < 0) { ARX_MISSILES_Kill(i); continue; } framediff3 = tim - missiles[i].timecreation; switch (missiles[i].type) { case MISSILE_NONE: break; case MISSILE_FIREBALL: { Vec3f pos; pos = missiles[i].startpos + missiles[i].velocity * framediff3; if (missiles[i].longinfo != -1) { DynLight[missiles[i].longinfo].pos = pos; } #ifdef BUILD_EDITOR if (USE_COLLISIONS) #endif { orgn = missiles[i].lastpos; dest = pos; EERIEPOLY *ep; EERIEPOLY *epp; Vec3f tro; tro.x = 70.0F; tro.y = 70.0F; tro.z = 70.0F; CURRENTINTER = NULL; ep = GetMinPoly(dest.x, dest.y, dest.z); epp = GetMaxPoly(dest.x, dest.y, dest.z); if(closerThan(player.pos, pos, 200.f)) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&pos); Add3DBoom(&pos); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if (ep && ep->center.y < dest.y) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if (epp && epp->center.y > dest.y) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if (EERIELaunchRay3(&orgn, &dest, &hit, tp, 1)) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&hit); Add3DBoom(&hit); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } if ( !EECheckInPoly(&dest) || EEIsUnderWater(&dest) ) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } long ici = IsCollidingAnyInter(dest.x, dest.y, dest.z, &tro); if (ici != -1 && ici != missiles[i].owner) { ARX_MISSILES_Kill(i); ARX_BOOMS_Add(&dest); Add3DBoom(&dest); DoSphericDamage(&dest, 180.0F, 200.0F, DAMAGE_AREAHALF, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL); break; } } long j = ARX_PARTICLES_GetFree(); if (j != -1 && !ARXPausedTimer) { ParticleCount++; particle[j].exist = true; particle[j].zdec = 0; particle[j].ov.x = pos.x; particle[j].ov.y = pos.y; particle[j].ov.z = pos.z; particle[j].move.x = missiles[i].velocity.x + 3.0f - 6.0F * rnd(); particle[j].move.y = missiles[i].velocity.y + 4.0F - 12.0F * rnd(); particle[j].move.z = missiles[i].velocity.z + 3.0F - 6.0F * rnd(); particle[j].timcreation = tim; particle[j].tolive = 500 + (unsigned long)(rnd() * 500.f); particle[j].tc = tc; particle[j].siz = 12.0F * (float)(missiles[i].tolive - framediff3) * ( 1.0f / 4000 ); particle[j].scale.x = 15.0F + rnd() * 5.0F; particle[j].scale.y = 15.0F + rnd() * 5.0F; particle[j].scale.z = 15.0F + rnd() * 5.0F; particle[j].special = FIRE_TO_SMOKE; } missiles[i].lastpos.x = pos.x; missiles[i].lastpos.y = pos.y; missiles[i].lastpos.z = pos.z; break; } } missiles[i].lastupdate = tim; } }