Beispiel #1
0
        static void AdvanceAni(RegisterMemory mem)
        {
            var    gModel     = new zCModel(mem.EBX);
            var    gActiveAni = new zCModelAniActive(mem.ESI);
            string aniName    = gActiveAni.ModelAni.Name.ToString();

            if (World.Current.TryGetVobByAddress(gModel.Owner.Address, out Vob vob))
            {
                vob.Model.ForEachActiveAniPredicate(aa =>
                {
                    if (string.Equals(aa.AniJob.Name, aniName, StringComparison.OrdinalIgnoreCase))
                    {
                        // guc ani
                        if (!aa.IsIdleAni)
                        {
                            float startFrame = aa.Ani.StartFrame;
                            float endFrame   = aa.Ani.EndFrame;

                            float percent = gActiveAni.ModelAni.IsReversed ? (1 - aa.GetProgress()) : aa.GetProgress();

                            float actFrame = startFrame + (endFrame - startFrame) * percent;
                            gActiveAni.SetActFrame(actFrame);
                        }
                        return(false);
                    }
                    return(true);
                });
            }
        }
        public static Int32 oCStartAnim_ModelAnim(String message)
        {
            int     address = Convert.ToInt32(message);
            Process process = Process.ThisProcess();
            int     err     = 0;

            try
            {
                err = 1;
                zCModel thisModel = new zCModel(process, process.ReadInt(address));
                err = 2;
                int ownerAddress = thisModel.Owner.Address;
                err = 3;
                if (!sWorld.SpawnedVobDict.ContainsKey(ownerAddress))
                {
                    return(0);
                }
                Vob v = sWorld.SpawnedVobDict[ownerAddress];
                if (!(v is NPCProto))
                {
                    return(0);
                }

                NPCProto player = (NPCProto)v;
                if (player == null)
                {
                    return(0);
                }

                if (player != Player.Hero)
                {
                    return(0);
                }

                zCModelAni modelAni = new zCModelAni(process, process.ReadInt(address + 4));
                if (modelAni == null || modelAni.Address == 0)
                {
                    return(0);
                }



                int aniID = modelAni.GetAniID();
                //String name = modelAni.AniName.Value.Trim();//Works
                if (player.Animation == aniID)
                {
                    return(0);
                }

                player.Animation = (short)aniID;
                AnimationUpdateMessage.Write(player);
            }
            catch (Exception ex)
            {
                zERROR.GetZErr(process).Report(2, 'G', err + "Exception: " + ex.Message + " " + ex.StackTrace + " " + ex.Source, 0, "Program.cs", 0);
            }


            return(0);
        }
Beispiel #3
0
        partial void pAfterDespawn()
        {
            this.inventory.ForEach(item =>
            {
                if (item.gVob != null)
                {
                    item.DeleteGVob();
                }
            });

            this.humanAI = null;
            this.gmodel  = null;
        }
Beispiel #4
0
        /// <summary> Spawns the NPC in the given world at the given position & direction. </summary>
        public override void Spawn(World world, Vec3f position, Angles angles)
        {
            base.Spawn(world, position, angles);

            gVob.HP    = this.hp;
            gVob.HPMax = this.hpmax;

            gVob.InitHumanAI();
            this.humanAI = gVob.HumanAI;
            this.gmodel  = gVob.GetModel();

            // do detect walk stop chasm
            humanAI.Bitfield0 &= ~zCAIPlayer.Flags.DetectWalkChasm; // some shitty flag which makes npcs always check their ground

            if (this.hp <= 0)
            {
                gModel.StartAnimation("S_DEAD");
            }
        }