Jump to content

Adding a Mission Requirement Before an Icon Pops Up On Radar/Map


KC702

Recommended Posts

A radar icon is displaying at the start of a new game. Essentially, I am looking to add a line to a cleo script which states:

(Do not show mission marker until missions "Fish in a barrel" and "Breaking the bank at Caligula's" complete)

 

1) Is this more complicated than adding a line to an existing script?

2) After searching through the opcode list, would this involve Declare_mission_flag - can_player_start_mission? Does anyone know what/if there is the opcode in sanny builder to add a mission requirement before a mission pops up on radar?

3) When plugging in a mission trigger requirement, how would one go about communicating that in a code the game understands? - For instance, does a script in cleo understand "Fish in a Barrel," or is there a directory which indicates "Fish in a Barrel" is represented by Mission_074_Complete = true

 

Alternatively, I know there are missions that are hidden behind the acquiring of an estate/asset (like the Abandoned Airfield). So, if the above is not possible/too complicated for a novice - would making the Icon pop up after CJ receives Madd Dogg's Crib as a save point be more viable?

 

If this is outside of the opcode list, I am shooting in the dark.

Any help or direction is appreciated.

Edited by KC702
verbiage
Link to comment
Share on other sites

Adding mission requirements in fairly easy, the hard part is adding a mission marker in a manner that won't duplicated the marker every time the save is loaded and re-saved, and retains the handle of the script so the marker can be removed later. Let's start with the easy part:

Decompile main.scm with Sanny Builder - the examples I'll show are using SB's default SA edit mode, with the option to Show Opcodes.

 

Search for "Fish in a Barrel" to find where the mission is defined.

DEFINE MISSION 87 AT @CASINO7          // Fish in a Barrel

 

Search for "MISSION 87" to find the sniffer script that launches the mission.

:CASINO_284
00D6: if 
0038:   $Casino_Total_Passed_Missions == 6 
004D: jump_if_false @CASINO_336 
0004: $ONMISSION = 1 
00BA: show_text_styled GXT 'CASINO7' time 1000 style 2  // Fish in a Barrel
0050: gosub @PSAVE1_3245 
0417: start_mission 87  // Fish in a Barrel

 

So, if $Casino_Total_Passed_Missions == 6 then the mission can start.
Search again for MISSION 87 to find:

//-------------Mission 87---------------
// Originally: Fish in a Barrel

 

Then scroll down until you find the segment that awards mission complete. Opcodes that set_latest_mission_passed, and/or award progress_made, are good clues that you have found the correct segment. (Coding may vary, especially in larger scripts.)
 

:CASINO7_319
0164: disable_marker $582 
0008: $Casino_Total_Passed_Missions += 1 
0318: set_latest_mission_passed 'CASINO7'  // Fish in a Barrel
0629: change_integer_stat 306 to 1 
0110: clear_player $PLAYER_CHAR wanted_level 
030C: progress_made = 1 
0051: return

 

Two detectible changes occur. Global variables are the standard detection strategy used in the game and are easy to work with. Stat changes for mission complete are usually specific to radio messages. Not all missions trigger radio messages. Stats need to be read before checking the condition. 

0008: $Casino_Total_Passed_Missions += 1 
0629: change_integer_stat 306 to 1

 

So, if $Casino_Total_Passed_Missions > 6 then Fish in a Barrel is complete.

 

Breaking the Bank... is flagged as complete in a very similar manner.

 

Edited by OrionSR
Link to comment
Share on other sites

2 hours ago, OrionSR said:

Decompile main.scm with Sanny Builder

Thank you again for the response. This was my first time diving in to the main.scm which helped make a lot more sense of where information comes from.

 

Breaking the Bank ended up being Mission 101 @ HEIST_9

So, I managed to find the sniffer and reward segment. 

 

sniffer

Spoiler
:HEIST_446
00D6: if and
0038: $Heist_Total_Passed_Missions == 5
0038: $1384 == 1
004D: goto_if_false @HEIST_546
00D6: if 
0038: $37 == 1
004D: goto_if_false @HEIST_530
0004: $ONMISSION = 1
00BA: print_big 'HEIST_9' time 1000 style 2
0050: gosub @PSAVE1_3405
0417: load_and_launch_mission 101 // Breaking the Bank at Caligula's
0002: goto @HEIST_546

 

reward

Spoiler
0008: $Heist_Total_Passed_Missions += 1
030C: player_made_progress 1
0318: register_mission_passed 'HEIST_9'
01E3: print_with_number_big 'M_PASSS' number 100000 time 5000 style 1
0109: add_score $PLAYER_CHAR value 100000
0998: award_player_mission_respect 100
0394: play_mission_passed_tune 1
0110: clear_wanted_level $PLAYER_CHAR
0395: clear_area 2444.772 655.0391 10.3874 radius 30.0 clear_particles 1
0004: $Croupier_Uniform_Available = 1
0629: set_int_stat 307 to 1
0051: return

 

 

thinking - 

If and
	$Casino_Total_Passed_Missions > 6
	$Heist_Total_Passed_Missions > 5

 

I was not able to add on to the .cs as I intended. The original is filled with "unknown directives" and will not compile long before it reaches my inserted code... which is strange because the script works great in game lol. So, I was wondering, can a cleo script act as a gatekeeper to another cleo script in the same folder? 

For instance, the below would be a separate .cs in the same cleo folder as mission script that adds the marker? 

Just throwing stuff out there, not even sure it is a thing lol

 

If and
	$Casino_Total_Passed_Missions > 6
	$Heist_Total_Passed_Missions > 5
Then
	goto (insert other script name)?
Else
	end
end

 

Link to comment
Share on other sites

30 minutes ago, KC702 said:

thinking - 

Good thinking.

 

30 minutes ago, KC702 said:

The original is filled with "unknown directives" and will not compile

It could be that the script is "locked" in a way that confuses Sanny. 
 

30 minutes ago, KC702 said:

I was wondering, can a cleo script act as a gatekeeper to another cleo script in the same folder? 

Yes. As you may have noticed, that's the way it's done with sniffer scripts and missions in main.scm.

To keep the other script from running automatically, change the file extension from .cs to .s.

Launching a .s script located in the cleo folder with a cleo script.

stream_custom_script  "Testing.s"  

 

See also, custom missions (.cm):

0A94: load_and_launch_custom_mission "missions\CustomMission1"

 

Edited by OrionSR
Link to comment
Share on other sites

7 hours ago, KC702 said:

This was my first time diving in to the main.scm which helped make a lot more sense of where information comes from.

keep swimming and try to learn the structure and the initiations/connections of each codes, labels or segments.. you will find fantastic stuff in there 🙂

 

talking about main.scm i created a simple content about the definitions of each segments.. you may check it out if you want 😉

 

 

  • Like 2
Link to comment
Share on other sites

10 hours ago, ArmanCan said:

check it out

That is awesome, thanks for sharing that~ Scrolling the mouse wheel through the main.scm seemed endless lol

 

17 hours ago, OrionSR said:

keep the other script from running automatically

I want to thank you again, finally managed to get the radar icon displaying to my liking. I did come across the problem you mentioned earlier regarding reloading of the mission marker after a load/save... that was fun to track down and play around with. Also, one of the scripts I wrote was so bad that it froze my comp up and had to hard reset lmao. But it is all good now!

  • Like 2
Link to comment
Share on other sites

Hello again,

In the heart of the original message, I find myself looking to edit yet another mission requirement - this one intertwined in the main story.

Prior to "End of the Line (1)" you are required to take over 35% gang territory

I have Story Mode 2.0 which lowers this to 30% (which I think takes priority?)

Due to Extended Gang Wars and Save Editing dozens of additional territories across the map - I wish to lower this even further.

 

I first tried editing the Story Mode 2.0 main.scm - changing the $Gang_Turf_Controlled > 31 to a > 8 seemed easy enough but was met with an abundance of flags that would not let me save/compile this edit.

I then utilized the lesson above to attempt my own .cs. There were numerous attempts - just posting this to show where my head is at...

Attempt:

Spoiler
{$CLEO .cs}
:TerritoryRequirement
03A4: name_thread 'TRTYREQ'

:TRTYREQ1
00D6: if 
0018: $RIOT_TOTAL_PASSED_MISSIONS > 1
004D: goto_if_false @TRTYREQ1
08E2: get_territory_under_control_percentage $GS_GANG_TURF_CONTROLLED
00D6: if 
0018: $GS_GANG_TURF_CONTROLLED > 8
004D: goto_if_false @TRTYREQ1
LOAD_AND_LAUNCH_MISSION_INTERNAL 110  // End of the Line (1)
TERMINATE_THIS_CUSTOM_SCRIPT

 

Most were met with an error on loading the game, but this one was met with an endless loading screen when booting up game... but hey I got to a full bar! lol

 

1) For some reason, when I attempt to make IF/THEN or IFAND/THEN scripts, I am unable to close them off with an "end" or any variation of end. This confuses me as even on the guide I read "end_custom_thread" (for .cs) or "end_thread" (for .cm) are used but they always pop up as an unrecognized directive. This is why I continued to close it off with terminate.

 

2) In the main.scm it includes the line 08E2: get_territory_under_control_percentage $GS_GANG_TURF_CONTROLLED. Am I correct in including this line in the script so it knows to look for a percentage?

 

3) I do think I am way off base with the load_and_launch as the script posted below shows all the requirement scripts in main.scm to start the mission. There are numerous boxes to check off for this mission, one of which I have no idea how to include in the code - that being the phone call CJ receives after controlling enough territory (in code below). Should I instead be pointing the finish line to the phone call instead of load_and_launch?

 

Below are the requirements for initiating the mission script

Spoiler
//This is if character walks on the blip without enough gang territory//
:MOB_LA2_537
0050: gosub @MOB_GF_3168
08E2: get_territory_under_control_percentage $GS_GANG_TURF_CONTROLLED
00D6: if 
002A: 31 >= $GS_GANG_TURF_CONTROLLED
004D: goto_if_false @MOB_LA2_583
00BC: print_now 'MORTURF' time 12000 flag 1 // ~s~You need to take over at least 20 gang territories around Los Santos.

:MOB_LA2_583
0002: goto @MOB_LA2_15

//This initiates the phone call when enough territory required//
:MOB_LA2_590
00D6: if 
0018: $RIOT_TOTAL_PASSED_MISSIONS > 1
004D: goto_if_false @MOB_LA2_756
08E2: get_territory_under_control_percentage $GS_GANG_TURF_CONTROLLED
00D6: if 
0018: $GS_GANG_TURF_CONTROLLED > 31
004D: goto_if_false @MOB_LA2_756
00D6: if 
0038: $1354 == 0
004D: goto_if_false @MOB_LA2_756
0004: $CELLPHONE_CALL_ID = 23
0050: gosub @MOB_GF_1087
00D6: if 
0038: $CALL_ANSWERED == 1
004D: goto_if_false @MOB_LA2_695
0050: gosub @CELLFON_60
0050: gosub @MOB_GF_3328

//This, I think, is what triggers when the phone call is answered//
:MOB_LA2_695
00D6: if 
0038: $CALL_ANSWERED == 1
004D: goto_if_false @MOB_LA2_742
0164: remove_blip $MARKER_SWEET_HOUSE
02A7: add_sprite_blip_for_contact_point $X_SWEET_HOUSE $Y_SWEET_HOUSE $Z_SWEET_HOUSE sprite $ICON_SWEET store_to $MARKER_SWEET_HOUSE
0004: $1354 = 1

 

Any guidance/help would be greatly appreciated. Thank you

Link to comment
Share on other sites

The easiest solution should be to change those to 31 values to something else, like 8.
 

//002A: 8 >= $GS_GANG_TURF_CONTROLLED
002A: 31 >= $GS_GANG_TURF_CONTROLLED
...
//0018: $GS_GANG_TURF_CONTROLLED > 31
0018: $GS_GANG_TURF_CONTROLLED > 8


Editing this part of the main.txt (anything before the first mission) can cause save compatibility issues unless the script remains exactly the same size. A change of 31 to 8 won't change the size. There shouldn't be a compiler error, even if you do change the overall size of the script. Can you re-compile the script with no modifications?

 

12 hours ago, KC702 said:

1) For some reason, when I attempt to make IF/THEN or IFAND/THEN scripts, I am unable to close them off with an "end" 

The 004D: goto_if_false command is closing the 00D6: IF construct. High-level constructs like IF..THEN..END get broken down into more primitive opcode commands. Try compiling a simple IF..THEN..END construct and then decompiling without using the source code to see how it looks as an SCM construct.

 

12 hours ago, KC702 said:

$GS_GANG_TURF_CONTROLLED. Am I correct in including this line in the script

Save this for later. If you can't get a modified main to recompile we can revisit this idea. The goal would be to set the appropriate flags and reset the markers or whatever else is needed for the RIOT script to launch the multi-part EoL mission. It can probably be done safely but this is a really complex mission strand. 

This is the part that triggers the mission. If you can't tweak main.scm, your script can set the appropriate flags.

 

:RIOT_372
00D6: if 
0038:   $1355 == 1 
004D: jump_if_false @RIOT_483 
00D6: if 
0038:   $1354 == 1 
004D: jump_if_false @RIOT_467 
00D6: if 
0038:   $Riot_Total_Passed_Missions == 2 
004D: jump_if_false @RIOT_460 
0004: $ONMISSION = 1 
00BA: show_text_styled GXT 'RIOT_4' time 1000 style 2  // End Of The Line
0050: gosub @PSAVE1_1320 
0417: start_mission 110  // End Of The Line (1)

 

See if this is enough for the mission to launch if you find the spot in front of Sweet's house. Does the marker need to be placed too?

0004: $1354 = 1 // $Cellphone_Call_ID = 23 recieved 
0004: $1355 = 1 // $Cellphone_Call_ID = 22 recieved
0004: Riot_Total_Passed_Missions = 2

 

Call ID 22: Sweet's call to take over turfs; "CJ, I been thinking. The city's big, but it ain't that big."
Call ID 23: Sweet calling, Big Smoke is found; "Carl, it's Sweet!. Hey wassup, you find Smoke?"

 

Edited by OrionSR
Link to comment
Share on other sites

4 hours ago, OrionSR said:

Can you re-compile the script with no modifications?

 

Glad I was not too far off base in thinking changing the 31 to another number would do the trick. If I can figure out the compiling roadblock would definitely like to take the easy route lol.

 

When I try to compile, both with and without any modification, it keeps jumping back to this line and tells me there is a parameter error. I add the "wait" lines suggested by SB but still a parameter error. This happens with both the main.scm right off the directory and the main.scm that is in the mod in modloader.

 

:HJ_2341
042D: convert_metres_to_feet_int $HJ_Stunt_Distance_Max_Int store_to ,$HJ_Stunt_Distance_Max_Int
042D: convert_metres_to_feet_int $HJ_Stunt_Height store_to ,$HJ_Stunt_Height
0302: print_with_4_numbers 'HJSTATF' numbers $HJ_Stunt_Distance_Max_Int $HJ_Stunt_Height $HJ_Stunt_Flips $HJ_Stunt_Rotation_Int time 5000 flag 5 // Distance: ~1~ft Height: ~1~ft Flips: ~1~ Rotation: ~1~|

error 0049

"Not enough actual parameters. Expected 2 params."

Edited by KC702
Link to comment
Share on other sites

6 hours ago, KC702 said:

"Not enough actual parameters. Expected 2 params."

Get rid of those commas between parameters in the 042D lines.

 

 Added: Ah ha! There's an error in the SCR edit mode's SASCM.ini file.

042D=2,convert_metres_to_feet_int %1d% store_to ,%2d%


I'll mention the issue to Seemann, Sanny's author.
 

Update: Fixed in SB4, which is still in the alpha testing stage.

Edited by OrionSR
Link to comment
Share on other sites

40 minutes ago, OrionSR said:

Get rid of those commas

Removing the commas worked~

 

After that it kicked over to another line of code (below) which prompted error 0072: Missing logical operator - but when you add an IFAND/IFOR like it asks, it prompts error 0073: redundant logical operator. Not sure what that is all about but fortunately someone had the same issue on forums and was told to close out the four lines with // Not sure what effect that may have in my next playthrough? but will see.

Spoiler
:SYND4_3650
00D6: if 
004D: jump_if_false @SYND4_3672 
0001: wait 0 ms 
0002: jump @SYND4_3650

I was able to compile though after these two lines were messed with and was able to test it in game, it worked~

Thank you again for that. I am happy I was able to go the route of changing the number rather than take cracks at a new script.

Link to comment
Share on other sites

4 hours ago, KC702 said:

Not sure what that is all about but fortunately someone had the same issue

Yeah, good fix. That syndicate issue is built into the standard main.scm. It's a dead code segment that is never executed, so commenting out the codes should work fine with no unexpected issues.

Link to comment
Share on other sites

  • 4 weeks later...

Hello again, 

 

I thought I understood this process well enough but have been trying to tackle an issue for a couple days now and keep coming up short. I created a .cs for a .cm and for the life of me I cannot get the mission marker to appear on map at all.

Here is the .cs

Spoiler
{$CLEO .cs}
0000:

thread 'WHRBSMK'
0A95: save_this_custom_script

:WHRBSMK_1
wait 0
if and
    0038: $Riot_Total_Passed_Missions > 0
    0038: $Riot_Total_Passed_Missions <= 2   
then
    02A7: 0@ = create_icon_marker_and_sphere 37 at 2492.500 -1686.000 14.000
end
    
while true
    wait 0
    if and
    0038: $Riot_Total_Passed_Missions <= 2
    0102:   actor $PLAYER_ACTOR in_sphere 2492.500 -1686.000 14.000 radius 1.0 1.0 1.0 sphere 0 stopped_on_foot
    then
    jump @HANDLE_MISSION_START
    end
end

:HANDLE_MISSION_START
$ONMISSION = 1
Player.CanMove($PLAYER_CHAR, False)
00BA: show_text_styled GXT 'WBS1' time 2000 style 2 // Where Theres Smoke...
wait 1000
Marker.Disable(0@)
fade 0 1500
wait 5000
0A94: load_and_launch_custom_mission "where_theres_smoke"

0A93: terminate_this_custom_script

 

So, I want the mission marker to appear on map between Los Desperados and End of the Line (1)

*Sniffer for End of the Line (1)*

Spoiler
:RIOT_372
00D6: if 
0038: $1355 == 1
004D: goto_if_false @RIOT_483
00D6: if 
0038: $1354 == 1
004D: goto_if_false @RIOT_467
00D6: if 
0038: $Riot_Total_Passed_Missions == 2
004D: goto_if_false @RIOT_460
0004: $ONMISSION = 1
00BA: print_big 'RIOT_4' time 1000 style 2
0050: gosub @PSAVE1_1320
0417: load_and_launch_mission 110 // End Of The Line (1)

 

Seems easy enough, $Riot > 0 and $Riot <= 2

- I have switched the zero to > 1, and == 2

- I have switched the top end to == 2 and < 3

Various combos have been applied but nothing makes the marker appear on map or on the coordinates. However, the "while true" works correctly (only triggers after Los Desperados complete, and before End of the Line), even without the mission marker on map or at the coordinates? I thought they are tied together, so why would one work and not the other? 

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

    0038: $Riot_Total_Passed_Missions > 0
    0038: $Riot_Total_Passed_Missions <= 2   

If the opcode ID is included, then it doesn't matter how you change stuff like ==, > or <=. The command, in this case ==, will always be executed on the two supplied arguments, regardless of any text or operators. Also, even with ==, there are different commands for var == integer, lvar == float, var == lvar etc. You must supply the correct opcode ID for it to work as expected.
 

Alternatively, you can leave out the opcode and let Sanny try to figure out which opcode to use based on context. If vars or lvars are used for both parameters then you can declare the variable types so Sanny can figure those out too.

 

I'm not sure this is the only problem. This bit is an obvious error, something I regularly scan for in my codes, and I still mess it up sometimes. I prefer to declare the variable types and let Sanny figure it out.

 

Added:

jump @HANDLE_MISSION_START

Consider using break, to break out of your while true loop. It's... improper to jump out of loops; a bad practice that can lead to really confusing code if it gets out of hand.

 

Edited by OrionSR
Link to comment
Share on other sites

35 minutes ago, OrionSR said:

If the opcode ID is included, then it doesn't matter

Oh I see! Thank you for this. Made edits based on this and popped right up after Los Desperados complete and Sweets phone call received.

Looking back at my previous implementations of this, I did leave out the opcode on each line. I do not know why I even added the opcode to this script - I think I copied the $Riot line from the main.scm and just ran with it~ Lesson learned. Ill edit the "while true" as well.

Thank you again OrionSR

Edited by KC702
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.