Rags707
25th Jun 04, 5:14 AM
Yes!!! I have an ear to ear grin on right now despite the lack of sleep.
My first thought was to make a Sob_Group out of all the players resourcers and have the mission wait till they were all docked before hypering, but that didn’t work out so good. Probably because I’m still new to this SCAR/LUA thingermabobber. Well that and the NIS, but we’ll discuss that later.
While browsing through the mission 1 lua to find out how they made the resource Sob work I found an interesting method used to invoke a cheat in the mission. I haven’t tried their cheat yet but I found the implementation really useful.
Basically I have modified mission 3 so that once all the objectives are completed, the player has to type:
J U M P
In order to trigger the final letterbox scene and auto hyper.
Now that I have a much better understanding of how the mission scripts work I intend to go through all of them and implement this method. Well not all the missions, some like mission one are ‘emergency’ hyperspaces and should probably be let alone. I’m just using a letterbox and text message which leads me to a question. Is there anyone who knows the # of the audio file where fleet command says something like “jump at your discretion”? I know I’ve heard that before, I’d really to play that clip along with the message.
I’ll post up somewhere for everyone to use the finished modified missions once they are complete, however if your interested in how it was done, I started by using the m03_staging.lua from Evillejedi's Awesome Data Files.
Step 1) Repair Broken Lua.
Apparently LuaDC makes these things go out of order a bit. I had to copy all the functions and place them above the Events in the file. OnInit() should be the very first function after the globals. File structure like so:
---------------------------------------------
globals
OnInit()
all other functions
Events = {}
event scripts
---------------------------------------------
Step 2) Add global variables. I add these 4 to track the key presses:
-- Added to allow players to type jump when ready to Hyperspace out of the mission
g_jpressed = 0
g_upressed = 0
g_mpressed = 0
g_ppressed = 0
Step 3) Modify function Rule_NISCompleted(). Comment out 1 and then add the following lines as shown. You can leave out the print, I just used a boat load of prints together with the –luatrace option to help me figure out what was going on. Many thanks to ZaTcH for telling me about that.
-- Event_Start("MissionWon")
print("========================== CALLING hyper bypass event MissionWonWait")
EventPlaying = 1
Event_Start("MissionWonWait")
Rule_AddInterval("Rule_PlayMissionWonWait", 1)
Step 4) Add new function rule. The lines below as shown:
function Rule_PlayMissionWonWait()
if Event_IsDone("MissionWonWait")==1 then
print("========================== Hyperspace now activated")
Rule_Add("Rule_HyperspaceActivate")
UI_BindKeyEvent(JKEY, "Rags_HyperJ")
UI_BindKeyEvent(UKEY, "Rags_HyperU")
UI_BindKeyEvent(MKEY, "Rags_HyperM")
UI_BindKeyEvent(PKEY, "Rags_HyperP")
Rule_Remove("Rule_PlayMissionWonWait")
end
end
I originally had these bind key commands in Rule_Init() as they are in mission 1, but it didn’t always work. Something to do with loading saves I think. I tried writing an OnStartOrLoad() function but that broke most everything else! I will investigate further and see what I can figure out.
Step 5) Add new functions. These are all related so I’ll list them in one block. All they do is increment or reset the global variables, and the last 3 are nearly a straight cut and paste.
function Rags_HyperJ()
if g_jpressed>1 then
g_jpressed = 0
g_upressed = 0
g_mpressed = 0
g_ppressed = 0
else
g_jpressed = ( g_jpressed + 1 )
end
end
function Rags_HyperU()
if g_jpressed==1 then
g_upressed = 1
end
end
function Rags_HyperM()
if g_jpressed==1 then
g_mpressed = 1
end
end
function Rags_HyperP()
if g_jpressed==1 then
g_ppressed = 1
end
end
Someone can probably tell me a better method for these, but the other ways I tried made it really difficult to get it to recognize that you had typed ‘jump’.
Step 6) Add new function Rule. This is the guy that does most of the work:
function Rule_HyperspaceActivate()
if g_jpressed==1 then
print("========================== J passed")
if g_upressed==1 then
print("========================== U passed")
if g_mpressed==1 then
print("========================== M passed")
if g_ppressed==1 then
print("========================== JUMP detected")
EventPlaying = 1
Event_Start("MissionWon")
Rule_Remove("Rule_HyperspaceActivate")
end
end
end
end
end
again feel free to leave out the prints, they were just for debugging.
Step 7) Finally the actual event where we tell the player about the new command. This event syntax is a real pain in my @$$. Took me a long time and many crashes to desktop to figure it out. I left the commented lines in because I think I’ll probably need them in other missions. They weren’t needed here because the Bentusi NIS event that plays right before this one doesn’t shut down letterbox or re-enable sound and stuff when it finishes. It wouldn’t surprise me if I’d had the code correct for some time before figuring out The previous event was messing it up:
Events.MissionWonWait =
{
{
{ "Sound_EnableAllSpeech(1)", "" },
-- { "Sound_EnterIntelEvent()", "" },
-- { "Universe_EnableSkip(1)", "" },
},
-- {
-- HW2_Letterbox(1),
-- HW2_Wait(2),
-- },
{
HW2_SubTitleEvent(Actor_FleetCommand, "De-select all ships and type { j u m p } to hyperspace", 5),
},
{
HW2_Wait(2),
},
{
HW2_Letterbox(0),
HW2_Wait(2),
{ "Universe_EnableSkip(0)", "" },
{ "Sound_ExitIntelEvent()", "" },
{ "EventPlaying = 0", "", },
},
}
Step 8) Go play the mission and enjoy freedom of hyperspace choice!
Again there is something not right with the save games. I’m almost positive if you wait until after the jump message then save, that when you reload that game you’ll be stuck in the mission for all eternity. Other than that it works pretty good.
The biggest hurdles I had doing this were lack of knowledge/experience with the SCAR when setting up the event, and the other mission events causing my event to fail. The functions stuff is pretty straight forward to me. I’m guessing that integrating these changes with the existing mission events will probably be the most challenging part.
Well that’s it. I hope you found this informative or at least somewhat amusing. Thank you for spending your time to read it.
Rags
P.S. I’m still looking for a working de-compiled scar_util.lua if anyone is willing to share. And the message number for the hyperspace fleet command audio.
My first thought was to make a Sob_Group out of all the players resourcers and have the mission wait till they were all docked before hypering, but that didn’t work out so good. Probably because I’m still new to this SCAR/LUA thingermabobber. Well that and the NIS, but we’ll discuss that later.
While browsing through the mission 1 lua to find out how they made the resource Sob work I found an interesting method used to invoke a cheat in the mission. I haven’t tried their cheat yet but I found the implementation really useful.
Basically I have modified mission 3 so that once all the objectives are completed, the player has to type:
J U M P
In order to trigger the final letterbox scene and auto hyper.
Now that I have a much better understanding of how the mission scripts work I intend to go through all of them and implement this method. Well not all the missions, some like mission one are ‘emergency’ hyperspaces and should probably be let alone. I’m just using a letterbox and text message which leads me to a question. Is there anyone who knows the # of the audio file where fleet command says something like “jump at your discretion”? I know I’ve heard that before, I’d really to play that clip along with the message.
I’ll post up somewhere for everyone to use the finished modified missions once they are complete, however if your interested in how it was done, I started by using the m03_staging.lua from Evillejedi's Awesome Data Files.
Step 1) Repair Broken Lua.
Apparently LuaDC makes these things go out of order a bit. I had to copy all the functions and place them above the Events in the file. OnInit() should be the very first function after the globals. File structure like so:
---------------------------------------------
globals
OnInit()
all other functions
Events = {}
event scripts
---------------------------------------------
Step 2) Add global variables. I add these 4 to track the key presses:
-- Added to allow players to type jump when ready to Hyperspace out of the mission
g_jpressed = 0
g_upressed = 0
g_mpressed = 0
g_ppressed = 0
Step 3) Modify function Rule_NISCompleted(). Comment out 1 and then add the following lines as shown. You can leave out the print, I just used a boat load of prints together with the –luatrace option to help me figure out what was going on. Many thanks to ZaTcH for telling me about that.
-- Event_Start("MissionWon")
print("========================== CALLING hyper bypass event MissionWonWait")
EventPlaying = 1
Event_Start("MissionWonWait")
Rule_AddInterval("Rule_PlayMissionWonWait", 1)
Step 4) Add new function rule. The lines below as shown:
function Rule_PlayMissionWonWait()
if Event_IsDone("MissionWonWait")==1 then
print("========================== Hyperspace now activated")
Rule_Add("Rule_HyperspaceActivate")
UI_BindKeyEvent(JKEY, "Rags_HyperJ")
UI_BindKeyEvent(UKEY, "Rags_HyperU")
UI_BindKeyEvent(MKEY, "Rags_HyperM")
UI_BindKeyEvent(PKEY, "Rags_HyperP")
Rule_Remove("Rule_PlayMissionWonWait")
end
end
I originally had these bind key commands in Rule_Init() as they are in mission 1, but it didn’t always work. Something to do with loading saves I think. I tried writing an OnStartOrLoad() function but that broke most everything else! I will investigate further and see what I can figure out.
Step 5) Add new functions. These are all related so I’ll list them in one block. All they do is increment or reset the global variables, and the last 3 are nearly a straight cut and paste.
function Rags_HyperJ()
if g_jpressed>1 then
g_jpressed = 0
g_upressed = 0
g_mpressed = 0
g_ppressed = 0
else
g_jpressed = ( g_jpressed + 1 )
end
end
function Rags_HyperU()
if g_jpressed==1 then
g_upressed = 1
end
end
function Rags_HyperM()
if g_jpressed==1 then
g_mpressed = 1
end
end
function Rags_HyperP()
if g_jpressed==1 then
g_ppressed = 1
end
end
Someone can probably tell me a better method for these, but the other ways I tried made it really difficult to get it to recognize that you had typed ‘jump’.
Step 6) Add new function Rule. This is the guy that does most of the work:
function Rule_HyperspaceActivate()
if g_jpressed==1 then
print("========================== J passed")
if g_upressed==1 then
print("========================== U passed")
if g_mpressed==1 then
print("========================== M passed")
if g_ppressed==1 then
print("========================== JUMP detected")
EventPlaying = 1
Event_Start("MissionWon")
Rule_Remove("Rule_HyperspaceActivate")
end
end
end
end
end
again feel free to leave out the prints, they were just for debugging.
Step 7) Finally the actual event where we tell the player about the new command. This event syntax is a real pain in my @$$. Took me a long time and many crashes to desktop to figure it out. I left the commented lines in because I think I’ll probably need them in other missions. They weren’t needed here because the Bentusi NIS event that plays right before this one doesn’t shut down letterbox or re-enable sound and stuff when it finishes. It wouldn’t surprise me if I’d had the code correct for some time before figuring out The previous event was messing it up:
Events.MissionWonWait =
{
{
{ "Sound_EnableAllSpeech(1)", "" },
-- { "Sound_EnterIntelEvent()", "" },
-- { "Universe_EnableSkip(1)", "" },
},
-- {
-- HW2_Letterbox(1),
-- HW2_Wait(2),
-- },
{
HW2_SubTitleEvent(Actor_FleetCommand, "De-select all ships and type { j u m p } to hyperspace", 5),
},
{
HW2_Wait(2),
},
{
HW2_Letterbox(0),
HW2_Wait(2),
{ "Universe_EnableSkip(0)", "" },
{ "Sound_ExitIntelEvent()", "" },
{ "EventPlaying = 0", "", },
},
}
Step 8) Go play the mission and enjoy freedom of hyperspace choice!
Again there is something not right with the save games. I’m almost positive if you wait until after the jump message then save, that when you reload that game you’ll be stuck in the mission for all eternity. Other than that it works pretty good.
The biggest hurdles I had doing this were lack of knowledge/experience with the SCAR when setting up the event, and the other mission events causing my event to fail. The functions stuff is pretty straight forward to me. I’m guessing that integrating these changes with the existing mission events will probably be the most challenging part.
Well that’s it. I hope you found this informative or at least somewhat amusing. Thank you for spending your time to read it.
Rags
P.S. I’m still looking for a working de-compiled scar_util.lua if anyone is willing to share. And the message number for the hyperspace fleet command audio.