global func BlueExplosionEffect(int level, int x, int y) { var glimmer = { Prototype = Particles_Glimmer(), R = PV_Random(100, 150), G = PV_Random(100, 150), B = PV_Random(200, 255) }; var fire = { Prototype = Particles_Fire(), R = PV_Random(100, 150), G = PV_Random(100, 150), B = PV_Random(200, 255), Size = PV_Random(level/2, level/3) }; var smoke = { Prototype = Particles_SmokeTrail(), R = PV_Linear(PV_Random(100, 150), 0), G = PV_Linear(PV_Random(100, 150), 0), B = PV_Linear(PV_Random(200, 255), 0), Size = PV_Random(level - 5, level + 5) }; // Blast particle. CreateParticle("SmokeDirty", x, y, PV_Random(-2, 2), PV_Random(-2, 2), PV_Random(20, 40), smoke, 10); CreateParticle("MagicFire", x, y, PV_Random(-20, 20), PV_Random(-20, 20), PV_Random(5, 10), fire, 20); if(!GBackLiquid(x,y)) CreateParticle("SphereSpark", x, y, PV_Random(-100, 100), PV_Random(-100, 100), PV_Random(5, 36 * 3), glimmer, level); if(GBackLiquid(x,y)) CastObjects(Fx_Bubble, level * 4 / 10, level, x, y); return; }
func FxParticlesStop(object target, proplist effect, int reason, bool temporary) { if(temporary) return; SetSolidMask(); var props = { Size = PV_Linear(4, 0), ForceY = GetGravity(), Stretch = PV_Speed(1000, 500), Rotation = PV_Direction(), OnCollision = PC_Die(), CollisionVertex = 0, R = 100, G = 100, B = 100, BlitMode = GFX_BLIT_Additive, }; CreateParticle("Smoke", 0, 0, PV_Random(-10 , 10), PV_Random(-10, 20), 50, props, 10); var smoke = { ForceX = PV_Wind(200 - 180), DampingX = 900, DampingY = 900, Alpha = PV_Linear(255, 0), R = 100, G = 100, B = 100, Size = PV_Linear(PV_Random(4, 10), PV_Random(20, 30)), Phase = PV_Random(0, 15) }; CreateParticle("Smoke", PV_Random(-5,5), PV_Random(-5,5), PV_Random(-15, 15), PV_Random(-15, 15), 30, smoke, 15); }
func FxLifeStop(object target, proplist effect, int reason, bool temporary) { if(temporary) return; var prt = { Size = 15, Alpha = PV_Linear(255, 0), Rotation = PV_Step(15, PV_Random(0, 360)), ForceY = GetGravity() }; CreateParticle("SawbladePrt", 0, 0, PV_Random(-35, 35), PV_Random(-35, 5), 40, prt, 6); var prt2 = { Size = PV_Linear(2, 0), ForceY = GetGravity(), Stretch = PV_Speed(1000, 500), Rotation = PV_Direction(), R = 255, G = PV_Linear(128,32), B = PV_Random(0, 128, 2), Alpha = PV_Random(255,0,3), BlitMode = GFX_BLIT_Additive, }; CreateParticle("Flash", 0, 0, PV_Random(-35, 35), PV_Random(-35, 5), 70, prt2, 20); Sound("sawblade_destroyed", false, 50); RemoveObject(); }
func Intro_PlaneHit() { // Plane hit ground! Continue sequence. Sound("Objects::Plane::PlaneCrash", true); SetR(-90); var particles = Particles_Smoke(true); particles.Size = PV_Linear(PV_Random(20, 60), PV_Random(50, 100)); CreateParticle("Smoke", PV_Random(-30,30), PV_Random(-30,30), PV_Random(-60, 60), PV_Random(-20,0), PV_Random(200, 500), particles, 20); particles.Size = PV_Linear(PV_Random(50, 80), PV_Random(100, 200)); CreateParticle("Smoke", PV_Random(-30,30), PV_Random(-30,30), PV_Random(-20, 20), PV_Random(-20,0), PV_Random(100, 200), particles, 20); for (var iplr=0,plr; iplr<GetPlayerCount(C4PT_User); ++iplr) { plr = GetPlayerByIndex(iplr, C4PT_User); var icrew=0,crew; while (crew=GetCrew(plr, icrew++)) { crew->Exit(0,-5, 0, Random(1)+1, Random(5)-6); crew->SetAction("Tumble"); } } SetMeshMaterial("CrashedAirplane"); this.MeshTransformation=Trans_Mul(Trans_Rotate(10,0,2,1), Airplane.MeshTransformation); this.Hit = this.intro_seq.plane_Hit; this.intro_seq.plane_crashed = true; this.intro_seq->ScheduleNext(50); return true; }
func CreateMuzzleFlash(int x, int y, int angle, int size) { // main muzzle flash CreateParticle("MuzzleFlash", x, y, 0, 0, 10, {Prototype = Particles_MuzzleFlash(), Size = size, Rotation = angle}); // and some additional little sparks var xdir = Sin(angle, size * 2); var ydir = -Cos(angle, size * 2); CreateParticle("StarFlash", x, y, PV_Random(xdir - size, xdir + size), PV_Random(ydir - size, ydir + size), PV_Random(5, 15), Particles_Glimmer(), size); }
protected func SmokeTrail() { Smoke(0, 0, 2); Smoke(0, -5, Random(3)); var i = Random(20); while (i--) { var c = (20+Random(41))/2; CreateParticle("PxSpark", Random(11)-5, Random(11)-5, 0, 0, c, RGBa(255, Random(100), c*4, 128)); } CreateParticle("PxSpark", 0, 0, 0, 0, 20, RGBa(255, 155, 0, 128)); //Bitte hier Schaden für Wipfe setzen //*99/100 = Grenzwertig stark, *98/100=Meistens 0 Schaden SetYDir(GetYDir(this, 1000)*982/1000, this, 1000); }
void Emitter::Update(double elapsed) { Array<int> deleteParticles; if (emitting) { int nParticles = (minrate + (maxrate - minrate) * (float)rand() / RAND_MAX) * elapsed; for (int i = 0; i < nParticles; i++) particles.Add(CreateParticle()); } for (int i = 0; i < particles.Size(); i++) { particles[i]->Update(elapsed); for (uint8 a = 0; a < affectors.Size(); a++) if (affectors[a]->IsCollide(particles[i])) affectors[a]->AffectParticle(particles[i]); if ( particles[i]->GetLifetime() <= 0 ) deleteParticles.Add(i); } for (int i = 0; i < deleteParticles.Size(); i++ ) { for (uint8 a = 0; a < affectors.Size(); a++) affectors[a]->DeleteAffectedParticle(particles[i]); particles.RemoveAt(i); } }
//----------------------------------------------------------------------------- // The animation events will create particles on the attachment points //----------------------------------------------------------------------------- void C_EnvParticleScript::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options ) { // Handle events to create + destroy particles switch( event ) { case CL_EVENT_SPRITEGROUP_CREATE: { char pAttachmentName[256]; char pSpriteName[256]; int nArgs = sscanf( options, "%255s %255s", pAttachmentName, pSpriteName ); if ( nArgs == 2 ) { CreateParticle( pAttachmentName, pSpriteName ); } } return; case CL_EVENT_SPRITEGROUP_DESTROY: { char pAttachmentName[256]; int nArgs = sscanf( options, "%255s", pAttachmentName ); if ( nArgs == 1 ) { DestroyAllParticles( pAttachmentName ); } } return; } // Fall back BaseClass::FireEvent( origin, angles, event, options ); }
void NNParticleSystem::Update( float dTime ) { NNObject::Update( dTime ); if ( mIsCreate == true ) { mTimer += dTime; if ( mTimer >= 1.f/mCreateParticlePerSecond) { for (int i=0; i< 2*dTime*mCreateParticlePerSecond/(mMinLifeTime+mMaxLifeTime); i++ ) { CreateParticle(); } mTimer = 0.f; } } for (auto& iter=mParticleList.begin(); iter!=mParticleList.end(); iter++ ) { (*iter)->Update( dTime ); if ( (*iter)->GetNowLifeTime() > (*iter)->GetLifeTime() ) { delete *iter; iter = mParticleList.erase( iter ); if ( iter == mParticleList.end() ) { break; } } } }
void dfParticleSystem::Update() { dfComponent::Init(); if(active) { timer += dfDeltaTime; if(timer > nextParticleTime && numParticles < maxActiveParticles) { CreateParticle(); nextParticleTime = minSecondsBetweenParticles + (dfRand() * (maxSecondsBetweenParticles - minSecondsBetweenParticles)); } } for(int i = 0; i < numParticles; i++) { if(particles[i].color.x == 1 && particles[i].color.y == 1 && particles[i].color.z == 1) int fut = 4; if(!particles[i].dead) { UpdateParticle(particles[i], i); } } }
func InitEffect() { Sound("Fire::Fireball", false, 100, nil, nil, nil, 200); Sound("Fire::FuseLoop", false, 20, nil, 1, nil, 200); SetLightRange(30, 70); SetLightColor(RGB(100, 100, 255)); var snow = { R = 200, G = 200, B = 255, Alpha = PV_Linear(255, 0), Size = PV_Random(0, 2), CollisionVertex = 0, OnCollision = PC_Stop(), ForceX = PV_Random(-5, 5, 10), ForceY = PV_Gravity(100), DampingX = 900, DampingY = 900 }; trail_particles = { R = PV_Random(200, 255), G = PV_Random(200, 255), B = 255, Prototype = Particles_FireTrail(), Size = PV_Linear(10, 0), BlitMode = nil, Rotation = PV_Random(0, 360), BlitMode = GFX_BLIT_Additive }; CreateParticle("StarFlash", 0, 0, PV_Random(-30, 30), PV_Random(-30, 30), 100, snow, 100); }
func Initialize() { var iTimeout,pWipf; SetGamma(RGB(15,15,15),RGB(118,118,118),RGB(215,215,215)); SetSkyParallax(0,15,17,0,0,0,0); //Handgemacht... ;) Meeresrauschen(170); Meeresrauschen(1100); Meeresrauschen(2060); Meeresrauschen(2900); Meeresrauschen(3800); Meeresrauschen(4800); Meeresrauschen(5700); Moewen(900); Moewen(2300); Moewen(3900); Moewen(5000); //Nebel platzieren for(var i;i<260;++i) CreateParticle("Fog",Random(LandscapeWidth()),Random(LandscapeHeight()*2/3),RandomX(3,9),0,RandomX(1000,1500)); //Wipfe platzieren while(pWipf=FindObject(WIPF,0,0,0,0,0,0,0,0,pWipf)) { iTimeout=0; while(Stuck(pWipf)||GetMaterial(GetX(pWipf),GetY(pWipf))!=Material("Tunnel")) { SetPosition(Random(LandscapeWidth()),RandomX(LandscapeHeight()*2/3,LandscapeHeight()),pWipf); if(iTimeout++ > 50000) { RemoveObject(pWipf); break; } } } ScriptGo(1); }
VParticleWallmark* VWallmarkManager::CreateWallmark( VTextureObject *pTexture, VIS_TransparencyType eBlending, const hkvVec3& vCenter, const hkvMat3 &alignment, VColorRef color, float fLifetime, float fFadeOutTime, bool bApplyDeferredLighting) { VISION_PROFILE_FUNCTION(PROFILING_WALLMARK_CREATION); VParticleWallmark* p = CreateParticle(pTexture,eBlending,bApplyDeferredLighting,vCenter,true); p->pos[0] = vCenter.x; p->pos[1] = vCenter.y; p->pos[2] = vCenter.z; p->color = color; hkvVec3 normal = alignment.getAxis(0); hkvVec3 right = alignment.getAxis(1); hkvVec3 up = alignment.getAxis(2); p->size = up.getLength()*2.f; normal.normalizeIfNotZero(); p->normal[0] = normal.x; p->normal[1] = normal.y; p->normal[2] = normal.z; p->distortion[0] = right.x*2.f; p->distortion[1] = right.y*2.f; p->distortion[2] = right.z*2.f; p->velocity[0] = fLifetime + fFadeOutTime; p->velocity[1] = fFadeOutTime; p->velocity[2] = (float)color.a; // original alpha (255 based) return p; }
func CheckForEnemies(Size) { for(var o in FindObjects(Find_Distance(Size), Find_Func("CanBeHit", this))) { if(o->GetOwner() == GetOwner() || GetEffect("BallHitCD", o)) continue; o->AddBallHitEffect(); o->Fling(0, -2); AddEffect("BallHitCD", o, 1, 15); var trailparticles = { Prototype = Particles_ElectroSpark2(), Size = PV_Linear(PV_Random(5,15),0), BlitMode = GFX_BLIT_Additive, Rotation = PV_Random(0,360), R = pR, G = pG, B = pB, }; CreateParticle("Lightning", o->GetX() - GetX(), o->GetY() - GetY(), 0, 0, 10, trailparticles, 5); WeaponDamage(o, SpellDamage); Sound("Ball::ball_hit", false, 50); } }
global func CreateBurnMark(int iX, int iY, int iLevel, int Count) { var boom; if(!ObjectCount(BOOM)) boom = CreateObject(BOOM,0,0,-1); else boom = FindObject(BOOM); var angle=Random(360/Count); //variablen für die überprüfung var type; for(var z; z < Count; z++) { angle += Max(1,360/Count); // Check: Sky or Solid/Liquid var x = iX+Cos(angle,iLevel); var y = iY+Sin(angle,iLevel); if((GetMaterialVal("Density","Material",GetMaterial(x,y)) != 0) || (GetMaterial(x,y) == -1)) continue; type = 1+Random(3); var size = BurnMarkCheck(angle,RandomX(iLevel/2,iLevel*2),iX,iY); var sin = Sin(angle,(size-iLevel)/2+iLevel+Random(3)); var cos = Cos(angle,(size-iLevel)/2+iLevel+Random(3)); CreateParticle("BurnMark",iX+cos,iY+sin,Cos(angle+RandomX(-5,5),50),Sin(angle+RandomX(-5,5),50),size*5+Random(25),RGBa(0,0,0,64),boom,1); } }
func FxDischargeStart(object target, proplist effect, int temporary) { for(var i = 0; i < 360; i+= 10) { var props = { Size = PV_Linear(4, 0), Stretch = 10000, Rotation = i + 180, R = pR, G = pG, B = pB, BlitMode = GFX_BLIT_Additive, }; var x = Sin(i, DischargeSize + RandomX(-2, 2)); var y = -Cos(i, DischargeSize + RandomX(-2, 2)); var rnd = RandomX(4,20); var xdir = Sin(i + 180, rnd); var ydir = -Cos(i + 180, rnd); CreateParticle("Flash", x, y, xdir, ydir, 25, props, 1); } }
func ChargeEffect(proplist params) { var a = params.new_angle; var x = Sin(a, 10, 10); var y = -Cos(a, 10, 10); CreateParticle("Shockwave2", x, y, PV_Random(-10,10), PV_Random(-15, 5), 20, chargeprt, 1); }
func FxPointingStart(object target, int index, int temp, int plr, object obj, string msg) { SetVisibility(VIS_Owner, target); CreateParticle("PSpark", 0, 0, 0, 0, 500, GetClrModulation(), this, true); EffectVar(0, target, index) = plr; EffectVar(1, target, index) = obj; EffectVar(2, target, index) = msg; return true; }
global func FxFireScorchingTimer(object target, proplist effect, int time) { if (time >= effect.duration) { RemoveObject(); return FX_Execute_Kill; } // particles var wind = BoundBy(GetWind(), -5, 5); CreateParticle("SmokeDirty", PV_Random(-5, 5), PV_Random(-5, 5), wind, -effect.strength/8, PV_Random(20, 40), Particles_SmokeTrail(), 2); return FX_OK; }
func ContactBottom() { inherited(...); var particle = Particles_Spark(); particle.R = 0xff; particle.G = 0xff; particle.B = PV_Random(150,200); CreateParticle("MagicSpark", 0,ReturnHeight()/2-1, PV_Random(-10,10), PV_Random(-10,10), PV_Random(10,50), particle, 15); Sound("Hits::LightMetalHit?", false, 20); }
func FxMoveToTimer(object target, proplist fx, int time) { if(!master) { KillBall(); return; } if(GetEffect("Blocked", this)) { ox=GetX(); oy=GetY(); return; } DrawParticleLine("Flash", 0, 0, ox-GetX(), oy-GetY(), 1, 0, 0, 15, movetrailparticles); if(time%7 == 0) { for(var i = 0; i < 360; i+=5) { CreateParticle("Flash", Sin(i, 3), -Cos(i, 5), 0, 0, 10, moveparticle2, 2); } } MoveToPos(fx.x, fx.y); ox=GetX(); oy=GetY(); var dst = Distance(GetX(), GetY(), fx.x, fx.y); if(dst < 5) { SetXDir(0); SetYDir(0); CheckForEnemies(AttackSize); Idle(); CreateParticle("StarSpark", 0, 0, 0, 0, 10, moveparticle, 5); return -1; } }
Particles::Particles(int _NumParticles, Vector2 pPosition, Vector2 pForce, float pLifespan, Texture pTexture) { numParticles = _NumParticles; for(int i = 0; i< numParticles; ++i) { CreateParticle(i, pPosition, pForce, pLifespan, pTexture); } }
func Launch(object clonk, int x, int y) { CreateParticle("Smoke", PV_Random(-5,5), PV_Random(-10,10), PV_Random(-5,5), 0, 30, Particles_Smoke(), 20); clonk.Visibility = VIS_Owner; clonk->SetClrModulation(RGBa(255,255,255,50)); clonk->Sound("vanish", false, 50); var fx = AddEffect("ShadowWalk", clonk, 20, 1, nil, GetID()); fx.dur = Dur; RemoveObject(); }
func ContactBottom() { inherited(...); var particle = Particles_Spark(); particle.R = 0xff; particle.G = 0xff; particle.B = PV_Random(150,200); CreateParticle("Dust", 0,10, PV_Random(-3,3), PV_Random(-3,3), PV_Random(5,8), particle, 15); // CreateParticle(,0, 10, RandomX(-3,3),RandomX(-3,3),RandomX(50,75),DoRGBaValue(-7183302,128,0)); Sound("Clonk::Action::Dig::Dig?"); }
global func FxSmokeTrailTimer(object pTarget, int iEffectNumber, int iEffectTime) { var iStrength = EffectVar(0, pTarget, iEffectNumber); var iAStr = EffectVar(1, pTarget, iEffectNumber); var iX = EffectVar(2, pTarget, iEffectNumber); var iY = EffectVar(3, pTarget, iEffectNumber); var iXDir = EffectVar(4, pTarget, iEffectNumber); var iYDir = EffectVar(5, pTarget, iEffectNumber); iAStr = Max(1,iAStr-iAStr/10+Random(2)); iAStr--; iYDir += GetGravity()*2/3; iYDir += GetWind(iX,iY)/20; var xdir = iXDir*iAStr/iStrength; var ydir = iYDir*iAStr/iStrength; // Neu: Random iX += RandomX(-3,3); iY += RandomX(-3,3); // zuerst zeichnen CreateParticle("Smoke3",iX,iY,RandomX(-2,2),RandomX(-2,2)-3,20+iAStr*8,RGBa(128,128,128,55+35*iAStr/iStrength)); CreateParticle("Blast",iX,iY,0,0,10+iAStr*8,RGBa(250,100+Random(100),100,160)); // dann nächste position berechnen iX += xdir/100; iY += ydir/100; if(GBackSemiSolid(iX,iY)) return -1; if(iAStr <= 1) return -1; EffectVar(1, pTarget, iEffectNumber) = iAStr; EffectVar(2, pTarget, iEffectNumber) = iX; EffectVar(3, pTarget, iEffectNumber) = iY; EffectVar(5, pTarget, iEffectNumber) = iYDir; }
void Explosion::InitParticles(cResourceHandle* textureParticle) { mTextureParticle = textureParticle; lfTimeUntilNextStep = 0; lfColorTime = 0; mfAngle = 0; mvParticleSysPos.LoadIdentity(); for(int i = 0; i < NUM_PARTICLES; i++) { CreateParticle(particles + i); } for(int i = 0; i < 5 / STEP_TIME; i++) { StepParticles(); } }
void ParticleSystem::Update( double delta ) { for( unsigned int i = 0; i < mParticles.size(); i++ ) { mParticles[i].Update( delta ); // if particle's life time has been depleated replace with a new particle if( mParticles[i].GetLifeTime() <= 0.0 ) { mParticles[i] = CreateParticle(); } } }
func JumpEffect(object clonk, dir) { var from; var to; if (dir == "Up") { from = 50; to = 130; } if (dir == "Left") { from = -30; to = 50; } if (dir == "Right") { from = 130; to = 210; } if (dir == "Down") { from = 230; to = 310; } clonk->Sound("time_hit", false, 30); for(var i = from; i < to; i+=5) { var r = 10; var x = clonk->GetX() + Cos(i, r); var y = clonk->GetY() + Sin(i, r); var angle = Angle(0,0,Cos(i, r),Sin(i, r)); var trailparticles = { Prototype = Particles_ElectroSpark2(), Size = PV_Linear(10,0), Rotation = angle, R = 255, G = 165, B = 50, OnCollision = PC_Bounce(), }; CreateParticle("Lightning", x, y, Cos(i, r), Sin(i, r), 10, trailparticles); } }
func JumpEffect(object clonk, dir) { var from; var to; if (dir == "Up") { from = 50; to = 130; } if (dir == "Left") { from = -30; to = 50; } if (dir == "Right") { from = 130; to = 210; } if (dir == "Down") { from = 230; to = 310; } Sound("hookjump", false, 30); for(var i = from; i < to; i+=5) { var r = 10; var x = clonk->GetX() + Cos(i, r); var y = clonk->GetY() + Sin(i, r); var angle = Angle(0,0,Cos(i, r),Sin(i, r)); var trailparticles = { //Prototype = Particles_ElectroSpark2(), Size = PV_Linear(10,0), Rotation = angle, R = 150, G = 150, B = 150, OnCollision = PC_Bounce(), }; CreateParticle("Shockwave", x, y, Cos(i, r + RandomX(-1,1)), Sin(i, r + RandomX(-1, 1)), 10, trailparticles); } }
// Timer during movement: Draw tail func Drawing() { var x=GetX(), y=GetY(); var vx=x-last_x, vy=y-last_y; last_x = x; last_y = y; var v=Distance(vx,vy); if (!v) return; var s1=v; var s2=4; var dx1=vx*s1/v, dy1=vy*s1/v, dx2=vy*s2/v, dy2=-vx*s2/v; x -= dx1; y -= dy1; DrawMaterialQuad("Gold-gold", x+dx1+dx2,y+dy1+dy2, x+dx1-dx2,y+dy1-dy2, x-dx1-dx2,y-dy1-dy2, x-dx1+dx2,y-dy1+dy2, true); CreateParticle("MagicSpark", 0,0, PV_Random(-vx*2-15,-vx*2+15), PV_Random(-vy*2-15,-vy*2+15), PV_Random(30,80), Particles_Colored(Particles_Spark(),GetPlayerColor(GetOwner())), 3); return true; }