Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,821 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Sign in to follow this  
Seemann

Project CLEO

Recommended Posts

Seemann

1. INTRODUCTION

 

After the recent discussion about the memory handling I thought that it would be really cool to create some new opcodes. As I said there's a possibility to add 100 new opcodes in range of [0A8C..0AEF]. edit: But it does not mean that we can create only 100 new opcodes. Its number is not limited ever (with some coding tricks).

 

I have done this today and decided to publish first opcodes group. I created 6 new opcodes doing what I considered as absolutely necessary right now. For sure I have the ideas for the next opcodes and waiting for your ideas.

 

Worked on the version 1.0 only

 

2. OPCODES HANDLER ACTIVATION

 

But before I post that I should say: the fake opcodes handler has a TEMPORARY pointer. It means that you HAVE TO rewrite them after the game loads (after new game starting or the save loading), otherwise the using of opcodes will cause the game's crashing. edit: It order to provide it, make the opcode gosub @CLEO_RUN the first opcode in your source code (place it before 03A4: name_thread 'MAIN'). The CLEO handler pointer will be set each time the game started.

 

The code to write the fake handler is very easy:

 

 

:[email protected] = -429539&0([email protected],1i) =  0xA49960&0([email protected],1i) += @CLEO_HANDLERreturn

 

 

I've written that as a subroutine, but you could insert it directly in the script and do not use gosub

 

After you use that code you are able to use the fake opcodes.

 

 

 

3. THE CODE

 

Here's the stripped scm including the handler and the opcodes itself.

 

http://sannybuilder.com/dev/cleo.txt

 

 

Remember: you do not need to modify any code to use the opcodes. The only thing you have to do is to write the handler's pointer as written above. Add the CLEO code anywhere in MAIN and that's all!

 

 

 

4. OPCODES LIST

 

I created the following opcodes so far:

 

 

0A8C: write_memory (1) size (2) value (3) virtual_protect (4)

0A8D: (1) = read_memory (2) size (3) virtual_protect (4)

 

these ones similar to the MemProof code. Requested by Y_Less

 

0A8E: (1) = (2) + (3) // int

0A8F: (1) = (2) - (3) // int

0A90: (1) = (2) * (3) // int

0A91: (1) = (2) / (3) // int

 

these opcodes allow to make the math operations with two operands. Now, you can use [email protected] = [email protected] + [email protected] instead of [email protected] = [email protected];

[email protected] += [email protected]

 

Worked only with integer values

 

  0A96: = actor struct

  0A97: = car struct   

  0A98: = object struct

 

returns the ones's struct pointer

 

  0A99: chdir

  0A9A: = openfile "path" mode

  0A9B: closefile  

  0A9C: = file size

  0A9D: readfile size to  

  0A9E: writefile size from

 

file management opcodes

 

 

  0A9F: = current_thread_address

 

returns the current thread struct pointer 

 

  0AA0: gosub_if_false

  0AA1: return_if_false

 

allows to gosub or return if a condition is false

 

  0AA2: = load_library "path"

  0AA3: free_library

  0AA4: = get_proc_address "name" library

 

DLL management routines

 

  0AA5: call

num_params pop [param1, param2...]

 

allows to call any function and to pass the numeric parameters to it.

 

 

 

Read this topic for more information 

 

 

 

5. INI CHANGES

 

To compile the opcodes add the following lines to your SASCM.INI

 

 

; CLEO Opcodes 0A8C=4,write_memory %1d% size %2d% value %3d% virtual_protect %4d% 0A8D=4,%4d% = read_memory %1d% size %2d% virtual_protect %3d% 0A8E=3,%3d% = %1d% + %2d%; int 0A8F=3,%3d% = %1d% - %2d%; int 0A90=3,%3d% = %1d% * %2d%; int 0A91=3,%3d% = %1d% / %2d%; int 0A96=2,%2d% = actor %1d% struct 0A97=2,%2d% = car %1d% struct 0A98=2,%2d% = object %1d% struct 0A99=1,chdir %1b:userdir/rootdir% 0A9A=3,%3d% = openfile %1s% mode %2d% // IF and SET 0A9B=1,closefile %1d% 0A9C=2,%2d% = file %1d% size 0A9D=3,readfile %1d% size %2d% to %3d% 0A9E=3,writefile %1d% size %2d% from %3d% 0A9F=1,%1d% = current_thread_pointer 0AA0=1,gosub_if_false %1p% 0AA1=0,return_if_false   0AA2=2,%2h% = load_library %1s% // IF and SET 0AA3=1,free_library %1h% 0AA4=3,%3d% = get_proc_address %1s% library %2d% 0AA5=-1,call %1d% num_params %2h% pop %3h%;

 

 

 

 

6. EXAMPLES

 

not many so far:

 

 

 0A8D: [email protected] = read_memory 0x863984 size 4 virtual_protect 10A8C: write_memory 0x863984 size 4 value [email protected] virtual_protect 10A8E: [email protected] = [email protected] + 10A8F: [email protected] = [email protected] - 20A90: [email protected] = [email protected] * 30A91: [email protected] = [email protected] / 4

 

Edited by Seemann

Share this post


Link to post
Share on other sites
Seemann

*reserved*

Share this post


Link to post
Share on other sites
sleeper777

This is awesome, interesting that I spent most of yesterday compiling together most of your posts on memory rewriting and custom keypress hacking into a single tutorial on advanced coding with these techniques. This will be a great addition to the Sanny Builder repertoire. If you want see my edited static tutorial you can view it on my website under the tutorials section. I will be writing a large compliment of custom cheat codes and keypress mods to give a larger group of examples for anyone to peruse and use.

 

for a direct link to this particular tutorial click here.

Share this post


Link to post
Share on other sites
PLPynton

how deep we can go with our ideas?

will that be so simple math only? no offence, but look for something we can not achieve thru script so EASY.

Y_Less memory accessing opcodes are a good idea!

-will be that easy for you to access vehicle pool and search thru it to find any AIRBORNE vehicle? i know it is not that simple but it is not difficult either and as you know: we have absolutelly no way to intercept thru a script any of random airplanes/helis and. i rate that idea as a medium with small remark- not many people needs that. it could be intercept any vehicle from pool woith specified modelID.

-set_vehicle XYZ_angles_to - we sure have access thru script to Z and Y, but X remains unavailable and Y does not work as independent angle.

-set_actor immune_to_teargas 1/0 - the problem is that i do not know either address at actor for this.

Share this post


Link to post
Share on other sites
Seemann

 

If you want see my edited static tutorial you can view it on my website under the tutorials section

It will be nice to see in your tutorial some links on the original posts. Would be useful probably.

 

And good job on this wink.gif Could I include that in the Sanny Builder help as well?

 

 

 

how deep we can go with our ideas?

Well, ideas could be ANY. You know, the asm code is not limited of anything, it means we can create the opcodes we like. There are only the limit of size and the correct memory addresses/flags knowledge requirement.

 

 

-will be that easy for you to access vehicle pool and search

 

thru it to find any AIRBORNE vehicle?

It could be done right know via the array's method. The pool pointer address is known, you could read how much vehicles are there and check all of them with the loop.

 

So far I'm not sure about case-specific opcodes like "get_any_airborne_vehicle_to". I want to write the common opcodes. My idea is to write:

 

 

[email protected] = actor [email protected] [email protected] = car [email protected] [email protected] = object [email protected] struct

 

 

which will return the pointer at the one's struct in memory and then you can read/set any flags for that (for example X_angle) using write_mem/read_mem.

 

For sure, if you KNOW the algorithm how to set x_angle, immune_to_teargas tell me and probably we write these ones together. I just don't know how to do that sad.gif

 

 

btw, done with those extra info in scm, worked just great.

Share this post


Link to post
Share on other sites
PLPynton

get v/a/o structure is a great idea.

 

0xB74494 contains a pointer. This pointer:

* +0 contains a pointer to the first element in the pool.

* +8 [DWord] is the maximum number of elements in the pool.

* +12 [DWord] is the current number of elements in the pool.

* +32 is the vehicle pool start.

For each vehicle in the pool:

* +20 contains a pointer to the rotation/position matrix (84 Bytes).

o +0 [Float] = X-axis Rotation (Grad)

o +4 [Float] = Y-axis Rotation (Grad)

o +8 [Float] = Z-axis Rotation (Grad)

o +16 [Float] = X-axis Rotation (Looking)

o +20 [Float] = Y-axis Rotation (Looking)

o +24 [Float] = Z-axis Rotation (Looking)

* +34 [Word] Vehicle ID from vehicles.ide

i would rather write all 3 angles in one opcode. we have such an opcode for actor already.

 

another idea for set/get vehicle:

# +1172 [Float] Steer angle 1

# +1176 [Float] Steer angle 2

# +1180 [Float] Gas pedal

# +1184 [Float] Break pedal

as it might allow to make autopilot via scm.

more about addresses here

Edited by PLPynton

Share this post


Link to post
Share on other sites
Seemann

+3 new opcodes

 

http://sannybuilder.com/dev/cleo.txt

 

 

0A96: [email protected] = actor [email protected] struct0A97: [email protected] = car [email protected] struct    0A98: [email protected] = object [email protected] struct

 

 

They stores the actor/car/object struct pointer to a variable.

 

 

SASCM.INI lines:

 

0A96=2,%2d% = actor %1d% struct0A97=2,%2d% = car %1d% struct0A98=2,%2d% = object %1d% struct

 

 

 

Share this post


Link to post
Share on other sites
Y_Less

 

This is awesome, interesting that I spent most of yesterday compiling together most of your posts on memory rewriting and custom keypress hacking into a single tutorial on advanced coding with these techniques.  This will be a great addition to the Sanny Builder repertoire.  If you want see my edited static tutorial you can view it on my website under the tutorials section.  I will be writing a large compliment of custom cheat codes and keypress mods to give a larger group of examples for anyone to peruse and use.

 

for a direct link to this particular tutorial click here.

You really do have to credit CyQ in that tutorial, he is the originator of all this, we've just built on and ported what he did.

 

And this is really nice stuff Seemann, now all we need are network OpCodes and we can have entirely SCM based MPs tounge.gif (which was actually suggested in CyQs original topic).

 

Also, could you make file handlers, fopen, fread, fwrite, fclose etc?

Share this post


Link to post
Share on other sites
DexX

 

As I said there's a possibility to add 100 new opcodes in range of [0A8C..0AEF].

Any possibility of increasing that limit? each new idea, will probably require several, 2-3, possibly more, opcodes to be fully realized. Also, can we reserve a, or a range of opcodes ?

 

One of my ideas is to be able to add, change and delete actual working lights, within the script. something like this:

create_real_light <light> with_color <RGB> at <XYZ> light_type <type>

set_real_light <light> color_to <RGB>

destroy_light <light>

 

This way we could make flashlights, miner helmets, extra em lights on vehicles, etc. i've got more ideas, but this is probably the simplest of them.

Share this post


Link to post
Share on other sites
sleeper777
This is awesome, interesting that I spent most of yesterday compiling together most of your posts on memory rewriting and custom keypress hacking into a single tutorial on advanced coding with these techniques.  This will be a great addition to the Sanny Builder repertoire.  If you want see my edited static tutorial you can view it on my website under the tutorials section.  I will be writing a large compliment of custom cheat codes and keypress mods to give a larger group of examples for anyone to peruse and use.

 

for a direct link to this particular tutorial click here.

You really do have to credit CyQ in that tutorial, he is the originator of all this, we've just built on and ported what he did.

 

And this is really nice stuff Seemann, now all we need are network OpCodes and we can have entirely SCM based MPs tounge.gif (which was actually suggested in CyQs original topic).

 

Also, could you make file handlers, fopen, fread, fwrite, fclose etc?

I thought that alot of this was like his old ASM ideas i just wasn't 100% but thanks for the heads up ...

Share this post


Link to post
Share on other sites
Seemann

 

Also, could you make file handlers, fopen, fread, fwrite, fclose etc?

That is what I planned for the next group. Even more, I want to create an opcode:

 

 

[email protected] = thread "name" struct // 0 for this thread

 

 

which will allow to change the thread struct fields, for example Thread->IP

The possibility to change the thread IP will allow to use really external SCMs (opened with fopen) and remove all size limits. In theory it should work.

 

 

 

Any possibility of increasing that limit?

well, without exe-editing we could try to add yet more 100 opcodes but I think it will the maximum. At this moment we still have 87 free opcodes (0A92..0A95 were reserved by me for some reasons).

 

 

Also, can we reserve a, or a range of opcodes ?

Yes, if you mean to skip some names and leave them for the next ideas (as I did with those 0A92..0A95).

 

 

One of my ideas is to be able to add, change and delete actual working lights, within the script.

 

Nice idea. But, you know, I am NOOB at this physics/engine stuff. AFAIR, you posted the functions list at the SA memory topic. If in order to create a light it is enough to call some engine functions I think I could make this. But I still need to know what these

functions are.

 

For example:

 

_RpLightSetColor 00751A90

Is it enough for

 

 

set_real_light  color_to 

 

 

Help me, please.

 

 

 

Share this post


Link to post
Share on other sites
sleeper777

Would it be prudent to create an opcode that does the memory address calculation from the scm position ....

 

 

to internalize this code [email protected] -= [email protected] /= 4maybe something like0AXX: calculate_memory_address 0x969183

 

 

I wasn't sure if the read and write opcodes above did this procedure or not but it was probably already on your mind Seemann.

 

 

Share this post


Link to post
Share on other sites
Seemann
Would it be prudent to create an opcode that does the memory address calculation from the scm position ....

 

 

to internalize this code [email protected] -= [email protected] /= 4maybe something like0AXX: calculate_memory_address 0x969183

 

 

I wasn't sure if the read and write opcodes above did this procedure or not but it was probably already on your mind Seemann.

0A8C and 0A8D already have that. There's no need for something else.

Share this post


Link to post
Share on other sites
Seemann

+7 opcodes

 

http://sannybuilder.com/dev/cleo.txt

 

 

 

0A99: chdir 

 

flag 0 - set the current dir to the game root dir.

flag 1 - set the current dir to the user files dir.

 

 

0A9A:  = openfile "path" mode 

 

associates the external file with a file variable.

 

The is relative to the current dir (opcode 0A99).

 

The is a charset which sets how the file will be open:

 

0x72 (char r) - open for reading

0x77 (char w) - open for writing

 

0x62 (char b) - open as byte file

 

You could combine the chars. For example, mode 0x7762 opens a file as bytefile for writing.

 

In most cases the using only of 0x72 or 0x77 is enough.

If function succeed, the will contain the file pointer (hFile). Otherwise the function returns zero.

 

Also, opcode 0A9A can be used as a condition. If the file was opened successfully the condition result will be true.

 

 

0A9B: closefile 

 

Closes the opened .

 

 

0A9C:  = file  size 

 

returns the size in bytes; if failed returns -1

 

 

0A9D: readfile  size  to 

 

Reads bytes from the to the location. The file has to be opened with mode 0x72

 

 

0A9E: writefile  size  from 

 

Writes bytes from the location to the . The file has to be opened with mode 0x77

 

 

0A9F:  = current_thread_address

 

Stores to the variable the address of the thread called it.

 

 

 

 

SASCM.INI lines:

 

 

0A99=1,chdir %1b:userdir/rootdir%0A9A=3,%3d% = openfile %1s% mode %2d% // IF and SET0A9B=1,closefile %1d%0A9C=2,%2d% = file %1d% size0A9D=3,readfile %1d% size %2d% to %3d%0A9E=3,writefile %1d% size %2d% from %3d%0A9F=1,%1d% = current_thread_pointer

 

 

-----------------

 

Also, I modified the CLEO_RUN subroutine as that gosub could be used as condition. If the game version is not 1.0 the result will false:

 

 

if    gosub @CLEO_RUNthen  // well it's version 1.0  // CLEO opcodes could be usedend............:[email protected] = -429566&0([email protected],1i) == 4611680jf @CLEO_v2 // [email protected] = -429539&0([email protected],1i) =  0xA49960&0([email protected],1i) += @CLEO_HANDLER0485: return_truereturn:CLEO_v2059A: return_falsereturn

 

 

 

----------------

 

I was able to execute the scm code from the external scms. It helps to avoid the scm size limit and allows to write modifiable scripts

 

which wont break the saves compatibility as you could change it separately from the major SCM. These scms are like the DLLs.

 

Example of using of the external code:

 

if   // test if it's supported game version;    // otherwise skip CLEO code   gosub @CLEO_RUNthen   0A99: chdir 0 // Game Path   if      0A9A: [email protected] = openfile "data\test\external.scm" mode 0x72 // 0x72 - read / 0x77 - write   then      // skip first 2 bytes; necessary in order the file to be loaded      0A9D: readfile [email protected] size 2 to [email protected]       // read the file pos       0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0             dec([email protected], 0xA49960)      // gosub at file      gosub [email protected]      // close file      0A9B: closefile [email protected]   end    end

 

 

I put the following code in my D:\San Andreas\data\test\external.scm:

 

 

0000 0901 0208000405 5100

 

 

0000 is necessary to load the file in memory using 0A9D (0A9A doesn't load it itself). Next bytes are

 

0109: player $player_char money += 5

0051: return

 

so, after gosub [email protected] player get +$5.

 

 

Pay attention that Sanny Builder v2.99e does not allow to use \s and \n in the strings. Use the hex..end to compile such strings.

 

Enjoy.

Edited by Seemann

Share this post


Link to post
Share on other sites
Seemann

There's another example how to use the external files.

 

http://sannybuilder.com/dev/cleo1.20.txt

 

 

The external code was compiled as a script in order the labels were relative to script base IP.

 

Then extract ext.scm from script.img using any imgtool and place at directory \data\test.

 

Share this post


Link to post
Share on other sites
Y_Less

One minor thing I thought of while reading your nice use of conditional gosubs which was thought up a long time ago:

 

gosub_if_false

Share this post


Link to post
Share on other sites
sleeper777

I really like the list of file reading and writing codes .... question is this code ready or are you still working on it i tried t download both links above and the cleo.txt is previous to the 7 new opcodes and the above cleo1.20.txt is not working even with save link (target) as ....

 

i really want to try this code out as soon as i can .... thanks ... ph34r.gif

Share this post


Link to post
Share on other sites
Seemann

+2 opcodes

 

http://sannybuilder.com/dev/cleo.txt

 

 

0AA0: gosub_if_false 

 

parameter: @label

 

 

0AA1: return_if_false

 

no parameters

 

 

see new SASCM.INI lines in the source code.

 

---------

 

sleeper; should work, try open it in new window.

Mirror for the current version 1.22

 

and previous version 1.20 with the file management example

 

Edited by Seemann

Share this post


Link to post
Share on other sites
Beep

I don't know if this is possible. But get the xyz coordinates from where the player/actor is shooting.

Share this post


Link to post
Share on other sites
PLPynton

@Beep: you can do that checking if actor is shoting and then get his XYZ coord.

i am sorry for that:

what gosub if false brings? or return? that is almost pointles since we can do it with 1 additional label. i hate being in oposition, i REALLY hate, but i have to contribute: take it easy, do not rush. sure is hard to stop and think, use commom sense when something is going on, but we all have to do it sometime my friend. it is up to you, you have your own freedom but such a "speed" does not bring clever results, now does it?

besides keep up the good work.

edit: once again, that is just me or i am missing something beyound my understanding, kind of hard right? useful could be something like:

get remaining actor/object/vehicle entries - in the way it returns you quantity of mentioned remaining to overlap the pool limit. just like you have 132 actors created from 140 of tatal available and it returns you 8. it could quite help to avoid game crashes during mass production of mentioned game objects.

edit2: any chances to mark actor/vehicle/object as NEEDED that means randomly spawned ped is an actor that has been already marked as no longer needed, there is no pocode to reverse this process. random intercept codes use mark as needed: 0327 yes and 053E will not mark that actor at all.

 

Edited by PLPynton

Share this post


Link to post
Share on other sites
Seemann

 

I don't know if this is possible. But get the xyz coordinates from where the player/actor is shooting.

D'you mean to get the target point coords?

There's no exact memory address and i'm pretty sure these coords are calculated somewhere somehow. So far, I don't know where and how, sorry.

 

 

what gosub if false brings? or return? that is almost pointles since we can do it with 1 additional label.

you're right. Some opcodes may seem to be useless. But still, we have yet 78 free opcodes and I don't think we should care about what opcodes are more useful than others.

 

 

get remaining actor/object/vehicle entries

AFAIK, when the game creates a new actor (car/object) (random ped or mission one), it uses the internal counter, so every new actor is added to the actor pool by this counter's value. You could read this one and to find out how much actors are created:

 

 

[email protected] = 305868008B: [email protected] = &0([email protected],1i)[email protected] -= [email protected] /= 40084: $actorscount = &0([email protected],1i)

 

 

and substract this value from 140 (max count) to get the remaining value.

for cars max count is 110

for objects - 350.

 

don't know if theres another way to check it.

 

edit:

[email protected] = 305869 // for cars pool

[email protected] = 305871 // for objects pool

 

 

 

any chances to mark actor/vehicle/object as NEEDED

no problem for a car but not sure about actor/object, I will see that later.

Edited by Seemann

Share this post


Link to post
Share on other sites
Beep

What about rockets opcodes. Like setting it's XYZ and type.

 

Link to offsets

Share this post


Link to post
Share on other sites
ceedj

I've always wanted a "less-than" set of opcodes, similar to the greater than/greater than or eaqul to" conditional opcodes. Is this possible?

Share this post


Link to post
Share on other sites
Y_Less

& and | for decent bit manipulation, I may have a go at some later.

Share this post


Link to post
Share on other sites
Seemann

+4 opcodes

 

http://sannybuilder.com/dev/cleo.txt

 

 

0AA2:  = load_library "path"

 

loads DLL or EXE by the passed to the game address space and stores its handle to the . Could be used as a condition (similar to 0A9A: openfile)

 

 

0AA3: free_library 

 

releases loaded module (DLL or EXE) from memory

 

 

0AA4:  = get_proc_address "name" library 

 

returns the address of the exported function with the specified from DLL . edit: also used as a condition (returns false if there's no such function)

 

 

0AA5: call 
num_params pop [param1, param2...]

 

executes the function by the

. Also passes the parameters (total count is specified by the num_params parameter) followed like in create_thread manner (parameters number is variable).

Initially designed for DLLs but could be used for any in-game addresses.

 

edit2:

added extra parameter 'pop': sets how much the stack pointer has to be incremented after a function calling. In most cases should be equal to the num_param parameter. If the function restores the stack pointer itself this parameter has to set to 0 (zero).

 

Also, the call parameters should be passed in descending order: the latest funtion parameter goes first, the first one goes at very end of 0AA5.

 

 

 

Example:

 

 

if gosub @CLEO_RUN // no need ever as this one goes at the beginning of the filethen   0A99: chdir 0   if     0AA2: [email protected] = load_library "data\test\test.dll"   then      if       0AA4: [email protected] = get_proc_address "TestProc" library [email protected]     then       0AA5: call [email protected] num_params 1 {parameter(s):} 1     end     0AA3: free_library [email protected]   end     end // if

 

 

The code loads test.dll from the folder \DATA\test and executes its function TestProc (also passes one parameter (= 1) to it).

 

 

edit2:

IMPORTANT INFO:

 

I found a way to provide that the fake handler pointer will be written after the game starting independently from is that new game or save loading (as I said at first post this handler has temporary pointer). The way is: just make the opcode gosub @CLEO_RUN very first opcode (like in cleo.txt before 03A4: name_thread 'MAIN') and that's it. Whenever you start the game these opcodes will work (if this is version 1.0, for sure).

 

edit3:

i had a thought: we don't limited with that 100 opcodes number. We can create the only opcode which the first parameter will set what opcode is parsed actually. For example

 

 

0aa6: opcode 0D1E parameters "R.I.P."

 

 

0AA6 will have variable number of parameters (like 004F) to fit any opcode. 1st param (0x0D1E) will point to the related asm code like now).

 

 

edit4:

 

Example 2. Creating a car in front of a player using the only opcode (like in CarSpawner)

 

 

0AA5: call 0x43A0B6 num_params 1 pop 1 #INFERNUS

 

 

Example 3. Show the text box with custom text

 

 

0A8E: [email protected] = 0xA49964 + @_TextPtr // MainScm + 2 bytes of opcode + 2 bytes of datatype and string length + label0AA5: call 0x588BE0 num_params 4 pop 4 0 0 0 [email protected]:_TextPtr0900: "Custom Text"0000: null-terminator

 

 

 

Edited by Seemann

Share this post


Link to post
Share on other sites
Seemann

+1 opcode

 

http://sannybuilder.com/dev/cleo.txt

 

 

0AA6: call_method 
struct
num_params pop [param1, param2...]

 

 

similar to 0AA5 but calls the method function for the specified object (actor, car, thread, menu ...). You should pass the method function address, object struct pointer, number of parameters passed and number of parameters popped after function executioning.

 

The object struct pointer for actor, car, object can be achieved using opcodes 0A96, 0A97, 0A98.

 

Normally a method restores the stack itself, so the pop parameter should be equal to 0.

 

 

 

Example: how to mark car as needed (was discussed previously with PLPynton).

 

 

// let [email protected] be a car handle which must be marked as needed0A97: [email protected] = car [email protected] struct// call CVehicle->SetReference method// parameter: 2 - addref, 1 - removeref (like 01C3)0AA6: call_method 0x6D5D70 struct [email protected] num_params 1 pop 0 2  

 

 

still dont know how to do it for actors/object.

 

Edit: It seems that for actors the SetReference method is at 0x5E47E0 (UNTESTED!)

 

 

Edited by Seemann

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

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