예제 #1
0
void activate_trap_shot_head_for_target90(struct Thing *traptng, struct Thing *creatng)
{
    struct TrapStats *trapstat;
    trapstat = &trap_stats[traptng->model];
    if (trapstat->field_1A <= 0)
    {
        ERRORLOG("Trap activation of bad shot kind %d",(int)trapstat->field_1A);
        return;
    }
    struct Thing *shotng;
    shotng = create_shot(&traptng->mappos, trapstat->field_1A, traptng->owner);
    if (!thing_is_invalid(shotng))
    {
        {
            MapCoord crpos_x, crpos_y;
            MapCoord trpos_x, trpos_y;
            trpos_x = traptng->mappos.x.val;
            trpos_y = traptng->mappos.y.val;
            crpos_x = creatng->mappos.x.val;
            crpos_y = creatng->mappos.y.val;
            if (abs(trpos_x - crpos_x) <= abs(trpos_y - crpos_y))
            {
                if (crpos_y >= trpos_y)
                    shotng->move_angle_xy = LbFPMath_PI;
                else
                    shotng->move_angle_xy = 0;
            } else
            {
                if (crpos_x >= trpos_x)
                    shotng->move_angle_xy = LbFPMath_PI/2;
                else
                    shotng->move_angle_xy = 3*LbFPMath_PI/2;
            }
        }
        shotng->move_angle_z = 0;
        struct ShotConfigStats *shotst;
        shotst = get_shot_model_stats(trapstat->field_1A);
        struct ComponentVector cvect;
        angles_to_vector(shotng->move_angle_xy, 0, shotst->old->speed, &cvect);
        shotng->veloc_push_add.x.val += cvect.x;
        shotng->veloc_push_add.y.val += cvect.y;
        shotng->veloc_push_add.z.val += cvect.z;
        shotng->state_flags |= TF1_PushAdd;
        shotng->byte_16 = trapstat->field_1B;
        if (shotst->old->firing_sound > 0) {
            thing_play_sample(traptng, shotst->old->firing_sound+UNSYNC_RANDOM(shotst->old->firing_sound_variants),
                NORMAL_PITCH, 0, 3, 0, 6, FULL_LOUDNESS);
        }
        if (shotst->old->shot_sound > 0) {
            thing_play_sample(shotng, shotst->old->shot_sound, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
        }
    }
}
예제 #2
0
void update_god_lightning_ball(struct Thing *thing)
{
    struct CreatureControl *cctrl;
    struct Thing *target;
    struct ShotConfigStats *shotst;
    long i;
//    _DK_update_god_lightning_ball(thing);
    if (thing->health <= 0)
    {
        lightning_modify_palette(thing);
        return;
    }
    i = (game.play_gameturn - thing->creation_turn) % 16;
    switch (i)
    {
    case 0:
        god_lightning_choose_next_creature(thing);
        break;
    case 1:
        target = thing_get(thing->shot.target_idx);
        if (thing_is_invalid(target))
            break;
        draw_lightning(&thing->mappos,&target->mappos, 96, 60);
        break;
    case 2:
        target = thing_get(thing->shot.target_idx);
        if (thing_is_invalid(target))
            break;
        shotst = get_shot_model_stats(24);
        apply_damage_to_thing_and_display_health(target, shotst->old->damage, shotst->damage_type, thing->owner);
        if (target->health < 0)
        {
            cctrl = creature_control_get_from_thing(target);
            cctrl->shot_model = ShM_GodLightBall;
            kill_creature(target, INVALID_THING, thing->owner, CrDed_DiedInBattle);
        }
        thing->shot.target_idx = 0;
        break;
    }
}
예제 #3
0
void external_activate_trap_shot_at_angle(struct Thing *thing, long a2)
{
    struct TrapStats *trapstat;
    trapstat = &trap_stats[thing->model];
    if (trapstat->field_1A <= 0) {
        ERRORLOG("Cannot activate trap with shot model %d",(int)trapstat->field_1A);
        return;
    }
    struct Thing *shotng;
    shotng = create_shot(&thing->mappos, trapstat->field_1A, thing->owner);
    if (thing_is_invalid(shotng)) {
        return;
    }
    struct ShotConfigStats *shotst;
    shotst = get_shot_model_stats(shotng->model);
    struct ComponentVector cvect;
    shotng->move_angle_xy = a2;
    shotng->move_angle_z = 0;
    angles_to_vector(shotng->move_angle_xy, 0, shotst->old->speed, &cvect);
    shotng->veloc_push_add.x.val += cvect.x;
    shotng->veloc_push_add.y.val += cvect.y;
    shotng->veloc_push_add.z.val += cvect.z;
    shotng->state_flags |= TF1_PushAdd;
    shotng->byte_16 = trapstat->field_1B;
    const struct ManfctrConfig *mconf;
    mconf = &game.traps_config[thing->model];
    thing->long_14 = game.play_gameturn + mconf->shots_delay;
    if (thing->byte_13 != 255)
    {
        if (thing->byte_13 > 0) {
            thing->byte_13--;
        }
        if (thing->byte_13 <= 0) {
            thing->health = -1;
        }
    }
}