Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Script-KI - Depots
#1
(09-04-2020, Thursday-18:11:30 )Dwachs2 schrieb: Das Skript versucht einen neuen Convoi in dem Depot zu erstellen, wo ein anderer der Linie erstellt wurde. Da koennte man noch eine Suche nach einem Depot einbauen...

globale Funktion ( weil auch in *_connection verwendet )
Code:
/**
* search existing depot on range to station
*
*/
function search_depot(field_pos, wt) {
 
 local list_exists_depot = depot_x.get_depot_list(our_player, wt)
 // search range
 local seach_field = 10

 local tile_min = [field_pos.x - seach_field, field_pos.y - seach_field]
 local tile_max = [field_pos.x + seach_field, field_pos.y + seach_field]
 local depot_found = false

 foreach(key in list_exists_depot) {

   if ( key.x >= tile_min[0] && key.y >= tile_min[1] && key.x <= tile_max[0] && key.y <= tile_max[1] ) {
     depot_found = tile_x(key.x, key.y, key.z)
     break
   }
       
 }

 return depot_found

}

weis nicht genau, ob die Zeilennummern noch passen bei sqai/industry_manager.nut
Code:
--- a/ai/sqai/industry_manager.nut
+++ b/ai/sqai/industry_manager.nut
@ -300,7 +300,17 @@ class industry_manager_t extends manager_t
       // directly append
       // TODO put into report
       local proto = cnv_proto_t.from_convoy(cnv, lf)
-       local depot = cnv.get_home_depot()
+       local depot  = null //cnv.get_home_depot()      
+       local stations_list = cnv.get_schedule().entries
+       for (local i=0; i<stations_list.len(); i++) {
+    
+         local c = tile_x(stations_list[i].x, stations_list[i].y, stations_list[i].z)
+         local depot = search_depot(c, wt)
+         if ( depot ) {
+           break
+         }
+      
+       }

       local c = vehicle_constructor_t()

@@ -423,7 +423,19 @@ class industry_manager_t extends manager_t
   dbgprint("Upgrade line "  + line.get_name())
   // build the new one, withdraw the old ones
   // directly append
-   local depot  = cnv.get_home_depot()
+   local depot  = null //cnv.get_home_depot()      
+   local stations_list = cnv.get_schedule().entries
+   for (local i=0; i<stations_list.len(); i++) {
+
+     local c = tile_x(stations_list[i].x, stations_list[i].y, stations_list[i].z)
+     local depot = search_depot(c, wt)
+     if ( depot ) {
+       break
+     }
+      
+   }
Script-KI für Simutrans r10894+ / Simutrans Nightly Builds
Zitieren


Nachrichten in diesem Thema
Script-KI - Depots - von Andarix - 21-04-2020, Tuesday-23:08:35
RE: Script-KI - Depots - von Andarix - 16-01-2021, Saturday-00:28:19
RE: Script-KI - Depots - von Dwachs2 - 16-01-2021, Saturday-13:32:47
RE: Script-KI - Depots - von Andarix - 16-01-2021, Saturday-15:12:48
RE: Script-KI - Depots - von Dwachs2 - 16-01-2021, Saturday-15:25:15
RE: Script-KI - Depots - von Andarix - 09-07-2021, Friday-21:25:19
RE: Script-KI - Depots - von Andarix - 10-07-2021, Saturday-13:59:48
RE: Script-KI - Depots - von Dwachs2 - 12-07-2021, Monday-09:37:44
RE: Script-KI - Depots - von Andarix - 12-07-2021, Monday-11:05:38
RE: Script-KI - Depots - von Dwachs2 - 12-07-2021, Monday-16:35:41
RE: Script-KI - Depots - von Dwachs2 - 20-07-2021, Tuesday-19:30:47
RE: Script-KI - Depots - von Andarix - 20-07-2021, Tuesday-23:51:34
RE: Script-KI - Depots - von Dwachs2 - 21-07-2021, Wednesday-09:55:20
RE: Script-KI - Depots - von Andarix - 21-07-2021, Wednesday-11:02:42
RE: Script-KI - Depots - von Dwachs2 - 21-07-2021, Wednesday-11:13:16
RE: Script-KI - Depots - von Andarix - 21-07-2021, Wednesday-11:19:16

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste