Exemple #1
0
void OrbitingEmitter::Update(uint32 diff)
{
    if(_deletable)
        return;

    uint32 workdiff;
    for(workdiff = diff + _overlaptime; workdiff > _density; workdiff -= _density)
    {
        float xoffs = sin(_lastspawntime / _speed) * _radius;
        float yoffs = cos(_lastspawntime / _speed) * _radius;
        float o = 0; // TODO: formula here!
        
        Creature *npc = _parent->SummonCreatureCustom(_entry,sx + xoffs,sy + yoffs,sz,o,_summontype,_staytime);
        if(npc)
        {
            npc->FallGround();
        }
        _objects++;

        _lastspawntime += _density;
    }
    _overlaptime = workdiff;

    if(_createtime + _staytime < _lastspawntime)
        _deletable = true;
}
Exemple #2
0
void BeamEmitter::Update(uint32 diff)
{
    if(_deletable)
        return;

    uint32 newtime = WorldTimer::tickTime();
    float _radfact = _maxradius / _speed; // speed dependant radius factor
    float radius = _radfact * ((newtime - _createtime) / 1000.0f); // current radius
    if(_lastspawntime + _staytime < newtime)
    {
        _deletable = true;
        return;
    }

    if(_done)
        return;

    // doesnt really matter here that they are spawned backwards.. since it happens in the same time nobody will see
    uint32 workdiff;
    for(workdiff = diff + _overlaptime; workdiff >= _speedfactor && _objects <= _density; workdiff -= _speedfactor)
    {
        radius = _radfact * ((_lastspawntime - _createtime + workdiff) / 1000.0f);
        if(radius > _maxradius)
            continue;
        float x = (basex * radius) + sx;
        float y = (basey * radius) + sy;

        float z = sz;
        _lastspawntime += _speedfactor;
        Creature *npc = _parent->SummonCreatureCustom(_entry,x,y,z,0,_summontype,_staytime);
        if(npc)
        {
            npc->FallGround();
        }
        _objects++;
    }
    _overlaptime = workdiff;

    for(std::list<Emitter*>::iterator it = children.begin(); it != children.end(); it++)
    {
        (*it)->Update(diff);
    }

    if(/*radius > _maxradius ||*/ _objects > _density)
        _done = true;
}
Exemple #3
0
void RandomEmitter::Update(uint32 diff)
{
    uint32 newtime = WorldTimer::tickTime();
    
    if(_lastspawntime + _staytime < newtime)
    {
        _deletable = true;
        return;
    }
    if(_objects > _density)
    {
        _done = true;
        return;
    }

    uint32 workdiff;
    for(workdiff = diff + _overlaptime; workdiff > _speedfactor && _objects <= _density; workdiff -= _speedfactor)
    {
        float x = (sin(float((rand()%100000) / 100.0f)) * _maxradius) + sx;
        float y = (cos(float((rand()%100000) / 100.0f)) * _maxradius) + sy;

        float z = sz;
        _lastspawntime += _speedfactor;

        Creature *npc = _parent->SummonCreatureCustom(_entry,x,y,z,0,_summontype,_staytime);
        if(npc)
        {
            npc->FallGround();
        }
        _objects++;
    }
    _overlaptime = workdiff;

    for(std::list<Emitter*>::iterator it = children.begin(); it != children.end(); it++)
    {
        (*it)->Update(diff);
    }
}