Quantcast

Jump to content

» «
Photo

DARKPACT level III San Andreas

23 replies to this topic
Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#1

Posted 30 September 2005 - 01:23 AM

The original Darkpact SA thread was overrun with SAMB support questions. Bottom line: Do not use this technique unless both your Mission Builder and the code you're using it for WORK wink.gif No download required, only original SA main.scm and Barton Waterduck's Mission Builder 0.33 for SA Craig version. For those familiar with Darkpact level 2 or 3 for VC, this process is even easier! wow.gif For those not, this will allow your mod to be injected into an existing SCM without having to restart. The resultant SCM will be fully operational even during the starting of a new game. Can be used on original code or code already Darkpacted.

SA's thread execution is a bit more messy than in previous games. Furthermore there are NO threads that loop in bounds of Y_Less's VMA's FFFF limitation. So we're going to have to modify the MAIN thread. Since this thread is already running before during and after Mission 2 (which is Darkpact level III's home in SA as opposed to Mission 1 in VC), we'll need to include a check that will prevent it from trying to start the mission in the event that the user is starting a new game. We do this by putting a flag check in front of the start_mission command. Anyways, in original code, search for :MAIN_392. We're going to add 4 lines after the if there and comment out the next 4 lines (coincidence only) like so
QUOTE
0038:  $24 ==  1  ;; integer values
004D: jump_if_false ��MAIN_392
0417: start_mission  2  ; Originally:
0002: jump ��MAIN_392


beforeafter
user posted imageuser posted image


Next, we have to add some code to Mission 2. Mission 2's pass flag is $24. So we check to see if that's NOT 0. If false, it jumps ahead and runs the game's original Mission 2. However, if it's not 0, then our Darkpact code will run. The beginning of the code incorporates Y_Less's VMA (variable memory access) and self-modifying code techniques so that the changes we made to the MAIN thread are restored to their original value. This is important both for game functionality as well as stopping it from launching Mission 2 repeatedly. Then the code will detect which mods (if any) are injected and inject the rest of them. After name thread, add your code like so. In the event of multiple (or additional) mods, make sure ALL create_threads are here and that the $120 equals line indicates the number of create_threads present.
QUOTE
00D6: if  0
8038:  NOT  $24 ==  0
004D: jump_if_false �NEWGAMECONTINUE
008B: @0 = $59
0004: $59 =  8650752
0004: $60 =  48929538
0004: $61 =  5329828
0006: @1 = 236
0004: $5353 =  134349398
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  16796928
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  61784
0050: gosub @1
0008: $60 +=  1024
0004: $5353 = -1409153154
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  84300288
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  1677852853
0050: gosub @1
008A: $59 = @0
008B: @0 = $120
0012: @0 *= -8
000A: @0 += �DARKPACTOR
0050: gosub @0
004E: end_thread

:DARKPACTOR
004F: create_thread ��DARKPACTLEVEL3MOD1
0004: $120 = 1
0051: return

:NEWGAMECONTINUE

Darkpacting original codeDarkpacting Darkpacted code
OR multiple mods
user posted imageuser posted image

The last necessary step is actually adding our mods. They go right before Mission 0 an MUST be in the same order as your create_threads like so.
Darkpacting original codeDarkpacting Darkpacted code
OR multiple mods
user posted imageuser posted image

This last part is optional, but recommended as it overcomes Mission 2's way of not ending right away (and therefore your mods will not necessarily auto-start right away). Search for :INTRO_924 and move the jump at the end of that block to the start of that block like so.
beforeafter
user posted imageuser posted image

Minor testing has been done. If you find any bugs, let me know. Bit tired now, so forgive me if I've left anything out. Feel free to ask smile.gif

Whacko
  • Whacko

    Crackhead

  • Members
  • Joined: 20 Sep 2004

#2

Posted 01 October 2005 - 08:56 AM Edited by Whacko, 01 October 2005 - 09:38 AM.

Hum, SA Builder compiles the edited version of the original main.scm correctly, but no save game is loading with the new main. It breaks the game before the location text fades in (all crashes with Level 2 happend after the location text appeared).
I went through the syntax numerous times but could`n find a mistake I might have done typing it...

Would it be possible for you to host a prepared main.scm for download, please?

*a bit confused*

Edit: Ah, the location wasn`t shown because I saved in a house - my other test-saves were outside. So that doesn`t seem to mean anything.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#3

Posted 01 October 2005 - 11:38 AM

QUOTE (Whacko @ Oct 1 2005, 04:56)
Would it be possible for you to host a prepared main.scm for download, please?

I'm assuming you mean TXT file as the SCM is going to be different for everybody based on the mods you're trying to inject. Hosting a TXT would be redundant because it would be the same as it is here. However, I suppose it's possible that while writing this, I skipped a step on accident confused.gif At any rate, I'm assuming that you've been able to add it to SCM before and it works, is that correct? Otherwise, it could be an error with the mod. And I'm assuming that the SCM that you made these saves with was original code, correct??

Whacko
  • Whacko

    Crackhead

  • Members
  • Joined: 20 Sep 2004

#4

Posted 01 October 2005 - 11:54 AM Edited by Whacko, 01 October 2005 - 03:34 PM.

Yes, I just took a original SCM and compiled it to a text file which I was darkpacting with. No mods.
I just retried with Level 3 what already was working with Level 2, that`s causing my confusion. The only difference is that is was creating the "template" for my work myself instead of taking an existing one like I did on Level 2 with the Storemod-Darkpact file. So it`s realtivly clear someting must be wrong with mine, but I cant find the mistake. I was following the readme above step by step, found anything that has to be edited right away and had no problems... well, untill I tried to load a savegame, hehe.

Ah, forgot about this: I compiled my template without having own code added. Meaning only with the modifications for darkpact and it won`t load, too.

Erm, and yes. I meant a txt, not a scm file. smile.gif

YetAnotherEdit:
Oki, ich did it once more step by step and comparing to the Level 2 Code the DARKPACTER part is missing in Level 3. I still didn`t get how DP exactely works, but I guess here`s the problem. I tried to put in that part from Level 2 but the game`s still crashing on loading a savegame.
Please don`t feel badgered by my edits, just notes. smile.gif

MagicM@n
  • MagicM@n

    Player Hater

  • Members
  • Joined: 28 Sep 2005

#5

Posted 01 October 2005 - 08:27 PM

I have to say that I did the modification to my original msc files and added no mod to it for I have none to add and it would compile but crash the savegame. I didn't try to put a "return" rather then leave empty, which would then possibly create one hell of a loop in the code and crash. Anyway I'll do more testing and see if I can make it work, else I'll have to make the "trafic trailored tanker" mod works in order to test this more. it's unfortunate that I was unable yet to fix that mod problem.

Anyway, time to do something here. Laters.

MagicM@n.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#6

Posted 02 October 2005 - 02:22 AM

@Whacko: You keep saying level 2, but there was no level 2 for SA. Could that be the problem? Also, I don't fully follow you, but it sounds like you're using this on a previously Darkpacted SCM. If so, your main needs to be the same as it was to begin with (as in MAIN with whatever mod(s) at the end). You need to have a create_thread for every mod present (including ones already injected). The code for whatever mod you added needs to be identically coded and whatever you're trying to further add into it has to come after the old mod.

@Magic: If you have no mod to add, then this isn't the thread for you. Darkpact's purpose is to inject mods while maintaining savegame compatibility. It sounds as if you're creating a blank thread. That has any number of ways of crashing the game. You said you added a return, but you didn't add a gosub I'm assuming, so yeah, crash.

Whacko
  • Whacko

    Crackhead

  • Members
  • Joined: 20 Sep 2004

#7

Posted 02 October 2005 - 08:29 AM

Oh, right. I`m sorry - it was Level 1, my bad (had the latest release in mind and as it`s acutally 3 I always think of 2).
I`ve been trying a lot yestersday and didn`t note all of it here, so it might be confusing (even more when I do mistakes like Level 2 and 1 and so wink.gif ).

First I took a original SCM, decompiled it with the Builder version above to main_wh.txt and followed the steps as postet. To have no blank thread I just created a marker sphere next to my save point.
With Level 3 no game would load up - I didn`t try a new game, `cause this isn`t what I want to mod. And I placed the marker inside the Madd Dogg Mansion so I won`t have access to check it anway.
I tried this a few times with minor changes I didn`t write down completely - no progress.

Second I saw that the save code from DARKPACTER was missing and I tried to "convert" Level 1 code into Level 3. I pasted what`s on Mission 1 and 0 in Level 1 into Mission 2 (Storemod.txt) and 0 in Level 3 (original main.txt) and added the steps above.
A couple of tries - no success.

Third, to make sure I don`t have anything in my additional little script crashing the game, I put it in Level 1 and anything worked fine. Only the thread handling in Level 1 is still kind of mystery to me. So it wasn´t possibe for me to a) create the sphere and b) give out a text-box when the player is inside it, but that has nothing to do with DP in any matter - my personal lack of coding knowledge... can be fixed. wink.gif

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#8

Posted 02 October 2005 - 12:30 PM

Okay, take an original SCM. Follow the steps above. Since code was already injected before, make sure that code appears at the end of MAIN AND that there's a create_thread for it where the steps above tell you to put create_threads. Then add your create_threads and new code after the existing ones. Also, while documenting steps to take, I tried to explain why and what's doing what. Can you tell me what part leaves you in the dark? I ask because you've indicated you don't understand what the game's doing and if you do, it might help you catch what's wrong.

Whacko
  • Whacko

    Crackhead

  • Members
  • Joined: 20 Sep 2004

#9

Posted 02 October 2005 - 01:48 PM Edited by Whacko, 02 October 2005 - 02:09 PM.

Gnaa... don´t ask me why, but now it works. blink.gif
First thing totally confusing me was the missing save-code. I didn`t realize that it`s not longer needed, well, it seems so, `cause the sphere appeared instantly after loading a "original" save game.

This is what I want to add, but doesn`t work right in DP:
CODE
:DARKPACTLEVEL3MOD1
; --- MODSTART
03BC: @902 = create_sphere  1253.2223  -779.2285  91.0302  1.5

0001: wait 2500 ms
00D6: if  0
0102:   actor $PLAYER_ACTOR stopped_near_point_on_foot  1253.2223  -779.2285  91.0302 radius  2.0  2.0  3.0 sphere  1
004D: jump_if_false MAIN_414

:WTRASH
03E5: text_box 'WTRASH'
0470: @10 = actor $PLAYER_ACTOR armed_weapon unknown
0001: wait 2500 ms
00D6: if  0
00E1:   key pressed  0  15
004D: jump_if_false MAIN_414
0555: remove_weapon  @10 from_actor $PLAYER_ACTOR
0002: jump MAIN_414
; --- MODEND

I wrote that code in a stripped main.txt at the bottom of the Main part and it worked fine. In DP nothing happens standing in the sphere. I choose "MAIN_414" to loop it all what might not be ok, but I didn`t find another mark fitting better as kind of return target.

Any hint`s how I can improve that - or even get it running? smile.gif

I know it`s perhaps a bit too general for this thread, but it works without DP, so I guess there are spezifications I didin`t figure out yet.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#10

Posted 03 October 2005 - 02:35 AM

Your code jumps to main_414. That is not part of your mod. You shouldn't be jumping to it. I have quite a few more tips, but here isn't really the place. Keeping that in mind, I think you're going a little too far. Stick to stripped SCMs until you get your mod working and then tinker with advanced techniques. As stated in the first post, if your mod doesn't work without Darkpact level III, don't expect it work with it (and therefore be a reason to post it here).

Whacko
  • Whacko

    Crackhead

  • Members
  • Joined: 20 Sep 2004

#11

Posted 03 October 2005 - 08:13 AM Edited by Whacko, 03 October 2005 - 05:43 PM.

Hi, it works inside a stripped main and only transported into Darkpact it does not, otherwise I wont have been posting here. But I don`t wanna bore people here, so thanks for any help untill now.

Edit: MAIN _414 seemed to be the return-Label that fits best to the return MAIN_3 I used in the stripped main.
If there is a better place to return Im not able to figure it out yet - could be any Label to me then.
The code above is the one I placed in Darkpact - the only difference to the one in the stripped is MAIN_414 instead of MAIN_3.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#12

Posted 03 October 2005 - 12:21 PM

Any command with jump MAIN_414 would not work in a stripped SCM. So I don't see how you could say it works in a stripped SCM.

pdescobar
  • pdescobar

    Conformist Scum Panda

  • Members
  • Joined: 19 Jul 2005

#13

Posted 01 September 2006 - 11:19 PM

Yeah, I know this is a pretty large bump, but Darkpact is still an incredibly useful way to use script mods and I am continually amazed by the fact that it works at all; the ease of implementation of level 3 darkpacting is just the icing on the cake. So I don't mind bringing it back up. wink.gif

Anyhow, if anyone would like to use this method on the SA version 2 scripts so that their mods can be injected into version 2 savegames, there are just a few small changes which need to be made. For consistency with Dem's v1 instructions in the first post, I'll assume SA Mission Builder 0.33 for these instructions, although the process can be done in Sanny Builder too without much difficulty.

First of all, you obviously start out with the original v2 scripts rather than the original v1 scripts. Since the MAIN portion of v2 is slightly smaller, some of the labels you are working with are different. Thus the first change occurs a little after the label MAIN_388 rather than MAIN_392. You will want to adjust the two jumps to reflect this label as well so the 4 added lines of code become:
QUOTE
0038:  $24 ==  1  ;; integer values
004D: jump_if_false MAIN_388
0417: start_mission  2  ; Originally:
0002: jump MAIN_388


The other change which must be made is in the VMA/self-modifying-code section at the start of mission 2. In this case, two of the VMA variables need to be adjusted to reflect the fact that the code change occurs 21 bytes sooner than in v1. So the initial assignment of $60 changes from 48929538 to 48924162 and the third assignment of $5353 changes from 61784 to 61763. The added code thus becomes the following:
QUOTE
00D6: if  0
8038:  NOT  $24 ==  0
004D: jump_if_false NEWGAMECONTINUE
008B: @0 = $59
0004: $59 =  8650752
0004: $60 =  48924162
0004: $61 =  5329828
0006: @1 = 236
0004: $5353 =  134349398
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  16796928
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  61763
0050: gosub @1
0008: $60 +=  1024
0004: $5353 = -1409153154
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  84300288
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  1677852853
0050: gosub @1
008A: $59 = @0
008B: @0 = $120
0012: @0 *= -8
000A: @0 += DARKPACTOR
0050: gosub @0
004E: end_thread

:DARKPACTOR
004F: create_thread DARKPACTLEVEL3MOD1
0004: $120 = 1
0051: return

:NEWGAMECONTINUE

And that's it. Following Dem's first post instructions, with the above few changes, will allow you to create a Darkpacted version of your mod which can be injected into version 2 saves. By keeping a Darkpact template for each SA version, you can simply copy & paste your script mods into each template and get both SA-v1-save-compatible and SA-v2-save-compatible versions of your mod.

pdescobar
  • pdescobar

    Conformist Scum Panda

  • Members
  • Joined: 19 Jul 2005

#14

Posted 23 September 2006 - 05:15 AM

So here I am following up a technical post that makes it sounds like I know what I'm talking about with newbie questions. tounge2.gif

What is the best procedure for making darkpacted one-time adjustments? For example, say you wanted to add some vehicle spawns and inject them into a save. The last time I did this, I took what I'm pretty sure is a poor approach and created a thread which did everything I needed and then ended itself. While it did inject my changes and preserve save compatibility with the unmodified scripts, there's not a whole lot of room in MAIN and there was an oddity. In order to inject another mod later on in any of the saves following that, I had to go back to my original darkpact script and add the new mod as another thread after the first one. I see that mentioned in the instructions but didn't realize it applied if the first darkpacted thread was no longer actually running...

So, should one-time changes simply be added inside Mission 2? If so, should they go between the last gosub and the end thread, or between the $120 assignment and the return of the DARKPACTOR subroutine, or somewhere else?

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#15

Posted 24 September 2006 - 01:48 AM

If anybody thought that was a newbie question, they'd be revealing that they themselves are a newbie and inexperienced enough to not realize how advanced a question that really is.

AS DOCUMENTED, there is no answer. See, Darkpact, Y_Less's VMA, CyQ's arrays... these things are advanced techniques. Worse than that, they're advanced techniques being applied to the most fragile of procedures. Scary stuff to somebody who doesn't grasp it. It is unfortunate, but this procedure was a major breakthrough that I feel deserves to be in the hands of anybody who wishes for it. So the documentation was meant to be as idiotproof as possible. Which implies that somebody that doesn't get it is an idiot, which couldn't be further from the truth for the reasons stated above. Just a testament to how simplistic we tried to make the documentation. At the time, it was done that way under the assumption that the breakthrough would provoke rabid implimentation. Users wanting to combine this and that, etc. So we tried to keep it simple AND scalable. However, scalable doesn't much provide for create_threads that pass parameters, one time injections outside MAIN, etc If you look at the source for Pillager, it's in fact a piggy back mission; no permanent or one-time effects at all.

The answer is one that might fly over the heads of others, but I'm sure YOU will grasp just fine wink.gif It requires you to first get rid of the 2nd setting of @0 and subsequent subroutine and of course would require anybody taking your code and adding to it to be given special instructions as to how to scale it. Perhaps this is a good reason for the approach of Level III to change to a less easier to understand, but more versatile approach. It would look something like this:

CODE
:label if NOT $120 > 0 jf label2
;first injection here. could be a create_thread, could be one time, etc

:label if NOT $120 > 1 jf label3
;2nd injection

;repeat above as needed

:labelY
$120 = X;X = number of injected sections (last value of NOT $120 > plus one)


That's what I would do. Though I must confess that Mr. Cole is the main brains. That is to say the guy that usually takes our own mental prisons and somehow thinks beyond them. He might have a more efficient, easier to document, whatever solution.

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#16

Posted 24 September 2006 - 03:21 AM Edited by Y_Less, 24 September 2006 - 03:32 AM.

This is my way of adding lots of run once code (also streamlines the process slightly):

CODE
00D6: if  0
8038:  NOT  $24 ==  0
004D: jump_if_false NEWGAMECONTINUE
008B: @0 = $59
0004: $59 =  8650752
0004: $60 =  48929538
0004: $61 =  5329828
0006: @1 = 236
0004: $5353 =  134349398
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  16796928
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  61784
0050: gosub @1
0008: $60 +=  1024
0004: $5353 = -1409153154
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  84300288
0050: gosub @1
0008: $60 +=  1024
0004: $5353 =  1677852853
0050: gosub @1
008A: $59 = @0
00D6: if 0
0038:   $120 == 0
004D: jf $120

// code you only want to execute once goes here
// this includes create_threads

004F: create_thread DARKPACTLEVEL3MOD1

:DARKPACTOR_EVERY_TIME
// Code you want to execute evey time goes here

:DARKPACTOR_END
0004: $120 = DARKPACTOR_EVERY_TIME
004E: end_thread

:NEWGAMECONTINUE


This is for V1 but the numbers haven't changed so it shouldn't be a problem. Also, as promised, the sanny version:

CODE
00D6: if  0
8038:  NOT  $24 ==  0
004D: jump_if_false @NEWGAMECONTINUE

hex
04 00 02 9B EA 01 56 02 02 08
04 00 02 9F EA 01 00 4D 00 01
04 00 02 A3 EA 01 58 F1 00 00
04 00 02 A7 EA 01 7E 07 02 AC
04 00 02 AB EA 01 00 52 06 05
04 00 02 AF EA 01 B5 00 02 64
end

00D6: if 0
0038:   $120 == 0
004D: jf $120

// code you only want to execute once goes here
// this includes create_threads

004F: create_thread @DARKPACTLEVEL3MOD1

:DARKPACTOR_EVERY_TIME
// Code you want to execute evey time goes here

:DARKPACTOR_END
0004: $120 = @DARKPACTOR_EVERY_TIME
004E: end_thread

:NEWGAMECONTINUE


And for V2:

CODE
00D6: if  0
8038:  NOT  $24 ==  0
004D: jump_if_false @NEWGAMECONTINUE

hex
04 00 02 86 EA 01 56 02 02 08
04 00 02 8A EA 01 00 4D 00 01
04 00 02 8E EA 01 58 F1 00 00
04 00 02 92 EA 01 7E 07 02 AC
04 00 02 96 EA 01 00 52 06 05
04 00 02 9A EA 01 B5 00 02 64
end

00D6: if 0
0038:   $120 == 0
004D: jf $120

// code you only want to execute once goes here
// this includes create_threads

004F: create_thread @DARKPACTLEVEL3MOD1

:DARKPACTOR_EVERY_TIME
// Code you want to execute evey time goes here

:DARKPACTOR_END
0004: $120 = @DARKPACTOR_EVERY_TIME
004E: end_thread

:NEWGAMECONTINUE

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#17

Posted 24 September 2006 - 01:07 PM

I thought of a mistake. Sorry I didn't catch it when we were discussing it in private. The published approach made it so that author B could add subsequent mods and so long as he adjusted the $120 = line correctly, the new mods would be added once and only once. With the way you have it there, if somebody took already Darkpacted code and wanted to add one more create_thread for example, they could put it in the runonce section and therefore it wouldn't be run or they could put it in the runeverytime section and it would be run everytime. Both the published and my suggested revision don't have this issue. Or am I missing something?

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#18

Posted 24 September 2006 - 02:27 PM

OK, assuming it's been run once:

CODE
jf $120

004F: create_thread DARKPACTLEVEL3MOD1

:DARKPACTOR_EVERY_TIME // Location of the last saved $120

004F: create_thread DARKPACTLEVEL3MOD1

:DARKPACTOR_EVERY_TIME // Location of the compiled label and what is now stored to $120


Don't really know how better to explain it, hope you can see it from that.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#19

Posted 24 September 2006 - 05:44 PM

It's been my experience that when you have 2 identical lables, MB assumes you mean the first (on compile). What you're suggesting there would work fine if MB presumed the last, but I don't think that's how it works. Have you tested/verified it?

pdescobar
  • pdescobar

    Conformist Scum Panda

  • Members
  • Joined: 19 Jul 2005

#20

Posted 08 October 2006 - 02:23 AM

I finally got around to playing with this again. smile.gif There's an error in Y-Less' Sanny-specific v2 code, corrected below in yellow highlighting. One of the internal labels in the hex section wasn't adjusted.
QUOTE (Y-Less)
hex
04 00 02 86 EA 01 56 02 02 08
04 00 02 8A EA 01 00 4D 00 01
04 00 02 8E EA 01 43 F1 00 00
04 00 02 92 EA 01 7E 07 02 AC
04 00 02 96 EA 01 00 52 06 05
04 00 02 9A EA 01 B5 00 02 64
end



To make YLess' suggestion for adding a second mod work, you just need to comment out (or rename) the previous definition of the label. Here's a simple (Sanny) example I used for testing.

First modification:
QUOTE
//Initial Darkpact code above...
00D6: if 0
0038:  $120 == 0
004D: jf $120

// code you only want to execute once goes here
// this includes create_threads

004F: create_thread @DARKPACTLEVEL3MOD1

:DARKPACTOR_EVERY_TIME
// Code you want to execute every time goes here
00BB: text_lowpriority 'CRED609' 5000 ms 1  // Test Team

:DARKPACTOR_END
//Final Darkpact code below...


Second modification with code commented out in orange and code added in yellow
QUOTE
//Initial Darkpact code above...
00D6: if 0
0038:  $120 == 0
004D: jf $120

// code you only want to execute once goes here
// this includes create_threads

004F: create_thread @DARKPACTLEVEL3MOD1

//:DARKPACTOR_EVERY_TIME
004F: create_thread @DARKPACTLEVEL3MOD2

:DARKPACTOR_EVERY_TIME

// Code you want to execute every time goes here
00BB: text_lowpriority 'CRED609' 5000 ms 1  // Test Team

:DARKPACTOR_END
//Final Darkpact code below...

Initially, $120 points to the original DARKPACTOR_EVERY_TIME label. When this code is compiled, that label essentially moves but that doesn't change the value of $120 in the save. So when you load up the save, it jumps to the remembered position, executes the new create_thread command then continues on and updates $120 to the newly redifined location. The above code worked fine in brief testing.

Going back to my previous question on making a completely-transparent one-time change, I understand Dem's answer as basically saying the thing to do is to avoid all the mucking about with $120 and just do what I need and get out. As an example, let's say I wanted to create an almost trivially simple darkpactor to cure the gym glitch (4 variable assignments) on a save from the unmodified game with the intent to have it continue to be useable on the unmodified game. In that case, using Y_Less' method, I would do the following.
CODE
//Initial Darkpact code above...
//00D6: if 0
//0038:   $120 == 0
//004D: jf $120

// Simple gym glitch fix
$5345 = -1
$5346 = -1
$5347 = -1
$5348 = -1

:DARKPACTOR_END
//0004: $120 = @DARKPACTOR_EVERY_TIME
004E: end_thread

:NEWGAMECONTINUE

So there I just make my change and exit, leaving $120 alone. Is that correct? It seems to work in testing, but I want to make sure I'm not overlooking anything.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#21

Posted 08 October 2006 - 06:41 AM

QUOTE (pdescobar @ Oct 7 2006, 22:23)
I understand Dem's answer as basically saying the thing to do is to avoid all the mucking about with $120 and just do what I need and get out.

Not at all. My way checks $120 as many times as there are "mods". The difference being that in my offering, each "mod" doesn't need to be 8 bytes. DPLIII calculates its jump forward based on the assumption that each injection is a create_thread. Since you asked about a one time thing, without breaking into MAIN, this will inject the first section if the SCM it's applied to hasn't already, then the second if it hasn't, and so forth. Like if you wanted to just toss in a pickup. Rather than a thread in MAIN that is at least 27 bytes in size, it could be in the modified version of DPLIII's code. And the fact that it itself is not 8 bytes won't be a problem as it would in DPLIII's released code.

Demarest
  • Demarest

    what could be

  • BUSTED!
  • Joined: 12 Jul 2003

#22

Posted 12 October 2006 - 01:28 AM

QUOTE (pdescobar @ Sep 1 2006, 19:19)
First of all, you obviously start out with the original v2 scripts rather than the original v1 scripts. Since the MAIN portion of v2 is slightly smaller, some of the labels you are working with are different. Thus the first change occurs a little after the label MAIN_388 rather than MAIN_392. You will want to adjust the two jumps to reflect this label as well so the 4 added lines of code become:
QUOTE
0038:  $24 ==  1  ;; integer values
004D: jump_if_false MAIN_388
0417: start_mission  2  ; Originally:
0002: jump MAIN_388

I can't speak for the average coder, but I keep ONE template for DPLIII. It has both lines pdescobar changed in Mission 2 in it, with comments to indicate which is v1 and which is v2. Plus, he has also discovered another discrepency in general v1 / v2 conversions, so I've got both of those lines, with comments to indicate which is which. So commenting out one version while making the sure the other version is not commented out, along with the commenting out/in of the 4 lines starting and ending with process_cutscene_only. For others that choose this route, I just wanted to point out that the change quoted here will not need to be made. As soon as you comment out the 4 lines mentioned, MAIN_392 is at the same offset MAIN_388 would be in raw v2 code.

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#23

Posted 12 October 2006 - 02:57 PM

@PD: ooops, well spotted mate, I will admit I don't have V2 so that was untested.

If you don't update $120 that code will be run every time, as with the code after the :DARKPACTOR_EVERY_TIME label. I don't know how clear I made it but with this part:

CODE
00D6: if 0
0038:   $120 == 0
004D: jf $120

// code you only want to execute once goes here
// this includes create_threads

004F: create_thread @DARKPACTLEVEL3MOD1

:DARKPACTOR_EVERY_TIME


It doesn't matter how many bytes anything is, unlike previous versions, so you would put your fix in the same area as the new create_threads to make them run only once.

@Dem: PD basically explained how this works, there aren't two labels, just the stored old position of the label in $120 (which, as it was the position of the label at the time) is after the already done create_threads and the new one in the text file which is updated to the variable after the new run-once code is executed. Hope you get that.


matt11504
  • matt11504

    drug free since '93

  • Members
  • Joined: 14 Jul 2006

#24

Posted 12 November 2007 - 04:07 AM

um im confused about how to use DARKPACT level 3 could somebody help me?
i have Version 2




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users