#1 08.01.2012 09:20:33

akfaew
Administrator
Posts: 619

recent changes

Dangerous times lie ahead, newcomers can now defend their transport ships:

(best_unit(a, b) means - if any player can build unit a, then return unit a. else return unit b)

-    boattype = lt_newcomer_best_unit(L_FERRYBOAT);
+    struct unit_type *defboat;
+    static int r = 0;
+    struct player *best;
+    int bestscore = 0;
+
+    boattype = best_unit("Transport", "Galleon");
+    if (boattype == NULL)
+      boattype = lt_newcomer_best_unit(L_FERRYBOAT);
+
+    switch (r) {
+    case 0:
+      defboat = best_unit("Submarine", "Frigate");
+      break;
+    case 1:
+      defboat = best_unit("Battleship", "Frigate");
+      break;
+    case 2:
+      defboat = best_unit("Cruiser", "Frigate");
+      break;
+    case 3:
+      defboat = best_unit("AEGIS Cruiser", "Frigate");
+      break;
+    case 4:
+      defboat = best_unit("Destroyer", "Frigate");
+      break;
+    }
+    r++;
+    if (r > 4)
+      r = 0;
+    if (defboat != NULL)
+      create_unit(pplayer, ptile, defboat, 0, 0, -1);

Did any newcomer get at least a musketeer? If not I need to fix this as well.

Other changes: I fixed delegation, it should work now.
I changed my nick from dude to akfaew in LTeX23 by editing the savegame - a couple of people told me it was confusing...

Offline

#2 08.01.2012 09:24:04

akfaew
Administrator
Posts: 619

Re: recent changes

I want to work a bit more on the code, the server might be randomly offline today, sorry for that.

Offline

#3 08.01.2012 11:41:11

akfaew
Administrator
Posts: 619

Re: recent changes

A newcomer gets each of these four types of units per city. Right now he gets 28 cities. Here is the change I made. The server has resumed normal operation.

+  switch (role) {
+  case L_DEFEND_OK:
+    if (can_anyone_build("Riflemen"))
+      return unit_type_by_rule_name("Riflemen");
+    else if (can_anyone_build("Partisan"))
+      return unit_type_by_rule_name("Partisan");
+    else if (can_anyone_build("Musketeers"))
+      return unit_type_by_rule_name("Musketeers");
+    return unit_type_by_rule_name("Warriors");
+  case L_DEFEND_GOOD:
+    if (can_anyone_build("Mech. Inf."))
+      return unit_type_by_rule_name("Mech. Inf.");
+    else if (can_anyone_build("Armor"))
+      return unit_type_by_rule_name("Armor");
+    else if (can_anyone_build("Alpine Troops"))
+      return unit_type_by_rule_name("Alpine Troops");
+    else if (can_anyone_build("Riflemen"))
+      return unit_type_by_rule_name("Riflemen");
+    else if (can_anyone_build("Partisan"))
+      return unit_type_by_rule_name("Partisan");
+    else if (can_anyone_build("Musketeers"))
+      return unit_type_by_rule_name("Musketeers");
+    else if (can_anyone_build("Pikemen"))
+      return unit_type_by_rule_name("Pikemen");
+    return unit_type_by_rule_name("Phalanx");
+  case L_ATTACK_FAST:
+    if (can_anyone_build("Armor"))
+      return unit_type_by_rule_name("Armor");
+    else if (can_anyone_build("Dragoons"))
+      return unit_type_by_rule_name("Dragoons");
+    else if (can_anyone_build("Cavalry"))
+      return unit_type_by_rule_name("Cavalry");
+    else if (can_anyone_build("Knights"))
+      return unit_type_by_rule_name("Knights");
+    else if (can_anyone_build("Chariot"))
+      return unit_type_by_rule_name("Chariot");
+    return unit_type_by_rule_name("Horsemen");
+  case L_ATTACK_STRONG:
+    if (can_anyone_build("Howitzer"))
+      return unit_type_by_rule_name("Howitzer");
+    else if (can_anyone_build("Armor"))
+      return unit_type_by_rule_name("Armor");
+    else if (can_anyone_build("Marines"))
+      return unit_type_by_rule_name("Marines");
+    else if (can_anyone_build("Legion"))
+      return unit_type_by_rule_name("Legion");
+    return unit_type_by_rule_name("Archer");
+  }

Offline

Board footer

Powered by FluxBB