public static void TestSpell(Session session, params string[] parameters) { uint templatid; float x, y, z; float friction; float electicity; try { templatid = Convert.ToUInt32(parameters[0]); x = float.Parse(parameters[1], CultureInfo.InvariantCulture.NumberFormat); y = float.Parse(parameters[2], CultureInfo.InvariantCulture.NumberFormat); z = float.Parse(parameters[3], CultureInfo.InvariantCulture.NumberFormat); friction = float.Parse(parameters[4], CultureInfo.InvariantCulture.NumberFormat); electicity = float.Parse(parameters[5], CultureInfo.InvariantCulture.NumberFormat); } catch (Exception) { ChatPacket.SendServerMessage(session, $"Invalid Spell Parameters", ChatMessageType.Broadcast); return; } AceVector3 velocity = new AceVector3(x, y, z); LandblockManager.AddObject(SpellObjectFactory.CreateSpell(templatid, session.Player.Location.InFrontOf(2.0f), velocity, friction, electicity)); }
/// <summary> /// Perfroms additional set up of the spell projectile based on the spell id or its derived type. /// </summary> /// <param name="spellId"></param> public void Setup(uint spellId) { Spell = new Server.Entity.Spell(spellId); SpellType = GetProjectileSpellType(spellId); InitPhysicsObj(); // Runtime changes to default state ReportCollisions = true; Missile = true; AlignPath = true; PathClipped = true; if (!Spell.Name.Equals("Rolling Death")) { Ethereal = false; } IgnoreCollisions = false; if (SpellType == ProjectileSpellType.Bolt || SpellType == ProjectileSpellType.Streak || SpellType == ProjectileSpellType.Arc || SpellType == ProjectileSpellType.Volley || SpellType == ProjectileSpellType.Blast || WeenieClassId == 7276 || WeenieClassId == 7277 || WeenieClassId == 7279 || WeenieClassId == 7280) { PhysicsObj.DefaultScript = ACE.Entity.Enum.PlayScript.ProjectileCollision; PhysicsObj.DefaultScriptIntensity = 1.0f; } // Some wall spells don't have scripted collisions if (WeenieClassId == 7278 || WeenieClassId == 7281 || WeenieClassId == 7282 || WeenieClassId == 23144) { ScriptedCollision = false; } AllowEdgeSlide = false; // No need to send an ObjScale of 1.0f over the wire since that is the default value if (ObjScale == 1.0f) { ObjScale = null; } if (SpellType == ProjectileSpellType.Ring) { ScriptedCollision = false; } // Whirling Blade spells get omega values and "align path" turned off which // creates the nice swirling animation if (WeenieClassId == 1636 || WeenieClassId == 7268 || WeenieClassId == 20979) { AlignPath = false; Omega = new AceVector3(12.56637f, 0f, 0f); } }
public static SetupModel ReadFromDat(DatReader datReader) { SetupModel m = new SetupModel(); m.ModelId = datReader.ReadUInt32(); m.TypeId = datReader.ReadUInt32(); if ((m.TypeId & 4) == 1) { m.Type4 = true; } else { m.Type4 = false; } if ((m.TypeId & 8) == 1) { m.Type8 = true; } else { m.Type8 = false; } // Get all the GraphicsObjects in this SetupModel. These are all the 01-types. uint numSubObjects = datReader.ReadUInt32(); for (int i = 0; i < numSubObjects; i++) { m.SubObjectIds.Add(datReader.ReadUInt32()); } if ((m.TypeId & 1) == 1) { for (int i = 0; i < numSubObjects; i++) { m.ObjectUnks.Add(datReader.ReadUInt32()); } } if ((m.TypeId & 2) == 1) { for (int i = 0; i < numSubObjects; i++) { m.ObjectScales.Add(new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle())); } } m.LT94Count = datReader.ReadInt32(); datReader.Offset += (9 * 4 * m.LT94Count); // skip over the LT94 Objects. Some sort of location/positional data. m.LT98Count = datReader.ReadInt32(); datReader.Offset += (9 * 4 * m.LT98Count); // skip over the LT98 Objects. Some other sort of location/positional data. int placementsCount = datReader.ReadInt32(); for (int i = 0; i < placementsCount; i++) { uint key = datReader.ReadUInt32(); // there is a frame for each SubObject datReader.Offset += m.SubObjectIds.Count * 7 * 4; // This is frame data. Vector3 + Quaternion. uint hookCount = datReader.ReadUInt32(); for (int j = 0; i < hookCount; j++) { // TODO: Handle this! HOWEVER, no objects appear to actually use this. At least none currently parsed as of 2017-03-29. } } int cylinderSphereCount = datReader.ReadInt32(); for (int i = 0; i < cylinderSphereCount; i++) { // Sphere is a Vector3 origin + float radius AceVector3 origin = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()); m.CylSpheres.Add(new CylSphere(origin, datReader.ReadSingle(), datReader.ReadSingle())); } int sphereCount = datReader.ReadInt32(); for (int i = 0; i < sphereCount; i++) { // Sphere is a Vector3 origin + float radius AceVector3 origin = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()); m.Spheres.Add(new CSphere(origin, datReader.ReadSingle())); } m.Height = datReader.ReadSingle(); m.Radius = datReader.ReadSingle(); m.StepDownHeight = datReader.ReadSingle(); m.StepUpHeight = datReader.ReadSingle(); m.SortingSphere = new CSphere(new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()), datReader.ReadSingle()); m.SelectionSphere = new CSphere(new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()), datReader.ReadSingle()); int lightCount = datReader.ReadInt32(); // Light is made up of a Int32 uknown, Frame (Vector3 + Quaternion), int32 RGBColor, float unknown, float uknown and int32 unknown datReader.Offset += 12 * 4 * lightCount; m.DefaultAnimation = datReader.ReadUInt32(); m.DefaultScript = datReader.ReadUInt32(); m.DefaultMotionTable = datReader.ReadUInt32(); m.DefaultSoundTable = datReader.ReadUInt32(); m.DefaultScriptTable = datReader.ReadUInt32(); return(m); }
public static WorldObject CreateSpell(uint templateId, Position position, AceVector3 velocity, float friction, float electicity) { ushort weenieClassId = 0; Spell spellId = 0; uint modelId = 0; uint soundTableId = 0; uint physicsTableId = 0; // todo: impletment more advanced templating. switch (templateId) { case 0: weenieClassId = 20974; spellId = Spell.FlameBolt; modelId = (uint)33555469; soundTableId = (uint)536870967; physicsTableId = (uint)872415237; break; case 1: weenieClassId = 7264; spellId = Spell.ForceBolt; modelId = (uint)33555443; soundTableId = (uint)536870971; physicsTableId = (uint)872415241; break; case 2: weenieClassId = 1635; spellId = Spell.LightningBolt; modelId = (uint)33555440; soundTableId = (uint)536870968; physicsTableId = (uint)872415239; break; case 3: weenieClassId = 1503; spellId = Spell.FrostBolt; modelId = (uint)33555444; soundTableId = (uint)536870966; physicsTableId = (uint)872415238; break; case 4: weenieClassId = 1636; spellId = Spell.WhirlingBlade; modelId = (uint)33555452; soundTableId = (uint)536870972; physicsTableId = (uint)872415240; break; } SpellLikeEffect mobj = new SpellLikeEffect(ObjectType.MissileWeapon, new ObjectGuid(CommonObjectFactory.DynamicObjectId, GuidType.None), "Spell", weenieClassId, ObjectDescriptionFlag.None, WeenieHeaderFlag.Spell, position, spellId, modelId, soundTableId, physicsTableId); mobj.PhysicsData.DefaultScript = (uint)Network.Enum.PlayScript.ProjectileCollision; mobj.PhysicsData.DefaultScriptIntensity = (float)1; mobj.PhysicsData.PhysicsDescriptionFlag = PhysicsDescriptionFlag.CSetup | PhysicsDescriptionFlag.Stable | PhysicsDescriptionFlag.Petable | PhysicsDescriptionFlag.Position | PhysicsDescriptionFlag.Velocity | PhysicsDescriptionFlag.Friction | PhysicsDescriptionFlag.Elasticity | PhysicsDescriptionFlag.DefaultScript | PhysicsDescriptionFlag.DefaultScriptIntensity; mobj.PhysicsData.Velocity = velocity; mobj.PhysicsData.Friction = (float)friction; mobj.PhysicsData.Elastcity = (float)electicity; mobj.PhysicsData.PhysicsState = PhysicsState.Spell; mobj.PlayerScript = PlayScript.Launch; return(mobj); }
public CylSphere(AceVector3 origin, float radius, float height) { this.Origin = origin; this.Radius = radius; this.Height = height; }
public CSphere(AceVector3 origin, float radius) { this.Origin = origin; this.Radius = radius; }
public static SetupModel ReadFromDat(uint fileId) { // Check the FileCache so we don't need to hit the FileSystem repeatedly if (DatManager.PortalDat.FileCache.ContainsKey(fileId)) { return((SetupModel)DatManager.PortalDat.FileCache[fileId]); } else { DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId); SetupModel m = new SetupModel(); m.ModelId = datReader.ReadUInt32(); m.Bitfield = datReader.ReadUInt32(); // Get all the GraphicsObjects in this SetupModel. These are all the 01-types. uint numParts = datReader.ReadUInt32(); for (int i = 0; i < numParts; i++) { m.Parts.Add(datReader.ReadUInt32()); } if ((m.Bitfield & 1) > 0) { for (int i = 0; i < numParts; i++) { m.ParentIndex.Add(datReader.ReadUInt32()); } } if ((m.Bitfield & 2) > 0) { for (int i = 0; i < numParts; i++) { m.DefaultScale.Add(new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle())); } } int numHoldingLocations = datReader.ReadInt32(); if (numHoldingLocations > 0) { for (int i = 0; i < numHoldingLocations; i++) { int key = datReader.ReadInt32(); m.HoldingLocations.Add(key, LocationType.Read(datReader)); } } int numConnectionPoints = datReader.ReadInt32(); if (numConnectionPoints > 0) { for (int i = 0; i < numConnectionPoints; i++) { int key = datReader.ReadInt32(); m.ConnectionPoints.Add(key, LocationType.Read(datReader)); } } int placementsCount = datReader.ReadInt32(); for (int i = 0; i < placementsCount; i++) { int key = datReader.ReadInt32(); // there is a frame for each Part m.PlacementFrames.Add(key, PlacementType.Read(m.Parts.Count, datReader)); } int cylinderSphereCount = datReader.ReadInt32(); for (int i = 0; i < cylinderSphereCount; i++) { // Sphere is a Vector3 origin + float radius AceVector3 origin = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()); m.CylSpheres.Add(new CylSphere(origin, datReader.ReadSingle(), datReader.ReadSingle())); } int sphereCount = datReader.ReadInt32(); for (int i = 0; i < sphereCount; i++) { // Sphere is a Vector3 origin + float radius AceVector3 origin = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()); m.Spheres.Add(new CSphere(origin, datReader.ReadSingle())); } m.Height = datReader.ReadSingle(); m.Radius = datReader.ReadSingle(); m.StepDownHeight = datReader.ReadSingle(); m.StepUpHeight = datReader.ReadSingle(); m.SortingSphere = new CSphere(new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()), datReader.ReadSingle()); m.SelectionSphere = new CSphere(new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle()), datReader.ReadSingle()); int numLights = datReader.ReadInt32(); if (numLights > 0) { for (int i = 0; i < numLights; i++) { int key = datReader.ReadInt32(); m.Lights.Add(key, LightInfo.Read(datReader)); } } m.DefaultAnimation = datReader.ReadUInt32(); m.DefaultScript = datReader.ReadUInt32(); m.DefaultMotionTable = datReader.ReadUInt32(); m.DefaultSoundTable = datReader.ReadUInt32(); m.DefaultScriptTable = datReader.ReadUInt32(); // Store this object in the FileCache DatManager.PortalDat.FileCache[fileId] = m; return(m); } }