Beispiel #1
0
 public void SetScale(Vec3f scale)
 {
     using (zVec3 vec = scale.CreateGVec())
     {
         thisVob.SetModelScale(vec);
     }
 }
Beispiel #2
0
        partial void pDespawn()
        {
            // check the level for hits
            //Vec3f currentPos = this.GetPosition();
            //Vec3f direction = (this.Destination - currentPos).Normalise();

            Vec3f startPos = this.BaseInst.StartPosition;                                                       // currentPos + direction * -100;
            Vec3f ray      = (Destination - startPos).Normalise() * (Destination.GetDistance(startPos) + 100f); //direction * 200;

            using (zVec3 zStart = startPos.CreateGVec())
                using (zVec3 zRay = ray.CreateGVec())
                {
                    var gWorld = GothicGlobals.Game.GetWorld();

                    const zCWorld.zTraceRay parm = zCWorld.zTraceRay.Ignore_Alpha | zCWorld.zTraceRay.Test_Water | zCWorld.zTraceRay.Return_POLY | zCWorld.zTraceRay.Ignore_NPC | zCWorld.zTraceRay.Ignore_Projectiles | zCWorld.zTraceRay.Ignore_Vob_No_Collision;
                    if (gWorld.TraceRayNearestHit(zStart, zRay, parm))
                    {
                        var poly = gWorld.Raytrace_FoundPoly;

                        SoundDefinition sfx;
                        if (poly.Address == 0)
                        {
                            sfx = sfx_wo_wo; // wood
                        }
                        else
                        {
                            switch (poly.Material.MatGroup)
                            {
                            default:
                            case 0: // undef
                            case 3: // wood
                                sfx = sfx_wo_wo;
                                break;

                            case 1: // metal
                                sfx = sfx_wo_me;
                                break;

                            case 2: // stone
                                sfx = sfx_wo_st;
                                break;

                            case 4: // earth
                                sfx = sfx_wo_ea;
                                break;

                            case 5: // water
                                sfx = sfx_wo_wa;
                                break;

                            case 6: // snow
                                sfx = sfx_wo_sa;
                                break;
                            }
                        }
                        SoundHandler.PlaySound3D(sfx, Destination);
                    }
                }
        }
Beispiel #3
0
        static bool CanSee(Vec3f start, Vec3f end, BaseVobInst target)
        {
            using (zVec3 zStart = start.CreateGVec())
                using (zVec3 zDir = (end - start).CreateGVec())
                {
                    var zWorld = GothicGlobals.Game.GetWorld();
                    if (zWorld.TraceRayFirstHit(zStart, zDir, zCWorld.zTraceRay.Ignore_Alpha | zCWorld.zTraceRay.Ignore_NPC | zCWorld.zTraceRay.Ignore_Vob_No_Collision))
                    {
                        return(zWorld.Raytrace_FoundVob.Address == target.BaseInst.gVob.Address);
                    }
                }

            return(true);
        }
Beispiel #4
0
        static void CalcRangedTrace(NPCInst npc, out Vec3f start, out Vec3f end)
        {
            Vec3f projStartPos;

            using (var matrix = Gothic.Types.zMat4.Create())
            {
                var weapon = npc.GetDrawnWeapon();
                var node   = (weapon == null || weapon.ItemType == ItemTypes.WepBow) ? oCNpc.NPCNodes.RightHand : oCNpc.NPCNodes.LeftHand;
                npc.BaseInst.gVob.GetTrafoModelNodeToWorld(node, matrix);
                projStartPos = (Vec3f)matrix.Position;
            }

            const zCWorld.zTraceRay traceType = zCWorld.zTraceRay.Ignore_Alpha | zCWorld.zTraceRay.Ignore_Projectiles | zCWorld.zTraceRay.Ignore_Vob_No_Collision | zCWorld.zTraceRay.Ignore_NPC;

            var camVob = GothicGlobals.Game.GetCameraVob();

            start = (Vec3f)camVob.Position;
            Vec3f ray = 500000f * (Vec3f)camVob.Direction;

            end = start + ray;

            using (var zStart = start.CreateGVec())
                using (var zRay = ray.CreateGVec())
                {
                    var gWorld = GothicGlobals.Game.GetWorld();

                    if (gWorld.TraceRayNearestHit(zStart, zRay, traceType))
                    {
                        end = (Vec3f)gWorld.Raytrace_FoundIntersection;
                    }

                    start = projStartPos;
                    ray   = end - start;

                    start.SetGVec(zStart);
                    ray.SetGVec(zRay);

                    if (gWorld.TraceRayNearestHit(zStart, zRay, traceType))
                    {
                        end = (Vec3f)gWorld.Raytrace_FoundIntersection;
                    }
                }
        }
Beispiel #5
0
        static void RequestShootAuto(NPCInst hero)
        {
            Vec3f start;

            using (var matrix = Gothic.Types.zMat4.Create())
            {
                var weapon = hero.GetDrawnWeapon();
                var node   = (weapon == null || weapon.ItemType == ItemTypes.WepBow) ? oCNpc.NPCNodes.RightHand : oCNpc.NPCNodes.LeftHand;
                hero.BaseInst.gVob.GetTrafoModelNodeToWorld(node, matrix);
                start = (Vec3f)matrix.Position;
            }

            const zCWorld.zTraceRay traceType = zCWorld.zTraceRay.Ignore_Alpha | zCWorld.zTraceRay.Ignore_Projectiles | zCWorld.zTraceRay.Ignore_Vob_No_Collision | zCWorld.zTraceRay.Ignore_NPC;

            NPCInst enemy = PlayerFocus.GetFocusNPC();
            Vec3f   dir   = enemy == null ? (Vec3f)hero.BaseInst.gVob.Direction : (enemy.GetPosition() - start).Normalise();
            Vec3f   ray   = 500000f * dir;

            Vec3f end;

            using (var zStart = start.CreateGVec())
                using (var zRay = ray.CreateGVec())
                {
                    var gWorld = GothicGlobals.Game.GetWorld();

                    if (gWorld.TraceRayNearestHit(zStart, zRay, traceType))
                    {
                        end = (Vec3f)gWorld.Raytrace_FoundIntersection;
                    }
                    else
                    {
                        end = start + ray;
                    }
                }

            NPCInst.Requests.Shoot(hero, start, end);
        }