Quantcast

Jump to content

» «
Photo

Project CLEO

26 replies to this topic
Seemann
  • Seemann

    Ruhe

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

#1

Posted 09 March 2007 - 12:45 PM Edited by Seemann, 24 March 2007 - 03:40 AM.

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:

CODE
:CLEO_RUN
0@ = -429539
&0(0@,1i) =  0xA49960
&0(0@,1i) += @CLEO_HANDLER
return


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:

QUOTE

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 0@ = 1@ + 2@ instead of 0@ = 1@;
0@ += 2@

Worked only with integer values


  0A96: <var> = actor <handle> struct
  0A97: <var> = car <handle> struct   
  0A98: <var> = object <handle> struct

returns the ones's struct pointer

  0A99: chdir <flag>
  0A9A: <var> = openfile "path" mode <dword>
  0A9B: closefile <hFile> 
  0A9C: <var> = file <hFile> size
  0A9D: readfile <hFile> size <dword> to <var> 
  0A9E: writefile <hFile> size <dword> from <var>

file management opcodes


  0A9F: <var> = current_thread_address
 
returns the current thread struct pointer 
 
  0AA0: gosub_if_false <label>
  0AA1: return_if_false

allows to gosub or return if a condition is false

  0AA2: <var> = load_library "path"
  0AA3: free_library <hLib>
  0AA4: <var> = get_proc_address "name" library <hLib>

DLL management routines

  0AA5: call <address> num_params <byte> pop <byte> [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

CODE
; 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:

CODE
0A8D: 0@ = read_memory 0x863984 size 4 virtual_protect 1
0A8C: write_memory 0x863984 size 4 value 0@ virtual_protect 1

0A8E: 0@ = 1@ + 1
0A8F: 0@ = 1@ - 2
0A90: 0@ = 1@ * 3
0A91: 0@ = 1@ / 4

Seemann
  • Seemann

    Ruhe

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

#2

Posted 09 March 2007 - 12:51 PM

*reserved*

sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#3

Posted 09 March 2007 - 10:48 PM

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.

PLPynton
  • PLPynton

    Player Hater

  • Members
  • Joined: 09 Jul 2005

#4

Posted 09 March 2007 - 11:21 PM

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.

Seemann
  • Seemann

    Ruhe

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

#5

Posted 10 March 2007 - 09:57 AM

QUOTE (sleeper777 @ Mar 10 2007, 06:48)
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?


QUOTE (PLPynton @ Mar 10 2007, 07:21)
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.

QUOTE (PLPynton @ Mar 10 2007, 07:21)
-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:

CODE
1@ = actor 0@ struct
1@ = car 0@ struct
1@ = object 0@ 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.

PLPynton
  • PLPynton

    Player Hater

  • Members
  • Joined: 09 Jul 2005

#6

Posted 10 March 2007 - 10:49 AM Edited by PLPynton, 10 March 2007 - 10:55 AM.

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

Seemann
  • Seemann

    Ruhe

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

#7

Posted 10 March 2007 - 02:02 PM

+3 new opcodes

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

CODE
0A96: 1@ = actor 0@ struct
0A97: 1@ = car 0@ struct    
0A98: 1@ = object 0@ struct


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


SASCM.INI lines:
CODE
0A96=2,%2d% = actor %1d% struct
0A97=2,%2d% = car %1d% struct
0A98=2,%2d% = object %1d% struct



Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#8

Posted 12 March 2007 - 04:03 AM

QUOTE (sleeper777 @ Mar 9 2007, 22:48)
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?

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#9

Posted 12 March 2007 - 06:11 AM

QUOTE
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.

sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#10

Posted 12 March 2007 - 06:43 AM

QUOTE (Y_Less @ Mar 11 2007, 23:03)
QUOTE (sleeper777 @ Mar 9 2007, 22:48)
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 ...

Seemann
  • Seemann

    Ruhe

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

#11

Posted 12 March 2007 - 07:28 AM

QUOTE (Y_Less @ Mar 12 2007, 12:03)
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:

CODE
1@ = 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.


QUOTE (DexX @ Mar 12 2007, 14:11)
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).

QUOTE (DexX @ Mar 12 2007, 14:11)
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).

QUOTE (DexX @ Mar 12 2007, 14:11)
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:
QUOTE
_RpLightSetColor 00751A90

Is it enough for

CODE
set_real_light <light> color_to <RGB>


Help me, please.



sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#12

Posted 13 March 2007 - 08:56 AM

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

CODE

to internalize this code ...
0@ -= 0xA49960
0@ /= 4
maybe something like

0AXX: 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.


Seemann
  • Seemann

    Ruhe

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

#13

Posted 13 March 2007 - 09:15 AM

QUOTE (sleeper777 @ Mar 13 2007, 16:56)
Would it be prudent to create an opcode that does the memory address calculation from the scm position ....

CODE

to internalize this code ...
0@ -= 0xA49960
0@ /= 4
maybe something like

0AXX: 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.

Seemann
  • Seemann

    Ruhe

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

#14

Posted 16 March 2007 - 02:41 PM Edited by Seemann, 17 March 2007 - 02:28 AM.

+7 opcodes

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


CODE
0A99: chdir <flag>

flag 0 - set the current dir to the game root dir.
flag 1 - set the current dir to the user files dir.

CODE
0A9A: <var> = openfile "path" mode <dword>

associates the external file with a file variable.

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

The <mode> 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 <variable> 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.

CODE
0A9B: closefile <hFile>

Closes the opened <file>.

CODE
0A9C: <var> = file <hFile> size

returns the <file> size in bytes; if failed returns -1

CODE
0A9D: readfile <hFile> size <dword> to <var>

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

CODE
0A9E: writefile <hFile> size <dword> from <var>

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

CODE
0A9F: <var> = current_thread_address

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




SASCM.INI lines:

CODE
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


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

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:

CODE


if
   gosub @CLEO_RUN
then
  // well it's version 1.0
  // CLEO opcodes could be used
end


............

:CLEO_RUN
0@ = -429566
&0(0@,1i) == 4611680
jf @CLEO_v2 // 1.0
0@ = -429539
&0(0@,1i) =  0xA49960
&0(0@,1i) += @CLEO_HANDLER
0485: return_true
return

:CLEO_v2
059A: return_false
return




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

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:
CODE


if
   // test if it's supported game version;
   // otherwise skip CLEO code
   gosub @CLEO_RUN
then
   0A99: chdir 0 // Game Path
   if
      0A9A: 1@ = 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 1@ size 2 to 2@

      // read the file pos
      0A8D: 2@ = read_memory 1@ size 4 virtual_protect 0      
      dec(2@, 0xA49960)

      // gosub at file
      gosub 2@

      // close file
      0A9B: closefile 1@
   end    
end


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

CODE
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 2@ 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.

Seemann
  • Seemann

    Ruhe

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

#15

Posted 17 March 2007 - 04:22 AM

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

http://sannybuilder....ev/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 <game>\data\test.

Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#16

Posted 17 March 2007 - 05:00 AM

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

sleeper777
  • sleeper777

    Mission Coder | Help Guru | Tech Ninja

  • Members
  • Joined: 28 Mar 2003

#17

Posted 17 March 2007 - 07:57 AM

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

Seemann
  • Seemann

    Ruhe

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

#18

Posted 17 March 2007 - 09:59 AM Edited by Seemann, 17 March 2007 - 10:04 AM.

+2 opcodes

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

CODE
0AA0: gosub_if_false <label>

parameter: @label

CODE
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

Beep
  • Beep

    Ywa FTW!

  • Members
  • Joined: 22 Oct 2006

#19

Posted 18 March 2007 - 03:29 PM

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

PLPynton
  • PLPynton

    Player Hater

  • Members
  • Joined: 09 Jul 2005

#20

Posted 18 March 2007 - 04:20 PM Edited by PLPynton, 18 March 2007 - 11:01 PM.

@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.

Seemann
  • Seemann

    Ruhe

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

#21

Posted 19 March 2007 - 09:36 AM Edited by Seemann, 19 March 2007 - 09:54 AM.

QUOTE (Beep @ Mar 18 2007, 23:29)
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.

QUOTE (PLPynton @ Mar 19 2007, 00:20)
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.

QUOTE (PLPynton @ Mar 19 2007, 00:20)
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:

CODE
0@ = 305868
008B: 0@ = &0(0@,1i)
0@ -= 0xA49954
0@ /= 4
0084: $actorscount = &0(0@,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:
0@ = 305869 // for cars pool
0@ = 305871 // for objects pool


QUOTE (PLPynton @ Mar 19 2007, 00:20)
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.

Beep
  • Beep

    Ywa FTW!

  • Members
  • Joined: 22 Oct 2006

#22

Posted 19 March 2007 - 03:25 PM

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

Link to offsets

ceedj
  • ceedj

    PEDS Creator

  • Feroci
  • Joined: 21 May 2005
  • None

#23

Posted 23 March 2007 - 04:57 AM

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?

Seemann
  • Seemann

    Ruhe

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

#24

Posted 23 March 2007 - 07:16 AM

yep, just make the opcode negative, for example:

CODE
8019:  NOT 0@ > 0
8019:  0@ <= 0


Y_Less
  • Y_Less

    629

  • Members
  • Joined: 14 Mar 2004

#25

Posted 23 March 2007 - 08:07 AM

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

Seemann
  • Seemann

    Ruhe

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

#26

Posted 23 March 2007 - 11:06 AM Edited by Seemann, 23 March 2007 - 03:56 PM.

+4 opcodes

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

CODE
0AA2: <var> = load_library "path"

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

CODE
0AA3: free_library <hLib>

releases loaded module (DLL or EXE) from memory

CODE
0AA4: <var> = get_proc_address "name" library <hLib>

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

CODE
0AA5: call <address> num_params <byte> pop <byte> [param1, param2...]

executes the function by the <address>. 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:

CODE


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



The code loads test.dll from the folder <game>\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

CODE
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)

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


Example 3. Show the text box with custom text

CODE

0A8E: 0@ = 0xA49964 + @_TextPtr // MainScm + 2 bytes of opcode + 2 bytes of datatype and string length + label
0AA5: call 0x588BE0 num_params 4 pop 4 0 0 0 0@


...


:_TextPtr
0900: "Custom Text"
0000: null-terminator




Seemann
  • Seemann

    Ruhe

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

#27

Posted 24 March 2007 - 04:31 AM Edited by Seemann, 24 March 2007 - 06:43 AM.

+1 opcode

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

CODE
0AA6: call_method <address> struct <address> num_params <byte> pop <byte> [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).

CODE


// let 1@ be a car handle which must be marked as needed

0A97: 2@ = car 1@ struct

// call CVehicle->SetReference method
// parameter: 2 - addref, 1 - removeref (like 01C3)

0AA6: call_method 0x6D5D70 struct 2@ 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!)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users