Example #1
0
        static public object Rit_SummonPet(Thea2.Server.Group target, RitualsTask sourceTask)
        {
            if (target != null && target.characters != null)
            {
                DBClass t = Globals.GetInstanceFromDB("ITEM_CARGO-WEAK_ONE_RANDOM_DOMESTIC_PET");
                if (t != null)
                {
                    Type tp = t.GetType();

                    if (tp == typeof(ItemCargo))
                    {
                        CountEntityBase ceb = ItemBase.InstantaiteFrom(t as ItemCargo);
                        target.AddItem(ceb);
                    }
                }
            }
            return(null);
        }
Example #2
0
        static public List <string> GroupGetModels(Thea2.Server.Group targetGroup)
        {
            if (targetGroup.settlement)
            {
                return(new List <string>()
                {
                    targetGroup.settlementModel
                });
            }

            List <string> actors = new List <string>();

            if (!World.IsLand(targetGroup.Position))
            {
                if (targetGroup.items != null)
                {
                    var             tag   = TAG.SHIP;
                    CountEntityBase ship  = null;
                    int             value = 0;
                    foreach (var v in targetGroup.items)
                    {
                        if (v.GetItem().attributes.Contains(tag))
                        {
                            if (ship == null)
                            {
                                ship = v;
                            }
                            else
                            {
                                ClientEntityItem it = new ClientEntityItem(v, false, true);
                                int newValue        = it.GetValue();

                                if (value == FInt.ZERO)
                                {
                                    it    = new ClientEntityItem(ship, false, true);
                                    value = it.GetValue();
                                }
                                if (value < newValue)
                                {
                                    value = newValue;
                                    ship  = v;
                                }
                            }
                        }
                    }

                    string graphic = null;
                    if (ship != null)
                    {
                        graphic = ship.GetItem().GetDescriptionInfo().iconName;
                    }
                    else
                    {
                        Tag  seaMp   = (Tag)TAG.SEA_MOVEMENT_RANGE;
                        bool canSwim = targetGroup.characters != null && targetGroup.characters.Count > 0;
                        foreach (var v in targetGroup.characters)
                        {
                            if (v.Get().attributes.GetFinal(seaMp) < FInt.ONE)
                            {
                                canSwim = false;
                                break;
                            }
                        }

                        if (!canSwim)
                        {
                            if (targetGroup.ownerID > 0)
                            {
                                graphic = "Raft";
                            }
                            else
                            {
                                graphic = "ShipPirate2";
                            }
                        }
                    }

                    //if some ship graphic have been assigned use it, otherwise fall back to normal unit graphics
                    if (graphic != null)
                    {
                        actors.Add(graphic);
                        return(actors);
                    }
                }
            }

            if (targetGroup.characters == null || targetGroup.characters.Count < 1)
            {
                actors.Add("GroundCargo");
            }
            else
            {
                List <EntityReference <Character> > sortedChars = new List <EntityReference <Character> >();
                sortedChars = new List <EntityReference <Character> >(targetGroup.characters);

                sortedChars.Sort(delegate(EntityReference <Character> a, EntityReference <Character> b)
                {
                    var A = a.Get().GetPowerLevel(false);
                    var B = b.Get().GetPowerLevel(false);
                    return(-A.CompareTo(B));
                });

                for (int i = 0; i < 3; i++)
                {
                    if (sortedChars.Count > i)
                    {
                        string s = sortedChars[i].Get().model;
                        if (s != null)
                        {
                            actors.Add(s);
                        }
                        else
                        {
                            actors.Add("");
                            Debug.LogError("[ERROR]Missing name for character model " + sortedChars[i].Get().subrace.dbName);
                        }
                    }
                }
            }

            return(actors);
        }