- if (@ship){
- my $type = "kill";
- $type = "stun" if $ship[2] eq 'Emp';
- $type = "steal" if ($ship[2] eq 'Steal') or ($ship[2] eq 'Pod');
-
- $amount = int(($value*100/$ship[4])) if $amount eq 'value';
- $feud = '(FEUD: '.int($amount/0.75).') ' if defined $value;
- $value = prettyValue(($amount*$ship[4]/100));
- my $text = "$amount $feud $ship[0] ($ship[5]:$value) will $type:";
- my $st = $ND::DBH->prepare(q{
- SELECT name,"class","type",armor,metal+crystal+eonium,init,target,eres,race
- FROM ship_stats WHERE "class" = ?
- });
- $st->execute($ship[1]);
- while (my @target = $st->fetchrow()){
- my $dead = $ship[2] eq 'Emp' ? int($amount*$ship[7]*(100-$target[7])/100) : int($amount*$ship[3]/$target[3]);
- $value = prettyValue($dead*$target[4]/100);
- if (($target[6] eq $ship[6]) and ($target[5] <= $ship[5])){
- $target[5] = "${ND::C}04$target[5]$ND::C";
- }elsif(($target[6] eq $ship[6]) and ($target[5] > $ship[5])){
- $target[5] = "${ND::C}12$target[5]$ND::C";
+ if ($s){
+ if (defined $value){
+ $amount = int(($value*100/$s->{cost}));
+ $feud = '(FEUD: '.prettyValue(int($amount/0.85)).') ';
+ }
+ $value = prettyValue(($amount*$s->{cost}/100));
+ my $name = shipColor($s->{name},$s->{type});
+ my $text = prettyValue($amount)." $name ($s->{init}:$value) :";
+ for my $tn ('t1','t2','t3'){
+ next if ($eff && not defined $s->{$tn});
+ $text .= " $ND::B${ND::C}03" . ($eff ? $s->{$tn} : $tn) . "$ND::O: ";
+ my $st = q{
+ SELECT name,"class","type",armor
+ ,metal+crystal+eonium AS cost
+ ,init,t1,t2,t3,eres,race
+ ,damage,guns
+ FROM ship_stats
+ };
+ if ($eff){
+ $st = $ND::DBH->prepare($st . q{
+ WHERE "class" = $1
+ AND ("class" ILIKE $2 OR race ILIKE $2)
+ });
+ $st->execute($s->{$tn},$target);
+ }else{
+ $st = $ND::DBH->prepare($st . qq{
+ WHERE $tn = \$1
+ AND ("class" ILIKE \$2 OR race ILIKE \$2)
+ });
+ $st->execute($s->{class},$target);
+ }
+ while (my $t = $st->fetchrow_hashref()){
+ my $number = calcEff($s,$t,$amount,$eff);
+ if ($eff){
+ $number *= 0.60 if $tn eq 't2';
+ $number *= 0.30 if $tn eq 't3';
+ }else{
+ $number /= 0.60 if $tn eq 't2';
+ $number /= 0.30 if $tn eq 't3';
+ }
+ $number = int($number);
+ $value = prettyValue($number*$t->{cost}/100);
+ my $name = shipColor($t->{name},$t->{type});
+ $text .= " $ND::B$number$ND::O $name ($t->{init}:$value),";