AI War 2:Granting Techs

From Arcen Wiki
Revision as of 09:50, 4 September 2018 by X4000Chris (talk | contribs)
Jump to navigation Jump to search

Question: How do I give the player a new type of Ship based on an event (lets say Hacking)

Answer, from Chris' email, Sept 2 2018. So, to unlock a new ship line for the player, you just call UnlockShipLine( NameOfGameEntityType, true ) on the faction of the player. Ideally on the faction of ALL human players, for multiplayer purposes. The true is for a variable called IsFree, which means it won't try to charge the player for it.

In order for this to function, however, a couple of other things need to be true first:

  • 1. This tag must be on the ship itself: ship_line_must_be_unlocked="LineMustBeGrantedByStructure"
    • Note that won't harm the AI or faction using it.
  • 2. built_by="FleetShips" or built_by="Starships" if it's to be built from either the Space Dock or the Starship Constructor queues, OR if you want it to be built directly then you can make it go into built_by="Defenses" or similar.
    • Note that it can be in multiple built_by menus, some for the player and some for the AI or dyson, no problem. See Raptor or any other bonus ship type for example.
  • 3. IF you want this ship to then be upgradeable via tech costs, then you also need to specify a tech_cost="FleetShip" or anything else you prefer (you can make your own custom tech cost if you want), but this should not be required.
    • However, if you don't specify one of these, and you give the player a mark 3 ship or mark 1 or whatever, it will be that way forever and can't be upgraded.
    • As a convention, I've never been giving the player un-upgradeable ships that have a mark on them. Even if they're really strong, I just beef up the stats directly and make it Markless, so the players don't have to wonder how to upgrade it. I figure that's simpler.
  • 4. In terms of choosing how to choose which ships the dyson can unlock, that's really up to you. There are two overall ways:
    • Firstly, you could just use tags, which you're plenty used to. Just pick one at random using your own code from the ones that have the tag you want, and you're good to go.
    • Secondly, if you want to define a new BuildMenu to contain things like DysonUnlocks, then that would be more in line with how the ARSes and similar work. See how I've been using StarshipAndFleetshipUnlocks and FleetShipUnlocks and StarshipUnlocks for the other ships. I'd kind of prefer that this be used since it keeps things consistent, but I don't have super strong feelings on it. There's something to be said for the simplicity of just using tags (doesn't require editing another file), so as a model for other modders that is something that makes sense. So using method one might ultimately be preferable.

A couple of other notes:

  • A. NOTHING can normally build a new ship that gets added unless it gets added to specific built_by BuildMenus. That goes for the AI and for players.
    • Normally everything is available right away, at whatever the starting mark level is. It's that ship_line_must_be_unlocked="LineMustBeGrantedByStructure" that prevents that from being the case.
    • If you want it to have to be unlocked by a structure for players, BUT you want the AI to have it from the start, then setting ai_can_use_this_without_unlocking_it="true" is required.
    • This is for the "usual" methods of the AI seeding or spawning stuff, though, which basically means: BasicWaveDrawBag, BasicReinforcementDrawBag, or the ones that are for guardians, guard posts, or other specialized bits.
  • B. If something is in one of those AI-available build lists, but it doesn't have it unlocked yet, then those are the things it will choose from to unlock when the AIP gets high enough that the AI gets a new unlock.
  • C. All those things that have a built_by="Unused" are basically saying "I get found and constructed via some other unusual method, probably based on my tags or even by spawn_on_death or similar."
    • This is how most of the factions build things, of course, but then for all the special goodies that we're spreading around, we're doing that same sort of thing. If they only get built or granted in unusual situations, there's no reason to be using BuildMenus in the middle. And that in turn means that techs are irrelevant, incidentally (since nothing will ever be able to unlock it, and by default it's completely unlocked -- not having a build menu and turning on a ship_line_must_be_unlocked other than the default would cause it to never be buildable even by tags. So don't mix those. :)
  • D. If you assign built_by on a copy_from line(like EnemyArmorShip), then it will completely overwrite the other build menus. That's one reason I use "Unused" at times, because I want tag-based stuff to apply but it not to show up in the player or AI rosters.