public void ServerCmdcarUnmountObj(coGameConnection client, coPlayer obj) { obj.unmount(); obj.setControlObject(obj); TransformF ejectpos = obj.getTransform(); ejectpos += new TransformF(0, 0, 5); obj.setTransform(ejectpos); coVehicle mvehicle = obj["mVehicle"]; Point3F ejectvel = mvehicle.getVelocity(); ejectvel += new Point3F(0, 0, 10); ejectvel = ejectvel.vectorScale(((coSimDataBlock) (obj.getDataBlock()))["mass"].AsFloat()); obj.applyImpulse(ejectpos.MPosition, ejectvel); }
public void GameConnectionLoadOut(coGameConnection client, coPlayer player) { ShapeBaseClearWeaponCycle(player); ShapeBaseShapeBaseSetInventory(player, "Ryder", 1); ShapeBaseShapeBaseSetInventory(player, "RyderClip", ShapeBaseShapeBaseMaxInventory(player, "RyderClip")); ShapeBaseShapeBaseSetInventory(player, "RyderAmmo", ShapeBaseShapeBaseMaxInventory(player, "RyderAmmo")); ShapeBaseAddToWeaponCycle(player, "Ryder"); ShapeBaseShapeBaseSetInventory(player, "Lurker", 1); ShapeBaseShapeBaseSetInventory(player, "LurkerClip", ShapeBaseShapeBaseMaxInventory(player, "LurkerClip")); ShapeBaseShapeBaseSetInventory(player, "LurkerAmmo", ShapeBaseShapeBaseMaxInventory(player, "LurkerAmmo")); ShapeBaseAddToWeaponCycle(player, "Lurker"); ShapeBaseShapeBaseSetInventory(player, "LurkerGrenadeLauncher", 1); ShapeBaseShapeBaseSetInventory(player, "LurkerGrenadeAmmo", ShapeBaseShapeBaseMaxInventory(player, "LurkerGrenadeAmmo")); ShapeBaseAddToWeaponCycle(player, "LurkerGrenadeLauncher"); ShapeBaseShapeBaseSetInventory(player, "ProxMine", ShapeBaseShapeBaseMaxInventory(player, "ProxMine")); ShapeBaseAddToWeaponCycle(player, "ProxMine"); ShapeBaseShapeBaseSetInventory(player, "DeployableTurret", ShapeBaseShapeBaseMaxInventory(player, "DeployableTurret")); ShapeBaseAddToWeaponCycle(player, "DeployableTurret"); coSimDataBlock playerdatablock = player.getDataBlock(); string junk = playerdatablock["mainWeapon.image"]; if (junk == "") player.mountImage("LurkerWeaponImage", 0, true, ""); else player.mountImage(junk, 0, true, ""); //ShapeBase.mountImage(player, junk == "" ? junk : "LurkerWeaponImage", 0, true, ""); }
public TransformF PointInSpawnSphere(coPlayer objectToSpawn, coSpawnSphere spawnSphere) { bool spawnLocationFound = false; int attemptsToSpawn = 0; TransformF spherLocationP3F = new TransformF(); while (!spawnLocationFound && attemptsToSpawn < 5) { spherLocationP3F = spawnSphere.getTransform(); Random r = new Random(); float angleY = (float)tMath.mDegToRad((r.NextDouble() * 100) * tMath.M_2PI_F); float angleXZ = (float)tMath.mDegToRad((r.NextDouble() * 100) * tMath.M_2PI_F); int radius = spawnSphere["radius"].AsInt(); spherLocationP3F.MPosition.x += (float)(Math.Cos(angleY) * Math.Sin(angleXZ) * (r.Next(radius * -1, radius))); spherLocationP3F.MPosition.y += (float)(Math.Cos(angleXZ) * (r.Next(radius * -1, radius))); spawnLocationFound = true; // Now have to check that another object doesn't already exist at this spot. // Use the bounding box of the object to check if where we are about to spawn in is // clear. TransformF boundingboxsize = new TransformF(((coSimDataBlock)objectToSpawn.getDataBlock())["boundingBox"]); float searchRadius = boundingboxsize.MPosition.x; float boxSizeY = boundingboxsize.MPosition.y; if (boxSizeY > searchRadius) { searchRadius = boxSizeY; } List<UInt32> objectsfound = console.ContainerRadiusSearch(spherLocationP3F.MPosition, searchRadius, (UInt32)SceneObjectTypesAsUint.PlayerObjectType, false); if (objectsfound.Count > 0) spawnLocationFound = false; attemptsToSpawn++; } if (!spawnLocationFound) { spherLocationP3F = spawnSphere.getTransform(); console.warn("WARNING: Could not spawn player after 5 times"); } return spherLocationP3F; }
public void TeleporterTriggerTeleFrag(coSimDataBlock thisobj, coPlayer player, coTrigger exit) { // When a telefrag happens, there are two cases we have to consider. // The first case occurs when the player's bounding box is much larger than the exit location, // it is possible to have players colide even though a player is not within the bounds // of the trigger Because of this we first check a radius the size of a player's bounding // box around the exit location. // Get the bounding box of the player Point3F boundingBoxSize = new Point3F(((coPlayerData)player.getDataBlock())["boundingBox"]); float radius = boundingBoxSize.x; float boxSizeY = boundingBoxSize.y; float boxSizeZ = boundingBoxSize.z; // Use the largest dimention as the radius to check if (boxSizeY > radius) radius = boxSizeY; if (boxSizeZ > radius) radius = boxSizeZ; Point3F position = exit.getTransform().MPosition; // new TransformF(con.getTransform(exit)); uint mask = (uint)SceneObjectTypesAsUint.PlayerObjectType; // Check all objects within the found radius of the exit location, and telefrag // any players that meet the conditions. Dictionary<uint, float> r = console.initContainerRadiusSearch(position, radius, mask); foreach (coShapeBase objectNearExit in r.Keys.Where(objectNearExit => ((coShapeBase)objectNearExit).isMemberOfClass("Player")).Where(objectNearExit => objectNearExit.AsString() != player)) { ShapeBaseDamage(objectNearExit, player, exit.getTransform().MPosition, 10000, "Telefrag"); } // The second case occurs when the bounds of the trigger are much larger // than the bounding box of the player. (So multiple players can exist within the // same trigger). For this case we check all objects contained within the trigger // and telefrag all players. int objectsInExit = exit.getNumObjects(); // Loop through all objects in the teleporter exit // And kill any players for (int i = 0; i < objectsInExit; i++) { coShapeBase objectInTeleporter = console.Call(exit, "getObject", new[] { i.AsString() }); if (objectInTeleporter.isMemberOfClass("Player")) continue; // Avoid killing the player that is teleporting in the case of two // Teleporters near eachother. if (objectInTeleporter == player) continue; ShapeBaseDamage(objectInTeleporter, player, exit.getTransform().MPosition, 10000, "Telefrag"); } }