Exemple #1
0
function Do_Farm_Work_Plots($plots, $action = "harvest")
{
    global $vCnt63000;
    list(, , , , , , , , , , $fuel) = explode(';', fBGetDataStore('playerinfo'));
    if (@strlen($vCnt63000) == 0) {
        $vCnt63000 = 63000;
    }
    $px_Setopts = LoadSavedSettings();
    if (!@$px_Setopts['bot_speed'] || @$px_Setopts['bot_speed'] < 1) {
        $px_Setopts['bot_speed'] = 1;
    }
    if (@$px_Setopts['bot_speed'] > PARSER_MAX_SPEED) {
        $px_Setopts['bot_speed'] = PARSER_MAX_SPEED;
    }
    $vMaxEquip = 16;
    if (@(!$fuel) || @$fuel < 0) {
        $fuel = 0;
    }
    if ($fuel == 0 && $action == 'tractor') {
        return;
    }
    if ($fuel == 0) {
        Do_Farm_Work($plots, $action);
        return;
    }
    while (count($plots) > 0) {
        $amf = new AMFObject("");
        $amf->_bodys[0] = new MessageBody();
        $amf->_bodys[0]->targetURI = 'FlashService.dispatchBatch';
        $amf->_bodys[0]->responseURI = '/1/onStatus';
        $amf->_bodys[0]->responseIndex = '/1';
        $amf->_bodys[0]->_value[0] = GetAMFHeaders();
        $amf->_bodys[0]->_value[2] = 0;
        $vCntSpeed = 0;
        while (count($plots) > 0 && $vCntSpeed < $px_Setopts['bot_speed'] && $fuel > 0) {
            $amf->_bodys[0]->_value[1][$vCntSpeed]['sequence'] = GetSequense();
            $amf->_bodys[0]->_value[1][$vCntSpeed]['functionName'] = "EquipmentWorldService.onUseEquipment";
            if ($action == 'tractor') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][0] = 'plow';
            } else {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][0] = $action;
            }
            $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['id'] = -1;
            if ($action == 'harvest') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'V1:32';
            }
            # fully expanded harvester
            if ($action == 'tractor' || $action == 'plow') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'T1:32';
            }
            # fully expanded tractor
            if ($action == 'place') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'S1:32';
            }
            # fully expanded seeder
            $vCntEquip = 0;
            $vSeed = '';
            $vLastSeed = '';
            while (count($plots) > 0 && $vCntEquip < $vMaxEquip && $fuel > 0) {
                $vPlot = array_pop($plots);
                if ($action == 'place') {
                    $vSeed = $vPlot['itemName'];
                    if ($vLastSeed == '') {
                        $vLastSeed = $vSeed;
                    } elseif ($vLastSeed != $vSeed) {
                        array_push($plots, $vPlot);
                        break;
                    }
                }
                if (@(!$plotsstring)) {
                    $plotsstring = $vPlot['itemName'] . " " . GetPlotName($vPlot);
                } else {
                    $plotsstring = $plotsstring . ", " . $vPlot['itemName'] . " " . GetPlotName($vPlot);
                }
                if (@(!$OKstring)) {
                    $OKstring = $action . " " . $vPlot['itemName'] . " on plot " . GetPlotName($vPlot);
                } else {
                    $OKstring = $OKstring . "\r\n" . $action . " " . $vPlot['itemName'] . " on plot " . GetPlotName($vPlot);
                }
                $fuel--;
                if ($action == 'tractor') {
                    $vCnt63000++;
                    $vPlot['id'] = $vCnt63000;
                    $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][2][$vCntEquip] = $vPlot;
                } else {
                    $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][2][$vCntEquip]['id'] = $vPlot['id'];
                }
                $vCntEquip++;
            }
            if ($action == 'tractor' || $action == 'harvest' || $action == 'plow') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][3] = 'plowed';
            }
            if ($action == 'place') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][3] = $vSeed;
            }
            $vCntSpeed++;
        }
        AddLog2($action . " " . $plotsstring);
        $res = RequestAMF($amf);
        AddLog2("result {$res}");
        unset($amf->_bodys[0]->_value[1]);
        if ($res === 'OK') {
            AddLog($OKstring);
            $need_reload = true;
        } else {
            if ($res) {
                AddLog("Error: {$res} on " . $OKstring);
                if (intval($res) == 29 || strpos($res, 'BAD AMF') !== false) {
                    // Server sequence was reset
                    DoInit();
                }
            }
        }
        unset($plotsstring, $OKstring);
    }
    $px_Setopts = LoadSavedSettings();
    if ($action == 'plow' || $action == 'tractor') {
        $px_Setopts['fuel_plow'] = $fuel;
    }
    if ($action == 'place') {
        $px_Setopts['fuel_place'] = $fuel;
    }
    if ($action == 'harvest') {
        $px_Setopts['fuel_harvest'] = $fuel;
    }
    SaveSettings($px_Setopts);
}
function AM_farmGold_moveAnimalsToBuilding($building, $getLeft, $getFarm, $getIDs, $getNames, $getPositions)
{
    global $TB_settings;
    global $AM_settings;
    if ($getLeft == 0) {
        return;
    }
    $i = 0;
    $farm = array();
    $farm = $getFarm;
    $left = $getLeft;
    $index = 0;
    while ($left > 0) {
        if (empty($getNames[$index])) {
            continue;
        }
        $amf = CreateMultAMFRequest($amf, $i, 'store', 'WorldService.performAction');
        $amf->_bodys[0]->_value[1][$i]['params'][1]['id'] = $building['id'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['contents'][0]['num'] = $index;
        //$amf->_bodys[0]->_value[1][$i]['params'][1]['contents'][0]['item']	= '';
        $amf->_bodys[0]->_value[1][$i]['params'][1]['itemName'] = $building['itemName'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['direction'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['buildTime'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['className'] = $building['className'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['position']['x'] = $building['position']['x'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['position']['y'] = $building['position']['y'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['position']['z'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['deleted'] = false;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['state'] = $building['state'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['tempId'] = 'NaN';
        //$amf->_bodys[0]->_value[1][$i]['params'][1]['plantTime']          		= $time;
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['resource'] = $getIDs[$index];
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['cameFromLocation'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['storedItemCode'] = TB_GetCodeByName($getNames[$index]);
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['storedClassName'] = 'animal';
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['isGift'] = false;
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['storedItemName'] = $getNames[$index];
        $farm[$getPositions[$index]['x']][$getPositions[$index]['y']] = true;
        $farm[$getPositions[$index]['x'] + 1][$getPositions[$index]['y']] = true;
        $farm[$getPositions[$index]['x']][$getPositions[$index]['y'] + 1] = true;
        $farm[$getPositions[$index]['x'] + 1][$getPositions[$index]['y'] + 1] = true;
        $i++;
        $left--;
        $index++;
        if ($i >= $TB_settings['TB_speedAction']) {
            $res = RequestAMF($amf);
            if ($res == 'OK') {
                AddLog2('-> ' . $res . ' ' . $left . ' left');
                $i = 0;
            } else {
                AddLog2("ERROR - {$res}");
                return false;
            }
        }
    }
    if ($i > 0) {
        $res = RequestAMF($amf);
        if ($res == 'OK') {
            AddLog2('-> ' . $res);
            return $farm;
        } else {
            AddLog2("ERROR - {$res}");
            return false;
        }
    } else {
        return $farm;
    }
}
Exemple #3
0
function Sections_WalkRotate_Speed()
{
    global $vAnnounceWalkRotateArray;
    $px_Setopts = LoadSavedSettings();
    if (!@$px_Setopts['bot_speed'] || @$px_Setopts['bot_speed'] > 50 || @$px_Setopts['bot_speed'] < 1) {
        $vSpeed = 1;
    } else {
        $vSpeed = $px_Setopts['bot_speed'];
    }
    $vCntMoves = count($vAnnounceWalkRotateArray);
    $vRunMainLoop = ceil($vCntMoves / $vSpeed);
    for ($vI = 0; $vI < $vRunMainLoop; $vI++) {
        $need_reload = false;
        $res = 0;
        $amf = new AMFObject("");
        $amf->_bodys[0] = new MessageBody();
        $amf->_bodys[0]->targetURI = 'FlashService.dispatchBatch';
        $amf->_bodys[0]->responseURI = '/1/onStatus';
        $amf->_bodys[0]->responseIndex = '/1';
        $amf->_bodys[0]->_value[0] = GetAMFHeaders();
        unset($vMSG);
        $vNumAction = 0;
        for ($vJ = $vI * $vSpeed; $vJ < $vI * $vSpeed + $vSpeed && $vJ < $vCntMoves; $vJ++) {
            $o = $vAnnounceWalkRotateArray[$vJ]['o'];
            $vWalk = $vAnnounceWalkRotateArray[$vJ]['vWalk'];
            $vRotate = $vAnnounceWalkRotateArray[$vJ]['vRotate'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'] = array();
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][0] = 'move';
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][1] = $o;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2] = array();
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['canWander'] = $vWalk;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['state'] = $o['state'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['direction'] = $vRotate;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['x'] = $o['position']['x'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['y'] = $o['position']['y'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['z'] = $o['position']['z'];
            $amf->_bodys[0]->_value[1][$vNumAction]['sequence'] = GetSequense();
            $amf->_bodys[0]->_value[1][$vNumAction]['functionName'] = 'WorldService.performAction';
            $vNumAction++;
            $vMSG[] = $o['position']['x'] . '/' . $o['position']['y'];
        }
        $amf->_bodys[0]->_value[2] = 0;
        AddLog2("Sections: Speed_WalkRotate on " . implode(' ', $vMSG));
        $res = RequestAMF($amf);
        AddLog2("Sections: result {$res}");
        if ($res === 'OK') {
            $need_reload = true;
        }
    }
    return $need_reload;
}
Exemple #4
0
function GB_DoColAdd($ItemName, $ItemCode, $Amount_to_add)
{
    while ($Amount_to_add > 0) {
        $res = 0;
        //AddLog2("Accessing the giftbox for item " . $ItemName);
        $amf = CreateRequestAMF('', 'CollectionsService.addGiftItemToCollection');
        $amf->_bodys[0]->_value[1][0]['params'][0] = $ItemCode;
        $amf->_bodys[0]->_value[1][1]['params'][0][0][0]['data'][0] = "Storage";
        $amf->_bodys[0]->_value[1][1]['params'][0][0][0]['data'][1] = "accessing_goods";
        $amf->_bodys[0]->_value[1][1]['params'][0][0][0]['data'][2] = "general_HUD_icon";
        $amf->_bodys[0]->_value[1][1]['params'][0][0][0]['data'][3] = "";
        $amf->_bodys[0]->_value[1][1]['params'][0][0][0]['data'][4] = "";
        $amf->_bodys[0]->_value[1][1]['params'][0][0][0]['data'][5] = "";
        $amf->_bodys[0]->_value[1][1]['params'][0][0][0]['data'][6] = "1";
        $amf->_bodys[0]->_value[1][2]['params'][0] = $ItemName;
        $res = RequestAMF($amf);
        $Amount_to_add--;
        if ($res == "OK") {
            AddLog2($ItemName . " Added to Collection " . $Amount_to_add . " to Go");
        } else {
            AddLog2("GiftBox: Error Adding " . $ItemName . " to Collection - " . $res);
            return;
        }
    }
    return $res;
}
 private function _fvFarmWork($items, $action = 'harvest')
 {
     $count = count($items);
     if ($count > 0) {
         $i = 0;
         $amf = '';
         foreach ($items as $plot) {
             if ($action == 'harvest') {
                 $pUnit = Units_GetUnitByName($plot['itemName'], true);
                 $Seed = $plot['itemName'];
                 $LastSeed = $Seed;
                 if ($this->currbushel != $pUnit['bushelItemCode']) {
                     $this->_fvDoBushels($pUnit['bushelItemCode']);
                 }
             }
             $amf = CreateMultAMFRequest($amf, $i, $action, 'WorldService.performAction');
             $amf->_bodys[0]->_value[1][$i]['params'][1] = $plot;
             $amf->_bodys[0]->_value[1][$i]['params'][2] = array();
             $amf->_bodys[0]->_value[1][$i]['params'][2][0]['energyCost'] = 0;
             $prealname = trim(Units_GetRealnameByName($plot['itemName']));
             if (@(!$plotsstring)) {
                 $plotsstring = $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y'];
             } else {
                 $plotsstring = $plotsstring . ", " . $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y'];
             }
             if (@(!$OKstring)) {
                 $OKstring = ucfirst($action) . " " . $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y'];
             } else {
                 $OKstring = $OKstring . "\r\n" . ucfirst($action) . " " . $plot['itemName'] . " " . $plot['position']['x'] . '-' . $plot['position']['y'];
             }
             $i++;
             if ($i == $this->botspeed || $i >= $count) {
                 $count -= $i;
                 $i = 0;
                 AddLog2('fvFarmer: ' . ucfirst($action) . " " . $plotsstring);
                 $res = RequestAMF($amf, true);
                 $amf2 = $res['amf2'];
                 $amf = '';
                 if ($res['res'] === 'OK') {
                     AddLog2("fvFarmer Result: " . $res['res']);
                     foreach ($amf2->_bodys[0]->_value['data'][0]['data'] as $result) {
                         if (isset($result['data']['foundBushel'])) {
                             $crop = $result['data']['foundBushel']['bushelCode'];
                             $cUnit = Units_GetUnitByCode($crop, true);
                             AddLog2('fvFarmer: Found Bushel ' . $cUnit['realname']);
                             if ($result['data']['foundBushel']['bushelAddedToStall'] == 1) {
                                 $this->fmBushels[] = $crop;
                             }
                         }
                     }
                 } else {
                     if ($res['res']) {
                         AddLog("fvFarmer Error: " . $res['res'] . " on {$OKstring}");
                         if (intval($res['res']) == 29 || intval($res['res']) == 28) {
                             DoInit();
                         }
                     }
                 }
                 unset($plotsstring, $OKstring);
             }
         }
     }
 }
Exemple #6
0
function Grifter_TurboSell($name, $x)
{
    Addlog2('selling ' . $name . ' : ' . $x . ' times');
    $vSpeed = 8;
    $Code = Units_GetCodeByName($name);
    unset($GLOBALS['amfphp']['encoding']);
    $vRunMainLoop = ceil($x / $vSpeed);
    for ($vI = 0; $vI < $vRunMainLoop; $vI++) {
        $vNumAction = 0;
        for ($vJ = $vI * $vSpeed; $vJ < $vI * $vSpeed + $vSpeed && $vJ < $x; $vJ++) {
            @($amf = CreateMultAMFRequest($amf, $vNumAction, '', 'UserService.sellStoredItem'));
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][0]['code'] = $Code;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][1] = false;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2] = -1;
            $vNumAction++;
        }
        $res = RequestAMF($amf);
        if ($res == 'OK') {
            Addlog2(" result {$res}");
        } else {
            AddLog2("GiftBox: Error - " . $res);
            return $res;
        }
    }
    return $res;
}
 private function _fvDoGreenhouse()
 {
     $bsInfo = unserialize(fBGetDataStore('bsinfo'));
     $greenhouses = GetObjectsByName('greenhousebuildable_finished');
     if (empty($greenhouses)) {
         return;
     }
     $trayscnt = $bsInfo[0]['upgradeUnlockedTrays'];
     $totaltrays = $trayscnt[$greenhouses[0]['expansionLevel']];
     $bsStats = unserialize(fBGetDataStore('bsstats'));
     $fthybrids = unserialize($this->fvGetSettings('fthybrids'));
     $genealogy = $bsInfo[0]['genealogy'];
     foreach ($genealogy as $gene) {
         foreach ($gene['ingredient'] as $key => $ingred) {
             $gene['ingredient'][$key]['quantity'] = $ingred['quantity'] * 50;
         }
         $recipes[$gene['itemCode']] = $gene['ingredient'];
     }
     $alltrays = $bsStats['breedingFeatures']['farm']['greenhousebuildable_finished']['trays'];
     //Harvest Trays
     foreach ($alltrays as $key => $tray) {
         if (count($tray['helpingFriendIds']) >= 3 || $_SESSION['servertime'] >= $tray['startTime'] + $bsInfo[0]['breedingDuration']) {
             $amf = CreateRequestAMF('', 'BreedingService.finishBreedingProject');
             $amf->_bodys[0]->_value[1][0]['params'][0] = 'greenhousebuildable_finished';
             $amf->_bodys[0]->_value[1][0]['params'][1] = $key;
             $res = RequestAMF($amf);
             AddLog2('fvTools: Collecting Seeds From Tray ' . ($key + 1) . ': ' . $res);
             if ($res = 'OK') {
                 unset($alltrays[$key]);
             }
         }
     }
     //Start New Trays
     if (empty($fthybrids)) {
         return;
     }
     $traycnt = 0;
     for ($x = count($alltrays); $x < $totaltrays; $x++) {
         $traycode = $fthybrids['tray_' . $x];
         $seedname = Units_GetRealnameByCode($traycode);
         $amf = CreateRequestAMF('', 'BreedingService.beginNewBreedingProject');
         $amf->_bodys[0]->_value[1][0]['params'][0] = 'greenhousebuildable_finished';
         $amf->_bodys[0]->_value[1][0]['params'][1] = $traycnt;
         $amf->_bodys[0]->_value[1][0]['params'][2] = $recipes[$traycode];
         $res = RequestAMF($amf);
         AddLog2('fvTools: Starting ' . $seedname . ' in Tray ' . ($traycnt + 1) . ': ' . $res);
         $traycnt++;
     }
 }
Exemple #8
0
function SM_doPlace($itemName, $unit, $x, $y)
{
    global $TB_settings;
    AddLog2("Placing " . $unit['realname']);
    $amf = CreateRequestAMF('place', 'WorldService.performAction');
    $amf->_bodys[0]->_value[1][0]['params'][1]['className'] = $unit['className'];
    $amf->_bodys[0]->_value[1][0]['params'][1]['itemName'] = $itemName;
    $amf->_bodys[0]->_value[1][0]['params'][1]['direction'] = 0;
    $amf->_bodys[0]->_value[1][0]['params'][1]['position']['x'] = $x;
    $amf->_bodys[0]->_value[1][0]['params'][1]['position']['y'] = $y;
    $amf->_bodys[0]->_value[1][0]['params'][1]['position']['z'] = 0;
    $amf->_bodys[0]->_value[1][0]['params'][1]['deleted'] = false;
    $amf->_bodys[0]->_value[1][0]['params'][1]['state'] = 'static';
    $amf->_bodys[0]->_value[1][0]['params'][1]['tempId'] = -1;
    $amf->_bodys[0]->_value[1][0]['params'][2][0]['isStorageWithdrawal'] = -1;
    $amf->_bodys[0]->_value[1][0]['params'][2][0]['isGift'] = false;
    $amf->_bodys[0]->_value[1][0]['params'][2][0]['isInventoryWithdrawal'] = true;
    $res = RequestAMF($amf);
    if ($res == 'OK') {
        AddLog2('-> ' . $res);
        return true;
    } else {
        AddLog2("ERROR - {$res}");
        return false;
    }
}