예제 #1
0
        public override void onDisabled(ShapeBase obj, string lastState)
        {
            //console.print("### AI DEAD ###!");
            Player npc = obj.ID;

            Util.cancelAll(npc);
            ScriptObject aimanager = null;

            aimanager = npc["aiManager"];
            if (!aimanager.isObject())
            {
                console.error("Bad aiManager");
                return;
            }
            npc.setImageTarget(0, false);



            SimObject item = ((SimObject)npc.getMountedImage(iGlobal["$WeaponSlot"]))["item"];

            if (item.isObject())
            {
                //string item = console.GetVarString(ShapeBase.getMountedImage(npc, WeaponSlot).AsString() + ".item");
                if (r.Next(1, 100) > 80)
                {
                    int amount = npc.getInventory(item["image.ammo"]);

                    if (amount.AsBool())
                    {
                        npc.Throw(item["image.clip"], 1);
                    }
                }
            }

            npc.tossPatch();
            npc.playDeathCry();
            npc.playDeathAnimation();
            int ctov = 2000;

            if (AI.lastcount > 0)
            {
                AI.spawnAI(aimanager);
            }

            npc.schedule((ctov - 1000).AsString(), "startFade", "1000", "0", "true");
            Util._schedule("1", "0", "SafeDeleteCallback", npc);
        }