Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => Modding => Topic started by: Ford_Prefect on November 03, 2014, 09:19:16 PM

Title: JAC
Post by: Ford_Prefect on November 03, 2014, 09:19:16 PM
I'm working on creating an open source (GPLv3) SMAC clone using Java 7.

Currently its just 93KiB of text parsers for reading in all the available factions and rules.

Currently I'm working on:

Todo:
* Everything that isn't done.  ::)
* script.txt  Gonna save this for when I'm feeling ambitious.  Gonna have to design it properly to handle the translations.

Whats done.
* Loading/Saving Individual factions.
* Loading Chassis/Armor/weapons/Reactor
* Loading Ideologies.
* Loading blurbs
* Partial Loading of facilities and unit abilities.  These only store some of the information in the txt file.  Will need to manually input values for their effects.


Goals:

Ideas:

Title: Re: JAC
Post by: DrazharLn on November 03, 2014, 10:34:56 PM
As I hinted at before, I think it would be a better idea to base the new datafile standard on json (and it should be thought about a little, documented and versioned so we can change it in future if necessary).

Why JSON rather than XML? JSON is much more human readable and editable and thus supports the common SMAC practice of modding by editing text files better.

JSON parsers exist for a wide range of languages, just like XML parsers, so support shouldn't be a problem.

Once basic functionality is complete, I think the following are desirable:
* Scripting language for modding/extension that hooks into game logic
* Sensible mod management with signed mods, versioning, dependencies, etc.
* AI scripting environment and toolkit to try to evaluate better AI strategies (I have some background in AI and would be interested in developing AIs for SMAC. The Freeciv projects and so on probably have interesting work in this area).
* Better MP support (lobbies, ladder, browser, PUG/matchmaking support (suited for slower pace of SMAC))
Title: Re: JAC
Post by: Ford_Prefect on November 03, 2014, 11:49:41 PM
I'm currently using the JAXB functionality in java.  I'm not sure if I want to learn a different library to save/load jsons.  (Or is it really easy? if so... point me at an example.  :D )

Btw... this is what the faction settings currently looks like.  (There is another xml for the text.)  Note:  Don't use this as an example.  The file format isn't stable yet.
Code: [Select]
?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<factionSettings>
    <ai_fight>-1</ai_fight>
    <ai_power>1</ai_power>
    <ai_tech>1</ai_tech>
    <ai_wealth>0</ai_wealth>
    <ai_growth>0</ai_growth>
    <Free_Techs>InfNet</Free_Techs>
    <num_of_free_techs>0</num_of_free_techs>
    <social>
        <entry>
            <key>ECONOMY</key>
            <value>-2</value>
        </entry>
        <entry>
            <key>MORALE</key>
            <value>1</value>
        </entry>
        <entry>
            <key>RESEARCH</key>
            <value>1</value>
        </entry>
    </social>
    <morale>0</morale>
    <psi>0</psi>
    <free_facilitys>4</free_facilitys>
    <research>0</research>
    <drone_bonus>-1</drone_bonus>
    <talent>-1</talent>
    <energy>0</energy>
    <interest>0</interest>
    <commerce>0</commerce>
    <pop_cap_difference>0</pop_cap_difference>
    <hurry>50</hurry>
    <unit>NONE</unit>
    <techcost>100</techcost>
    <sharetech>-1</sharetech>
    <tech_share>false</tech_share>
    <terraform_cost>100</terraform_cost>
    <fungus_nutrient>0</fungus_nutrient>
    <fungus_minerals>0</fungus_minerals>
    <fungus_energy>0</fungus_energy>
    <extra_frequency>0</extra_frequency>
    <mind_control_immunity>true</mind_control_immunity>
    <fanatic>false</fanatic>
    <votes>0</votes>
    <freeproto>false</freeproto>
    <aquatic_faction>false</aquatic_faction>
    <alien_faction>false</alien_faction>
    <pro_ideologies>
        <item>values</item>
        <item>knowledge</item>
    </pro_ideologies>
    <anti_ideologies>
        <item>values</item>
        <item>power</item>
    </anti_ideologies>
    <ai_emphesis>RESEARCH</ai_emphesis>
    <revolt_success_modifier>0</revolt_success_modifier>
    <probe_cost>100</probe_cost>
    <drone_reduction>0</drone_reduction>
    <offence>100</offence>
    <defence>100</defence>
    <wormpolice>1</wormpolice>
    <techsteal>false</techsteal>
</factionSettings>

Quote
Sensible mod management with signed mods, versioning, dependencies, etc.

Quote
* Scripting language for modding/extension that hooks into game logic
Not sure how to do this.  Probably a post 1.0 feature.  The security issues alone will make that quite difficult.

Quote
* AI scripting environment and toolkit to try to evaluate better AI strategies (I have some background in AI and would be interested in developing AIs for SMAC. The Freeciv projects and so on probably have interesting work in this area).
Definitely will have a toolkit for evaluating AI performance.  Not sure about scripting. 

Quote
Better MP support (lobbies, ladder, browser, PUG/matchmaking support (suited for slower pace of SMAC))
That will require a matchmaking server (Or doing horrible things via email  :D ).  But it will be a goal.  Probably version 1.1 First I need to get a working multi-player in place.
Title: Re: JAC
Post by: Sompom on November 04, 2014, 08:07:59 AM
Hi Ford,
   Not to spam you, but I'll repeat my offer to help here, so that it's in the right post. Let me know whenever you're comfortable letting others on the project!
Thanks,
Sompom
Title: Re: JAC
Post by: Ford_Prefect on November 04, 2014, 12:33:10 PM
@Sompon
Thanks for the offer!  I plan to make use off it once I've got the foundation built.

I plan to open the codebase up after:
[li$i]The player can select a faction and build a colony pod to make a base[/li]
[li]Cleaned up and make sure to comment on all the functions[/li]
[/list]

After those are achieved, I don't think the game's structure will change much.  It will just be allot of implementation details, testing and asset creation.  Not to mention someone will have to create the 3d stuff.  ;)

There is probably a weeks worth of work for the variables.  It will take longer than that because of work. (Sorghum doesn't harvest itself. ::) ) 
The multi-player will take an indeterminate amount of time as I will be learning the library calls and stuff to do so.  (I know some of the general theories of how to design multi-player.... I've just never done it before.). 

I will post here when I reach one of the milestones.
Title: Re: JAC
Post by: Ford_Prefect on November 08, 2014, 09:10:46 PM
Any preferences for the open source licensing?

LGPL, GPL, other?

Status update:
Making good progress on reading in text files.  Still need to do Techlong, techshort, scripts, concepts, flavor, and interludes. I'll probably work on unit tests for a while.
Title: Re: JAC
Post by: Sompom on November 08, 2014, 11:33:05 PM
I don't have a license preference as long as it's nice and open. Your pick!
Title: Re: JAC
Post by: Ford_Prefect on November 09, 2014, 08:04:34 PM
I've been applying some skull sweat towards a problem.  How should the effects of special abilities be stored in a way that allows modding?  This is made especially interesting by the fact that some of the effects change depending on chassis/reactor/who is attacking whom/etc.   The idea I have is to store a list of effects.  Each effect will contain 0 or more restrictions and a list of 1 or more tags that are active under those restrictions.

Here is a list that I think should cover all possible unit abilities.

Code: [Select]
Restrictions:
the units chassis type
reactor type
minimum police rating
enemyunit_chassis_type  Air/Land/Sea
enemyunit_armor_type Energy/Physical/Binary
enemyunit_weapon_type Energy/.... etc.


// Tags:
// Attack/defense effects

defence_effect(%) - defensive bonus.  (If you want to only apply to a certain scenario, like when
       being attacked by air, use the enemyunit_chassis_type, etc restrictions)
offence_effect(%) - offensive damage % change. 

killcitypop(%) - kill a % of a cities inhabitants if the unit wins.
atrocity(); - is this an atrocity to use.
moraleEffect(#) - change this units morale by #
IgnoreBaseDefenses() - unit attacks the unit inside the base without any of the bases defenses taking effect.
artillery(range) - unit becomes artillery capable of range.
Amphibiouspods - unit can go from sea base to land and vice versa.  ground unit in transport can attack adjacent units in the sea.

//Non-combat effects
range_bonus(#) increase the range of a unit by #

clean_reactor() - no maintenance cost.
radar_bonus(#) - increase radar range by #.
drop_pods - unit can make air drops.
ignore_zoc() - unit ignores zones of control.
cost_to_subvert(%) - change the cost to subvert a unit by the given %.
police_bonus(#) - gives a bonus of #.  If you want to restrict, use the minimum police rating.

//Terraformer effects
fungicide(%) - remove fungus rate % modifier.
terraform_rate_nonfungal(%) - % change in the terraform rate for non-fungal actions. 
terraform_rate_all - % change in all terraform actions.

//Transport effects
allow_transportair() - allow transports to carry air units.
transport_heals_cargo() - transports will heal units being carried.


Does anyone see any problems with this idea?  Or does anyone have any request for a unit effect that I missed?
Title: Re: JAC
Post by: Yitzi on November 09, 2014, 10:33:22 PM
I've been applying some skull sweat towards a problem.  How should the effects of special abilities be stored in a way that allows modding?

Don't store them in the special ability; instead store them in the relevant area (combat bonuses/penalties for combat effects, police effect for police, etc.), and simply have the presence/absence of each ability be a condition that can be applied.

That way it's easy to make a new ability with more than one effect, it should be the most efficient way in terms of runtime, and if someone decides to make an ability that affects something you never thought of (like an ability for colony pods that makes them build a base with 2 pop or add 2 pop to a base), it can be done easily if the matter being affected is moddable in the first place.
Title: Re: JAC
Post by: Flux on November 10, 2014, 01:40:09 AM
Now that we have JAC being worked on it would be cool to have AC ports into 2 different languages. (the other being python with opensmac)
Maybe "port" is not the right word?
I wonder which one will be finished first.

Anyway, I am excited to see this develop though I have only the faintest knowledge of Java.

-Flux
Title: Re: JAC
Post by: Ford_Prefect on November 15, 2014, 12:43:06 AM
The Weekly Report.

I'm still working on implementing the system for modding unit abilities and base facilities.  I've come up with a solution, but implementing it is taking quite a bit of time.

The code base has increased to 131KiB.  :(

I might take a break from working on the unit abilities, etc and instead work on learning how to create a server and client.  I'm new to network programming so it will be interesting (or frustrating  ::) )

Title: Re: JAC
Post by: Ford_Prefect on December 03, 2014, 02:16:51 AM
Decided to post to say that I'm still alive.  I've had a bunch of paperwork to deal with in real life... so not much progress has been done in the last two weeks.  I'm currently working on implementing the map into the game (so I have someplace to put the units.  :) ).
Title: Re: JAC
Post by: Buster's Uncle on December 03, 2014, 02:27:50 AM
Glad you're alive. ;b;
Title: Re: JAC
Post by: Ford_Prefect on January 03, 2015, 05:24:15 PM
Status Update:
Happy new year!  :D
Map work is allot more complicated than I thought it would be. I'm still working on maps.  ::) 
177kb of src.  But I suspect at least 20kb of that is the copyright notice that is pasted at the top of each source file.  ::)
 
Complications:
Title: Re: JAC
Post by: Yitzi on January 03, 2015, 11:45:21 PM
    [li$i]TODO: The variability of nutrients/minerals/energy.  You are capped on the food output of a square until you have a certain tech unless the square has bonus nutrients?!  Figuring out a simple way to set this up and making it modifiable is a pain.[/li]
    [/list]

    Allow people to add conditional caps, with "faction has tech" and "square has bonus resource" as valid conditions (and with the conditions including conjunctions and disjunctions of other conditions.)
    Title: Re: JAC
    Post by: Ford_Prefect on January 08, 2015, 09:42:20 PM
    I thought I share a recent development on JAC.  I've come up with (and implemented) a new system for modders to change gameplay.  And its really good.

    The original system I was working on, was basically similar to what SMAC did, except with allot more variables that modders could change.  You would tell it "I want this unit's speed to be X" or "I want this to produce x energy per turn", etc, etc.

    Now, it is much, much, much, much more flexable.  Now for every variable, you can use a formula.   :D  >, =, <, ADD, MULTIPLY, OR, AND, NOT, are all possible.  So now you can do crazy stuff like "If the unit is on dirt and the player has the tech "Dirtpower" then let firepower = 9000, else let firepower = 100".

    The xml will likely look something like this:
    Code: [Select]
    <firepower>
    <OnTerrain>
    <Terrain>Dirt</Terrain>
     <True>
       <Hastech>
         <Tech>DirtSupremacy</Tech>
         <True>9000</Tech>
         <False>100</False>
       </hastech>
     </True>
     <False> 100 </False>
    </firepower>

    This new system solves several problems at once.   :D 

    200kb
    Title: Re: JAC
    Post by: Yitzi on January 09, 2015, 12:29:47 PM
    I think this is a good move.
    Title: Re: JAC
    Post by: Flux on January 10, 2015, 11:55:53 PM
    Looking forward to this.
    Also, I know nothing about Java scripting. But if this was completed, would it allow people to make custom units? :luv:
    Title: Re: JAC
    Post by: Yitzi on January 11, 2015, 12:32:26 AM
    Looking forward to this.
    Also, I know nothing about Java scripting. But if this was completed, would it allow people to make custom units? :luv:

    Custom units are easy.  The tricky part is custom abilities and chasses with custom rules...and this method would very easily allow such things.
    Title: Re: JAC
    Post by: Ford_Prefect on January 11, 2015, 01:58:05 AM
    It allows you to really customize the units.  Also, its written in Java not javascript.  But don't worry!  Unless you want to work on the engine or AI, all you will need to know is XML.


    218kb
    Templates: 1: Printpage (default).
    Sub templates: 4: init, print_above, main, print_below.
    Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
    Style sheets: 0: .
    Files included: 31 - 840KB. (show)
    Queries used: 14.

    [Show Queries]