Useful feature: "Hostile Pause"

More
12 years 1 month ago #19178 by SRC
Hello All,

I'm learning to code in POG and am trying to implement in Bineshi's old Unleashed IWar-2 mod a function that will PAUSE game play on the first appearance of a "hostile" within the player ship's sensor range.

This has obvious utility for stepping away from the screen without manually pausing, and also could be useful for ambushes of factions which are already hostile, for example by lurking at a L-point. One could get on with one's life and come back to find the game PAUSEd just at the right time to spring an ambush and collect some cargo.


This fragment returns a Boolean variable whether there are hostiles within sensor range:

Set.IsEmpty(iSim.PlayerHostilesInRadius( iShip.MaxSensorRange( player_ship ), TM_Ship ) )

This is most of the way to my desired function, but I cannot discover how to invoke the Pause function. The config file binds a function called "Spaceflight.Pause" to a key, but when I try to call this (and I'm not sure of the syntax, arguments, etc, so I'm coding blind), the compile.bat cannot find a prototype for this function, and I don't know whether it is in any of the .h files that are released; it is presumably not in the header files in the "include" folder that comes with the Pog compiler.

Any help would be appreciated. This function might also be a helpful thing to add to TS or US for the same "wait until ambush" agenda.

It's a great game; thanks to all who have worked on it.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #17148 by cambragol
I don't know anything off hand, as I am relatively new to POG coding myself, but I do know that you can pause the game by playing a movie.

iGame.PlayMovieLooped( string url );

Will also loop a movie, which might serve the purpose you are looking for? The movie could just be short, looped flashing message: 'Hostiles Detected' or some such.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #17149 by SRC
Replied by SRC on topic Useful feature: "Hostile Pause"
Hi Cambragol,

That works, thanks! I'm testing the function now; will post the code in a followup message if it tests out.

There's something odd that I noticed right away, though. Right after launching from Lucrecia's Base, I hear the ominous music that typically signals hostiles within sensor range but not near enough to attack.

There are no red contacts, just the customary Act 0 blue contacts of the home base and the rem fighter, and the neutral contact of the racing drone, but when I activate the "Hostile Pause" function, the HUD annunciator immediately reports 5 hostile contacts and the "pause movie" launches.

Does this mean that there are some invisible hostile contacts lurking around Lucrecia's Base at all times?

While lingering in sight of the Blackeye L-Point to see if the Pause movie launches on the appearance of hostiles, the movie seems to launch just before a hostile shows up on the contact list.

I'll let it run for a while and post the code if it's working.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #17150 by SRC
Replied by SRC on topic Useful feature: "Hostile Pause"
It seems to work. And it always reports 5 hostiles in the vicinity of
Lucrecia's base, which accounts for the "threats near" music on launch
and the combat music on return. I don't know whether those 5 invisible
hostiles are part of Bineshi's mod or if they were there in the original.

Anway, here is the code, for whomever may be interested. This can be
inserted into the source/iUnleashed.pog file, which would then need
to be compiled:

A) This function toggles a property which is checked in a code addition to the main
"MonitorShips" task of Bineshi's Unleashed rev 9.4 mod:

// ****************************************************************************
// * HostilePauseToggle
// ****************************************************************************

HostilePauseToggle()
{
hship player_ship = iShip.FindPlayerShip();

if ( !Object.PropertyExists( player_ship, "hostile_pause_active" ) )
{
Object.AddBoolProperty( player_ship, "hostile_pause_active", true );
iHUD.Print( "FIRST HOSTILE ALARM ACTIVATED" );

}
else
{
if ( Object.BoolProperty( player_ship, "hostile_pause_active" ) == true )
{
Object.SetBoolProperty( player_ship, "hostile_pause_active", false );
iHUD.Print( "FIRST HOSTILE ALARM DEACTIVATED" );
}
else
{
Object.SetBoolProperty( player_ship, "hostile_pause_active", true );
iHUD.Print( "FIRST HOSTILE ALARM ACTIVATED" );

}
}

}


B) This code goes into the "MonitorShips" task to check for hostiles and pause play
on their first appearance:

first, some declarations in the beginning of the task:

set hostile_ships; // Hostile ships within player ship sensor range
list hostile_ships_list; // Hostile ships list

and the check itself, which I put near the beginning of the "polling event"

// Check for hostile pause execution

if ( Object.PropertyExists( player_ship, "hostile_pause_active" ) )
{
if ( Object.BoolProperty( player_ship, "hostile_pause_active" ) == true )
{
hostile_ships = iSim.PlayerHostilesInRadius( iShip.MaxSensorRange( player_ship ), TM_Ship );
hostile_ships_list = List.FromSet( hostile_ships );
number_ships = List.ItemCount( hostile_ships_list );

if ( number_ships > 0 )
{
iHUD.Print( "HOSTILES PRESENT WITHIN SENSOR RANGE" );
iHUD.Print( String.FormatInt( "THERE ARE %d HOSTILE SHIPS IN THE AREA", number_ships ) );

// Disable the alarm
Object.SetBoolProperty( player_ship, "hostile_pause_active", false );
iHUD.Print( "FIRST HOSTILE ALARM DEACTIVATED" );
// klugey substitute for the Spaceflight.Pause func

iGame.PlayMovieLooped( "movies/intro" );
}

}
}



This also needs to go into the early part of the .pog file

provides
HostilePauseToggle,


and

// Local functions ////////////////////////////////////////////////////////////

prototype HostilePauseToggle();

and

// ****************************************************************************
// * EnterSpace
// ****************************************************************************

EnterSpace()
{
.
.
.
Input.BindKey( "iUnleashed.HostilePauseToggle", "iUnleashed.HostilePauseToggle" );

and a KeyBinding is needed in the configs/default.ini file:

I used

; Toggle Hostile Pause
[iUnleashed.HostilePauseToggle]
Keyboard, P, SHIFT



I have a one other fiddle to the Unleashed mod which I'll put up later. Bineshi's
"TurretToggle" function activates and deactivates both the auto-turrets and the
point-defense turrets of the player ship "Pinguin". It would be nice to just turn
off the Autoturrets, so that the anti-missile point defense turrets remain active
when approaching a potential conflict situation.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #17151 by SRC
Replied by SRC on topic Useful feature: "Hostile Pause"
Also, the "uses" section at the beginning of the Pog file needs to
include

iGame

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #17152 by Tarcoon
Those five hostile targets around Lucretia's base seem to correspond with the five cubes at the shooting range for weapons test purposes.




There is no safe distance


There is no safe distance

Please Log in or Create an account to join the conversation.