Esempio n. 1
0
TbBool playing_creature_sound(struct Thing *thing, long snd_idx)
{
    struct CreatureSound *crsound;
    long i;
    crsound = get_creature_sound(thing, snd_idx);
    for (i=0; i < crsound->count; i++)
    {
        if (S3DEmitterIsPlayingSample(thing->snd_emitter_id, crsound->index+i, 0))
          return true;
    }
    return false;
}
Esempio n. 2
0
void stop_creature_sound(struct Thing *thing, long snd_idx)
{
    struct CreatureSound *crsound;
    int i;
    crsound = get_creature_sound(thing, snd_idx);
    if (crsound->index <= 0) {
        SYNCDBG(19,"No sample %d for creature %d",snd_idx,thing->model);
        return;
    }

    for (i = 0; i < crsound->count; i++)
    {
        if (S3DEmitterIsPlayingSample(thing->snd_emitter_id, crsound->index+i, 0))
        {
            S3DDeleteSampleFromEmitter(thing->snd_emitter_id, crsound->index+i, 0);
        }
    }
}
Esempio n. 3
0
void play_creature_sound_and_create_sound_thing(struct Thing *thing, long snd_idx, long a2)
{
    struct CreatureSound *crsound;
    struct Thing *efftng;
    long i;
    if (playing_creature_sound(thing, snd_idx)) {
        return;
    }
    crsound = get_creature_sound(thing, snd_idx);
    if (crsound->index <= 0) {
        SYNCDBG(14,"No sample %d for creature %d",snd_idx,thing->model);
        return;
    }
    i = UNSYNC_RANDOM(crsound->count);
    efftng = create_effect(&thing->mappos, TngEff_Unknown49, thing->owner);
    if (!thing_is_invalid(efftng)) {
        thing_play_sample(efftng, crsound->index+i, NORMAL_PITCH, 0, 3, 0, a2, FULL_LOUDNESS);
    }
}
Esempio n. 4
0
void play_creature_sound(struct Thing *thing, long snd_idx, long a3, long a4)
{
    struct CreatureSound *crsound;
    long i;
    SYNCDBG(8,"Starting");
    if (playing_creature_sound(thing, snd_idx)) {
      return;
    }
    crsound = get_creature_sound(thing, snd_idx);
    if (crsound->index <= 0) {
        SYNCDBG(19,"No sample %d for creature %d",snd_idx,thing->model);
        return;
    }
    i = UNSYNC_RANDOM(crsound->count);
    SYNCDBG(18,"Playing sample %d (index %d) for creature %d",snd_idx,crsound->index+i,thing->model);
    if ( a4 ) {
        thing_play_sample(thing, crsound->index+i, NORMAL_PITCH, 0, 3, 8, a3, FULL_LOUDNESS);
    } else {
        thing_play_sample(thing, crsound->index+i, NORMAL_PITCH, 0, 3, 0, a3, FULL_LOUDNESS);
    }
}
Esempio n. 5
0
void play_thing_walking(struct Thing *thing)
{
    struct PlayerInfo *myplyr;
    myplyr = get_my_player();
    struct Camera *cam;
    cam = myplyr->acamera;
    { // Skip the thing if its distance to camera is too big
        MapSubtlDelta dist_x, dist_y;
        dist_x = coord_subtile(abs(cam->mappos.x.val - (MapCoordDelta)thing->mappos.x.val));
        dist_y = coord_subtile(abs(cam->mappos.y.val - (MapCoordDelta)thing->mappos.y.val));
        if (dist_x <= dist_y)
          dist_x = dist_y;
        if (dist_x >= 10) {
            return;
        }
    }
    if ((get_creature_model_flags(thing) & CMF_IsSpectator) != 0) {
        // Spectators don't do sounds
        return;
    }
    long loudness;
    loudness = (myplyr->view_mode == PVM_CreatureView) ? (FULL_LOUDNESS) : (FULL_LOUDNESS/5);
    // Flying diptera has a buzzing noise sound
    if ((get_creature_model_flags(thing) & CMF_IsDiptera) && ((thing->movement_flags & TMvF_Flying) != 0) && (thing->field_60 < (int)thing->mappos.z.val))
    {
        if ( !S3DEmitterIsPlayingSample(thing->snd_emitter_id, 25, 0) ) {
            thing_play_sample(thing, 25, 100, -1, 2, 0, 2, loudness);
        }
    }
    else
    {
        if ( S3DEmitterIsPlayingSample(thing->snd_emitter_id, 25, 0) ) {
            S3DDeleteSampleFromEmitter(thing->snd_emitter_id, 25, 0);
        }
        struct CreatureControl *cctrl;
        cctrl = creature_control_get_from_thing(thing);
        if ((cctrl->field_9) && get_foot_creature_has_down(thing))
        {
            int smpl_variant;
            smpl_variant = foot_down_sound_sample_variant[4 * ((cctrl->mood_flags & 0x1C) >> 2) + (cctrl->field_67 & 0x1F)];
            long smpl_idx;
            if ((thing->movement_flags & TMvF_Unknown80) != 0) {
                smpl_idx = 181 + smpl_variant;
            } else {
                struct CreatureSound *crsound;
                crsound = get_creature_sound(thing, CrSnd_Foot);
                smpl_idx = crsound->index + smpl_variant;
            }
            cctrl->field_67 = (cctrl->field_67 ^ (cctrl->field_67 ^ (cctrl->field_67 + 1))) & 0x1F;
            if ((cctrl->field_67 & 0x1F) >= 4)
            {
                cctrl->mood_flags &= ~0x1C;
                cctrl->mood_flags |=  (UNSYNC_RANDOM(4) << 2);
                cctrl->field_67 &= ~0x1F;
            }

            int v15;
            unsigned short smpl_delay;
            //TODO CONFIG creature model dependency; remove, add config file option for this
            v15 = thing->model;
            if ( v15 == 19 || v15 == 24 ) {//FLY or BUG
                smpl_delay = 400;
            } else
            if ( v15 == 27 ) {//HELL_HOUND
                smpl_delay = 300;
            } else {
                smpl_delay = 100;
            }
            thing_play_sample(thing, smpl_idx, smpl_delay, 0, 3, 3, 1, loudness);
            if ((thing->movement_flags & TMvF_IsOnWater) != 0) {
                thing_play_sample(thing, 21+SOUND_RANDOM(4), 90+SOUND_RANDOM(20), 0, 3, 3, 1, FULL_LOUDNESS);
            }
        }
    }