Example #1
0
        public bool ItemDataOnPickUp(coItemData datablock, coItem item, coPlayer player, string amount)
        {
            int count = item["count"].AsInt();

            //string count = console.GetVarString(item + ".count");

            if (count == 0)
            {
                count = datablock["count"].AsInt();
                if (count == 0)
                {
                    if (datablock["maxInventory"] != "")
                    {
                        if (count != datablock["maxInventory"].AsInt())
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        count = 1;
                    }
                }
            }
            ShapeBaseShapeBaseIncInventory(player, (((coItemData)datablock).getName()), count);


            coGameConnection client = player["client"];

            if (client.isObject())
            {
                MessageClient(client, "MsgItemPickup", console.ColorEncode(@"\c0You picked up %1"), datablock["pickupName"]);
            }


            // If the item is a static respawn item, then go ahead and
            // respawn it, otherwise remove it from the world.
            // Anything not taken up by inventory is lost.

            if (item.isStatic())
            {
                item.call("respawn");
            }
            else
            {
                item.delete();
            }


            return(true);
        }
Example #2
0
        public string ShapeBaseTossPatch(coShapeBase thisobj)
        {
            if (!thisobj.isObject())
            {
                return(string.Empty);
            }

            coItem item = console.Call_Classname("ItemData", "CreateItem", new[] { "HealthKitPatch" });

            item["istemp"] = true.AsString();

            item["sourceObject"] = thisobj;
            item["static"]       = false.AsString();

            (( coSimSet)"MissionCleanup").pushToBack(item);

            Random r = new Random();

            Point3F vec = new Point3F(-1 + (float)r.NextDouble() * 2, -1 * (float)r.NextDouble() * 2, (float)r.NextDouble());

            vec = vec.vecotrScale(10);
            Point3F eye = thisobj.getEyeVector();
            float   dot = new Point3F("0 0 1 ").vectorDot(eye);

            if (dot < 0)
            {
                dot = -dot;
            }

            vec = vec + new Point3F("0 0 8").vecotrScale(1 - dot);
            vec = vec + thisobj.getVelocity();

            TransformF pos = new TransformF(thisobj.getWorldBox().minExtents);

            item.setTransform(pos);
            item.applyImpulse(pos.MPosition, vec);
            item.setCollisionTimeout(thisobj);

            item.call("schedulePop");

            return(item);
        }