![]() |
|
#1
|
||||
|
||||
![]()
hey guys....im just building a mission, where i try to load submissions randomly into one main mission.
what i dont know how to achieve though is, how i can "destroy" ai planes if they have landed, and also vehicles or trains, when they have reached a certain waypoint.... i have attached the complete mission... there is one main mission, and 3 submissions which will be loaded randomly every 30seconds. the problem with it is, that the trains and vehicles will just stay on the map. i would like them to have destroyed when they reach their last waypoint.... in the script, there is a way to "destroy" planes after a certain time, but i would like to change it, that they will get destroyed after they have landed... (i know that this will happen automatically, but only after 10 minutes)i want that the planes are destroyed after maybe 30seconds when they have landed. Last edited by David198502; 04-24-2012 at 03:31 PM. |
#2
|
||||
|
||||
![]()
here is the script only...
|
#3
|
|||
|
|||
![]()
To remove landed, crashlanded AI-Planes or Groundactors after completing their task :
Code:
using System; using System.Collections; using System.Collections.Generic; using maddox.game; using maddox.game.world; public class Mission : AMission { public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; } public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftCrashLanded(missionNumber, shortName, aircraft); if(IsActorDestroyable(aircraft)) aircraft.Destroy(); } public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftLanded(missionNumber, shortName, aircraft); if (IsActorDestroyable(aircraft)) aircraft.Destroy(); } private bool IsActorDestroyable(AiActor actor) { bool actorDestroyable = true; //Check if actor is empty (no Player) if (actor is AiAircraft) { if ((actor as AiAircraft).ExistCabin(0)) for (int i = 0; i < (actor as AiAircraft).Places(); i++) { if ((actor as AiAircraft).Player(i) != null) { actorDestroyable = false; break; } } } else if (actor is AiGroundActor) { if ((actor as AiGroundActor).ExistCabin(0)) for (int i = 0; i < (actor as AiGroundActor).Places(); i++) { if ((actor as AiGroundActor).Player(i) != null) { actorDestroyable = false; break; } } } return actorDestroyable; } // to remove GroundActors after their Task is completed public override void OnActorTaskCompleted(int missionNumber, string shortName, AiActor actor) { base.OnActorTaskCompleted(missionNumber, shortName, actor); if (actor is AiGroundActor) if (IsActorDestroyable(actor)) (actor as AiGroundActor).Destroy(); } } |
#4
|
||||
|
||||
![]()
thx Kodiak...will try that, though im not sure how to implement that part into my already existing one
|
#5
|
||||
|
||||
![]()
ok the mission now works, so that the submissions will be loaded and also the planes are destroyed after they have landed.
but ground vehicles and trains just remain on the map after they have reached their last waypoint.how can i make it, that they achieve their "task"? HTML Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using maddox.game;
using maddox.game.world;
public class Mission : AMission
{
Stopwatch MissionTimer = new Stopwatch();
public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionTimer.Start();
MissionNumberListener = -1;
}
public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
if(IsActorDestroyable(aircraft))
aircraft.Destroy();
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
if (IsActorDestroyable(aircraft))
aircraft.Destroy();
}
private bool IsActorDestroyable(AiActor actor)
{
bool actorDestroyable = true;
//Check if actor is empty (no Player)
if (actor is AiAircraft)
{
if ((actor as AiAircraft).ExistCabin(0))
for (int i = 0; i < (actor as AiAircraft).Places(); i++)
{
if ((actor as AiAircraft).Player(i) != null)
{
actorDestroyable = false;
break;
}
}
}
else if (actor is AiGroundActor)
{
if ((actor as AiGroundActor).ExistCabin(0))
for (int i = 0; i < (actor as AiGroundActor).Places(); i++)
{
if ((actor as AiGroundActor).Player(i) != null)
{
actorDestroyable = false;
break;
}
}
}
return actorDestroyable;
}
// to remove GroundActors after their Task is completed
public override void OnActorTaskCompleted(int missionNumber, string shortName, AiActor actor)
{
base.OnActorTaskCompleted(missionNumber, shortName, actor);
if (actor is AiGroundActor)
if (IsActorDestroyable(actor))
(actor as AiGroundActor).Destroy();
}
public override void OnTickGame()
{
if(MissionTimer.Elapsed.TotalSeconds >= 30) //Loads a mission every 120s
{
Random ZufaelligeMission = new Random();
MissionTimer.Restart(); // Sets timer to 0 and start again
switch (ZufaelligeMission.Next(1,4))
{
case 1:
GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission3.mis");
break;
}
}
}
}
Last edited by David198502; 04-24-2012 at 04:56 PM. |
#6
|
|||
|
|||
![]()
Removing Ai-Planes after landing, should work (have tested it), but OnActorTaskCompleted seems to work not correctly. Must make more tests, but in next Patch it should be possible to get the current waypoint from an Actor so should be no problem to remove an Actor if it reached the last waypoint. But we must wait for the patch.
Code:
using System; using System.Collections.Generic; using System.Diagnostics; using maddox.game; using maddox.game.world; public class Mission : AMission { Stopwatch MissionTimer = new Stopwatch(); public override void OnBattleStarted() { base.OnBattleStarted(); MissionTimer.Start(); MissionNumberListener = -1; } public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftCrashLanded(missionNumber, shortName, aircraft); if(IsActorDestroyable(aircraft)) aircraft.Destroy(); } public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftLanded(missionNumber, shortName, aircraft); if (IsActorDestroyable(aircraft)) aircraft.Destroy(); } private bool IsActorDestroyable(AiActor actor) { bool actorDestroyable = true; //Check if actor is empty (no Player) if (actor is AiAircraft) { if ((actor as AiAircraft).ExistCabin(0)) for (int i = 0; i < (actor as AiAircraft).Places(); i++) { if ((actor as AiAircraft).Player(i) != null) { actorDestroyable = false; break; } } } else if (actor is AiGroundActor) { if ((actor as AiGroundActor).ExistCabin(0)) for (int i = 0; i < (actor as AiGroundActor).Places(); i++) { if ((actor as AiGroundActor).Player(i) != null) { actorDestroyable = false; break; } } } return actorDestroyable; } public override void OnTickGame() { if(MissionTimer.Elapsed.TotalSeconds >= 30) //Loads a mission every 120s { Random ZufaelligeMission = new Random(); MissionTimer.Restart(); // Sets timer to 0 and start again switch (ZufaelligeMission.Next(1,4)) { case 1: GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission1.mis"); break; case 2: GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission2.mis"); break; case 3: GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission3.mis"); break; } } } } |
![]() |
|
|