Quantcast

Jump to content

» «
Photo

[SA] Disabling sub-missions via CLEO

25 replies to this topic
Darchang310
  • Darchang310

    Eternal Trekker

  • Members
  • Joined: 21 Jul 2014
  • Philippines

#1

Posted 14 August 2014 - 10:19 AM Edited by Darchang310, 17 August 2014 - 11:37 AM.

Is it possible to disable sub-missions like Taxi Driver and Vigilante via a CLEO script?

I'm currently working on a "Disguise" mod, where I'm hoping to make it so that the player needs a specific outfit to unlock and play a specific sub-mission, e.g. the Cop outfit is required to unlock and play Vigilante. This is more of a personal mod of mine made to work alongside other mods by myself and others, so I'm not sure if I'd want to release this.


ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union

#2

Posted 14 August 2014 - 03:25 PM

with 0459: is it possible with a cleo script to terminate a running thread of main.scm
but you can't start a script of main.scm, so it will problematical, because...
if you terminate the mission starter script you can't play anymore the submissions
if you terminate the running mission script, then the created stuff remains, like timer, actors, vehicles, markers

It's easier to set the onmission var to 1, which prevent the ability to start any mission script
or, if it's just for your own use, just give your player the desired outfit and play then the mission

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#3

Posted 14 August 2014 - 06:47 PM Edited by OrionSR, 14 August 2014 - 06:48 PM.

I'm not convinced that shutting down and relaunching the R3 thread is the best solution, but if you wanted to go this route it should be possible. Threads in main.scm can be launched by calling their global offset. I've been using this trick for quite a while to launch the race and school threads early in the game, and also to repair saves of people who tweaked the cities unlocked stat too soon.

// Repair for altering City Unlocked during LA1 mission strand
0629: change_integer_stat 181 to 0
//004F: create_thread @MOB_LA1_180158
004F: create_thread 180158 // @MOB_LA1 PCv1
//004F: create_thread 180137 // @MOB_LA1 PCv2

The tricky part for the R3 mission however is finding the correct global offset. Usually all I need to do is decompile with the thread+global offset option, but the R3 thread has an unusual label -- ":MS_Vehicle_SubMissions" with no global offset despite the correct setting. I'm sure it's still possible to launch it anyway but you'll have to tease out the correct address.


Seemann
  • Seemann

    Ruhe

  • Members
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"

#4

Posted 14 August 2014 - 06:56 PM

but the R3 thread has an unusual label -- ":MS_Vehicle_SubMissions" with no global offset despite the correct setting.

that offset is defined in the CustomLabels.ini

76402=MS_Vehicle_SubMissions

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#5

Posted 14 August 2014 - 08:32 PM

I figured it was something like that but I suspect this strategy may not be the best solution to the problem so I didn't follow through to the end. But... does CustomLabels.ini allow the use of 004F: create_thread @MS_Vehicle_SubMissions in cleo scripts (if the v1 scripts are installed)?


Seemann
  • Seemann

    Ruhe

  • Members
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"

#6

Posted 16 August 2014 - 08:17 AM

I figured it was something like that but I suspect this strategy may not be the best solution to the problem so I didn't follow through to the end. But... does CustomLabels.ini allow the use of 004F: create_thread @MS_Vehicle_SubMissions in cleo scripts (if the v1 scripts are installed)?

nope, you cant use any label that's not present in the source file. however it's an interesting idea.

Darchang310
  • Darchang310

    Eternal Trekker

  • Members
  • Joined: 21 Jul 2014
  • Philippines

#7

Posted 17 August 2014 - 11:35 AM Edited by Darchang310, 17 August 2014 - 01:31 PM.

Hmm. So disabling missions is more complicated than I thought..

 

Here's a code I came up with using Zaz's idea (setting $ONMISSION to 1). How is it? Will it break any missions?

:COPNARMY
wait 0
if or
    0500: player $PLAYER_CHAR skin == "POLICETR" on_bodypart 17
    0500: player $PLAYER_CHAR skin == "FIELD" on_bodypart 0
then
    Player.WantedLevel($PLAYER_CHAR) = 0
else
    if
        $ONMISSION == 0
    then
        if or
            00DD: actor $PLAYER_ACTOR driving_car_with_model 427
            00DD: actor $PLAYER_ACTOR driving_car_with_model 490
            00DD: actor $PLAYER_ACTOR driving_car_with_model 523
            00DD: actor $PLAYER_ACTOR driving_car_with_model 596
            00DD: actor $PLAYER_ACTOR driving_car_with_model 597
            00DD: actor $PLAYER_ACTOR driving_car_with_model 598
            00DD: actor $PLAYER_ACTOR driving_car_with_model 599
        then
            $ONMISSION = 1
            repeat
                wait 0
            until 80DF: not actor $PLAYER_ACTOR driving
            $ONMISSION = 0
        end
    end    
end

Note that this code is set to loop, so as long as CJ is wearing either the cop uniform or the combat jacket, Wanted Level is always set to 0.

 

How about just disabling the Submission key? Is it possible? It would be much simpler and mission-friendly if it is.

You know, I may just release a variant of this mod, anyway, to give those "special" outfits some purpose (apart from the paramedic uniform, which Zaz's mod has already covered)


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#8

Posted 17 August 2014 - 05:02 PM

Another imperfect option is set $390 bit 1. This flag indicates that CJ is on a date, which disables the submissions, but obviously it'll mess with the girlfriends, probably the airport tickets, and I'm not sure what else. Still, with careful flag management you might be able to get it to work without too many consequences.


Seemann
  • Seemann

    Ruhe

  • Members
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"

#9

Posted 17 August 2014 - 09:04 PM

An overkill solution is to use
09BD: 1
to forbid all text boxes to be shown. The R3 thread has this check in its very beginning:
89BE:   not are_text_boxes_locked_to_any_thread
which will fail due to 09BD. So, no submissions will be allowed. To make all things work again use
09BD: 0

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#10

Posted 17 August 2014 - 10:49 PM

I'm still stuck on vigilante but for the other R3 missions try adjusting these variables to turn the submissions on or off as required.

0004: $ONMISSION_TAXI = 1
0004: $ONMISSION_Paramedic = 1 
0004: $ONMISSION_Firefighter = 1 
0004: $ONMISSION_Burglary = 1
0004: $160 = 1 // On Freight Train Sub-Mission(?)
0004: $159 = 1 // On Pimping Sub-Mission(?)

Darchang310
  • Darchang310

    Eternal Trekker

  • Members
  • Joined: 21 Jul 2014
  • Philippines

#11

Posted 18 August 2014 - 06:01 AM Edited by Darchang310, 18 August 2014 - 06:52 AM.

Those may just be the codes I'm looking for. Will most likely make things easier. Thanks, OrionSR. I hope that you may also find out the one for Vigilante.


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#12

Posted 18 August 2014 - 07:45 AM

I looked. I couldn't find anything in the R3 trigger thread that looked like it would do the trick and hasn't already been mentioned. How about, if the vigilante mission is started and the cop outfit isn't equipped then end the vigilante thread before it has a chance to spawn any actors, vehicles, or markers that might want to stick around and display a mission abort message specifying the new requirement? Maybe even give CJ a 3 start wanted level. If you wanted to go this route there are probably more elegant ways to coax the vigilante mission into shutting down properly so you don't need to worry about mission cleanup.


Markuza97
  • Markuza97

  • Members
  • Joined: 20 Jan 2013
  • None

#13

Posted 18 August 2014 - 11:14 AM

Vigilante is mission started with opcode 0417

 

{78369} 0417: start_mission COPCAR // Vigilante Sub-Mission

{78660} 0417: start_mission COPCAR // Vigilante Sub-Mission

 

Disable vigilante

0A8C: write_memory 0xA5CB81 size 4 value 0 virtual_protect 1
0A8C: write_memory 0xA5CCA4 size 4 value 0 virtual_protect 1

Enable vigilante

0A8C: write_memory 0xA5CB81 size 4 value 0x7C040417 virtual_protect 1
0A8C: write_memory 0xA5CCA4 size 4 value 0x7C040417 virtual_protect 1

This will replace opcode 0417 with 0000 (NOP) so game will simply ignore it. You will still get "VIGILANTE" text but we can remove that easily later.

 

This requires original main.scm and GTA San Andreas v1.0 [US] HOODLUM EXE.

 


Seemann
  • Seemann

    Ruhe

  • Members
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"

#14

Posted 18 August 2014 - 04:03 PM Edited by Seemann, 18 August 2014 - 04:03 PM.

You can use advantage of CLEO scripting and hook the R3 thread, its wakeup value. The game will think you use a wait opcode, and the R3 thread loop will wait long enough for the next iteration. To make it normal, just reset the timer value.
{$cleo}

0000:
while true
    wait 250
    if
        0AB0:   key_pressed 45 // Insert
    then
        1@ = 99999999
        gosub @UpdateR3Thread
    end
    if
        0AB0:   key_pressed 46 // Home
    then
        1@ = 0
        gosub @UpdateR3Thread
    end
end

:UpdateR3Thread
0AAA: 0@ = thread 'R3' pointer
if 0@ > 0
then
    0@ += 0xCC
    0A8C: write_memory 0@ size 4 value 1@ virtual_protect 0
end
wait 1000 
return

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#15

Posted 18 August 2014 - 06:07 PM Edited by OrionSR, 18 August 2014 - 06:25 PM.

Ooh! I think we have a winner. This would eliminate most of my concerns about modifications persisting in the save if your mod is removed or altered.  One last thing - the wakeup timer will be saved, which could leave the R3 missions bugged indefinitely unless,,,

 

Instead of setting a really high wakeup timer, set it a few seconds ahead of the current time (I think this will work, I haven't used it quite this way) as part of your loop. When the script stops running the R3 thread will quickly heal itself.

 

Suggestion: Let it sleep. Copy the entire R3 thread into your script, modify it as required, and manage the launching of missions within your script.


Darchang310
  • Darchang310

    Eternal Trekker

  • Members
  • Joined: 21 Jul 2014
  • Philippines

#16

Posted 19 August 2014 - 08:26 AM

Thanks for the help, guys. Really appreciate the ideas. For now, setting $ONMISSION to 1 works just fine. It's yet to break any of the missions I've tested so far.


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown

#17

Posted 03 September 2014 - 03:44 PM

A proper way requires hooking the main "r3" script code and injecting a check which tests the untruthfulness of the $ONMISSION_VIGILANTE variable, declared by yourself, in order to start "Vigilante" mission, just like the other submission triggers. This code takes advantage of DMA to read the value of our switcher variable owned by the hooking script:
{$CLEO}

const
    LOCALID                   = 0
end
const
    _CTheScripts__ScriptSpace = 0x00A49960
end
const
    _memcmp                   = 31@
end

03A4: script_name 'R3HOOK'

0A8D: 0@ = read_process_memory 0x008E3070 size 4 vp 0
0A8E: 1@ = 0@ + 0x0115
0A8E: 2@ = 0@ + 0x0119
0A8D: 0@ = read_process_memory 1@ size 4 vp 0
0A8E: _memcmp = 0@ + 2@
_memcmp -= 0xB8

// Check if "r3" has been started and by the main script.
0AAA: 0@ = get_script_with_this_name 'R3' pointer
if or
    0@ == 0
    0@ <  0x00A8B430 // CTheScripts::ScriptsArray[0]
    0@ >= 0x00A90830 // CTheScripts::ScriptsArray[96]
then
    0A93: terminate_this_custom_script
end

0A9F: 1@ = get_script_pointer
0A8E: 2@ = 1@ + 0x10 // CRunningScript.m_pBaseAddress
0A8D: 2@ = read_process_memory 2@ size 4 vp 0
0A8F: 3@ = 2@ - @_aR3CommandScriptName
gosub @GetR3ScriptCodeAddr
0A8F: 5@ = 4@ - _CTheScripts__ScriptSpace
0A8E: 6@ = 5@ + 0x065B // r3+65Bh
0A8E: 7@ = 5@ + 0x08DD // r3+8DDh

0A8F: 8@ = 2@ - @_HOOK_OFF_00000654_r3
0A8F: 9@ = 8@ - _CTheScripts__ScriptSpace
0A8E: 10@ = 1@ + 0x3C // CRunningScript.m_aLocals
0A90: 11@ = LOCALID * 4
005A: 11@ += 10@
11@ -= _CTheScripts__ScriptSpace
11@ /= 4

// 00000654 GOTO HOOK_OFF_00000654_r3
0A8E: 12@ = 4@ + 0x0654 // r3.thread.ba+654h
0A8C: write_process_memory 12@ size 2 value 0x0002 vp 0
12@ += 2
0A8C: write_process_memory 12@ size 1 value 0x01 vp 0
12@ += 1
0A8C: write_process_memory 12@ size 4 value 9@ vp 0

0A8E: 12@ = 8@ + 3 // r3hook.thread.ba+3
0A8C: write_process_memory 12@ size 4 value 7@ vp 0
0A8E: 12@ = 8@ + 0x0D // r3hook.thread.ba+0Dh
0A8C: write_process_memory 12@ size 4 value 11@ vp 0
0A8E: 12@ = 8@ + 0x23 // r3hook.thread.ba+23h
0A8C: write_process_memory 12@ size 4 value 7@ vp 0
0A8E: 12@ = 8@ + 0x2A // r3hook.thread.ba+2Ah
0A8C: write_process_memory 12@ size 4 value 6@ vp 0

while true
    wait 0
    // 0@ = false/true - Vigilante enabled/disabled
end

:GetR3ScriptCodeAddr
0A8E: 4@ = 0@ + 0x14 // CRunningScript.m_iIP
0A8D: 4@ = read_process_memory 4@ size 4 vp 0
0A8E: 5@ = 0@ + 0xCC // CRunningScript.m_uiWakeTime
0A8D: 5@ = read_process_memory 5@ size 4 vp 0
01BD: 6@ = get_game_timer
0062: 5@ -= 6@
if
    5@ == 70
then
    0A8F: 7@ = 4@ - 0x0F
    0AA7: call_function _memcmp num_params 3 pop 3 num 6 ptr2 3@ ptr1 7@ ret 8@
    if
        8@ == 0
    then
        0085: 4@ = 7@
        return
    end
    4@ += 0x0F
    0A8D: 4@ = read_process_memory 4@ size 4 vp 0
    4@ -= 4
    4@ += _CTheScripts__ScriptSpace
else
    if
        5@ <> 5000
    then
        4@ = 0
        return
    end
    4@ += 3
end
0A8D: 4@ = read_process_memory 4@ size 4 vp 0
4@ -= 0x0F
4@ += _CTheScripts__ScriptSpace
return

:_aR3CommandScriptName
hex
    A403 09 "R3" 00
end

:_HOOK_OFF_00000654_r3
hex
    4D00 01 00000000              // 00000000 GOTO_IF_FALSE r3+8DDh
                                  // 00000007 {
                                  // 00000007 LVAR_INT var_index
    0600 03 0000 01 00000000      // 00000007 SET_LVAR_INT var_index r3hook.thread.tls[LOCALID]-scrblock
    D600 04 00                    // 00000011 ANDOR 0
    3800 07 0000 0000 01 00 04 00 // 00000015 IS_INT_VAR_EQUAL_TO_NUMBER DMA[var_index] 0
    4D00 01 00000000              // 00000020 GOTO_IF_FALSE r3+8DDh
    0200 01 00000000              // 00000027 GOTO r3+65Bh
                                  // 0000002E }
end
  • Seemann likes this

NTAuthority
  • NTAuthority

    hell, no, tunnel, no

  • Feroci
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Contribution Award [Modding]

#18

Posted 03 September 2014 - 11:37 PM

>actually exposing a lack of range checks as a feature

 

I know early Sanny is to blame for this, but really, are III modders this bad?


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown

#19

Posted 04 September 2014 - 10:18 AM Edited by Wesser, 04 September 2014 - 10:22 AM.

Where are they missed? I forgot to say the code works on a modified main script and an untouched "r3" script.

 

Anyway, what does SB matters?


Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#20

Posted 04 September 2014 - 06:17 PM

What's wrong with the constant tiny wait applied to the script from another script? This way is simpler and not to mention, compatible with modified SCMs

NTAuthority
  • NTAuthority

    hell, no, tunnel, no

  • Feroci
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Contribution Award [Modding]

#21

Posted 04 September 2014 - 06:53 PM

Where are they missed? I forgot to say the code works on a modified main script and an untouched "r3" script.

talking about this 'dma' thing

What's wrong with the constant tiny wait applied to the script from another script? This way is simpler and not to mention, compatible with modified SCMs

but doesn't Wesser's code scan for the script name command, and therefore work with anything having r3.sc?

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#22

Posted 04 September 2014 - 07:18 PM

but doesn't Wesser's code scan for the script name command, and therefore work with anything having r3.sc?


as if I could read code conveniently here.

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown

#23

Posted 04 September 2014 - 10:22 PM

Don't know if you noticed, we are dealing with workarounds, not definitive solutions.

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#24

Posted 04 September 2014 - 10:33 PM

A definitive solution would be to apply changes to main.scm, and I don't think the OP wants it. Your code behaves the same way as if the changes were applied to the SCM directly, but if there's a WAY less complex solution which behaves the same way to the end user and, what's important, has no side effects, why not use it and save hassle?

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown

#25

Posted 04 September 2014 - 11:27 PM Edited by Wesser, 05 September 2014 - 09:16 AM.

The point is they do not behave in the same way, they just aim to achieve the same thing, each one has its own side effects (excluding those stated to demonize my script). If you believe that changing the wake time is a reliable method it's just your opinion I do not approve.

EDIT: You led me to confusion. The OP asked for a way to enable a specific submission trigger only when the player wears a particular outfit which fits the job he is going to carry out. My script gives the ability to selectively allow/disallow doing the "Vigilante" submission, not simply disable the whole "r3" script temporarily.

turbocoder32
  • turbocoder32

    selfmade maniac

  • Members
  • Joined: 21 Aug 2014
  • United-States

#26

Posted 24 September 2014 - 10:01 PM Edited by turbocoder32, 24 September 2014 - 10:03 PM.

Hey guys , use $390 I read over the post. This works and tested , tried and true.

 

Spoiler




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users