![]() |
|
#1
|
|||
|
|||
![]()
Well, I've been messing around with changing spawn points for a while and I've got it mostly working except for one huge problem. The new spawn points don't update until I switch teams. For example, if I'm on red team and BirthPlace_1 switches to blue, I can still spawn there until I switch to blue and then back to red. I suspect it has something to do with the first mission still running after the second one is started, or the code isn't destroying BirthPlaces properly. It destroys "AiBirthPlaces". Do players use "AiBirthPlaces", or is that only for the AI. I saw no way to get a list of player "BirthPlaces".
Here's the code and the missions attached. If anybody sees any problems with it, please tell me. The spawn points and front lines will change sixty seconds after the mission starts. Code:
using System; using System.Collections; using maddox.game; using maddox.game.world; public class Mission : AMission { // MissionMarker class. Equivalent to "Front Markers" in FMB internal class MissionMarker { internal double x; //x coordinate internal double y; //y coordinate internal int army; //army that "owns" the marker. 1 is red. 2 is blue. internal MissionMarker(double x, double y, int army) { this.x = x; this.y = y; this.army = army; } } //create mission markers private MissionMarker[] MissionMarkers = new MissionMarker[] { new MissionMarker(12741, 16068, 1), new MissionMarker(17372, 11070, 1), new MissionMarker(23349, 23045, 2), new MissionMarker(29122, 22331, 2) }; //wheter or not markers have been initialized bool markersNotInitialized = true; public override void OnTickGame() { //if markers are not initialized, they won't show up on the player's map if (markersNotInitialized) { //just setting the markers army equal to it's current army for (int i = 0; i < MissionMarkers.Length; i++) GamePlay.gpPostMissionLoad(CreateNewFrontLineMission(i, MissionMarkers[i].army)); markersNotInitialized = false; } } internal ISectionFile CreateNewFrontLineMission(int markerNum, int newArmy) { //change the mission markers army to the new army MissionMarkers[markerNum].army = newArmy; //destroy all existing BirthPlaces/SpawnPoints, but only if the markers have been initialized if (!markersNotInitialized) { foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces()) { if (bp != null) bp.destroy(); } } //?? This must be the code that turns MissionMarkers into FrontMarkers ISectionFile f = GamePlay.gpCreateSectionFile(); string sect; string key; string value; sect = "FrontMarker"; for (int i = 0; i < MissionMarkers.Length; i++) { key = "FrontMarker" + i.ToString(); value = MissionMarkers[i].x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].army.ToString(); f.add(sect, key, value); } return f; } public override void OnTrigger(int missionNumber, string shortName, bool active) { //call base classes OnTrigger method. base.OnTrigger(missionNumber, shortName, active); //if the trigger that was called is the trigger that we're looking for if (shortName.Equals("trigger1") && active) { GamePlay.gpHUDLogCenter("Trigger1"); //change the mission marker at 0 to blue army GamePlay.gpPostMissionLoad(CreateNewFrontLineMission(0, 2)); //load new mission to change base ownership GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/triggerTest/changeBase.mis"); } //not sure what this does either. Do some action. From where? AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName)); if (action != null) action.Do(); } } |
#2
|
||||
|
||||
![]() Quote:
I suspect that BirthPlace has not much to do with creating planes, except as mean for UI making decision where it should show spawn points on map. Probably, we won't be able to handle this nicely until we get access to client UI (i.e. force refresh of UI). I don't think "Ai" is artificial intelligence in this case. Players should use AiBirthPlaces. Last edited by ZaltysZ; 05-18-2011 at 06:30 AM. |
#3
|
|||
|
|||
![]() Quote:
Code:
foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces()) { if (bp != null) bp.destroy(); } If we can change the frontline just by loading a new submission with moved frontline, why would we need the first part of the script defining the markers? I am a bit lost. I came to a simple practical idea to prevent spawning after AF is lost: 1) set trigger starting final an attack on the airfield only when all ground units on it are killed 2) load tanks attacking the af 3) load submission containing new forntline and new bp based on trigger (tanks reached af) 4) spawn arty and tanks to patrol the af. 5) anyone from the side that lost the af spawning on it is killed by arty or tanks and learns a lesson to check the frontline position before spawning. Not elegant but brutally practical. Did not have time to test it yet. Anyway we have to find out how to solve the issue in a more user-friendly way ...or ...isn't it a brutal military sim? Last edited by Ataros; 05-18-2011 at 09:30 AM. |
#4
|
|||
|
|||
![]() Quote:
Now that I think about it, I don't know what happens if I choose my army after the switch. It probably appears correctly then. Quote:
The reason that we can change spawn points by loading a new mission is because we can get all of the birthplaces and destroy them one by one, then let the ones in the new mission replace them. We can also create spawn points in code too, but I wanted to do that with a new mission because it was simpler. I'll try doing this tomorrow and see if it fixes my problem. |
#5
|
|||
|
|||
![]()
The method I used to delay the start of a flight is as follows. There could very well (and probably is) be a better way.
1. Create a trigger that fires after the desired amount of time in the FMB. 2. Create an action that spawns the aircraft you want in the FMB. 3. Put code like this in the script file. Specifically in the OnTrigger() method. Code:
public override void OnTrigger(int missionNumber, string shortName, bool active) { //call base classes OnTrigger method. base.OnTrigger(missionNumber, shortName, active); //if the trigger that was called is the trigger that we're looking for if (shortName.Equals("triggerName") && active) { AiAction action = GamePlay.gpGetAction("actionName")); if (action != null) action.Do(); } |
#6
|
|||
|
|||
![]() Quote:
Quote:
Later I think it will be possible to script removal of 1-2 af only. BTW the greatest solution would be to have bp side changed automatically if a submission loads new frontline leaving the bp to enemy! That would be an excellent piece of code! C# geniuses are called for help ![]() Quote:
![]() ![]() ![]() Where are you located? Last edited by Ataros; 05-18-2011 at 10:40 AM. |
#7
|
|||
|
|||
![]()
Attached my test mission.
Frontline moves in 1800 ticks then tanks clear the captured AF from remaining enemy arty. 2 spawnpoints are placed at the same spot. Do not work as intended yet iirc. |
#8
|
|||
|
|||
![]() Quote:
Quote:
![]() Salt Lake City, Utah, USA. Opposite side of the planet. ![]() |
#9
|
|||
|
|||
![]() Quote:
Actions are listed in the mission file not the script. A surprise of the month for me! lol |
#10
|
|||
|
|||
![]() Quote:
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|