Quantcast

Jump to content

» «
Photo

[VC|CLEO] Custom Sniper Scope

No replies to this topic
ThirteenAG
  • ThirteenAG

    Soldier

  • Feroci
  • Joined: 29 Dec 2008
  • None

#1

Posted 20 November 2012 - 04:08 PM Edited by ThirteenAG, 21 November 2012 - 08:51 PM.

I made a proper texture draw function, when i was working on gasoline and zonetext mods, but i didn't found a way to use it, and decided to make a little tutorial. There's what you need to know to make a texture mod:
1) TXD. I just downloaded dalva's custom scope DSS.TXD. Then, using txd workshop, i converted it to vice city format, and left only one scope texture.
user posted image

2)CLEO. Well, draw function itself:
CODE
:draw_texture
{example:
05F5: call_scm_func @draw_texture params 9 _and it is - position 220.0 170.0 size 191.25 170.0 RGBA 255 255 255 255 texture_id 1
}
05E0: 9@ = read_memory 0xA0FD04 size 4 virtual_protect 1  //X 1920
05E0: 10@ = read_memory 0xA0FD08 size 4 virtual_protect 1  //Y 1080
0093: 9@ = integer 9@ to_float
0093: 10@ = integer 10@ to_float
//coordX = sa_coordX*(currentResX/640.0)
0015: 9@ /= 640.0 //  currentResX/640.0
0069: 0@ *= 9@ // floating-point values
0015: 10@ /= 448.0 //  currentResY/448.0
0069: 1@ *= 10@ // floating-point values
0069: 2@ *= 9@ // floating-point values
0069: 3@ *= 10@ // floating-point values
03F0: enable_text_draw 1
038D: draw_texture 8@ position 0@ 1@ size 2@ 3@ RGBA 4@ 5@ 6@ 7@
05F6: ret 0

Position and size values are independent to game resolution, just like in SA. They can be 0.0 - 640.0 for X, and 0.0 - 448.0 for Y.

And the full code:
CODE
{$CLEO}
0000:
0390: load_txd_dictionary 'DSS'
038F: load_texture 'SCOPE' as 1
while true
   wait 0
   gosub @AimingCheck
   
   if
   10@ == true
   then
       if
           02D7:   player $PLAYER_CHAR currentweapon == 28  //#SNIPER
       then    
           05DF: write_memory 0x5786A0 size 4 value 0x90 virtual_protect 1
           05DF: write_memory 0x5786A0 size 2 value 0x28C2 virtual_protect 1
           05DF: write_memory 0x5786A2 size 1 value 0x00  virtual_protect 1
           05F5: call_scm_func @draw_texture params 9 _and it is - position 320.0 224.0 size 640.0 448.0 RGBA 255 255 255 255 texture_id 1
       end
    else
       05E0: 0@ = read_memory 0x5786A0 size 1 virtual_protect 1
       if
       0@ <> 0x8B
       then                                    
       05DF: write_memory 0x5786A0 size 4 value 0x0424448B virtual_protect 1   //restore CTexture__Draw
       end
   end
   
end


:draw_texture
{example:
05F5: call_scm_func @draw_texture params 9 _and it is - position 220.0 170.0 size 191.25 170.0 RGBA 255 255 255 255 texture_id 1
}
05E0: 9@ = read_memory 0xA0FD04 size 4 virtual_protect 1  //X 1920
05E0: 10@ = read_memory 0xA0FD08 size 4 virtual_protect 1  //Y 1080
0093: 9@ = integer 9@ to_float
0093: 10@ = integer 10@ to_float
//coordX = sa_coordX*(currentResX/640.0)
0015: 9@ /= 640.0 //  currentResX/640.0
0069: 0@ *= 9@ // floating-point values
0015: 10@ /= 448.0 //  currentResY/448.0
0069: 1@ *= 10@ // floating-point values
0069: 2@ *= 9@ // floating-point values
0069: 3@ *= 10@ // floating-point values
03F0: enable_text_draw 1
038D: draw_texture 8@ position 0@ 1@ size 2@ 3@ RGBA 4@ 5@ 6@ 7@
05F6: ret 0

:AimingCheck
05E6: 10@ = actor $PLAYER_ACTOR struct
10@ += 0x244
05E0: 10@ = read_memory 10@ size 1 virtual_protect 1
if 10@ <> 0x0C
then
10@ = false
else
10@ = true
end
return


user posted image

Download example[full mod below] - [VC]Custom_Sniper_Scope.zip




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users