Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-05 11:09:32 +0000
committerStijn Buys <ingar@osirion.org>2013-11-05 11:09:32 +0000
commit1c9a974d65db676a61ae99e6e426e95671af056e (patch)
tree93831727d9dc2f7b62d5dc032093f2738c2ea068 /src/game/base
parentb6eb7bc55c26444dd2bb3ee0e0a669f0b31bceeb (diff)
Completed support for the 'amount' key in patrol ship definitions.
Diffstat (limited to 'src/game/base')
-rw-r--r--src/game/base/patrol.cc61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/game/base/patrol.cc b/src/game/base/patrol.cc
index 52944de..48f687e 100644
--- a/src/game/base/patrol.cc
+++ b/src/game/base/patrol.cc
@@ -268,36 +268,40 @@ void Patrol::frame(const unsigned long elapsed)
continue;
}
- // add NPC
- NPC *npc = new NPC(patrol_profile, shipmodel);
+ const size_t nbships = 1 + math::randomi(item->amount());
+ for (size_t i = 0; i < nbships; i++) {
- // set NPC name
- if (shipmodel->npc_name().size()) {
- npc->set_name(shipmodel->npc_name());
- }
-
- // set NPC color
- if (faction()) {
- faction()->apply(npc);
- }
-
- // patrol ships are not dockable
- if (npc->has_flag(core::Entity::Dockable)) {
- unset_flag(core::Entity::Dockable);
- // delete menus
- for (Menus::iterator mit = npc->menus().begin(); mit != npc->menus().end(); mit++) {
- delete (*mit);
- (*mit) = 0;
+ // add NPC
+ NPC *npc = new NPC(patrol_profile, shipmodel);
+
+ // set NPC name
+ if (shipmodel->npc_name().size()) {
+ npc->set_name(shipmodel->npc_name());
+ }
+
+ // set NPC color
+ if (faction()) {
+ faction()->apply(npc);
}
- npc->menus().clear();
+
+ // patrol ships are not dockable
+ if (npc->has_flag(core::Entity::Dockable)) {
+ unset_flag(core::Entity::Dockable);
+ // delete menus
+ for (Menus::iterator mit = npc->menus().begin(); mit != npc->menus().end(); mit++) {
+ delete (*mit);
+ (*mit) = 0;
+ }
+ npc->menus().clear();
+ }
+
+ // dock npc at spawn
+ npc->set_zone(spawn->zone());
+ npc->set_dock(spawn);
+
+ // add NPC to patrol
+ add_member(npc);
}
-
- // dock npc at spawn
- npc->set_zone(spawn->zone());
- npc->set_dock(spawn);
-
- // add NPC to patrol
- add_member(npc);
}
set_leader();
@@ -330,7 +334,7 @@ void Patrol::frame(const unsigned long elapsed)
patrol_leader->set_autopilot_target(waypoint()->target());
}
} else {
- patrol_launch_timeout = core::server()->timestamp() + 15000 + (unsigned long) math::randomi(15000);
+ patrol_launch_timeout = core::server()->timestamp() + 15000 + (unsigned long) math::randomi(30000);
}
} else {
patrol_launch_timeout = 0;
@@ -338,7 +342,6 @@ void Patrol::frame(const unsigned long elapsed)
}
} else {
-
patrol_leader->launch();
}