It is currently Mon Dec 18, 2017 4:38 pm

All times are UTC + 9:30 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Code for CO Jeanne
PostPosted: Fri Feb 16, 2007 12:15 pm 
Offline
User avatar

Joined: Fri Jun 23, 2006 2:44 am
Posts: 1226
Location: X, Y, Z
Hi folks! I figured here would be the best place to put the topic for now (unless there's a better place to put it). I know Jeanne hasn't been approved officially for CW yet, but my code for her is working pretty well afaik. So if you want to try her out for fun or to give feedback, just copy and paste the code underneath into a "Jeanne.java" file of your own, follow the instructions for adding COs (instructions are here), then build it with the rest of the CW files and have fun! :3

If there are any bugs or other programming quirks, please direct them to this topic. For stuff which you feel falls under being a balance issue, direct that concern to Jeanne's CCO topic please (*points to sig*).

Thanks for reading the topic, btw. Hope you enjoy playing as Jeanne!

Code:
/*
 *Jeanne.java
 *Author: Someone
 *Contributors:
 *Creation: CoconutTank
 *The Jeanne class is used to create an instance of the Mercenary CO Jeanne
 */

public class Jeanne extends CO
{
    private int COPlimit;
    private int SCOPlimit;
    private int ttlPropCount;
   
    //constructor
    public Jeanne()
    {
        name = "Jeanne";
        //sid = 50;
       
        String CObiox = "The heir to the throne of Grey Twilight. Excels at attacking enemies that are pinned down.";             //Holds the condensed CO bio'
        String titlex = "The Successor";
        String hitx = "Precision"; //Holds the hit
        String missx = "Weakness"; //Holds the miss
        String skillStringx = "Superior firepower when attacking defenseless targets. Does not fully recover funds from joining units.";
        String powerStringx = "Deploys 4 HP Tanks to precise coordinates. The Tanks are ready to move upon landing. Firepower against defenseless targets is increased."; //Holds the Power description
        String superPowerStringx = "Deploys 6 HP Battle Copters to precise coordinates. The Battle Copters are ready to move upon landing. Firepower against defenseless targets is further increased."; //Holds the Super description
       
        CObio = CObiox;
        title = titlex;
        hit = hitx;
        miss = missx;
        skillString = skillStringx;
        powerString = powerStringx;
        superPowerString = superPowerStringx;
       
        String[] COPowerx =
        {"Now! Bear down from all sides!",
         "'Tis a good day to die...",
         "Say your prayers.",
         "Any last words?",
         "Out, vermin! Cowering will do you no good.",
         "Do you still intend to evade your doom?" };
       
        String[] Victoryx =
        {"Good fortune must have smiled upon me today.",
         "Fear, criminals and cowards! Fear the power of the Lanciers!",
         "A mild exercise, but now to the next battlefield..." };
       
        String[] Swapx =
        {"There will be justice...",
         "Tired already?"};
       
        COPower = COPowerx;
        Victory = Victoryx;
        Swap = Swapx;           
       
        String[] TagCOsx = {"Hawke", "Jess", "Eagle", "Javier", "Drake", "Kanbei"};              //Names of COs with special tags
        String[] TagNamesx  = {"Fall From Grace", "Dual Strike", "Dual Strike", "Dual Strike", "Dual Strike", "Dual Strike"};          //Names of the corresponding Tags
        int[] TagStarsx = {2, 0, 0, 0 ,0 ,0};           //Number of stars for each special tag.
        int[] TagPercentx = {115, 80, 80, 80, 80, 80};       //Percent for each special tag.
       
        TagCOs = TagCOsx;
        TagNames = TagNamesx;
        TagStars = TagStarsx;
        TagPercent = TagPercentx;   
       
        COPName = "Valkyrie Blitz";
        SCOPName = "Halberd of Heaven";
        COPStars = 5.0;
        maxStars = 9.0;
        this.army = army;
        style = GREEN_EARTH;
       
        COPlimit = 3;
        SCOPlimit = 5;
       
        ttlPropCount = 0;
    }

    //used to get the attack bonus for damage calculation
    public int getAtk(Unit friend, Unit enemy)
    {
        int firepower = 100;
       
        if(COP)
        {
            if(!BcanCounterA(friend, enemy))
            {
                firepower += 30;
            }
            else
            {
                firepower += 10;
            }
        }
        else if(SCOP)
        {
            if(!BcanCounterA(friend, enemy))
            {
                firepower += 60;
            }
            else
            {
                firepower += 10;
            }
        }
        else if(!BcanCounterA(friend, enemy))
        {
            firepower += 10;
        }
       
        return firepower;
    }
   
    //used to get the defense bonus for damage calculation
    public int getDef(Unit enemy, Unit friend)
    {
        int defense = 100;
       
        if(COP || SCOP)
        {
            defense += 10;
        }
       
        return defense;
    }
   
    public void setChange(Unit u){};
   
    public void unChange(Unit u){};
   
    //carries out Adder's CO Power, called by CO.activateCOP()
    public void COPower()
    {
        COP = true;
        selecting = true;
       
        setupDeployAmount();
    }
   
    //carries out Adder's Super CO Power, called by CO.activateSCOP()
    public void superCOPower()
    {
        SCOP = true;
        selecting = true;
       
        setupDeployAmount();
    }
   
    //used to deactivate Jeanne's CO Power the next day
    public void deactivateCOP()
    {
        COP = false;
        selecting = false;
    }
   
    //used to deactivate Jeanne's Super CO Power the next day
    public void deactivateSCOP()
    {
        SCOP = false;
        selecting = false;
    }
   
    public boolean BcanCounterA(Unit A, Unit B)
    {
        //First detect if either unit A is an indirect or unit B is an indirect.
        //If either unit is an indirect, then no counterattacks will occur in
        //this matchup.                 
        if((A.getMaxRange() > 1) || (B.getMaxRange() > 1))
        {
            return false;
        }
       
        //Otherwise, check if unit B is capable of counterattacking A.
        //This can be checked by seeing if the damage dealt by unit B
        //to unit A is -1 (which indicates cannot attack in the damage
        //charts). This method applies to all directs and transports (but
        //does not apply to indirects).       
        if(BaseDMG.find(A, B, true) == -1)
        {
            return false;
        }
       
        return true;
    }
   
    public void setupDeployAmount()
    {
        if(army.getUnits().length < 50)
        {
            ttlPropCount = 0;   //initialize the ttlPropCount
           
            if(COP)
            {
                ttlPropCount = -COPlimit;
            }
            else if(SCOP)
            {
                ttlPropCount = -SCOPlimit;
            }
           
            ttlPropCount += army.getNumberOfProperties();
        }
    }
   
    public boolean validSelection(Tile t)
    {
        if(army.getBattle().getMap().onMap(t.getLocation()))
        {
            if(SCOP) //Halberd now deploys air units
            {
                //Cannot land onto pipe terrain!!!
                int tType = army.getBattle().getMap().find(t.getLocation()).getTerrain().getIndex();

                if((tType == 15) || (tType == 17) || (tType == 18))
                {
                    return false;
                }
               
                //Cannot land onto other units!!
                if(army.getBattle().getMap().find(t.getLocation()).getUnit() != null)
                {
                    return false;
                }
            }
            else if(COP) //Blitz now deploys ground units
            {
                //Cannot land onto impassable terrain!!!
                int tType = army.getBattle().getMap().find(t.getLocation()).getTerrain().getIndex();

                if((tType == 2) || (tType == 5) || (tType == 6) || (tType == 7) || (tType == 8) || (tType == 15) || (tType == 17) || (tType == 18))
                {
                    return false;
                }
               
                //Cannot land onto other units!!
                if(army.getBattle().getMap().find(t.getLocation()).getUnit() != null)
                {
                    return false;
                }
            }
               
            return true;
        }
        return false;
    }
       
    public void selectAction(Tile t)
    {       
        if(COP)
        {
            //B Copter
            //army.getBattle().getMap().addUnit(t, new BCopter(t.getLocation().getCol(), t.getLocation().getRow(), army, army.getBattle().getMap()));
           
            //Tank
            army.getBattle().getMap().addUnit(t, new Tank(t.getLocation().getCol(), t.getLocation().getRow(), army, army.getBattle().getMap()));
            army.getBattle().getMap().find(t.getLocation()).getUnit().damage(60,false);
            army.getBattle().getMap().find(t.getLocation()).getUnit().setActive(true);
           
            ttlPropCount -= COPlimit;                                                   
        }
        else if(SCOP)
        {
            //Army temp = army.getBattle().getMap().find(t.getLocation()).getUnit().getArmy();
            //army.getBattle().getMap().find(t.getLocation()).getUnit().damage(1000, true);
           
            //Mega Tank
            //army.getBattle().getMap().addUnit(t, new MegaTank(t.getLocation().getCol(), t.getLocation().getRow(), army, army.getBattle().getMap()));
           
            //B Copter
            army.getBattle().getMap().addUnit(t, new BCopter(t.getLocation().getCol(), t.getLocation().getRow(), army, army.getBattle().getMap()));
            army.getBattle().getMap().find(t.getLocation()).getUnit().damage(40,false);           
            army.getBattle().getMap().find(t.getLocation()).getUnit().setActive(true);
           
            //megaList.add(army.getBattle().getMap().find(t.getLocation()).getUnit());
           
            //Army[] armArry = army.getBattle().getArmies();
           
            ttlPropCount -= SCOPlimit;                       
        }
       
        //If the previous unit is the last that can
        //be deployed by Jeanne's powers, then the targeting
        //section ends, and the cursor functions return to normal.
        if((ttlPropCount < 0) && (army.getUnits().length < 50))
        {
            selecting = false;
        }
    }
   
    public void cancelSelection() //If they press B
    {
        //DO NOTHING D:
    }
    public void invalidSelection() //IF they hit the wrong button
    {
        //DO NOTHING D:
    }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 9:30 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Blue Moon by Trent © 2007
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group