NPC 버그 수정, NPC 징병 룰 변경

징병시 최대 통솔 반영
발령 시 인구 바닥난 곳 고려 안하던 것 보정
징병 기준을 통솔과 관계없이 40000명인 경우에 시도하던 버그 수정
NPC는 30000 + 20000 일 경우에만 징병함.
This commit is contained in:
2019-11-10 04:08:48 +09:00
parent e75b6f2d5b
commit 65aa4c29a4
+18 -14
View File
@@ -6,6 +6,7 @@ class AIAllowedAction{
public $develop = true; public $develop = true;
public $warp = true; public $warp = true;
public $recruitLowestCivil = false;
public $randomRecruit = true; public $randomRecruit = true;
public $recruit = true; public $recruit = true;
public $recruit_high = false; public $recruit_high = false;
@@ -42,6 +43,8 @@ class AIAllowedAction{
$this->staffAction = false; $this->staffAction = false;
$this->recruitLowestCivil = true;
foreach($aiOptions as $key=>$value){ foreach($aiOptions as $key=>$value){
assert($value); assert($value);
switch($key){ switch($key){
@@ -168,7 +171,6 @@ function SetCrew($no, $nationID, $personal, $gold, $leader, $genType, $tech, $de
[$startyear, $year] = $gameStor->getValuesAsArray(['startyear', 'year']); [$startyear, $year] = $gameStor->getValuesAsArray(['startyear', 'year']);
$relYear = Util::valueFit($year-$startyear, 0); $relYear = Util::valueFit($year-$startyear, 0);
$type = 0;
switch($genType) { switch($genType) {
case 0: //무장 case 0: //무장
case 2: //무내정장 case 2: //무내정장
@@ -229,7 +231,7 @@ function SetCrew($no, $nationID, $personal, $gold, $leader, $genType, $tech, $de
} }
if($types){ if($types){
if(!$allowedAction->randomRecruit && in_array($currentCrewType, $types) && $type != GameUnitConst::DEFAULT_CREWTYPE){ if(!$allowedAction->randomRecruit && in_array($currentCrewType, $types) && ($currentCrewType != GameUnitConst::DEFAULT_CREWTYPE && $currentCrewType != $types[0])){
$type = $currentCrewType; $type = $currentCrewType;
} }
else{ else{
@@ -277,7 +279,7 @@ function processAI($no, &$reduce_turn) {
} }
$query = "select no,turn0,npcid,name,nation,nations,city,level,npcmsg,personal,leader,intel,power,gold,rice,crew,crewtype,train,atmos,troop,npc,affinity,mode,injury,picture,imgsvr,killturn,makelimit,dex0,dex10,dex20,dex30,dex40 from general where no='$no'"; $query = "select no,turn0,npcid,name,nation,nations,city,level,npcmsg,personal,leader,intel,power,horse,weap,book,item,special,special2,gold,rice,crew,crewtype,train,atmos,troop,npc,affinity,mode,injury,picture,imgsvr,killturn,makelimit,dex0,dex10,dex20,dex30,dex40 from general where no='$no'";
$result = MYDB_query($query, $connect) or Error("processAI01 ".MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error("processAI01 ".MYDB_error($connect),"");
$general = MYDB_fetch_array($result); $general = MYDB_fetch_array($result);
@@ -386,6 +388,9 @@ function processAI($no, &$reduce_turn) {
'tech'=>0, 'tech'=>0,
]; ];
setLeadershipBonus($general, $nation['level']);
$leadership = getGeneralLeadership($general, false, true, true, true);
$coreCommand = array(); $coreCommand = array();
if($general['level'] >= 5) { if($general['level'] >= 5) {
$query = "select l{$general['level']}turn0 from nation where nation='{$general['nation']}'"; $query = "select l{$general['level']}turn0 from nation where nation='{$general['nation']}'";
@@ -926,18 +931,17 @@ function processAI($no, &$reduce_turn) {
$ratio2 = Util::round($genCount2 / $genCount * 100); $ratio2 = Util::round($genCount2 / $genCount * 100);
$ratio3 = rand() % 100; $ratio3 = rand() % 100;
// 전체 인구 대비 확률로 현지에서 징병 // 전체 인구 대비 확률로 현지에서 징병
if($city['pop'] > 40000 && 100 + $ratio - $ratio2 > $ratio3) { $minRecruitPop = 30000 + max($allowedAction->recruitLowestCivil?0:20000, $leadership * 100);
if($city['pop'] >= $minRecruitPop && 100 + $ratio - $ratio2 > $ratio3) {
$command = EncodeCommand(0, 0, 0, 11); //인구 되면 징병 $command = EncodeCommand(0, 0, 0, 11); //인구 되면 징병
} else{ } else{
// 인구 안되면 4만 이상인 도시로 워프 $warpCityID = $db->queryFirstField('SELECT city FROM city WHERE nation=%i AND pop>=%i AND supply=1 ORDER BY rand() limit 1', $general['nation'], $minRecruitPop);
$query = "select city from city where nation='{$general['nation']}' and pop>40000 and supply='1' order by rand() limit 0,1"; if($warpCityID && $allowedAction->warp) {
$result = MYDB_query($query, $connect) or Error("processAI16 ".MYDB_error($connect),"");
$cityCount = MYDB_num_rows($result);
if($cityCount > 0 && $allowedAction->warp) {
$selCity = MYDB_fetch_array($result); $selCity = MYDB_fetch_array($result);
//워프 //워프
$query = "update general set city='{$selCity['city']}' where no='{$general['no']}'"; $db->update('general', [
MYDB_query($query, $connect) or Error("processAI18 ".MYDB_error($connect),""); 'city'=>$warpCityID
], 'no=%i', $general['no']);
$command = EncodeCommand(0, 0, 0, 50); //요양 $command = EncodeCommand(0, 0, 0, 50); //요양
$query = "update general set turn0='$command' where no='{$general['no']}'"; $query = "update general set turn0='$command' where no='{$general['no']}'";
@@ -1034,7 +1038,7 @@ function processAI($no, &$reduce_turn) {
return; return;
case EncodeCommand(0, 0, 0, 11): //징병 case EncodeCommand(0, 0, 0, 11): //징병
if ($allowedAction->recruit) { if ($allowedAction->recruit) {
SetCrew($general['no'], $general['nation'], $general['personal'], $general['gold'], $general['leader'], $genType, $nation['tech'], $general['dex0'], $general['dex10'], $general['dex20'], $general['dex30'], $general['dex40'], $general['crewtype'], $allowedAction); SetCrew($general['no'], $general['nation'], $general['personal'], $general['gold'], $leadership, $genType, $nation['tech'], $general['dex0'], $general['dex10'], $general['dex20'], $general['dex30'], $general['dex40'], $general['crewtype'], $allowedAction);
} }
else{ else{
$db->update('general', [ $db->update('general', [
@@ -1462,7 +1466,7 @@ function NPCStaffWork($general, $nation, $dipState){
if(!$generalCity['front']){ if(!$generalCity['front']){
continue; continue;
} }
if($generalCity['pop'] - 33000 > $nationGeneral['leader']){ if($generalCity['pop'] - 33000 > $nationGeneral['leader'] * 100){
continue; continue;
} }
if($nationGeneral['troop'] != 0){ if($nationGeneral['troop'] != 0){
@@ -1477,7 +1481,7 @@ function NPCStaffWork($general, $nation, $dipState){
$popTrial = 5; $popTrial = 5;
for($popTrial = 0; $popTrial < 5; $popTrial++){ for($popTrial = 0; $popTrial < 5; $popTrial++){
$targetCity = $nationCities[Util::choiceRandom($backupCitiesID)]; $targetCity = $nationCities[Util::choiceRandom($backupCitiesID)];
if($targetCity['pop'] < 33000 + $nationGeneral['leader']){ if($targetCity['pop'] < 33000 + $nationGeneral['leader'] * 100){
continue; continue;
} }
if (Util::randBool($targetCity['pop'] / $targetCity['pop2'])) { if (Util::randBool($targetCity['pop'] / $targetCity['pop2'])) {