![]() |
|
|
|
#1
|
||||
|
||||
|
ok i tried to combine your last script with the one where the same airgroup gets respawned everytime you shot a certain amount down....
doesnt work... PHP Code:
Last edited by David198502; 10-18-2011 at 07:54 PM. |
|
#2
|
|||
|
|||
|
Can i have the complete mission please?
|
|
#3
|
||||
|
||||
|
here it is...
it also would be great if the hurris of the main mission-could be destroyed after a while as well, but they should remain longer on the map then the He's...tried that by myself, but without luck, so i deleted the part again from the script. |
|
#4
|
|||
|
|||
|
FG28_Kodiak, it looks like PassThrough trigger works 2 times, when entering the zone and when exiting it. If there are several aircraft they can triger it several time as well. A solution is not to do any calculations or actions in onTrigger method but make them in some other method like OnTickGame if the trigger was active before. It looks like my mission works now with this workaround but it is not very convenient. If you have any advice I will be grateful.
The mission is here http://forum.1cpublishing.eu/showpos...1&postcount=10 Thanks again! |
|
#5
|
||||
|
||||
|
Evening Chaps,
got a strange problem using a TTime trigger that isn't firing while being called though a submission that is loaded via the GamePlay.gpPostMissionLoad function. If I load the mission by itself then the TTime trigger works fine. Apparently there's something within the main mission that seems to void a TTime trigger within a submission. I've read through the entire thread but since I'm a noob at coding, I haven't found anything that adresses the issue specifically. I'm sure most here will recognise the basic script. The Bold portion in the script below loads the submission: Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
public class Mission : AMission
{
AiAircraft PlayerPlane;
// destroys aircraft abandoned by a player.
private bool isAiControlledPlane (AiAircraft aircraft)
{
if (aircraft == null)
{
return false;
}
Player [] players = GamePlay.gpRemotePlayers ();
foreach (Player p in players)
{
if (p != null && (p.Place () is AiAircraft) && (p.Place () as AiAircraft) == aircraft)
{
return false;
}
}
return true;
}
private void destroyPlane (AiAircraft aircraft) {
if (aircraft != null) {
aircraft.Destroy ();
}
}
private void explodeFuelTank (AiAircraft aircraft)
{
if (aircraft != null)
{
aircraft.hitNamed (part.NamedDamageTypes.FuelTank0Exploded);
}
}
private void destroyAiControlledPlane (AiAircraft aircraft) {
if (isAiControlledPlane (aircraft)) {
destroyPlane (aircraft);
}
}
private void damageAiControlledPlane (AiActor actor) {
if (actor == null || !(actor is AiAircraft)) {
return;
}
AiAircraft aircraft = (actor as AiAircraft);
if (!isAiControlledPlane (aircraft)) {
return;
}
if (aircraft == null) {
return;
}
aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled);
aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled);
aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled);
aircraft.hitNamed (part.NamedDamageTypes.FuelPumpFailure);
int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
for (int i = 0; i < iNumOfEngines; i++)
{
aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}
/***Timeout (240, () =>
{explodeFuelTank (aircraft);}
);
* ***/
Timeout (300, () =>
{destroyPlane (aircraft);}
);
}
//////////////////////////////////////////
public override void OnPlaceLeave (Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave (player, actor, placeIndex);
Timeout (1, () =>
{damageAiControlledPlane (actor);}
);
}
public override void OnAircraftCrashLanded (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded (missionNumber, shortName, aircraft);
Timeout (300, () =>
{ destroyPlane(aircraft); }
);
}
public override void OnAircraftLanded (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}
/////////////////////////////////////////////////////////////////////////////
//Listen to events of every (sub)mission
public override void Init(maddox.game.ABattle battle, int missionNumber)
{
base.Init(battle, missionNumber);
MissionNumberListener = -1; //Listen to events of every mission
}
//////////////////////////////////////////////////////////////////////////////
// Loads random submissions
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
if ("trigger01".Equals(shortName) && active)
{
DoDamage();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
private void DoDamage()
{
PlayerPlane = (AiAircraft)GamePlay.gpPlayer().Place();
// Initial Mission - can be any type
Random RandomIncident = new Random();
switch (RandomIncident.Next(1, 13))
{
case 1:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB3.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB4.mis");
break;
case 5:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB5.mis");
break;
case 6:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
break;
case 7:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB7.mis");
break;
case 8:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB8.mis");
break;
case 9:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB9.mis");
break;
case 10:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB10.mis");
break;
case 11:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB11.mis");
break;
case 12:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB12.mis");
break;
}
}
public override void OnTickGame()
{
// loads the 1st sub-mission in 5 min and repeates it every 10 min.
if (Time.tickCounter() % 18000 == 9000) // 18000 = 10 min repeat. 9000 = 5 min delay.
// the 1st figure above must be always larger than 2nd!
{
Random RandomIncident = new Random();
// Fighter mission generation
switch (RandomIncident.Next(1, 7))
{
case 1:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB3.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB4.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB9.mis");
break;
case 5:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB11.mis");
break;
case 6:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB12.mis");
break;
}
}
// Loads Missions consecutively
if (Time.tickCounter() % 756000 == 1800) // 756000 = 420 (7 Hours) min repeat. 1800 = 1 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB7.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:01 am");
}
}
/* if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
}
if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
}
if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
}
if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
} */
}
}
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
using maddox.GP;
public class Mission : AMission
{
private const int All = -1;
private const int Allies = 1;
private const int Axis = 2;
public override void OnMissionLoaded(int missionNumber)
{
base.OnMissionLoaded(missionNumber);
}
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);
//Triggers for RAF actions
//Report Examples
//SendScreenMessageTo(Allies, "Message to Red");
//SendScreenMessageTo(Axis, "Message to Blue");
if ((shortName == "LW_Spawn_7A") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7A"); //TriggerName
if (action != null)
{
action.Do();
}
}
if ((shortName == "LW_Spawn_7B") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7B"); //TriggerName
if (action != null)
{
action.Do();
}
}
if ((shortName == "LW_Spawn_7C") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7C"); //TriggerName
if (action != null)
{
action.Do();
}
}
if ((shortName == "ALL_Radio_7A") && active)
{
AiAction action = GamePlay.gpGetAction("ALL_Radio_7A"); //TriggerName
SendScreenMessageTo(Allies, "CH reports heavy buildup rallying at AX-16 flying low. We're loosing contact.");
SendScreenMessageTo(Axis, "Bodo reports EG210 massing at AX-16. Low level Jabo to attack radar at AP-17 and AR-18.");
if (action != null)
{
action.Do();
}
}
if ((shortName == "LW_Radio_7A") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Radio_7A"); //TriggerName
SendScreenMessageTo(Axis, "Bodo reports EG210 now AR-16. Attacking AP-17 and AR-18 radar in 5 minutes.");
if (action != null)
{
action.Do();
}
}
if ((shortName == "GB_Radio_7A") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7A"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AP-17 Eastbourne is under attack!");
if (action != null)
{
action.Do();
}
}
if ((shortName == "GB_Radio_7B") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7B"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AR-18 Rye is under attack!");
if (action != null)
{
action.Do();
}
}
if ((shortName == "GB_Radio_7C") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7C"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AV-21 Dover is under attack!");
if (action != null)
{
action.Do();
}
}
if ((shortName == "GB_Radio_7D") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7C"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AS-22 Dunkirk is under attack!");
if (action != null)
{
action.Do();
}
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
private void SendScreenMessageTo(int army, string message)
{
if (army == All)
{
GamePlay.gpHUDLogCenter(message);
}
else
{
//Singleplayer (for Testing)
if (GamePlay.gpRemotePlayers() == null ||
GamePlay.gpRemotePlayers().Length <= 0)
{
if (GamePlay.gpPlayer() != null &&
GamePlay.gpPlayer().Army() == army)
{
GamePlay.gpHUDLogCenter(message);
}
}
else // Multiplayer
{
var playersInArmy = new List<Player>();
foreach (var player in GamePlay.gpRemotePlayers())
{
if (player.Army() == army)
{
playersInArmy.Add(player);
}
}
GamePlay.gpHUDLogCenter(playersInArmy.ToArray(), message);
}
}
}
}
I'd appreciate any help or suggestions. Danke schön Gromic
__________________
I5-750 @ 3,8GHz / MSI P55-GD65 / MSI GTX570 Twin Frozr II / 4x2GB G.Skill 1600MHz / Corsair TX650 PSU / RAID 0 2x640GB WD Black W7 Pro x64 SP1 / MS FFB2 +Saitek X45 / Freetrack + NP Clip Pro + PS3 Eye / Samsung BX2450 24" HDMI LED Last edited by Gromic; 02-03-2012 at 08:03 PM. Reason: Format Edit |
|
#6
|
||||
|
||||
|
Update
Been doing some "debugging" with a squadie who works in the field and now we're both scratching our heads. We've implimented a gpHUDLogCenter Message just to see if the triggers are actually meeting thier requirements. They definately are and this begs the question why those three flights aren't spawning. This has us both stumped. Code:
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
//base.OnTrigger(missionNumber, shortName, active);
{
GamePlay.gpHUDLogCenter(string.Format("Mission {0}, Name {1}, Active={2}", missionNumber, shortName, active));
}
//Triggers for RAF actions
//Report Examples
//SendScreenMessageTo(Allies, "Message to Red");
//SendScreenMessageTo(Axis, "Message to Blue");
if ((shortName == "LW_Spawn_7A") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7A"); //TriggerName
if (action != null)
{
GamePlay.gpHUDLogCenter(string.Format("We have action {0}", action.Name));
action.Do();
}
}
if ((shortName == "LW_Spawn_7B") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7B"); //TriggerName
if (action != null)
{
GamePlay.gpHUDLogCenter(string.Format("We have action {0}", action.Name));
action.Do();
}
}
if ((shortName == "LW_Spawn_7C") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7C"); //TriggerName
if (action != null)
{
GamePlay.gpHUDLogCenter(string.Format("We have action {0}", action.Name));
action.Do();
}
}
Frustrating to say the least.
__________________
I5-750 @ 3,8GHz / MSI P55-GD65 / MSI GTX570 Twin Frozr II / 4x2GB G.Skill 1600MHz / Corsair TX650 PSU / RAID 0 2x640GB WD Black W7 Pro x64 SP1 / MS FFB2 +Saitek X45 / Freetrack + NP Clip Pro + PS3 Eye / Samsung BX2450 24" HDMI LED |
|
#7
|
|||
|
|||
|
Have you tried compiling the whole cs, including the new loaded sub mis into one complete cs?
As it stands the triggers are a little buggy, especially as dedicated style hosting. I suspect the DS is simplified allowing for basic operation and missing many advanced ops awaiting final Dedicated proper to be created. I have been trying to get passthru triggers too work for players, proved to be quite difficult but have something semi functioning now. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|