Game-Xomb

 view release on metacpan or  search on metacpan

lib/Game/Xomb.pm  view on Meta::CPAN

          display_hitpoints(), display_cellobjs(), display_shieldup();
    }
}

sub score {
    my ($won) = @_;
    my $score = loot_value() + ($won ? 10000 : 0) + 10 * int exp $Level_Max;
    return "Score: $score in $Turn_Count turns (v$VERSION:$Seed)";
}

sub update_gameover {
    state $count = 0;
    raycast_fov(1);
    tcflush(STDIN_FILENO, TCIFLUSH);
    my $key = $RKFN->(\%Key_Commands);
    if ($count == 4) {
        has_lost();
    } elsif ($count >= 2) {
        print AT_MSG_ROW, CLEAR_RIGHT, '-- press Esc to continue --';
        has_lost() if $key eq "\033" or $key eq 'q';
    } elsif ($count == 1) {
        log_message('Communication lost with remote unit.');
    }
    $count++;
    return MOVE_OKAY, DEFAULT_COST;
}

sub update_fungi {
    my ($self) = @_;
    my ($mcol, $mrow) = $self->[LMC][WHERE]->@[ PCOL, PROW ];
    my ($tcol, $trow) = $Animates[HERO][LMC][WHERE]->@[ PCOL, PROW ];
    my $weap = $self->[STASH][WEAPON];

    my ($hits, $cost) = does_hit(distance($mcol, $mrow, $tcol, $trow), $weap);
    return MOVE_OKAY, $cost if $hits == -1;

    my (@burned, @path);
    $hits = 0;

lib/Game/Xomb.pm  view on Meta::CPAN

        my $max = 3;
        $max += 2 if onein(40);
        $max += 3 if onein(250);
        # mostly it just looks impressive
        plasma_annihilator($self, \%seen, \@spread, 1, $max);
    }

    return MOVE_OKAY, $cost;
}

sub update_ghast {
    my ($self) = @_;
    my ($mcol, $mrow) = $self->[LMC][WHERE]->@[ PCOL, PROW ];
    my ($tcol, $trow) = $Animates[HERO][LMC][WHERE]->@[ PCOL, PROW ];
    my $weap = $self->[STASH][WEAPON];

    my ($hits, $cost) = does_hit(distance($mcol, $mrow, $tcol, $trow), $weap);
    return MOVE_OKAY, $cost if $hits == -1;

    # but a gatling gun is often trigger happy ...
    if ($hits == 0) {

lib/Game/Xomb.pm  view on Meta::CPAN

        my $buddy = $LMap[$trow][$tcol][ANIMAL];
        apply_damage($buddy, 'attackby', $self) if defined $buddy;
    } else {
        apply_damage($Animates[HERO], 'attackby', $self);
        $Violent_Sleep_Of_Reason = 1;
    }

    return MOVE_OKAY, $cost;
}

sub update_mimic {
    my ($self) = @_;
    my ($mcol, $mrow) = $self->[LMC][WHERE]->@[ PCOL, PROW ];
    my ($tcol, $trow) = $Animates[HERO][LMC][WHERE]->@[ PCOL, PROW ];
    my $weap = $self->[STASH][WEAPON];

    my ($hits, $cost) = does_hit(distance($mcol, $mrow, $tcol, $trow), $weap);
    return MOVE_OKAY, $cost if $hits == -1;

    my @nearby;
    if ($hits == 0) {

lib/Game/Xomb.pm  view on Meta::CPAN

    } else {
        log_message('A mortar shell strikes you!');
        apply_damage($Animates[HERO], 'attackby', $self);
    }

    $Violent_Sleep_Of_Reason = 1;

    return MOVE_OKAY, $cost;
}

sub update_player {
    my ($self) = @_;
    my ($cost, $ret);

    # pre-move tasks
    sb_update_energy();
    if ($Violent_Sleep_Of_Reason == 1) {
        sleep($Draw_Delay);
        $Violent_Sleep_Of_Reason = 0;
    }
    raycast_fov(1);

lib/Game/Xomb.pm  view on Meta::CPAN

            print display_shieldup();
        }
    }

    $Energy_Spent += $cost;
    $Turn_Count++;
    return $ret, $cost;
}

# when player is in range try to shoot them
sub update_troll {
    my ($self) = @_;
    my ($mcol, $mrow) = $self->[LMC][WHERE]->@[ PCOL, PROW ];
    my ($tcol, $trow) = $Animates[HERO][LMC][WHERE]->@[ PCOL, PROW ];
    my $weap = $self->[STASH][WEAPON];

    my ($hits, $cost) = does_hit(distance($mcol, $mrow, $tcol, $trow), $weap);
    return MOVE_OKAY, $cost if $hits == -1;

    my @path;
    my $property_damage = 0;

lib/Game/Xomb.pm  view on Meta::CPAN

            apply_damage($Animates[HERO], 'attackby', $self);
            $Violent_Sleep_Of_Reason = 1;
        }
    }

    return MOVE_OKAY, $cost;
}

# like shooter but can only fire across totally open ground. advanced
# targetting arrays prevent friendly fire and property damage
sub update_stalker {
    my ($self) = @_;
    my ($mcol, $mrow) = $self->[LMC][WHERE]->@[ PCOL, PROW ];
    my ($tcol, $trow) = $Animates[HERO][LMC][WHERE]->@[ PCOL, PROW ];
    my $weap = $self->[STASH][WEAPON];

    my ($hits, $cost) = does_hit(distance($mcol, $mrow, $tcol, $trow), $weap);
    return MOVE_OKAY, $cost if $hits < 1;

    my @path;
    linecb(



( run in 0.541 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )