npc 워프 기준을 태수, 군사, 시중 모두 따르도록 변경. 워프 버그 수정
This commit is contained in:
+37
-31
@@ -982,31 +982,36 @@ function processAI($no, &$reduce_turn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count($target) == 0 && $allowedAction->warp) {
|
if(count($target) == 0 && $allowedAction->warp) {
|
||||||
//전방 도시 선택, 30% 확률로 태수 있는 전방으로 워프
|
//전방 도시 선택, 태수, 군사, 시중이 배정되어 있으면 이동 확률 증가
|
||||||
if(rand()%100 < 30) {
|
$warpCities = $db->queryAllLists('SELECT city, gen1, gen2, gen3 FROM city WHERE nation = %i AND supply = 1 AND front > 0', $general['nation']);
|
||||||
$query = "select city from city where nation='{$general['nation']}' and supply='1' and front>0 order by gen1 desc,rand() limit 0,1";
|
$warpCandidates = [];
|
||||||
} else {
|
foreach($warpCities as [$cityID, $gen1, $gen2, $gen3]){
|
||||||
$query = "select city from city where nation='{$general['nation']}' and supply='1' and front>0 order by rand() limit 0,1";
|
$score = 1;
|
||||||
|
if($gen1){
|
||||||
|
$score += 1;
|
||||||
|
}
|
||||||
|
if($gen2){
|
||||||
|
$score += 1;
|
||||||
|
}
|
||||||
|
if($gen3){
|
||||||
|
$score += 1;
|
||||||
|
}
|
||||||
|
$warpCandidates[$cityID] = $score;
|
||||||
}
|
}
|
||||||
$result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),"");
|
if($warpCandidates){
|
||||||
$cityCount = MYDB_num_rows($result);
|
$selCity = Util::choiceRandomUsingWeight($warpCandidates);
|
||||||
if($cityCount == 0) {
|
}
|
||||||
|
else{
|
||||||
//도시 수, 랜덤(상위 20%) 선택, 저개발 도시 선택
|
//도시 수, 랜덤(상위 20%) 선택, 저개발 도시 선택
|
||||||
$query = "select city from city where nation='{$general['nation']}' and supply='1'";
|
$cityCnt = $db->queryFirstField('SELECT count(city) FROM city WHERE nation=%i AND supply=1', $general['nation']);
|
||||||
$result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),"");
|
$citySelect = Util::randRangeInt(0, Util::toInt($cityCnt/5));
|
||||||
$cityCount = MYDB_num_rows($result);
|
|
||||||
$citySelect = rand() % (Util::round($cityCount/5) + 1);
|
|
||||||
|
|
||||||
$query = "select city,(def+wall)/(def2+wall2) as dev from city where nation='{$general['nation']}' and supply='1' order by dev limit {$citySelect},1";
|
$selCity = $db->queryFirstField('SELECT city, ,(def+wall)/(def2+wall2) as dev from city where nation=%i and supply=1 order by dev limit %i,1',$general['nation'], $citySelect);
|
||||||
$result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),"");
|
|
||||||
$selCity = MYDB_fetch_array($result);
|
|
||||||
} else {
|
|
||||||
$selCity = MYDB_fetch_array($result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($general['city'] != $selCity['city']) {
|
if($general['city'] != $selCity) {
|
||||||
//워프
|
//워프
|
||||||
$query = "update general set city='{$selCity['city']}' where no='{$general['no']}'";
|
$query = "update general set city='{$selCity}' where no='{$general['no']}'";
|
||||||
MYDB_query($query, $connect) or Error("processAI18 ".MYDB_error($connect),"");
|
MYDB_query($query, $connect) or Error("processAI18 ".MYDB_error($connect),"");
|
||||||
|
|
||||||
$command = EncodeCommand(0, 0, 0, 50); //요양
|
$command = EncodeCommand(0, 0, 0, 50); //요양
|
||||||
@@ -1064,7 +1069,6 @@ function NPCStaffWork($general, $nation, $dipState){
|
|||||||
|
|
||||||
$nationCities = [];
|
$nationCities = [];
|
||||||
$frontCitiesID = [];
|
$frontCitiesID = [];
|
||||||
$frontImportantCitiesID = [];
|
|
||||||
$supplyCitiesID = [];
|
$supplyCitiesID = [];
|
||||||
$backupCitiesID = [];
|
$backupCitiesID = [];
|
||||||
|
|
||||||
@@ -1086,10 +1090,18 @@ function NPCStaffWork($general, $nation, $dipState){
|
|||||||
if($nationCity['supply']){
|
if($nationCity['supply']){
|
||||||
$supplyCitiesID[] = $cityID;
|
$supplyCitiesID[] = $cityID;
|
||||||
if($nationCity['front']){
|
if($nationCity['front']){
|
||||||
$frontCitiesID[] = $cityID;
|
$score = 1;
|
||||||
if($nationCity['gen1']){
|
if($nationCity['gen1']){
|
||||||
$frontImportantCitiesID[] = $cityID;
|
$score += 1;
|
||||||
}
|
}
|
||||||
|
if($nationCity['gen2']){
|
||||||
|
$score += 1;
|
||||||
|
}
|
||||||
|
if($nationCity['gen3']){
|
||||||
|
$score += 1;
|
||||||
|
}
|
||||||
|
$frontCitiesID[$cityID] = $score;
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$backupCitiesID[] = $cityID;
|
$backupCitiesID[] = $cityID;
|
||||||
@@ -1097,7 +1109,6 @@ function NPCStaffWork($general, $nation, $dipState){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Util::shuffle_assoc($nationCities);
|
Util::shuffle_assoc($nationCities);
|
||||||
shuffle($frontCitiesID);
|
|
||||||
shuffle($supplyCitiesID);
|
shuffle($supplyCitiesID);
|
||||||
|
|
||||||
$nationGenerals = [];
|
$nationGenerals = [];
|
||||||
@@ -1155,7 +1166,7 @@ function NPCStaffWork($general, $nation, $dipState){
|
|||||||
$lostGeneral = $nationGenerals[$lostGeneralID];
|
$lostGeneral = $nationGenerals[$lostGeneralID];
|
||||||
if($lostGeneral['npc'] < 2){
|
if($lostGeneral['npc'] < 2){
|
||||||
if($dipState >= 3 && $frontCitiesID){
|
if($dipState >= 3 && $frontCitiesID){
|
||||||
$selCityID = Util::choiceRandom($frontCitiesID);
|
$selCityID = Util::choiceRandomUsingWeight($frontCitiesID);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$selCityID = Util::choiceRandom($supplyCitiesID);
|
$selCityID = Util::choiceRandom($supplyCitiesID);
|
||||||
@@ -1307,7 +1318,7 @@ function NPCStaffWork($general, $nation, $dipState){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($dipState >= 3 && $frontCitiesID){
|
if($dipState >= 3 && $frontCitiesID){
|
||||||
$selCityID = Util::choiceRandom($frontCitiesID);
|
$selCityID = Util::choiceRandomUsingWeight($frontCitiesID);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$selCityID = Util::choiceRandom($supplyCitiesID);
|
$selCityID = Util::choiceRandom($supplyCitiesID);
|
||||||
@@ -1425,12 +1436,7 @@ function NPCStaffWork($general, $nation, $dipState){
|
|||||||
$score *= 4;
|
$score *= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Util::randBool(0.3) && $frontImportantCitiesID){
|
$targetCityID = Util::choiceRandomUsingWeight($frontCitiesID);
|
||||||
$targetCityID = Util::choiceRandom($frontImportantCitiesID);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$targetCityID = Util::choiceRandom($frontCitiesID);
|
|
||||||
}
|
|
||||||
|
|
||||||
$command = EncodeCommand(0, $nationGeneral['no'], $targetCityID, 27);
|
$command = EncodeCommand(0, $nationGeneral['no'], $targetCityID, 27);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user