Esempio n. 1
0
        public int countAvailablePowers(Unit p)
        {
            if (p == null)
            {
                return(0);
            }
            int n = 0;

            if (p.isEnthralled())
            {
                foreach (Ability a in p.powers)
                {
                    if (a.castable(map, p))
                    {
                        n += 1;
                    }
                }
                return(n);
            }

            foreach (Ability a in powers)
            {
                if (a.castable(map, p))
                {
                    n += 1;
                }
            }
            return(n);
        }
Esempio n. 2
0
        public List <Ability> getAvailablePowers(Unit p)
        {
            if (p == null)
            {
                return(new List <Ability>());
            }
            List <Ability> reply = new List <Ability>();

            if (p.isEnthralled())
            {
                foreach (Ability a in p.powers)
                {
                    if (a.castable(map, p))
                    {
                        reply.Add(a);
                    }
                }
            }
            else
            {
                foreach (Ability a in powers)
                {
                    if (a.castable(map, p))
                    {
                        reply.Add(a);
                    }
                }
            }
            return(reply);
        }
 public override bool hostileTo(Unit u)
 {
     if (u.society.isDark())
     {
         return(false);
     }
     return(!u.isEnthralled());
 }
Esempio n. 4
0
 public override bool hostileTo(Unit u)
 {
     if (u.isEnthralled())
     {
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
 public override bool hostileTo(Unit u)
 {
     if (u.society.isDark())
     {
         return(false);
     }
     if (u.isEnthralled() == false)
     {
         return(true);
     }
     return(base.hostileTo(u));
 }
Esempio n. 6
0
        public override void turnTick(Unit unit)
        {
            //Enthralled can't just eat clues
            if (unit.isEnthralled())
            {
                unit.task = null;
                return;
            }

            if (unit.location.evidence.Count > 0)
            {
                dur += 1;
                if (dur >= unit.location.map.param.unit_investigateTime)
                {
                    Evidence ev = unit.location.evidence[0];
                    if (ev.pointsTo != null)
                    {
                        if (unit.person != null && ev.pointsTo.person != null)
                        {
                            unit.person.getRelation(ev.pointsTo.person).suspicion = System.Math.Min(1, unit.person.getRelation(ev.pointsTo.person).suspicion + ev.weight);
                        }
                        else
                        {
                            //Can't use suspicion system, go straight to murder
                            //Makes sense since they're probably non-human terrors
                            unit.hostility.Add(ev.pointsTo);
                        }

                        unit.location.map.addMessage(unit.getName() + " has found evidence from " + ev.pointsTo.getName(), MsgEvent.LEVEL_RED, false);
                    }
                    else if (ev.pointsToPerson != null)
                    {
                        if (unit.person != null && ev.pointsToPerson != null)
                        {
                            unit.person.getRelation(ev.pointsToPerson).suspicion = System.Math.Min(1, unit.person.getRelation(ev.pointsToPerson).suspicion + ev.weight);
                        }

                        unit.location.map.addMessage(unit.getName() + " has found evidence from " + ev.pointsToPerson.getFullName(), MsgEvent.LEVEL_RED, false);
                    }

                    unit.location.evidence.Remove(ev);
                    unit.task = null;
                }
            }
            else
            {
                //Evidence gone. Probably eaten by someone else. Return to idle to retask next turn
                unit.task = null;
            }
        }
        public void setTo(Unit unit)
        {
            if (unit == null)
            {
                setToNull(); return;
            }

            title.text    = unit.getName();
            desc.text     = unit.getDesc();
            task.text     = unit.getTaskShort();
            taskDesc.text = unit.getTaskDesc();

            if (unit.person == null)
            {
                clearPerson();
            }
            else
            {
                personBack.sprite = unit.person.getImageBack();
                personMid.sprite  = unit.person.getImageMid();
                personFore.sprite = unit.person.getImageFore();
                evidenceText.text = "Evidence: " + (int)(100 * unit.person.evidence) + "%";
            }

            if (unit.isEnthralled())
            {
                if (unit.movesTaken == 0)
                {
                    hasMoved.text = "Can Move";
                }
                else
                {
                    hasMoved.text = "Has Taken Turn";
                }
            }
            else
            {
                hasMoved.text = "Not an Enthralled Agent";
            }

            nationText.text = unit.society.getName();
            if (unit.parentLocation != null)
            {
                nationText.text += "\nFrom " + unit.parentLocation.getName();
            }
            nationFlag1.color = unit.society.color;
            nationFlag2.color = unit.society.color2;
        }
Esempio n. 8
0
        public override void turnTick(Unit unit)
        {
            if (unit.person == null)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement == null)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement.title == null)
            {
                unit.task = null; return;
            }
            if (unit.location.settlement.title.heldBy == null)
            {
                unit.task = null; return;
            }
            if (unit.location.soc is Society == false)
            {
                unit.task = null; return;
            }

            dur += 1;
            if (dur >= unit.location.map.param.unit_socialiseAtCourtTime)
            {
                Society soc         = (Society)unit.location.soc;
                double  maxPrestige = 0;
                foreach (Person p in soc.people)
                {
                    if (p.prestige > maxPrestige)
                    {
                        maxPrestige = p.prestige;
                    }
                }
                double prestige = unit.location.person().prestige;
                double scale    = 0;
                if (maxPrestige > 0)
                {
                    scale  = prestige / maxPrestige;
                    scale  = 1 - scale;//0 to 1, 1 if prestige is 0, 0 if prestige is MAX
                    scale *= 0.75;
                    scale += 0.25;
                }

                RelObj rel     = unit.location.settlement.title.heldBy.getRelation(unit.person);
                double maxGain = World.staticMap.param.unit_socialiseAtCourtGain;
                double delta   = maxGain * scale;
                delta = Math.Min(delta, 100 - rel.getLiking());
                if (delta < 0)
                {
                    delta = 0;
                }
                int iDelta = (int)(delta);

                rel.addLiking(iDelta, "Socialised at court", unit.location.map.turn);
                if (unit.isEnthralled())
                {
                    unit.location.map.world.prefabStore.popImgMsg(unit.getName() + " finishes socialising at court. " + unit.location.settlement.title.heldBy.getFullName() + "'s liking "
                                                                  + "for them increases by " + iDelta + " and is now " + ((int)rel.getLiking()), unit.location.map.world.wordStore.lookup("ABILITY_UNIT_SOCIALISE_AT_COURT"));
                }
                unit.task = null;
            }
        }
        public void combatAction(Unit u, Unit u2, Location loc)
        {
            if (u is Unit_Merchant && (u.isEnthralled() == false))
            {
                return;
            }
            if (u.isMilitary == false && u2.isMilitary == false && u.isEnthralled() && u2.society == loc.soc)
            {
                //Enthralled attacking an agent in their homeland
                //Can be defended by military units locally stationned
                Unit defender = null;
                if (loc.settlement != null && loc.settlement.embeddedUnit != null)
                {
                    defender = loc.settlement.embeddedUnit;
                }
                foreach (Unit u3 in loc.units)
                {
                    if (u3.isMilitary && u3.society == u2.society)
                    {
                        defender = u3;
                    }
                }
                if (defender != null)
                {
                    loc.map.world.prefabStore.popMsg("You agent cannot attack " + u2.getName() + " as they are defended the military unit present (" + defender.getName() + ")");
                    u.movesTaken -= 1;
                    return;
                }
            }

            double lethality    = loc.map.param.combat_lethality;
            double lethalityDef = loc.map.param.combat_lethalityDefensive;

            bool hadAttackBonus = false;

            foreach (Unit bonusU in u.location.units)
            {
                if (bonusU.society == u.society && bonusU is Unit_Investigator && bonusU.task is Task_SupportMilitary)
                {
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.knight)
                    {
                        lethality     *= param.unit_knightCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.basic)
                    {
                        lethality     *= param.unit_agentCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                }
            }
            foreach (Unit bonusU in u2.location.units)
            {
                if (bonusU.society == u2.society && bonusU is Unit_Investigator && bonusU.task is Task_SupportMilitary)
                {
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.knight)
                    {
                        lethalityDef  *= param.unit_knightCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.basic)
                    {
                        lethalityDef  *= param.unit_agentCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                }
            }

            if (burnInComplete)
            {
                world.prefabStore.particleCombat(u.location.hex, u2.location.hex);
            }
            int dmgDone = (int)(u.hp * (lethality + (Eleven.random.NextDouble() * lethality)));

            if (u2.isMilitary)
            {
                if (loc.settlement != null && loc.settlement.defensiveStrengthCurrent > 0 && u2.society == loc.soc)
                {
                    double ablated = Math.Min(loc.settlement.defensiveStrengthCurrent, dmgDone / 2d);
                    dmgDone -= (int)ablated;
                    loc.settlement.defensiveStrengthCurrent -= ablated;
                }

                int dmgReplied = (int)(u2.hp * (lethalityDef + (Eleven.random.NextDouble() * lethalityDef)));
                if (dmgReplied >= u.hp)
                {
                    dmgReplied = u.hp - 1;
                    if (dmgReplied < 0)
                    {
                        dmgReplied = 0;
                    }
                }
                u.hp -= dmgReplied;
            }


            if (dmgDone < 1)
            {
                dmgDone = 1;
            }

            bool kicked = false;

            if (dmgDone > 1 && (u2.isMilitary == false))
            {
                dmgDone = 1; kicked = true;
            }


            u2.hp -= dmgDone;
            if (u2.isEnthralled())
            {
                world.prefabStore.popMsgAgent(u, u2, u.getName() + " attacks " + u2.getName() + ", inflicting " + dmgDone + " HP damage!");
                //world.prefabStore.popMsg(u.getName() + " attacks " + u2.getName() + ", inflicting " + dmgDone + " HP damage!");
            }
            if (u.isEnthralled() && u2 is Unit_Investigator && u.person != null && u2.person != null)
            {
                u2.person.getRelation(u.person).suspicion = 1;
            }
            if (u.hp <= 0)
            {
                u.die(this, "Took damage attacking " + u2.getName());
            }

            if (u2.hp <= 0)
            {
                u2.die(this, "Attacked by " + u.getName());
            }
            else if (kicked)
            {
                int      c        = 0;
                Location kickedTo = null;
                foreach (Location l2 in u2.location.getNeighbours())
                {
                    bool bad = false;
                    foreach (Unit u3 in l2.units)
                    {
                        if (u3.hostileTo(u2) || u2.hostileTo(u3))
                        {
                            bad = true; break;
                        }
                    }
                    if (!bad)
                    {
                        c += 1;
                        if (Eleven.random.Next(c) == 0)
                        {
                            kickedTo = l2;
                        }
                    }
                }
                if (kickedTo != null)
                {
                    u2.task = null;
                    adjacentMoveTo(u2, kickedTo);
                    if (u2.isEnthralled())
                    {
                        world.prefabStore.popMsgAgent(u, u2, u2.getName() + " is forced to retreat, and is now in " + u2.location.getName());
                        //world.prefabStore.popMsg(u2.getName() + " is forced to retreat, and is now in " + u2.location.getName());
                    }
                }
            }

            if (u.isMilitary && loc.settlement != null)
            {
                //if (loc.settlement is Set_City)
                //{
                //    Set_City city = (Set_City)loc.settlement;
                //    //city.infrastructure *= (int)((Eleven.random.NextDouble() * 0.25) + 0.7);//0.05 to 0.3 dmg
                //    city.population *= (int)((Eleven.random.NextDouble() * 0.25) + 0.7);//0.05 to 0.3 dmg
                //    //if (city.infrastructure < 1) { city.infrastructure = 1; }
                //    if (city.population < 1) { city.population = 1; }
                //}
                loc.settlement.takeAssault(u.society, loc.soc, dmgDone);
            }

            if (u.isMilitary && u2.isMilitary && u.society is Society && u2.society is Society)
            {
                Property.addProperty(this, loc, "Recent Human Battle");
            }
        }
Esempio n. 10
0
        public void setTo(Unit unit)
        {
            if (unit == null)
            {
                setToNull(); return;
            }

            title.text    = unit.getName();
            desc.text     = unit.getDesc();
            task.text     = unit.getTaskShort();
            taskDesc.text = unit.getTaskDesc();

            if (unit.person == null)
            {
                clearPerson();
            }
            else
            {
                personBack.sprite = unit.person.getImageBack();
                personMid.sprite  = unit.person.getImageMid();
                personFore.sprite = unit.person.getImageFore();
                if (World.staticMap.param.option_useAdvancedGraphics == 1)
                {
                    Person p = unit.person;
                    if (p.isMale)
                    {
                        personMid.sprite      = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_faces[p.imgAdvFace];
                        personAdvEyes.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_eyes[p.imgAdvEyes];
                        personAdvMouth.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_mouths[p.imgAdvMouth];
                        personAdvHair.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_hair[p.imgAdvHair];
                        personAdvJewel.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_jewels[p.imgAdvJewel];
                    }
                    else
                    {
                        personMid.sprite      = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_faces[p.imgAdvFace];
                        personAdvEyes.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_eyes[p.imgAdvEyes];
                        personAdvMouth.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_mouths[p.imgAdvMouth];
                        personAdvHair.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_hair[p.imgAdvHair];
                        personAdvJewel.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_jewels[p.imgAdvJewel];
                    }
                    personFore.sprite = p.getImageFore();
                }
                else
                {
                    personAdvEyes.sprite  = world.textureStore.person_advClear;
                    personAdvMouth.sprite = world.textureStore.person_advClear;
                    personAdvHair.sprite  = world.textureStore.person_advClear;
                    personAdvJewel.sprite = world.textureStore.person_advClear;
                }

                personFore.color = Color.white;
            }

            if (unit.isEnthralled())
            {
                if (unit.movesTaken == 0)
                {
                    hasMoved.text = "Can Move";
                }
                else
                {
                    hasMoved.text = "Has Taken Turn";
                }
            }
            else
            {
                hasMoved.text = "Not an Enthralled Agent";
            }

            nationText.text = unit.society.getName();
            if (unit.parentLocation != null)
            {
                nationText.text += "\nFrom " + unit.parentLocation.getName();
            }
            nationFlag1.color = unit.society.color;
            nationFlag2.color = unit.society.color2;


            specialDesc.text  = unit.specialInfoLong();
            specialText.color = unit.specialInfoColour();
            specialText.text  = unit.specialInfo();
        }
Esempio n. 11
0
        public void bActions()
        {
            if (world.turnLock)
            {
                return;
            }
            if (blocker != null)
            {
                return;
            }

            world.audioStore.playClick();
            if (state == uiState.WORLD)
            {
                if (GraphicalMap.selectedSelectable != null && GraphicalMap.selectedSelectable is Unit)
                {
                    Unit u = (Unit)GraphicalMap.selectedSelectable;
                    if (u.isEnthralled())
                    {
                        List <Ability> abilities   = world.map.overmind.getAvailableAbilities(u);
                        List <Ability> uncastables = new List <Ability>();
                        foreach (Ability a in u.abilities)
                        {
                            if (abilities.Contains(a) == false)
                            {
                                uncastables.Add(a);
                            }
                        }
                        if (abilities.Count + uncastables.Count > 0)
                        {
                            addBlocker(world.prefabStore.getScrollSet(abilities, uncastables, u).gameObject);
                        }
                    }
                    else
                    {
                        List <Ability> abilities   = world.map.overmind.getAvailableAbilities((Unit)GraphicalMap.selectedSelectable);
                        List <Ability> uncastables = new List <Ability>();
                        foreach (Ability a in world.map.overmind.abilities)
                        {
                            if (abilities.Contains(a) == false)
                            {
                                uncastables.Add(a);
                            }
                        }
                        addBlocker(world.prefabStore.getScrollSet(abilities, uncastables, (Unit)GraphicalMap.selectedSelectable).gameObject);
                    }
                }
                else
                {
                    if (GraphicalMap.selectedHex == null)
                    {
                        return;
                    }
                    List <Ability> abilities   = world.map.overmind.getAvailableAbilities(GraphicalMap.selectedHex);
                    List <Ability> uncastables = new List <Ability>();
                    foreach (Ability a in world.map.overmind.abilities)
                    {
                        if (abilities.Contains(a) == false)
                        {
                            uncastables.Add(a);
                        }
                    }
                    addBlocker(world.prefabStore.getScrollSet(abilities, uncastables, GraphicalMap.selectedHex).gameObject);
                }
            }
            else if (state == uiState.SOCIETY)
            {
                if (GraphicalSociety.focus == null)
                {
                    return;
                }
                List <Ability> abilities   = world.map.overmind.getAvailableAbilities(GraphicalSociety.focus);
                List <Ability> uncastables = new List <Ability>();
                foreach (Ability a in world.map.overmind.abilities)
                {
                    if (abilities.Contains(a) == false)
                    {
                        uncastables.Add(a);
                    }
                }
                addBlocker(world.prefabStore.getScrollSet(abilities, uncastables, GraphicalSociety.focus).gameObject);
            }
        }
        public override void turnTick(Unit unit)
        {
            //Enthralled can't just eat clues
            if (unit.isEnthralled())
            {
                unit.task = null;
                return;
            }

            if (unit.location.evidence.Count > 0)
            {
                Evidence massiveEvidence = null;
                foreach (Evidence ev in unit.location.evidence)
                {
                    if (ev.instaDiscover)
                    {
                        massiveEvidence = ev; break;
                    }
                }
                if (massiveEvidence != null)
                {
                    discoverMassiveEvidence(massiveEvidence, unit);
                    return;
                }

                dur += 1;
                if (dur >= unit.location.map.param.unit_investigateTime)
                {
                    Evidence ev = unit.location.evidence[0];
                    if (ev.pointsTo != null)
                    {
                        if (unit.person != null && ev.pointsTo.person != null)
                        {
                            unit.person.getRelation(ev.pointsTo.person).suspicion = System.Math.Min(1, unit.person.getRelation(ev.pointsTo.person).suspicion + ev.weight);
                        }
                        else
                        {
                            //Can't use suspicion system, go straight to murder
                            //Makes sense since they're probably non-human terrors
                            unit.hostility.Add(ev.pointsTo);
                        }

                        unit.location.map.addMessage(unit.getName() + " has found evidence from " + ev.pointsTo.getName(), MsgEvent.LEVEL_ORANGE, false, unit.location.hex);
                    }
                    else if (ev.pointsToPerson != null)
                    {
                        if (unit.person != null && ev.pointsToPerson != null)
                        {
                            unit.person.getRelation(ev.pointsToPerson).suspicion = System.Math.Min(1, unit.person.getRelation(ev.pointsToPerson).suspicion + ev.weight);
                        }

                        unit.location.map.addMessage(unit.getName() + " has found evidence from " + ev.pointsToPerson.getFullName(), MsgEvent.LEVEL_ORANGE, false, unit.location.hex);
                    }


                    if (unit is Unit_Investigator)
                    {
                        Unit_Investigator inv = (Unit_Investigator)unit;
                        inv.evidenceCarried.Add(ev);
                        ev.discoveredBy = inv;
                    }
                    ev.locationFound = unit.location;
                    unit.location.evidence.Remove(ev);
                    unit.task = null;

                    unit.location.map.overmind.panicFromCluesDiscovered += unit.location.map.param.panic_fromClueFound;
                    if (unit.location.map.overmind.panicFromCluesDiscovered > 1)
                    {
                        unit.location.map.overmind.panicFromCluesDiscovered = 1;
                    }


                    //If we're already at maximum suspicion we can now begin pursuing them
                    if (unit is Unit_Investigator)
                    {
                        Unit_Investigator inv = (Unit_Investigator)unit;
                        if (inv.state == Unit_Investigator.unitState.investigator)
                        {
                            if (ev.pointsTo != null && ev.pointsTo.person != null && inv.person.getRelation(ev.pointsTo.person).suspicion >= 1)
                            {
                                Task_HuntEnthralled_InvState task = new Task_HuntEnthralled_InvState(inv, ev.pointsTo);
                                inv.task = task;
                                unit.location.map.world.prefabStore.popMsgAgent(inv, ev.pointsTo,
                                                                                inv.getName() + " has found evidence left by " + ev.pointsTo.getName() + ", and because they are an investigator who is 100% suspicious of " + ev.pointsTo.getName()
                                                                                + ", is able to use these clues to determine the location of " + ev.pointsTo.getName() + ", and will begin to chase them for " + task.turnsLeft + " turns.");
                            }
                        }
                    }

                    if (unit.task == null)
                    {
                        if (unit.location.person() != null)
                        {
                            Person noble = unit.location.person();
                            foreach (RelObj rel in unit.person.relations.Values)
                            {
                                ////Goes negative if they suspect more than we do, reaches 1.0 if we suspect 1.0 and they suspect 0.0
                                // if ((rel.suspicion - noble.getRelation(rel.them).suspicion) > Eleven.random.NextDouble())
                                if ((rel.suspicion > noble.getRelation(rel.them).suspicion * 1.1))
                                {
                                    unit.task = new Task_ShareSuspicions();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                //Evidence gone. Probably eaten by someone else. Return to idle to retask next turn
                unit.task = null;
            }
        }