protected void setVobData(Process process, zCVob vob) { if (this.Visual != null && this.Visual.Length != 0) { vob.SetVisual(this.Visual); } setPosition(this.Position); setDirection(this.Direction); if (CDDyn) { vob.BitField1 |= (int)zCVob.BitFlag0.collDetectionDynamic; } else { vob.BitField1 &= ~(int)zCVob.BitFlag0.collDetectionDynamic; } if (CDStatic) { vob.BitField1 |= (int)zCVob.BitFlag0.collDetectionStatic; } else { vob.BitField1 &= ~(int)zCVob.BitFlag0.collDetectionStatic; } }
public override zCVob CreateVob(zCVob vob = null) { oCMob ret = (vob == null || !(vob is oCMob)) ? oCMob.Create() : (oCMob)vob; base.CreateVob(ret); return(ret); }
public static Int32 hook_Sound(String message) { try { int address = Convert.ToInt32(message); Process process = Process.ThisProcess(); zCSoundFX sound = new zCSoundFX(process, process.ReadInt(address + 4)); zCVob vob = new zCVob(process, process.ReadInt(address + 8)); int x = process.ReadInt(address + 12); zTSound3DParams param = new zTSound3DParams(process, process.ReadInt(address + 16)); //X => 0,1,2,8 2 => Gespräch, 0 => Ambient? z.B. TorchBourn if (x == 2 && vob.VobType == zCVob.VobTypes.Npc) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Vob: " + vob.VobType + " | " + vob.ObjectName.Value + " | " + x + " | ", 0, "Program.cs", 0); sound.testValues(1024); for (int i = 0; i < 8; i++) { int add = process.ReadInt(param.Address + (i * 4)); zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Param i)" + i + ": 0x" + add.ToString("X4"), 0, "Program.cs", 0); if (add != 0) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Param i)" + i + ": " + new zCVob(process, add).VobType, 0, "Program.cs", 0); } } } } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Error: " + ex.ToString(), 0, "Program.cs", 0); } return(0); }
public virtual void Spawn(String map, Vec3f position, Vec3f direction) { this.Map = map; this.Position = position; this.Direction = direction; spawned = true; if (this.Address != 0) { return; } if (this.Map != Player.Hero.Map) { return; } Process process = Process.ThisProcess(); zCVob gVob = zCVob.Create(process); gVob.VobType = zCVob.VobTypes.Vob; this.Address = gVob.Address; sWorld.SpawnedVobDict.Add(this.Address, this); setVobData(process, gVob); oCGame.Game(process).World.AddVob(gVob); }
void Update2nd1H() { if (!IsSpawned) { return; } ItemInst weapon; if ((weapon = GetEquipmentBySlot(NPCSlots.OneHanded2)) == null) { if (secondMeleeVob != null) { secondMeleeVob.BitField1 &= ~zCVob.BitFlag0.showVisual; } return; } if (secondMeleeVob == null) { secondMeleeVob = zCVob.Create(); GothicGlobals.Game.GetWorld().AddVob(secondMeleeVob); } secondMeleeVob.BitField1 |= zCVob.BitFlag0.showVisual; secondMeleeVob.SetVisual(weapon.ModelDef.Visual); BaseInst.gVob.GetTrafoModelNodeToWorld(oCNpc.NPCNodes.Sword, secondMeleeVob.TrafoObjToWorld); var pos = (Vec3f)secondMeleeVob.Position; secondMeleeVob.SetPositionWorld(pos.X, pos.Y, pos.Z); secondMeleeVob.TrafoObjToWorld.PostRotateY(15); secondMeleeVob.TrafoObjToWorld.PostRotateZ(5); }
public static oCMsgMovement Create(SubTypes type, zCVob vob) { int address = Process.CDECLCALL <IntArg>(0x764680, null); //_CreateInstance() //Konstruktor... Process.THISCALL <NullReturnCall>(address, 0x765930, (IntArg)(int)type, vob); return(new oCMsgMovement(address)); }
public static int PlaySound3D(string snd, zCVob vob, int arg, zTSound3DParams param) { int ret; using (zString z = zString.Create(snd)) ret = PlaySound3D(z, vob, arg, param); return(ret); }
public ActiveSound(int id, zTSound3DParams sndParams, SoundDefinition sfx, zCVob sndVob = null) { this.startTime = GameTime.Ticks; this.idPtr = id; this.sndParams = sndParams; this.sfx = sfx; this.sndVob = sndVob; }
public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client) { int vobID = 0, targetID = 0, effectLevel = 0, damage = 0, damageType = 0; bool isProjectile = false; String effect = ""; stream.Read(out vobID); stream.Read(out effect); stream.Read(out targetID); stream.Read(out effectLevel); stream.Read(out damage); stream.Read(out damageType); stream.Read(out isProjectile); Vob vob = null; sWorld.VobDict.TryGetValue(vobID, out vob); if (vob == null) { throw new Exception("Vob was not found: " + vobID); } Vob targetVob = null; if (vobID != 0) { sWorld.VobDict.TryGetValue(targetID, out targetVob); if (targetVob == null) { throw new Exception("Target-Vob was not found: " + vobID); } } if (vob.Address == 0 || !vob.IsSpawned) { return; } Process process = Process.ThisProcess(); zCVob gVob = new zCVob(process, vob.Address); zCVob gTargetVob = null; if (targetVob != null && targetVob.Address != 0 && targetVob.IsSpawned) { gTargetVob = new zCVob(process, targetVob.Address); } else { gTargetVob = new zCVob(process, 0); } using (zString str = zString.Create(process, effect)) oCVisualFX.CreateAndPlay(process, str, gVob, gTargetVob, effectLevel, damage, damageType, isProjectile ? 1 : 0); }
public static void destroyPlayerVob() { if (playerVob == null) { return; } oCGame.Game(Process.ThisProcess()).World.RemoveVob(playerVob); playerVob = null; }
/// <summary> Sets the trafo of the given vob </summary> public void SetMatrix(zCVob vob) { SetMatrix(vob.TrafoObjToWorld); /*bool movement = vob.IsInMovement; * if (!movement) vob.BeginMovement(); * * var obj = vob.CollObj; * SetMatrix(obj.NewTrafo); * obj.TrafoHintRotation = true; * * if (!movement) vob.EndMovement();*/ }
public override zCVob CreateVob(zCVob vob = null) { oCNpc ret = (vob == null || !(vob is oCNpc)) ? oCNpc.Create() : (oCNpc)vob; base.CreateVob(ret); ret.Instance = this.ID; ret.Name.Set(Name); ret.SetAdditionalVisuals(BodyMesh, BodyTex, 0, HeadMesh, HeadTex, 0, -1); ret.Guild = this.Guild; ret.TrueGuild = this.guild; return(ret); }
public static void setPosition(Vec3f pos) { if (playerVob == null) { return; } Process process = Process.ThisProcess(); zCVob vob = playerVob; vob.TrafoObjToWorld.setPosition(pos.Data); vob.SetPositionWorld(pos.Data); vob.TrafoObjToWorld.setPosition(pos.Data); }
public override zCVob CreateVob(zCVob vob = null) { oCItem ret = (vob == null || !(vob is oCItem)) ? oCItem.Create() : (oCItem)vob; base.CreateVob(ret); // vob.CreateVob ret.Amount = 1; ret.Instance = this.ID; //ret.ItemVisual.Set(Visual); //ret.Name.Set(Name); //ret.Material = (int)Material; return(ret); }
internal virtual void DeleteGVob() { // we are finished with this gothic object, decrease the reference counter int refCtr = gvob.refCtr - 1; gvob.refCtr = refCtr; // Free the gothic object if no references are left, otherwise gothic should free it if (refCtr <= 0) { gvob.Dispose(); } gvob = null; }
public virtual void Despawn() { spawned = false; if (this.Address == 0) { return; } Process process = Process.ThisProcess(); zCVob gVob = new zCVob(process, this.Address); oCGame.Game(process).World.RemoveVob(gVob); sWorld.SpawnedVobDict.Remove(this.Address); this.Address = 0; }
public void SetVisual(string visualName) { if (string.Equals(visual, visualName, StringComparison.OrdinalIgnoreCase)) { return; } this.render = true; this.visual = visualName; if (zenTree != null) { zenTree.ReleaseVobSubTree(); zenTree = null; } if (!string.IsNullOrWhiteSpace(visualName)) { if (visualName.EndsWith(".ZEN", StringComparison.OrdinalIgnoreCase)) { renderVob.SetVisual(new zCVisual(0)); Gothic.zCOption.ChangeDir(0xE); // world directory zenTree = rndrWorld.MergeVobSubTree(visualName); if (zenTree.Address != 0) { zenTree.AddRefVobSubtree(); rndrWorld.RemoveVobSubTree(zenTree); return; } else { Logger.LogWarning("Could not load " + visualName); zenTree = null; } } else { renderVob.SetVisual(zCVisual.LoadVisual(visualName)); return; } } renderVob.SetVisual(new zCVisual(0)); render = false; }
public override zCVob CreateVob(zCVob vob = null) { zCVob ret = vob == null?zCVob.Create() : vob; var visualName = this.ModelInstance.Visual; if (visualName.EndsWith(".ZEN")) { ret.SetVisual(new zCVisual(0)); ret.SetCollDetDyn(false); ret.SetCollDetStat(false); Gothic.zCOption.ChangeDir(0xE); // world directory var world = GothicGlobals.Game.GetWorld(); world.AddVob(ret); ret.SetPositionWorld(0, 0, 0); zCVob zenVob = world.MergeVobSubTree(visualName); if (zenVob.Address != 0) { zenVob.SetCollDetDyn(false); zenVob.SetCollDetStat(false); zenVob.SetPositionWorld(0, 0, 0); ret.TrafoObjToWorld.Set(zenVob.TrafoObjToWorld); zenVob.AddRefVobSubtree(); world.RemoveVobSubTree(zenVob); world.AddVobAsChild(zenVob, ret); world.RemoveVobSubTree(ret); } else { Log.Logger.LogWarning("Could not load " + visualName); } } else { zCVisual vis = zCVisual.LoadVisual(this.ModelInstance.Visual); ret.SetVisual(vis); } ret.SetCollDetDyn(CDDyn); ret.SetCollDetStat(CDStatic); return(ret); }
public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client) { destroyPlayerVob(); Process process = Process.ThisProcess(); playerVob = zCVob.Create(process); playerVob.VobType = zCVob.VobTypes.Vob; Vec3f pos = (Vec3f)oCNpc.Player(process).GetPositionArray(); pos.Y -= oCNpc.Player(process).BBox3D.Height / 2.0f; setPosition(pos); setDirection((Vec3f)oCNpc.Player(process).TrafoObjToWorld.getDirection() * -1.0f); oCGame.Game(process).World.AddVob(playerVob); oCGame.Game(process).AICamera.SetTarget(playerVob); }
public void setPosition(Vec3f pos) { this.Position = pos; if (this.Address == 0) { return; } if (this is NPCProto) { NPCProto proto = (NPCProto)this; if (proto.Animation == GUC.States.StartupState.StartJumpID) { return; } if ((proto.Animation == GUC.States.StartupState.TurnLeftID || proto.Animation == GUC.States.StartupState.TurnRightID) && proto.AnimationStartTime + 10000 * 1000 < Program.Now) { oCNpc npc = new oCNpc(Process.ThisProcess(), this.Address); npc.GetModel().StopAni(proto.Animation); proto.Animation = short.MaxValue; } } Process process = Process.ThisProcess(); zCVob vob = new zCVob(process, this.Address); vob.TrafoObjToWorld.setPosition(this.Position.Data); vob.SetPositionWorld(this.Position.Data); vob.TrafoObjToWorld.setPosition(this.Position.Data); }
public static Int32 OnUnTrigger(String message) { int address = Convert.ToInt32(message); Process process = Process.ThisProcess(); try { zCVob str = new zCVob(process, process.ReadInt(address + 4)); zCVob str2 = new zCVob(process, process.ReadInt(address + 8)); oCMobInter mobInter = new oCMobInter(process, process.ReadInt(address)); if (oCNpc.Player(process).Address == str2.Address) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "UnTrigger: " + mobInter.State + " | StateNum: " + mobInter.StateNum + " | " + mobInter.Rewind + " | " + str.Address + " | " + str2.Address + " | " + str + " | " + str2 + " | " + oCNpc.Player(process).FocusVob.Address, 0, "Program.cs", 0); if (!sWorld.SpawnedVobDict.ContainsKey(mobInter.Address)) { return(0); } MobInter mI = (MobInter)sWorld.SpawnedVobDict[mobInter.Address]; mI.State = 0; BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.MobInterMessage); stream.Write((byte)MobInterNetwork.OnUnTrigger); stream.Write(Player.Hero.ID); stream.Write(mI.ID); Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); } } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', ex.ToString(), 0, "hMobInter.cs", 0); } return(0); }
public abstract zCVob CreateVob(zCVob vob = null);
public void SetVisualFromVob(zCVob vob) { args.SetVisual(vob.Visual); }
public static oCMsgConversation Create(Process process, TConversationSubType conversationType, zCVob vob) { oCMsgConversation rVal = null; IntPtr address = process.Alloc(0x98); zCClassDef.ObjectCreated(process, address.ToInt32(), 0x00AB2980); //Konstruktor... process.THISCALL <NullReturnCall>((uint)address.ToInt32(), 0x0076A1E0, new CallValue[] { (IntArg)((int)conversationType), vob }); rVal = new oCMsgConversation(process, address.ToInt32()); return(rVal); }
public static int PlaySound3D(zString snd, zCVob vob, int arg, zTSound3DParams param) { return(Process.THISCALL <IntArg>(GetZSound(), 0x004F1060, snd, vob, new IntArg(arg), param)); }
public void Dispose() { renderVob?.Dispose(); renderVob = null; }
public static void Write(oSDamageDescriptor oDD, oCNpc victim) { if (!sWorld.SpawnedVobDict.ContainsKey(victim.Address)) { throw new Exception("Victim: " + victim.Address + " " + victim.Name.Value + " was not found!"); } Vob vicProto = sWorld.SpawnedVobDict[victim.Address]; Vob attProto = null; Vob weaponVob = null; BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.OnDamageMessage); zVec3 locHit = oDD.LocationHit; zVec3 dirFly = oDD.DirectionFly; zCVob attacker = oDD.AttackerNPC; int weaponMode = oDD.ModeWeapon; int spellID = oDD.SpellID; zString weapon = oDD.Weapon.ObjectName; byte sendFlags = 0; if (locHit.Address != 0) { sendFlags |= 1; } if (dirFly.Address != 0) { sendFlags |= 2; } if (attacker.Address != 0) { if (!sWorld.SpawnedVobDict.ContainsKey(attacker.Address)) { throw new Exception("Attacker: " + attacker.Address + " " + attacker.ObjectName.Value + " was not found!"); } attProto = sWorld.SpawnedVobDict[attacker.Address]; sendFlags |= 4; } if (weaponMode != 0) { sendFlags |= 8; } if (spellID > 100) { sendFlags |= 16; } if (oDD.Weapon.Address != 0) { if (!sWorld.SpawnedVobDict.ContainsKey(oDD.Weapon.Address)) { throw new Exception("Weapon: " + oDD.Weapon.Address + " " + oDD.Weapon.ObjectName.Value + " was not found!"); } weaponVob = sWorld.SpawnedVobDict[oDD.Weapon.Address]; sendFlags |= 32; } if (oDD.DamageType == oSDamageDescriptor.DamageTypes.DAM_FALL) { sendFlags |= 64; } stream.Write(vicProto.ID); stream.Write((byte)oDD.ModeDamage); stream.Write(sendFlags); if (locHit.Address != 0) { stream.Write(new Vec3f(locHit.X, locHit.Y, locHit.Z)); } if (dirFly.Address != 0) { stream.Write(new Vec3f(dirFly.X, dirFly.Y, dirFly.Z)); } if (attacker.Address != 0) { stream.Write(attProto.ID); } if (weaponMode != 0) { stream.Write(weaponMode); } if (spellID > 100) { stream.Write(spellID); } if (oDD.Weapon.Address != 0) { stream.Write(weaponVob.ID); } if ((sendFlags & 64) == 64) { stream.Write(victim.HumanAI.FallDownDistanceY); } Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); }
internal virtual void CreateGVob() { this.gvob = this.instance.CreateVob(); }
public void OnMessage(zCEventMessage eventMessage, zCVob vob) { Process.THISCALL <NullReturnCall>(Address, FuncAddresses.OnMessage, eventMessage, vob); }
public static void setDirection(Vec3f dir) { if (playerVob == null) { return; } dir = dir.normalise(); Process process = Process.ThisProcess(); zCVob vob = playerVob; Vec3f zAxis = dir; Vec3f up = new Vec3f(0.0f, 0.0f, 0.0f); if (Math.Abs(zAxis.Y) > 0.5) { if (zAxis.Y > 0) { up.Z = -1.0f; } else { up.Z = 1.0f; } } else if (Math.Abs(zAxis.X) < 0.0001 && Math.Abs(zAxis.Y) < 0.0001) { if (zAxis.Y > -0.0001) { up.Y = 1.0f; } else { up.Y = -1.0f; } } else { up.Y = 1.0f; } Vec3f xAxis = up.cross(zAxis).normalise(); Vec3f yAxis = zAxis.cross(xAxis).normalise(); Matrix4 trafo = vob.TrafoObjToWorld; trafo.set(12, 0); trafo.set(13, 0); trafo.set(14, 0); trafo.set(15, 1); trafo.set(0, xAxis.X); trafo.set(4, xAxis.Y); trafo.set(8, xAxis.Z); trafo.set(1, yAxis.X); trafo.set(5, yAxis.Y); trafo.set(9, yAxis.Z); trafo.set(2, zAxis.X); trafo.set(6, zAxis.Y); trafo.set(10, zAxis.Z); zVec3 p = vob.GetPosition(); vob.SetPositionWorld(p); p.Dispose(); }