├── .github └── screenshot.png ├── .gitignore ├── .gitmodules ├── LICENSE ├── Menu.sln ├── README.md ├── include ├── RDR │ ├── consts32.h │ └── natives32.h ├── common.c ├── common.h ├── constants.h ├── intrinsics.h ├── natives.h ├── types.h └── varargs.h ├── src ├── Menu.vcxproj ├── Menu.vcxproj.filters ├── main.c ├── menu.c ├── menu.h ├── menu_backend.c ├── menu_backend.h ├── mods │ ├── animals.c │ ├── mods.c │ ├── mods.h │ ├── net.c │ ├── scriptloader.c │ ├── self.c │ ├── teleport.c │ ├── vehicles.c │ ├── weapon.c │ └── world.c ├── util.c └── util.h └── tools ├── compile 360.bat └── compile ps3.bat /.github/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connor-ms/RDR-Trainer/bcdd67160546c6c3fa75983772690962c78c6b11/.github/screenshot.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/visualstudio,c 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio,c 4 | 5 | ### C ### 6 | # Prerequisites 7 | *.d 8 | 9 | # Object files 10 | *.o 11 | *.ko 12 | *.obj 13 | *.elf 14 | 15 | # Linker output 16 | *.ilk 17 | *.map 18 | *.exp 19 | 20 | # Precompiled Headers 21 | *.gch 22 | *.pch 23 | 24 | # Libraries 25 | *.lib 26 | *.a 27 | *.la 28 | *.lo 29 | 30 | # Shared objects (inc. Windows DLLs) 31 | *.dll 32 | *.so 33 | *.so.* 34 | *.dylib 35 | 36 | # Executables 37 | *.exe 38 | *.out 39 | *.app 40 | *.i*86 41 | *.x86_64 42 | *.hex 43 | 44 | # Debug files 45 | *.dSYM/ 46 | *.su 47 | *.idb 48 | *.pdb 49 | 50 | # Kernel Module Compile Results 51 | *.mod* 52 | *.cmd 53 | .tmp_versions/ 54 | modules.order 55 | Module.symvers 56 | Mkfile.old 57 | dkms.conf 58 | 59 | ### VisualStudio ### 60 | ## Ignore Visual Studio temporary files, build results, and 61 | ## files generated by popular Visual Studio add-ons. 62 | ## 63 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 64 | 65 | # User-specific files 66 | *.rsuser 67 | *.suo 68 | *.user 69 | *.userosscache 70 | *.sln.docstates 71 | 72 | # User-specific files (MonoDevelop/Xamarin Studio) 73 | *.userprefs 74 | 75 | # Mono auto generated files 76 | mono_crash.* 77 | 78 | # Build results 79 | [Dd]ebug/ 80 | [Dd]ebugPublic/ 81 | [Rr]elease/ 82 | [Rr]eleases/ 83 | x64/ 84 | x86/ 85 | [Aa][Rr][Mm]/ 86 | [Aa][Rr][Mm]64/ 87 | bld/ 88 | [Bb]in/ 89 | [Oo]bj/ 90 | [Ll]og/ 91 | [Ll]ogs/ 92 | 93 | # Visual Studio 2015/2017 cache/options directory 94 | .vs/ 95 | # Uncomment if you have tasks that create the project's static files in wwwroot 96 | #wwwroot/ 97 | 98 | # Visual Studio 2017 auto generated files 99 | Generated\ Files/ 100 | 101 | # MSTest test Results 102 | [Tt]est[Rr]esult*/ 103 | [Bb]uild[Ll]og.* 104 | 105 | # NUnit 106 | *.VisualState.xml 107 | TestResult.xml 108 | nunit-*.xml 109 | 110 | # Build Results of an ATL Project 111 | [Dd]ebugPS/ 112 | [Rr]eleasePS/ 113 | dlldata.c 114 | 115 | # Benchmark Results 116 | BenchmarkDotNet.Artifacts/ 117 | 118 | # .NET Core 119 | project.lock.json 120 | project.fragment.lock.json 121 | artifacts/ 122 | 123 | # StyleCop 124 | StyleCopReport.xml 125 | 126 | # Files built by Visual Studio 127 | *_i.c 128 | *_p.c 129 | *_h.h 130 | *.meta 131 | *.iobj 132 | *.ipdb 133 | *.pgc 134 | *.pgd 135 | *.rsp 136 | *.sbr 137 | *.tlb 138 | *.tli 139 | *.tlh 140 | *.tmp 141 | *.tmp_proj 142 | *_wpftmp.csproj 143 | *.log 144 | *.vspscc 145 | *.vssscc 146 | .builds 147 | *.pidb 148 | *.svclog 149 | *.scc 150 | 151 | # Chutzpah Test files 152 | _Chutzpah* 153 | 154 | # Visual C++ cache files 155 | ipch/ 156 | *.aps 157 | *.ncb 158 | *.opendb 159 | *.opensdf 160 | *.sdf 161 | *.cachefile 162 | *.VC.db 163 | *.VC.VC.opendb 164 | 165 | # Visual Studio profiler 166 | *.psess 167 | *.vsp 168 | *.vspx 169 | *.sap 170 | 171 | # Visual Studio Trace Files 172 | *.e2e 173 | 174 | # TFS 2012 Local Workspace 175 | $tf/ 176 | 177 | # Guidance Automation Toolkit 178 | *.gpState 179 | 180 | # ReSharper is a .NET coding add-in 181 | _ReSharper*/ 182 | *.[Rr]e[Ss]harper 183 | *.DotSettings.user 184 | 185 | # TeamCity is a build add-in 186 | _TeamCity* 187 | 188 | # DotCover is a Code Coverage Tool 189 | *.dotCover 190 | 191 | # AxoCover is a Code Coverage Tool 192 | .axoCover/* 193 | !.axoCover/settings.json 194 | 195 | # Coverlet is a free, cross platform Code Coverage Tool 196 | coverage*[.json, .xml, .info] 197 | 198 | # Visual Studio code coverage results 199 | *.coverage 200 | *.coveragexml 201 | 202 | # NCrunch 203 | _NCrunch_* 204 | .*crunch*.local.xml 205 | nCrunchTemp_* 206 | 207 | # MightyMoose 208 | *.mm.* 209 | AutoTest.Net/ 210 | 211 | # Web workbench (sass) 212 | .sass-cache/ 213 | 214 | # Installshield output folder 215 | [Ee]xpress/ 216 | 217 | # DocProject is a documentation generator add-in 218 | DocProject/buildhelp/ 219 | DocProject/Help/*.HxT 220 | DocProject/Help/*.HxC 221 | DocProject/Help/*.hhc 222 | DocProject/Help/*.hhk 223 | DocProject/Help/*.hhp 224 | DocProject/Help/Html2 225 | DocProject/Help/html 226 | 227 | # Click-Once directory 228 | publish/ 229 | 230 | # Publish Web Output 231 | *.[Pp]ublish.xml 232 | *.azurePubxml 233 | # Note: Comment the next line if you want to checkin your web deploy settings, 234 | # but database connection strings (with potential passwords) will be unencrypted 235 | *.pubxml 236 | *.publishproj 237 | 238 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 239 | # checkin your Azure Web App publish settings, but sensitive information contained 240 | # in these scripts will be unencrypted 241 | PublishScripts/ 242 | 243 | # NuGet Packages 244 | *.nupkg 245 | # NuGet Symbol Packages 246 | *.snupkg 247 | # The packages folder can be ignored because of Package Restore 248 | **/[Pp]ackages/* 249 | # except build/, which is used as an MSBuild target. 250 | !**/[Pp]ackages/build/ 251 | # Uncomment if necessary however generally it will be regenerated when needed 252 | #!**/[Pp]ackages/repositories.config 253 | # NuGet v3's project.json files produces more ignorable files 254 | *.nuget.props 255 | *.nuget.targets 256 | 257 | # Microsoft Azure Build Output 258 | csx/ 259 | *.build.csdef 260 | 261 | # Microsoft Azure Emulator 262 | ecf/ 263 | rcf/ 264 | 265 | # Windows Store app package directories and files 266 | AppPackages/ 267 | BundleArtifacts/ 268 | Package.StoreAssociation.xml 269 | _pkginfo.txt 270 | *.appx 271 | *.appxbundle 272 | *.appxupload 273 | 274 | # Visual Studio cache files 275 | # files ending in .cache can be ignored 276 | *.[Cc]ache 277 | # but keep track of directories ending in .cache 278 | !?*.[Cc]ache/ 279 | 280 | # Others 281 | ClientBin/ 282 | ~$* 283 | *~ 284 | *.dbmdl 285 | *.dbproj.schemaview 286 | *.jfm 287 | *.pfx 288 | *.publishsettings 289 | orleans.codegen.cs 290 | 291 | # Including strong name files can present a security risk 292 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 293 | #*.snk 294 | 295 | # Since there are multiple workflows, uncomment next line to ignore bower_components 296 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 297 | #bower_components/ 298 | 299 | # RIA/Silverlight projects 300 | Generated_Code/ 301 | 302 | # Backup & report files from converting an old project file 303 | # to a newer Visual Studio version. Backup files are not needed, 304 | # because we have git ;-) 305 | _UpgradeReport_Files/ 306 | Backup*/ 307 | UpgradeLog*.XML 308 | UpgradeLog*.htm 309 | ServiceFabricBackup/ 310 | *.rptproj.bak 311 | 312 | # SQL Server files 313 | *.mdf 314 | *.ldf 315 | *.ndf 316 | 317 | # Business Intelligence projects 318 | *.rdl.data 319 | *.bim.layout 320 | *.bim_*.settings 321 | *.rptproj.rsuser 322 | *- [Bb]ackup.rdl 323 | *- [Bb]ackup ([0-9]).rdl 324 | *- [Bb]ackup ([0-9][0-9]).rdl 325 | 326 | # Microsoft Fakes 327 | FakesAssemblies/ 328 | 329 | # GhostDoc plugin setting file 330 | *.GhostDoc.xml 331 | 332 | # Node.js Tools for Visual Studio 333 | .ntvs_analysis.dat 334 | node_modules/ 335 | 336 | # Visual Studio 6 build log 337 | *.plg 338 | 339 | # Visual Studio 6 workspace options file 340 | *.opt 341 | 342 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 343 | *.vbw 344 | 345 | # Visual Studio LightSwitch build output 346 | **/*.HTMLClient/GeneratedArtifacts 347 | **/*.DesktopClient/GeneratedArtifacts 348 | **/*.DesktopClient/ModelManifest.xml 349 | **/*.Server/GeneratedArtifacts 350 | **/*.Server/ModelManifest.xml 351 | _Pvt_Extensions 352 | 353 | # Paket dependency manager 354 | .paket/paket.exe 355 | paket-files/ 356 | 357 | # FAKE - F# Make 358 | .fake/ 359 | 360 | # CodeRush personal settings 361 | .cr/personal 362 | 363 | # Python Tools for Visual Studio (PTVS) 364 | __pycache__/ 365 | *.pyc 366 | 367 | # Cake - Uncomment if you are using it 368 | # tools/** 369 | # !tools/packages.config 370 | 371 | # Tabs Studio 372 | *.tss 373 | 374 | # Telerik's JustMock configuration file 375 | *.jmconfig 376 | 377 | # BizTalk build output 378 | *.btp.cs 379 | *.btm.cs 380 | *.odx.cs 381 | *.xsd.cs 382 | 383 | # OpenCover UI analysis results 384 | OpenCover/ 385 | 386 | # Azure Stream Analytics local run output 387 | ASALocalRun/ 388 | 389 | # MSBuild Binary and Structured Log 390 | *.binlog 391 | 392 | # NVidia Nsight GPU debugger configuration file 393 | *.nvuser 394 | 395 | # MFractors (Xamarin productivity tool) working folder 396 | .mfractor/ 397 | 398 | # Local History for Visual Studio 399 | .localhistory/ 400 | 401 | # BeatPulse healthcheck temp database 402 | healthchecksdb 403 | 404 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 405 | MigrationBackup/ 406 | 407 | # Ionide (cross platform F# VS Code tools) working folder 408 | .ionide/ 409 | 410 | # End of https://www.toptal.com/developers/gitignore/api/visualstudio,c 411 | 412 | # Misc stuff 413 | notes.c 414 | test.c -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/SC-CL"] 2 | path = lib/SC-CL 3 | url = https://github.com/NativeFunction/SC-CL 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Menu.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30320.27 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Menu", "src\Menu.vcxproj", "{130629F0-649C-4E82-B00A-590905509FFB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | RDR _SC|X360 = RDR _SC|X360 11 | RDR SCO|X360 = RDR SCO|X360 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {130629F0-649C-4E82-B00A-590905509FFB}.RDR _SC|X360.ActiveCfg = RDR _SC|Win32 15 | {130629F0-649C-4E82-B00A-590905509FFB}.RDR _SC|X360.Build.0 = RDR _SC|Win32 16 | {130629F0-649C-4E82-B00A-590905509FFB}.RDR SCO|X360.ActiveCfg = RDR SCO|Win32 17 | {130629F0-649C-4E82-B00A-590905509FFB}.RDR SCO|X360.Build.0 = RDR SCO|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {78A78457-C4FC-44B5-8412-01722693A42A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RDR-Trainer 2 | A simple script trainer for Red Dead Redemption. Meant to be a base to build off of and add more features to. 3 | 4 | ![Screenshot of menu](.github/screenshot.png?raw=true "Screenshot of Menu") 5 | 6 | # Download 7 | For the latest download, navigate to the releases tab, or click [here](https://github.com/connorms/RDR-Trainer/releases). 8 | 9 | ## Features 10 | This is mainly meant to be used as a starting point, so just a few features are included to get an idea of how the menu works. Here are the features that are already included to get started from: 11 | - Self options 12 | - Invincible 13 | - Noclip 14 | - Drunk 15 | - Weapon Options 16 | - Give All Weapons 17 | - Toggle All Weapons Gold 18 | - Infinite Ammo 19 | - World Options 20 | - Set Weather 21 | - Teleporter 22 | - Teleport to Location 23 | - Teleport 2ft in Direction 24 | - Vehicle Spawner 25 | - Spawn Vehicle 26 | - Animal Spawner 27 | - Set Animal 28 | - Invincible 29 | - Rideable 30 | - Bodyguard 31 | - Spawn Animal 32 | - Network Options 33 | - Fix Server 34 | - Refresh Playerlist 35 | - Player Options 36 | - Teleport to 37 | - Spectate 38 | - Script Loader 39 | - Load Script 40 | 41 | ## Building 42 | 1. Download and install Git. 43 | 2. Open command prompt and type: 44 | ``` 45 | git clone --recursive-submodules https://github.com/connorms/RDR-Trainer 46 | ``` 47 | 3. Navigate to the cloned repository -> tools and run the batch file depending on if you want to build for PS3 or Xbox 360. 48 | 4. The output script file will be in `/bin/menu.(x/c)sc` (file extension depends on whether it was built for PS3 or 360). 49 | 50 | ## Installing 51 | 1. Use an RPF editor of your choice. 52 | 2. In the main RPF (usually either `rdr2_layer0.rpf` or `patch0_ps3.rpf`, but can vary depending on game version/console/etc.), navigate to `/content/release/scripting/DesignerDefined/ui/`. 53 | 3. Extract `fuieventmonitor.(x/c)sc`, rename it to `fuieventmonitor_o.(x/c)sc`, and import it back into the same directory. 54 | 4. Rename this script to `fuieventmonitor.(x/c)sc` and import it into the same directory. NOTE: If you're on Xbox, use `.xsc`. If you're on PS3, use `.csc`. 55 | 5. Save and rebuild the RPF, and replace the modified RPF with the original one on the console. 56 | 57 | ## How to use script loader 58 | To use the script loader, rename your script to a number that's 1-10 (while keeping original extension), and place it in `/content/release/scripting/`. In game, go to the script loader and select the number that corresponds to your script. -------------------------------------------------------------------------------- /include/common.c: -------------------------------------------------------------------------------- 1 | /*H********************************************************************** 2 | * FILENAME : common.c START DATE : 10 Sept 16 3 | * 4 | * DESCRIPTION : 5 | * Common functions to be used with all targets and platforms of SC-CL. 6 | * 7 | * NOTES : 8 | * This file is part of SC-CL's include library. 9 | * 10 | * LICENSE : 11 | * 12 | * Copyright 2016 SC-CL 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * * Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 20 | * * Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * * Neither SC-CL nor its contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * * Redistribution of this software in source or binary forms shall be free 28 | * of all charges or fees to the recipient of this software. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 31 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 33 | * DISCLAIMED. IN NO EVENT SHALL SC-CL BE LIABLE FOR ANY 34 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 35 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 37 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * AUTHORS : 42 | * Rocko Tompkins 43 | * Nathan James 44 | *H*/ 45 | #include "types.h" 46 | #include "constants.h" 47 | #include "natives.h" 48 | #include "intrinsics.h" 49 | 50 | #define GlobalCharBufferD "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 51 | 52 | char* GlobalCharBuffer = GlobalCharBufferD;//256 53 | 54 | void print(const char* str, int ms) 55 | { 56 | #if TARGET == TARGET_GTAV 57 | BEGIN_TEXT_COMMAND_PRINT("STRING"); 58 | ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(str); 59 | END_TEXT_COMMAND_PRINT(ms, 1); 60 | #elif TARGET == TARGET_RDR 61 | _CLEAR_PRINTS(); 62 | _PRINT_SUBTITLE(str, ms != 0 ? (float)ms / 1000.0f : 0, true, 2, 1, 0, 0, 0); 63 | #elif TARGET == TARGET_GTAIV 64 | CLEAR_PRINTS(); 65 | PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", str, ms, true); 66 | #endif 67 | } 68 | 69 | const char* IntToHex(int val, bool isLowercase) 70 | { 71 | char* hex_str; 72 | if(isLowercase) 73 | hex_str = "0123456789ABCDEF"; 74 | else 75 | hex_str = "0123456789abcdef"; 76 | 77 | byte* bin = (byte*)&val; 78 | 79 | char* str = " "; 80 | 81 | for (int i = 0; i < 4; i++) 82 | { 83 | str[i * 2] = hex_str[(bin[i] >> 4) & 0x0F]; 84 | str[i * 2 + 1] = hex_str[(bin[i]) & 0x0F]; 85 | } 86 | str[8] = 0; 87 | return str; 88 | } 89 | 90 | int HexToInt(const char *hex) 91 | { 92 | uint result = 0; 93 | 94 | while (*hex) 95 | { 96 | if (*hex > 47 && *hex < 58) 97 | result += (*hex - 48); 98 | else if (*hex > 64 && *hex < 71) 99 | result += (*hex - 55); 100 | else if (*hex > 96 && *hex < 103) 101 | result += (*hex - 87); 102 | 103 | if (*++hex) 104 | result <<= 4; 105 | } 106 | 107 | return result; 108 | } 109 | 110 | int IntToBase(int n, int b) 111 | { 112 | int rslt = 0, digitPos = 1; 113 | while (n) 114 | { 115 | rslt += (n%b)*digitPos; 116 | n /= b; 117 | digitPos *= 10; 118 | } 119 | return rslt; 120 | } 121 | 122 | const char* strcatGlobal(const char* str1, const char* str2) 123 | { 124 | //this takes advantage of strings being global 125 | //this returns a static pointer so if you want to use the function again without losing the return you have to strcpy it 126 | 127 | 128 | strcpy((char*)GlobalCharBuffer, str1, 255); 129 | stradd((char*)GlobalCharBuffer, str2, 255); 130 | return (char*)GlobalCharBuffer; 131 | } 132 | 133 | const char* straddiGlobal(const char* str, int i) 134 | { 135 | //this takes advantage of strings being global 136 | //this returns a static pointer so if you want to use the function again without losing the return you have to strcpy it 137 | 138 | strcpy((char*)GlobalCharBuffer, str, 255); 139 | straddi((char*)GlobalCharBuffer, i, 255); 140 | return (char*)GlobalCharBuffer; 141 | } 142 | 143 | const char* itosGlobal(int i) 144 | { 145 | //this takes advantage of strings being global 146 | //this returns a static pointer so if you want to use the function again without losing the return you have to strcpy it 147 | 148 | itos((char*)GlobalCharBuffer, i, 64); 149 | return (char*)GlobalCharBuffer; 150 | } 151 | 152 | void Throw(const char* str) 153 | { 154 | char Buffer[256]; 155 | #if TARGET == TARGET_RDR 156 | strcpy(Buffer, "Exception: ", 255); 157 | #else 158 | strcpy(Buffer, "~r~Exception~s~: ", 255); 159 | #endif 160 | 161 | stradd(Buffer, str, 255); 162 | print(Buffer, 10000); 163 | WAIT(10000); 164 | 165 | #if TARGET == TARGET_GTAV 166 | TERMINATE_THIS_THREAD(); 167 | #else 168 | TERMINATE_THIS_SCRIPT(); 169 | #endif 170 | } 171 | 172 | void Warn(const char* str) 173 | { 174 | char Buffer[256]; 175 | #if TARGET == TARGET_RDR 176 | strcpy(Buffer, "Warning: ", 255); 177 | #else 178 | strcpy(Buffer, "~y~Warning~s~: ", 255); 179 | #endif 180 | 181 | stradd(Buffer, str, 255); 182 | print(Buffer, 5000); 183 | } 184 | 185 | void Error(const char* str) 186 | { 187 | char Buffer[256]; 188 | #if TARGET == TARGET_RDR 189 | strcpy(Buffer, "Error: ", 255); 190 | #else 191 | strcpy(Buffer, "~r~Error~s~: ", 255); 192 | #endif 193 | 194 | stradd(Buffer, str, 255); 195 | print(Buffer, 5000); 196 | } 197 | 198 | int SwapEndian32(int value) 199 | { 200 | return ((((value) & 0xff000000) >> 24) | (((value) & 0x00ff0000) >> 8) | (((value) & 0x0000ff00) << 8) | (((value) & 0x000000ff) << 24)); 201 | } 202 | 203 | short SwapEndian16(short value) 204 | { 205 | return (((value) & 0xff000000) >> 24) | (((value) & 0x00ff0000) >> 8); 206 | } 207 | 208 | int CeilDivInt(uint a, uint b) 209 | { 210 | return a == 0 || b == 0 ? 0 : 1 + ((a - 1) / b); 211 | } 212 | 213 | int DivInt(int a, int b) 214 | { 215 | return a == 0 || b == 0 ? 0 : a / b; 216 | } 217 | 218 | float DivFloat(float a, float b) 219 | { 220 | return a == 0.0f || b == 0.0f ? 0.0f : a / b; 221 | } 222 | 223 | void SetBitAtIndex(int* valuePtr, uint bitIndex, bool bitValue) 224 | { 225 | *valuePtr = *valuePtr ^ ((-bitValue ^ *valuePtr) & (1 << (bitIndex % 32))); 226 | } 227 | 228 | 229 | int ModNegitive(int a, int b) 230 | { 231 | int ret = a % b; 232 | return ret < 0 ? ret + b : ret; 233 | } 234 | 235 | quaternion EulerToQuaternion(vector3 euler) 236 | { 237 | float cosYawOver2 = COS(euler.x * 0.5), 238 | sinYawOver2 = SIN(euler.x * 0.5), 239 | 240 | cosPitchOver2 = COS(euler.y * 0.5), 241 | sinPitchOver2 = SIN(euler.y * 0.5), 242 | 243 | cosRollOver2 = COS(euler.z * 0.5), 244 | sinRollOver2 = SIN(euler.z * 0.5); 245 | 246 | quaternion out = 247 | { 248 | (cosYawOver2 * cosPitchOver2 * cosRollOver2) + (sinYawOver2 * sinPitchOver2 * sinRollOver2), 249 | (cosYawOver2 * cosPitchOver2 * sinRollOver2) - (sinYawOver2 * sinPitchOver2 * cosRollOver2), 250 | (cosYawOver2 * sinPitchOver2 * cosRollOver2) + (sinYawOver2 * cosPitchOver2 * sinRollOver2), 251 | (sinYawOver2 * cosPitchOver2 * cosRollOver2) - (cosYawOver2 * sinPitchOver2 * sinRollOver2) 252 | }; 253 | return out; 254 | } 255 | 256 | vector3 RotationLookAtPoint(vector3 pos, vector3 endPos) 257 | { 258 | vector3 out = 259 | { 260 | ATAN2(pos.y, pos.z), 261 | ATAN2(pos.x * COS(endPos.x), pos.z), 262 | ATAN2(COS(endPos.x), SIN(endPos.x) * SIN(pos.y)) 263 | }; 264 | return out; 265 | } 266 | 267 | #if TARGET == TARGET_RDR 268 | #ifdef _MSC_VER 269 | #define aCOS(number) acosMSC(number) 270 | float acosMSC(float number) 271 | #else 272 | float aCOS(float number) 273 | #endif 274 | { 275 | //this works fine for floats as negitive ints and floats both have msb set 276 | if (reinterpretFloatToInt(number) < 0) 277 | { 278 | number = -number; 279 | return 280 | -((((((( 281 | -0.0187293f * number) 282 | + 0.0742610f) 283 | * number) 284 | - 0.2121144f) 285 | * number) 286 | + 1.5707288f) 287 | * SQRT(1.0 - number)) 288 | + PI; 289 | } 290 | 291 | return 292 | (((((( 293 | -0.0187293f * number) 294 | + 0.0742610f) 295 | * number) 296 | - 0.2121144f) 297 | * number) 298 | + 1.5707288f) 299 | * SQRT(1.0 - number); 300 | 301 | } 302 | #ifdef _MSC_VER 303 | #define aSIN(number) asinMSC(number) 304 | float asinMSC(float number) 305 | #else 306 | float aSIN(float number) 307 | #endif 308 | { 309 | //this works fine for floats as negitive ints and floats both have msb set 310 | if (reinterpretFloatToInt(number) < 0) 311 | { 312 | number = -number; 313 | return 314 | ((((((( 315 | -0.0187293f * number) 316 | + 0.0742610f) 317 | * number) 318 | - 0.2121144f) 319 | * number) 320 | + 1.5707288f) 321 | * SQRT(1.0 - number)) 322 | - 1.57079632; 323 | } 324 | return 325 | -((((((( 326 | -0.0187293f * number) 327 | + 0.0742610f) 328 | * number) 329 | - 0.2121144f) 330 | * number) 331 | + 1.5707288f) 332 | * SQRT(1.0 - number)) 333 | + 1.57079632; 334 | } 335 | #endif 336 | 337 | float StringToFloat(const char* str) 338 | { 339 | float rez = 0, fact = 1; 340 | bool point_seen = false; 341 | str -= 3; 342 | int d = 0, read_char = *str & 0xFF; 343 | 344 | if (read_char == '-') 345 | { 346 | fact = -1; 347 | read_char = *++str & 0xFF; 348 | } 349 | 350 | while (read_char) 351 | { 352 | if (read_char == '.') 353 | { 354 | point_seen = true; 355 | read_char = *++str & 0xFF; 356 | continue; 357 | } 358 | 359 | d = read_char - '0'; 360 | 361 | if (d >= 0 && d <= 9) 362 | { 363 | if (point_seen) 364 | fact /= 10; 365 | rez = rez * 10.0f + (float)d; 366 | } 367 | read_char = *++str & 0xFF; 368 | } 369 | return rez * fact; 370 | } 371 | 372 | //TODO: add these as intrinsics 373 | bool CmpLtU(int a, int b) 374 | { 375 | if (a >= 0 && b >= 0) 376 | return a < b; 377 | else 378 | { 379 | if (a == b) 380 | return false; 381 | 382 | int ltb = ~a & b; 383 | 384 | ltb |= ltb >> 1; 385 | ltb |= ltb >> 2; 386 | ltb |= ltb >> 4; 387 | ltb |= ltb >> 8; 388 | ltb |= ltb >> 16; 389 | return ((a & ~b) & ~ltb) == 0; 390 | } 391 | } 392 | 393 | bool CmpGtU(int a, int b) 394 | { 395 | if (a >= 0 && b >= 0) 396 | return a > b; 397 | else 398 | { 399 | int ltb = ~a & b; 400 | 401 | ltb |= ltb >> 1; 402 | ltb |= ltb >> 2; 403 | ltb |= ltb >> 4; 404 | ltb |= ltb >> 8; 405 | ltb |= ltb >> 16; 406 | 407 | return ((a & ~b) & ~ltb) != 0; 408 | } 409 | } 410 | 411 | int Diff64P(int* x, int* y) 412 | { 413 | int out[2]; 414 | out[0] = (int)x - (int)y; 415 | #if PTRWIDTH == 64 416 | *(int*)((char*)out + 4) = *(int*)((char*)&x + 4) - *(int*)((char*)&y + 4); 417 | if (CmpGtU(out[0], (int)x)) 418 | out[1]--; 419 | #endif 420 | return out[0]; 421 | 422 | } 423 | 424 | int* Sub64P(int* x, int yLeft, int yRight) 425 | { 426 | int out[2]; 427 | out[0] = (int)x - yLeft; 428 | #if PTRWIDTH == 64 429 | *(int*)((char*)out + 4) = *(int*)((char*)&x + 4) - yRight; 430 | if (CmpGtU(out[0], (int)x)) 431 | out[1]--; 432 | #endif 433 | return (int*)out[0]; 434 | } 435 | 436 | int* Add64P(int* x, int yLeft, int yRight) 437 | { 438 | int out[2]; 439 | out[0] = (int)x + yLeft; 440 | #if PTRWIDTH == 64 441 | *(int*)((char*)out + 4) = *(int*)((char*)&x + 4) + yRight; 442 | //if (CmpLtU(out[0], (int)x)) 443 | //out[1]++; 444 | #endif 445 | return (int*)out[0]; 446 | } 447 | 448 | int* Push64P(int LeftMost, int RightMost) 449 | { 450 | #if PTRWIDTH == 64 451 | int out[2]; 452 | out[0] = LeftMost; 453 | *(int*)((char*)out + 4) = RightMost; 454 | return (int*)out[0]; 455 | #else 456 | return (int*)LeftMost; 457 | #endif 458 | } 459 | -------------------------------------------------------------------------------- /include/common.h: -------------------------------------------------------------------------------- 1 | /*H********************************************************************** 2 | * FILENAME : common.h START DATE : 10 Sept 16 3 | * 4 | * DESCRIPTION : 5 | * Common functions to be used with all targets and platforms of SC-CL. 6 | * 7 | * NOTES : 8 | * This file is part of SC-CL's include library. 9 | * 10 | * LICENSE : 11 | * 12 | * Copyright 2016 SC-CL 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * * Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 20 | * * Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * * Neither SC-CL nor its contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * * Redistribution of this software in source or binary forms shall be free 28 | * of all charges or fees to the recipient of this software. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 31 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 33 | * DISCLAIMED. IN NO EVENT SHALL SC-CL BE LIABLE FOR ANY 34 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 35 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 37 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * AUTHORS : 42 | * Rocko Tompkins 43 | * Nathan James 44 | *H*/ 45 | #pragma once 46 | #include "types.h" 47 | 48 | /// Swaps the endian of a int or short. 49 | /// The value to be swapped. 50 | /// 51 | #define SwapEndian(x) _Generic((x),\ 52 | short int: SwapEndian16(x), unsigned short int: SwapEndian16(x),\ 53 | default: SwapEndian32(x)) 54 | 55 | /// Safely divides a and b to avoid division by zero. 56 | /// The left side value. 57 | /// The right side value. 58 | /// The divided value. 59 | #define SafeDiv(x, y) _Generic((x),\ 60 | float: DivFloat(x, y), double: DivFloat(x, y),\ 61 | default: DivInt(x, y)) 62 | 63 | /// Swaps the endian of a int to a constant value. 64 | /// The value to be swapped. 65 | /// 66 | #define SwapEndian32Const(value) ((((value) & 0xff000000) >> 24) | (((value) & 0x00ff0000) >> 8) | (((value) & 0x0000ff00) << 8) | (((value) & 0x000000ff) << 24)) 67 | 68 | /// Converts degrees to radians. 69 | /// The value to be converted. 70 | /// The value converted to radians. 71 | #define DegreesToRadians(degrees) (degrees * (PI / 180.0f)) 72 | 73 | /// Converts radians to degrees. 74 | /// The value to be converted. 75 | /// The value converted to degrees. 76 | #define RadiansToDegrees(radians) (radians * (180.0f / PI)) 77 | 78 | #if TARGET == TARGET_RDR 79 | #define ftos(flt, precision) _float_to_string(flt, 3, precision) 80 | #else 81 | #define ftos(flt, precision) 82 | #endif 83 | 84 | /// Prints the specified string to the subtitle buffer. 85 | /// The string to be printed. 86 | /// The milliseconds that the string should be printed for. 87 | /// 88 | void print(const char* str, int ms); 89 | 90 | /// Concatinates two strings into one using a global char buffer. 91 | /// The first string to be added to the buffer. 92 | /// The second string to be added to the buffer. 93 | /// The pointer to the global char buffer. 94 | const char* strcatGlobal(const char* str1, const char* str2); 95 | 96 | /// Copies str into the global char buffer then concatinates it with the string representation of i. 97 | /// The string to be added to the buffer. 98 | /// The int to be converted and added to the buffer. 99 | /// The pointer to the global char buffer. 100 | const char* straddiGlobal(const char* str, int i); 101 | 102 | /// Copies the string representation of i into the global char buffer. 103 | /// The int to be converted and copied to the buffer. 104 | /// The pointer to the global char buffer. 105 | const char* itosGlobal(int i); 106 | 107 | /// Prints the string as an exception for 10 seconds then exits the script. 108 | /// The string to be printed. 109 | /// 110 | void Throw(const char* str); 111 | 112 | /// Prints the string as an warning for 5 seconds. 113 | /// The string to be printed. 114 | /// 115 | void Warn(const char* str); 116 | 117 | /// Prints the string as an error for 5 seconds. 118 | /// The string to be printed. 119 | /// 120 | void Error(const char* str); 121 | 122 | /// Swaps the endian of a int. 123 | /// The value to be swapped. 124 | /// 125 | int SwapEndian32(int value); 126 | 127 | /// Swaps the endian of a short. 128 | /// The value to be swapped. 129 | /// 130 | short SwapEndian16(short value); 131 | 132 | /// Divides a and b then rounds up. 133 | /// The left side value. 134 | /// The right side value. 135 | /// The ceiled value. 136 | int CeilDivInt(uint a, uint b); 137 | 138 | /// Safely divides a and b to avoid division by zero. 139 | /// The left side value. 140 | /// The right side value. 141 | /// The divided value. 142 | int DivInt(int a, int b); 143 | 144 | /// Safely divides a and b to avoid division by zero. 145 | /// The left side value. 146 | /// The right side value. 147 | /// The divided value. 148 | float DivFloat(float a, float b); 149 | 150 | /// Converts a string representing a float to a float. 151 | /// The string to convert. 152 | /// The converted float value. 153 | float StringToFloat(const char* str); 154 | 155 | /// Converts a number to a hex string and stores it in a global char buffer. 156 | /// The value to convert. 157 | /// If to convert the hex result to lower case. 158 | /// A pointer to the global char buffer. 159 | const char* IntToHex(int val, bool isLowercase); 160 | 161 | /// Converts a hex string to decimal. 162 | /// Hex string to convert. 163 | /// The decimal result. 164 | int HexToInt(const char* hex); 165 | 166 | /// Converts a base 10 integer to a specified base. 167 | /// The base 10 integer. 168 | /// The base to convert to. 169 | /// The decimal representation of the new base. 170 | int IntToBase(int n, int b); 171 | 172 | /// Sets a bit at the bitIndex of a pointer to the specified value of bitValue. 173 | /// The pointer to the value that will be changed. 174 | /// The bit index of the bit relative to the pointer. 175 | /// The bit value to be set at the index. 176 | /// 177 | void SetBitAtIndex(int* valuePtr, uint bitIndex, bool bitValue); 178 | 179 | /// Preforms a modulo operation an a negative number. 180 | /// The left side value. 181 | /// The right side value. 182 | /// The modulo result. 183 | int ModNegitive(int a, int b); 184 | 185 | /// Converts a euler angle to a quaternion. 186 | /// The euler angle to be converted. 187 | /// The quaternion result. 188 | quaternion EulerToQuaternion(vector3 euler); 189 | 190 | /// Applies slow rotation to a look position eventualy converting it to endPos. 191 | /// The current look position. 192 | /// The end look position. 193 | /// The updated look position. 194 | vector3 RotationLookAtPoint(vector3 pos, vector3 endPos); 195 | 196 | #if TARGET == TARGET_RDR 197 | #ifdef _MSC_VER 198 | /// Returns the principal value of the arc cosine of x, expressed in radians. 199 | /// 200 | /// Value whose arc cosine is computed, in the interval [-1,+1]. 201 | /// If the argument is out of this interval, a domain error occurs. 202 | /// 203 | /// Principal arc cosine of x, in the interval [0,pi] radians. 204 | #define acos(x) acosMSC(x) 205 | float acosMSC(float number) {}; 206 | #else 207 | float acos(float number); 208 | #endif 209 | #ifdef _MSC_VER 210 | /// Returns the principal value of the arc sine of x, expressed in radians. 211 | /// 212 | /// Value whose arc sine is computed, in the interval [-1,+1]. 213 | /// If the argument is out of this interval, a domain error occurs. 214 | /// 215 | /// Principal arc sine of x, in the interval [-pi/2,+pi/2] radians. 216 | #define asin(number) asinMSC(number) 217 | float asinMSC(float number) {}; 218 | #else 219 | float asin(float number); 220 | #endif 221 | #endif 222 | 223 | bool CmpLtU(int a, int b); 224 | bool CmpGtU(int a, int b); 225 | int Diff64P(int* x, int* y); 226 | int* Sub64P(int* x, int yLeft, int yRight); 227 | int* Add64P(int* x, int yLeft, int yRight); 228 | int* Push64P(int LeftMost, int RightMost); -------------------------------------------------------------------------------- /include/constants.h: -------------------------------------------------------------------------------- 1 | /*H********************************************************************** 2 | * FILENAME : constants.h START DATE : 10 Sept 16 3 | * 4 | * DESCRIPTION : 5 | * General constants to be used with all targets and platforms of SC-CL. 6 | * consts.h file controller based on your current target and platform. 7 | * 8 | * NOTES : 9 | * This file is part of SC-CL's include library. 10 | * 11 | * LICENSE : 12 | * 13 | * Copyright 2016 SC-CL 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 18 | * * Redistributions of source code must retain the above copyright 19 | * notice, this list of conditions and the following disclaimer. 20 | * 21 | * * Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * 25 | * * Neither SC-CL nor its contributors may be used to endorse or promote products 26 | * derived from this software without specific prior written permission. 27 | * 28 | * * Redistribution of this software in source or binary forms shall be free 29 | * of all charges or fees to the recipient of this software. 30 | * 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 32 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 33 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 34 | * DISCLAIMED. IN NO EVENT SHALL SC-CL BE LIABLE FOR ANY 35 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 36 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 38 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | * 42 | * AUTHORS : 43 | * Rocko Tompkins 44 | * Nathan James 45 | *H*/ 46 | #pragma once 47 | 48 | #define TRUE 1 49 | #define FALSE 0 50 | #define true 1 51 | #define false 0 52 | #define NULL 0 53 | #define null 0 54 | #define nullptr 0 55 | #define nullstr "" 56 | 57 | #define PI 3.14159265 58 | 59 | #if TARGET == TARGET_RDR 60 | 61 | #include "RDR/consts32.h" 62 | 63 | #elif TARGET == TARGET_GTAV 64 | #include "GTAV/constsShared.h" 65 | 66 | #if PLATFORM == PLATFORM_PC 67 | #include "GTAV/consts64.h" 68 | #else 69 | #include "GTAV/consts32.h" 70 | #endif 71 | 72 | #elif TARGET == TARGET_GTAIV 73 | #include "GTAIV/consts32.h" 74 | #endif -------------------------------------------------------------------------------- /include/intrinsics.h: -------------------------------------------------------------------------------- 1 | /*H********************************************************************** 2 | * FILENAME : intrinsics.h START DATE : 10 Sept 16 3 | * 4 | * DESCRIPTION : 5 | * Intrinsic functions to be used with all targets and platforms of SC-CL. 6 | * 7 | * NOTES : 8 | * This file is part of SC-CL's include library. 9 | * 10 | * LICENSE : 11 | * 12 | * Copyright 2016 SC-CL 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * * Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 20 | * * Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * * Neither SC-CL nor its contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * * Redistribution of this software in source or binary forms shall be free 28 | * of all charges or fees to the recipient of this software. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 31 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 33 | * DISCLAIMED. IN NO EVENT SHALL SC-CL BE LIABLE FOR ANY 34 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 35 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 37 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * AUTHORS : 42 | * Rocko Tompkins 43 | * Nathan James 44 | *H*/ 45 | #pragma once 46 | #include "types.h" 47 | #include "constants.h" 48 | 49 | //Fix for intellisense nonsense 50 | #ifndef _MSC_VER 51 | /// Defines a function as an intrinsic for use in the compiler. 52 | #define __intrinsic __attribute((intrinsic(false))) 53 | 54 | /// Defines a function as an unsafe intrinsic for use in the compiler. 55 | #define __unsafeIntrinsic __attribute((intrinsic(true))) 56 | 57 | #else 58 | 59 | /// Computes the Jenkins one-at-a-time hash at compile time. 60 | /// String to be hashed. 61 | /// The Jenkins one-at-a-time hash key of the string. 62 | #define hashof(str) 0 63 | 64 | /// Computes the Jenkins one-at-a-time hash at compile time. 65 | /// String to be hashed. 66 | /// The Jenkins one-at-a-time hash key of the string. 67 | #define joaat(str) 0 68 | 69 | /// Defines a function as an intrinsic for use in the compiler. 70 | #define __intrinsic 71 | 72 | /// Defines a function as an unsafe intrinsic for use in the compiler. 73 | #define __unsafeIntrinsic 74 | 75 | #pragma warning( disable : 4391 ) 76 | #pragma warning( disable : 4392 ) 77 | #pragma warning( disable : 4244 ) 78 | #endif 79 | 80 | /// This macro with functional form returns the offset value in bytes of member in the data structure or union type type. 81 | /// A type in which member is a valid member designator. 82 | /// A member of type. 83 | /// A value of type unsigned int with the offset value of member in type. 84 | #define offsetof(type, member) ((uint)&(((type *)0)->member)) 85 | 86 | /// Computes the number of elements in a statically-allocated array 87 | /// The name of an array. 88 | /// The number of elements in the array, expressed as a unsigned int. 89 | #define countof(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) 90 | 91 | /// Computes the stack size of a type. 92 | /// The name of the type. 93 | /// The stack size of the type, expressed as a unsigned int. 94 | #define stacksizeof(x) ((sizeof(x) + 3) >> 2) 95 | 96 | #pragma region String //{ 97 | /// Sets the first num bytes of the block of memory pointed by ptr to the specified value. 98 | /// Pointer to the block of memory to fill. 99 | /// Value to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value. 100 | /// Number of bytes to be set. 101 | /// 102 | extern __intrinsic void memset(void* ptr, byte value, unsigned int len); 103 | 104 | /// Copies the values of len bytes from the location pointed to by source directly to the memory block pointed to by destination. 105 | /// Pointer to the destination array where the content is to be copied. 106 | /// Pointer to the source of data to be copied. 107 | /// Number of bytes to copy. 108 | /// 109 | extern __intrinsic void memcpy(void* dest, const void* src, unsigned int len); 110 | 111 | /// Copies the string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point). 112 | /// Pointer to the destination array where the content is to be copied. 113 | /// String to be copied. 114 | /// The length of the dest buffer.This value must be an integer literal in the range of 1 - 255. 115 | /// 116 | extern __intrinsic void strcpy(char* dest, const char* src, const byte destBufferLen); 117 | 118 | /// 119 | /// Appends a copy of the source string to the destination string. 120 | /// The terminating null character in destination is overwritten by the first character of source, 121 | /// and a null-character is included at the end of the new string formed by the concatenation of both in destination. 122 | /// 123 | /// Pointer to the destination array, which should contain a string, and be large enough to contain the concatenated resulting string. 124 | /// String to be appended. This should not overlap destination. 125 | /// The length of the dest buffer.This value must be an integer literal in the range of 1 - 255. 126 | /// 127 | extern __intrinsic void stradd(char* dest, const char* src, const byte destBufferLen); 128 | 129 | /// 130 | /// Appends a integer to the destination string. 131 | /// The terminating null character in destination is overwritten by the first character of the integer conversion, 132 | /// and a null-character is included at the end of the new string formed by the concatenation of both in destination. 133 | /// 134 | /// Pointer to the destination array, which should contain a string, and be large enough to contain the concatenated resulting string. 135 | /// Integer to be appended. 136 | /// The length of the dest buffer.This value must be an integer literal in the range of 1 - 255. 137 | /// 138 | extern __intrinsic void straddi(char* dest, int value, const byte destBufferLen); 139 | 140 | /// Converts a integer to a string. 141 | /// Pointer to the destination array where the content is to be copied. 142 | /// Integer to be copied. 143 | /// The length of the dest buffer.This value must be an integer literal in the range of 1 - 255. 144 | /// 145 | extern __intrinsic void itos(char* dest, int value, const byte destBufferLen); 146 | 147 | /// Copies the null-terminated byte string pointed to by src, including the null terminator, to the character array whose first element is pointed to by dest. 148 | /// Pointer to the character array to write to. 149 | /// Pointer to the null-terminated byte string to copy from. 150 | /// 151 | extern __intrinsic void strcpy_s(char* dest, const char* src); 152 | 153 | /// Appends a copy of the null-terminated byte string pointed to by src to the end of the null-terminated byte string pointed to by dest. 154 | /// Pointer to the null-terminated byte string to append to. 155 | /// Pointer to the null-terminated byte string to copy from. 156 | /// 157 | extern __intrinsic void stradd_s(char* dest, const char* src); 158 | 159 | /// Appends a copy of the null-terminated byte string converted from value to the end of the null-terminated byte string pointed to by dest. 160 | /// Pointer to the null-terminated byte string to append to. 161 | /// Value to be converted to a null-terminated byte string then appended. 162 | /// 163 | extern __intrinsic void straddi_s(char* dest, int value); 164 | 165 | /// Copies the null-terminated byte string converted from value, including the null terminator, to the character array whose first element is pointed to by dest. 166 | /// Pointer to the character array to write to. 167 | /// Value to be converted to a null-terminated byte string then copied. 168 | /// 169 | extern __intrinsic void itos_s(char* dest, int value); 170 | 171 | /// Computes the Jenkins one-at-a-time hash. 172 | /// String to be hashed. 173 | /// The Jenkins one-at-a-time hash key of the string. 174 | extern __intrinsic int getHashKey(const char* str); 175 | 176 | #pragma endregion //} 177 | 178 | #pragma region Misc_Opcodes //{ 179 | /// Gets a variable's index by its name. 180 | /// The variable name to be found.This value must be an string literal. 181 | /// The var index. 182 | extern __intrinsic const uint __varIndex(const char* varName); 183 | 184 | #pragma endregion //} 185 | 186 | #pragma region Math/Conversions //{ 187 | /// Reinterprets a int to a float without type conversion. 188 | /// The integer value to be converted. 189 | /// The integer data now representing an float. 190 | extern __intrinsic float reinterpretIntToFloat(int intValue); 191 | 192 | /// Reinterprets a float to a int without type conversion. 193 | /// The floating-point value to be converted. 194 | /// The floating-point data now representing an int 195 | extern __intrinsic int reinterpretFloatToInt(float floatValue); 196 | 197 | /// Creates a vector3 with all values initialized as the floating-point value. 198 | /// The floating-point value to be set. 199 | /// A vector3 with all values set as the floating-point value 200 | extern __intrinsic vector3 toVector3(float value); 201 | 202 | /// Adds each value of the left vector3 to each value the right vector3. 203 | /// The left side of the operation. 204 | /// The right side of the operation. 205 | /// The addition result of the two vector3s. 206 | extern __intrinsic vector3 vector3Add(vector3 left, vector3 right); 207 | 208 | /// Substacts each value of the left vector3 from each value the right vector3. 209 | /// The left side of the operation. 210 | /// The right side of the operation. 211 | /// The subtraction result of the two vector3s. 212 | extern __intrinsic vector3 vector3Sub(vector3 left, vector3 right); 213 | 214 | /// Multiplies each value of the left vector3 by each value the right vector3. 215 | /// The left side of the operation. 216 | /// The right side of the operation. 217 | /// The multiplication result of the two vector3s. 218 | extern __intrinsic vector3 vector3Mult(vector3 left, vector3 right); 219 | 220 | /// Divides each value of the left vector3 by each value the right vector3. 221 | /// The left side of the operation. 222 | /// The right side of the operation. 223 | /// The division result of the two vector3s. 224 | extern __intrinsic vector3 vector3Div(vector3 left, vector3 right); 225 | 226 | /// Negates each value of the vector3. 227 | /// The vector to be negated. 228 | /// The negation result of the vector3. 229 | extern __intrinsic vector3 vector3Neg(vector3 vector); 230 | 231 | /// Calculates the dot product of two vector3s. 232 | /// The left side of the operation. 233 | /// The right side of the operation. 234 | /// The dot product of the two vector3s. 235 | extern __intrinsic float vector3Dot(vector3 left, vector3 right); 236 | 237 | /// Flattens the height value of the vector3 to 0. 238 | /// The vector to be flattened. 239 | /// The flatten result of the vector3. 240 | extern __intrinsic vector3 vector3Flatten(vector3 vector); 241 | 242 | /// Creates a vector2 with all values initialized as the floating-point value. 243 | /// The floating-point value to be set. 244 | /// A vector2 with all values set as the floating-point value 245 | extern __intrinsic vector2 toVector2(float value); 246 | 247 | /// Adds each value of the left vector2 to each value the right vector2. 248 | /// The left side of the operation. 249 | /// The right side of the operation. 250 | /// The addition result of the two vector2s. 251 | extern __intrinsic vector2 vector2Add(vector2 left, vector2 right); 252 | 253 | /// Substacts each value of the left vector2 from each value the right vector3. 254 | /// The left side of the operation. 255 | /// The right side of the operation. 256 | /// The subtraction result of the two vector2s. 257 | extern __intrinsic vector2 vector2Sub(vector2 left, vector2 right); 258 | 259 | /// Multiplies each value of the left vector2 by each value the right vector3. 260 | /// The left side of the operation. 261 | /// The right side of the operation. 262 | /// The multiplication result of the two vector2s. 263 | extern __intrinsic vector2 vector2Mult(vector2 left, vector2 right); 264 | 265 | /// Divides each value of the left vector2 by each value the right vector3. 266 | /// The left side of the operation. 267 | /// The right side of the operation. 268 | /// The division result of the two vector2s. 269 | extern __intrinsic vector2 vector2Div(vector2 left, vector2 right); 270 | 271 | /// Negates each value of the vector2. 272 | /// The vector to be negated. 273 | /// The negation result of the vector2. 274 | extern __intrinsic vector2 vector2Neg(vector2 vector); 275 | 276 | /// Calculates the dot product of two vector2s. 277 | /// The left side of the operation. 278 | /// The right side of the operation. 279 | /// The dot product of the two vector2s. 280 | extern __intrinsic float vector2Dot(vector2 left, vector2 right); 281 | 282 | /// Converts a vector2 to a vector3 with z initialized as 0. 283 | /// The vector2 to be converted. 284 | /// The vector2 as a vector3 with z initialized as 0. 285 | extern __intrinsic vector3 vector2ToVector3(vector2 vector); 286 | 287 | /// Converts a vector3 to a vector2 with z truncated. 288 | /// The vector3 to be converted. 289 | /// The vector3 as a vector2 with z truncated. 290 | extern __intrinsic vector2 vector3ToVector2(vector3 vector); 291 | 292 | /// Returns the floating-point remainder of numer/denom 293 | /// The Value of the quotient numerator. 294 | /// The Value of the quotient denominator.If denom is zero, the function may either return zero or cause a domain error 295 | /// The remainder of dividing the arguments. 296 | extern __intrinsic float fMod(float numer, float denom); 297 | 298 | /// Tests if the bit at a index of a value is set. 299 | /// The value of the integer to be tested. 300 | /// The bit index to be tested.This value must be an integer literal. 301 | /// The if the bit is set. 302 | extern __intrinsic bool bit_test(int value, const byte bitIndex); 303 | 304 | /// Sets the bit at a index at the address of a value. 305 | /// The address of the value. 306 | /// The bit index to be set.This value must be an integer literal. 307 | /// 308 | extern __intrinsic void bit_set(int* address, const byte bitIndex); 309 | 310 | /// Resets the bit at a index at the address of a value. 311 | /// The address of the value. 312 | /// The bit index to be reset.This value must be an integer literal. 313 | /// 314 | extern __intrinsic void bit_reset(int* address, const byte bitIndex); 315 | 316 | /// Flips the bit at a index at the address of a value. 317 | /// The address of the value. 318 | /// The bit index to be flipped.This value must be an integer literal. 319 | /// 320 | extern __intrinsic void bit_flip(int* address, const byte bitIndex); 321 | 322 | /// Gets the byte at an address in big endian. 323 | /// The address of the value you want to get. 324 | /// The the byte at an address in big endian. 325 | extern __intrinsic unsigned char getByte(void* addr); 326 | 327 | /// Sets the byte at an address. 328 | /// The address of the value you want to set. 329 | /// The value you want to set. 330 | extern __intrinsic void setByte(void* addr, unsigned char value); 331 | #pragma endregion //} 332 | 333 | #pragma region Variables //{ 334 | /// Sets a static variable at a specific index. 335 | /// The index of the static to set.This value must be an integer literal. 336 | /// The value to set the static. 337 | /// 338 | extern __intrinsic void setStaticAtIndex(const uint index, int value); 339 | 340 | /// Gets a static variable at a specific index. 341 | /// The index of the static to get.This value must be an integer literal. 342 | /// The static value. 343 | extern __intrinsic int getStaticAtIndex(const uint index); 344 | 345 | /// Gets the pointer to a static variable at a specific index. 346 | /// The index of the static to get.This value must be an integer literal. 347 | /// The pointer to the static. 348 | extern __intrinsic void* getStaticPtrAtIndex(const uint index); 349 | 350 | /// Sets a global variable at a specific index. 351 | /// The index of the global to set.This value must be an integer literal. 352 | /// The value to set the global. 353 | /// 354 | extern __intrinsic void setGlobalAtIndex(const uint index, int value); 355 | 356 | /// Gets a global variable at a specific index. 357 | /// The index of the global to get.This value must be an integer literal. 358 | /// The global value. 359 | extern __intrinsic int getGlobalAtIndex(const uint index); 360 | 361 | /// Gets the pointer to a global variable at a specific index. 362 | /// The index of the global to get.This value must be an integer literal. 363 | /// The pointer to the global. 364 | extern __intrinsic void* getGlobalPtrAtIndex(const uint index); 365 | 366 | /// Gets the pointer to a variable at a specific index in a array. 367 | /// The pointer to the array. 368 | /// The index of the array item. 369 | /// The array item size.This value must be an integer literal. 370 | /// The pointer to the array item. 371 | extern __intrinsic void* getPtrFromArrayIndex(const void* array, int index, const int arrayItemSize); 372 | 373 | /// Gets the pointer at a immediate index of a pointer. 374 | /// The starting pointer. 375 | /// The immediate index.This value must be an integer literal. 376 | /// The pointer + immIndex * 4. 377 | extern __intrinsic void* getPtrImmIndex(const void* pointer, const int immIndex); 378 | 379 | #pragma endregion //} 380 | 381 | #if PTRWIDTH == 64 382 | #pragma region YSC_Specific //{ 383 | /// Sets the lower 32 bits of a value. 384 | /// The address of the value you want to set. 385 | /// The value to set. 386 | extern __intrinsic void setLoDWord(void* addr, int value); 387 | /// Sets the higher 32 bits of a value. 388 | /// The address of the value you want to set. 389 | /// The value to set. 390 | extern __intrinsic void setHiDWord(void* addr, int value); 391 | /// Gets the lower 32 bits of a value. 392 | /// The address of the value you want to get. 393 | /// The the lower 32 bits of the value. 394 | extern __intrinsic int getLoDWord(void* addr); 395 | /// Gets the higher 32 bits of a value. 396 | /// The address of the value you want to get. 397 | /// The the higher 32 bits of the value. 398 | extern __intrinsic int getHiDWord(void* addr); 399 | #pragma endregion //} 400 | #endif 401 | 402 | #pragma region Custom_ASM //{ 403 | /************************************************************************* 404 | * These perform the operation on the item(or vector) on top of the stack 405 | * This can lead to dangerous behaviour if you aren't sure what is currently on the stack 406 | *************************************************************************/ 407 | 408 | /// Pops multiple items off the stack. 409 | /// The amount of items to pop off.This value must be an integer literal. 410 | /// 411 | extern __unsafeIntrinsic void __popMult(const uint count); 412 | 413 | /// Pushes a vector3 on the stack. 414 | /// The vector3 to be pushed. 415 | /// 416 | extern __unsafeIntrinsic void __pushV(vector3 value); 417 | 418 | /// Pushes a struct on the stack. 419 | /// The struct to be pushed. 420 | /// 421 | extern __unsafeIntrinsic void __pushStruct(void* structure); 422 | 423 | /// Pops a struct off the stack. 424 | /// The struct to be poped. 425 | /// 426 | extern __unsafeIntrinsic void __popStruct(void* structure); 427 | 428 | /// Reverses items on the stack. 429 | /// The amount of items to be reversed.This value must be an integer literal. 430 | /// 431 | extern __unsafeIntrinsic void __rev(const int numItems); 432 | 433 | /// Exchanges two same sized structs on the stack. 434 | /// The size of the struct.This value must be an integer literal. 435 | /// 436 | extern __unsafeIntrinsic void __exch(const int structStackSize); 437 | 438 | /// Gets the top item on the stack as a int. 439 | /// The top item on the stack as a int. 440 | extern __unsafeIntrinsic int __popI(); 441 | 442 | /// Gets the top item on the stack as a float. 443 | /// The top item on the stack as a float. 444 | extern __unsafeIntrinsic float __popF(); 445 | 446 | /// Gets the top 3 items on the stack as a vector3. 447 | /// The top 3 items on the stack as a vector3. 448 | extern __unsafeIntrinsic vector3 __popV(); 449 | 450 | /// Pushes an amount of items from the specified pointer to the stack. 451 | /// The pointer to draw from. 452 | /// The amount of items to push to the stack. 453 | /// 454 | extern __unsafeIntrinsic void __ptrToStack(const void* address, int count); 455 | 456 | /// Pops an amount of items from the stack to the specified pointer. 457 | /// The pointer to place the items. 458 | /// The amount of items to pop from the stack. 459 | /// 460 | extern __unsafeIntrinsic void __ptrFromStack(const void* address, int count); 461 | #pragma endregion //} 462 | 463 | #pragma region ASM //{ 464 | /************************************************************************* 465 | * These perform an operation on the item(or vector) on top of the stack 466 | * This can lead to dangerous behaviour if you aren't sure what is currently on the stack 467 | *************************************************************************/ 468 | 469 | /// 470 | /// Adds specified amount of nops to the script in the interval [0,4096]. 471 | /// Note: GTAIV nops exit the script. 472 | /// 473 | /// The amount of nops to add.This value must be an integer literal. 474 | /// 475 | extern __intrinsic void __nop(const uint count); 476 | /// 477 | /// Pops two items off the stack. (signed int32, signed int32) 478 | /// Performs {(Stack.Top - 1) + Stack.Top} as a signed int32. 479 | /// Pushes one item on the stack. 480 | /// 481 | extern __unsafeIntrinsic void __add(); 482 | /// 483 | /// Pops two items off the stack. (signed int32, signed int32) 484 | /// Performs {(Stack.Top - 1) - Stack.Top} as a signed int32. 485 | /// Pushes one item on the stack. 486 | /// 487 | extern __unsafeIntrinsic void __sub(); 488 | /// 489 | /// Pops two items off the stack. (signed int32, signed int32) 490 | /// Performs {(Stack.Top - 1) * Stack.Top} as a signed int32. 491 | /// Pushes one item on the stack. 492 | /// 493 | extern __unsafeIntrinsic void __mult(); 494 | /// 495 | /// Pops two items off the stack. (signed int32, signed int32) 496 | /// Performs {(Stack.Top - 1) / Stack.Top} as a signed int32. 497 | /// Pushes one item on the stack. 498 | /// 499 | extern __unsafeIntrinsic void __div(); 500 | /// 501 | /// Pops two items off the stack. (signed int32, signed int32) 502 | /// Performs {(Stack.Top - 1) % Stack.Top} as a signed int32. 503 | /// Pushes one item on the stack. 504 | /// 505 | extern __unsafeIntrinsic void __mod(); 506 | /// 507 | /// Pops one item off the stack. (signed int32) 508 | /// Performs {!Stack.Top} as a signed int32. 509 | /// Pushes one item on the stack. 510 | /// 511 | extern __unsafeIntrinsic void __not(); 512 | /// 513 | /// Pops one item off the stack. (signed int32) 514 | /// Performs {-Stack.Top} as a signed int32. 515 | /// Pushes one item on the stack. 516 | /// 517 | extern __unsafeIntrinsic void __neg(); 518 | /// 519 | /// Pops two items off the stack. (signed int32, signed int32) 520 | /// Performs {(Stack.Top - 1) == Stack.Top} as a signed int32. 521 | /// Pushes one item on the stack. 522 | /// 523 | extern __unsafeIntrinsic void __cmpEq(); 524 | /// 525 | /// Pops two items off the stack. (signed int32, signed int32) 526 | /// Performs {(Stack.Top - 1) != Stack.Top} as a signed int32. 527 | /// Pushes one item on the stack. 528 | /// 529 | extern __unsafeIntrinsic void __cmpNe(); 530 | /// 531 | /// Pops two items off the stack. (signed int32, signed int32) 532 | /// Performs {(Stack.Top - 1) > Stack.Top} as a signed int32. 533 | /// Pushes one item on the stack. 534 | /// 535 | extern __unsafeIntrinsic void __cmpGt(); 536 | /// 537 | /// Pops two items off the stack. (signed int32, signed int32) 538 | /// Performs {(Stack.Top - 1) >= Stack.Top} as a signed int32. 539 | /// Pushes one item on the stack. 540 | /// 541 | extern __unsafeIntrinsic void __cmpGe(); 542 | /// 543 | /// Pops two items off the stack. (signed int32, signed int32) 544 | /// Performs {(Stack.Top - 1) < Stack.Top} as a signed int32. 545 | /// Pushes one item on the stack. 546 | /// 547 | extern __unsafeIntrinsic void __cmpLt(); 548 | /// 549 | /// Pops two items off the stack. (signed int32, signed int32) 550 | /// Performs {(Stack.Top - 1) <= Stack.Top} as a signed int32. 551 | /// Pushes one item on the stack. 552 | /// 553 | extern __unsafeIntrinsic void __cmpLe(); 554 | /// 555 | /// Pops two items off the stack. (float, float) 556 | /// Performs {(Stack.Top - 1) + Stack.Top} as a float. 557 | /// Pushes one item on the stack. 558 | /// 559 | extern __unsafeIntrinsic void __addF(); 560 | /// 561 | /// Pops two items off the stack. (float, float) 562 | /// Performs {(Stack.Top - 1) - Stack.Top} as a float. 563 | /// Pushes one item on the stack. 564 | /// 565 | extern __unsafeIntrinsic void __subF(); 566 | /// 567 | /// Pops two items off the stack. (float, float) 568 | /// Performs {(Stack.Top - 1) * Stack.Top} as a float. 569 | /// Pushes one item on the stack. 570 | /// 571 | extern __unsafeIntrinsic void __multF(); 572 | /// 573 | /// Pops two items off the stack. (float, float) 574 | /// Performs {(Stack.Top - 1) / Stack.Top} as a float. 575 | /// Pushes one item on the stack. 576 | /// 577 | extern __unsafeIntrinsic void __divF(); 578 | /// 579 | /// Pops two items off the stack. (float, float) 580 | /// Performs {(Stack.Top - 1) % Stack.Top} as a float. 581 | /// Pushes one item on the stack. 582 | /// 583 | extern __unsafeIntrinsic void __modF(); 584 | /// 585 | /// Pops one item off the stack. (float) 586 | /// Performs {-Stack.Top} as a float. 587 | /// Pushes one item on the stack. 588 | /// 589 | extern __unsafeIntrinsic void __negF(); 590 | /// 591 | /// Pops two items off the stack. (float, float) 592 | /// Performs {(Stack.Top - 1) == Stack.Top} as a float. 593 | /// Pushes one item on the stack. 594 | /// 595 | extern __unsafeIntrinsic void __cmpEqF(); 596 | /// 597 | /// Pops two items off the stack. (float, float) 598 | /// Performs {(Stack.Top - 1) != Stack.Top} as a float. 599 | /// Pushes one item on the stack. 600 | /// 601 | extern __unsafeIntrinsic void __cmpNeF(); 602 | /// 603 | /// Pops two items off the stack. (float, float) 604 | /// Performs {(Stack.Top - 1) > Stack.Top} as a float. 605 | /// Pushes one item on the stack. 606 | /// 607 | extern __unsafeIntrinsic void __cmpGtF(); 608 | /// 609 | /// Pops two items off the stack. (float, float) 610 | /// Performs {(Stack.Top - 1) >= Stack.Top} as a float. 611 | /// Pushes one item on the stack. 612 | /// 613 | extern __unsafeIntrinsic void __cmpGeF(); 614 | /// 615 | /// Pops two items off the stack. (float, float) 616 | /// Performs {(Stack.Top - 1) < Stack.Top} as a float. 617 | /// Pushes one item on the stack. 618 | /// 619 | extern __unsafeIntrinsic void __cmpLtF(); 620 | /// 621 | /// Pops two items off the stack. (float, float) 622 | /// Performs {(Stack.Top - 1) <= Stack.Top} as a float. 623 | /// Pushes one item on the stack. 624 | /// 625 | extern __unsafeIntrinsic void __cmpLeF(); 626 | /// 627 | /// Pops six items off the stack. (float, float, float, float, float, float) 628 | /// Performs {(Stack.Top - 5) + (Stack.Top - 2)} as a float. 629 | /// Performs {(Stack.Top - 4) + (Stack.Top - 1)} as a float. 630 | /// Performs {(Stack.Top - 3) + Stack.Top} as a float. 631 | /// Pushes three items on the stack. 632 | /// 633 | extern __unsafeIntrinsic void __addV(); 634 | /// 635 | /// Pops six items off the stack. (float, float, float, float, float, float) 636 | /// Performs {(Stack.Top - 5) - (Stack.Top - 2)} as a float. 637 | /// Performs {(Stack.Top - 4) - (Stack.Top - 1)} as a float. 638 | /// Performs {(Stack.Top - 3) - Stack.Top} as a float. 639 | /// Pushes three items on the stack. 640 | /// 641 | extern __unsafeIntrinsic void __subV(); 642 | /// 643 | /// Pops six items off the stack. (float, float, float, float, float, float) 644 | /// Performs {(Stack.Top - 5) * (Stack.Top - 2)} as a float. 645 | /// Performs {(Stack.Top - 4) * (Stack.Top - 1)} as a float. 646 | /// Performs {(Stack.Top - 3) * Stack.Top} as a float. 647 | /// Pushes three items on the stack. 648 | /// 649 | extern __unsafeIntrinsic void __multV(); 650 | /// 651 | /// Pops six items off the stack. (float, float, float, float, float, float) 652 | /// Performs {(Stack.Top - 5) / (Stack.Top - 2)} as a float. 653 | /// Performs {(Stack.Top - 4) / (Stack.Top - 1)} as a float. 654 | /// Performs {(Stack.Top - 3) / Stack.Top} as a float. 655 | /// Pushes three items on the stack. 656 | /// 657 | extern __unsafeIntrinsic void __divV(); 658 | /// 659 | /// Pops three items off the stack. (float, float, float) 660 | /// Performs {-(Stack.Top - 2)} as a float. 661 | /// Performs {-(Stack.Top - 1)} as a float. 662 | /// Performs {-Stack.Top} as a float. 663 | /// Pushes three items on the stack. 664 | /// 665 | extern __unsafeIntrinsic void __negV(); 666 | /// 667 | /// Pops two item off the stack. (signed int32, signed int32) 668 | /// Performs {(Stack.Top - 1) & Stack.Top} as a signed int32. 669 | /// Pushes one item on the stack. 670 | /// 671 | extern __unsafeIntrinsic void __and(); 672 | /// 673 | /// Pops two item off the stack. (signed int32, signed int32) 674 | /// Performs {(Stack.Top - 1) | Stack.Top} as a signed int32. 675 | /// Pushes one item on the stack. 676 | /// 677 | extern __unsafeIntrinsic void __or(); 678 | /// 679 | /// Pops two item off the stack. (signed int32, signed int32) 680 | /// Performs {(Stack.Top - 1) ^ Stack.Top} as a signed int32. 681 | /// Pushes one item on the stack. 682 | /// 683 | extern __unsafeIntrinsic void __xor(); 684 | /// 685 | /// Pops one item off the stack. (signed int32) 686 | /// Performs {(float)Stack.Top} as a signed int32. 687 | /// Pushes one item on the stack. 688 | /// 689 | extern __unsafeIntrinsic void __iToF(); 690 | /// 691 | /// Pops one item off the stack. (float) 692 | /// Performs {(int)Stack.Top} as a float. 693 | /// Pushes one item on the stack. 694 | /// 695 | extern __unsafeIntrinsic void __fToI(); 696 | /// 697 | /// Pops one item off the stack. (float) 698 | /// Pushes three items of value Stack.Top on the stack. 699 | /// 700 | extern __unsafeIntrinsic void __fToV(); 701 | /// Pushes two signed int32 values to the stack. 702 | /// The first value to push to the stack.This value must be an integer literal. 703 | /// The second value to push to the stack.This value must be an integer literal. 704 | extern __unsafeIntrinsic void __push2(const int value0, const int value1); 705 | /// Pushes three signed int32 values to the stack. 706 | /// The first value to push to the stack.This value must be an integer literal. 707 | /// The second value to push to the stack.This value must be an integer literal. 708 | /// The third value to push to the stack.This value must be an integer literal. 709 | extern __unsafeIntrinsic void __push3(const int value0, const int value1, const int value2); 710 | /// Pushes one signed int32 value to the stack. 711 | /// The value to push to the stack.This value must be an integer literal. 712 | extern __unsafeIntrinsic void __push(const int value); 713 | /// Pushes one float value to the stack. 714 | /// The value to push to the stack.This value must be an floating-point literal. 715 | extern __unsafeIntrinsic void __pushF(const float value); 716 | /// Pushes a duplicate of Stack.Top to the stack. 717 | extern __unsafeIntrinsic void __dup(); 718 | /// Pops one item off the stack and discards it. 719 | extern __unsafeIntrinsic void __drop(); 720 | /// 721 | /// Pops the amount of items off the stack that the function takes. 722 | /// Calls a native function. 723 | /// 724 | /// The hash relating to the native.This value must be an integer literal. 725 | /// The param count of the native.This value must be an integer literal. 726 | /// The return count of the native.This value must be an integer literal. 727 | extern __unsafeIntrinsic void __callNative(const uint nativeHash, const uint paramCount, const uint returnCount); 728 | /// 729 | /// Pops the amount of items off the stack that the function takes. 730 | /// Calls a native function. 731 | /// 732 | /// The upper 32 bits of the hash relating to the native.This value must be an integer literal. 733 | /// The lower 32 bits of the hash relating to the native.This value must be an integer literal. 734 | /// The param count of the native.This value must be an integer literal. 735 | /// The return count of the native.This value must be an integer literal. 736 | extern __unsafeIntrinsic void __callNativePc(const uint nativeHash64Part1, const uint nativeHash64Part2, const uint paramCount, const uint returnCount); 737 | /// Returns a function. 738 | /// The param count of the function.This value must be an integer literal. 739 | /// The return count of the function.This value must be an integer literal. 740 | extern __unsafeIntrinsic void __return(const uint paramCount, const uint returnCount); 741 | /// 742 | /// Pops one item off the stack. (void*) 743 | /// Performs {*Stack.Top} as a signed int32. 744 | /// Pushes one item on the stack. 745 | /// 746 | extern __unsafeIntrinsic void __pGet(); 747 | /// 748 | /// Pops two items off the stack. (signed int32, void*) 749 | /// Performs {*Stack.Top = (Stack.Top - 1)} as a signed int32. 750 | /// 751 | extern __unsafeIntrinsic void __pSet(); 752 | /// 753 | /// Pops two items off the stack. (void*, signed int32) 754 | /// Performs {*(Stack.Top - 1) = Stack.Top} as a signed int32. 755 | /// Pushes Stack.Top on the stack. 756 | /// 757 | extern __unsafeIntrinsic void __pPeekSet(); 758 | /// 759 | /// Pops two items off the stack. (signed int32, void*) 760 | /// Pushes items at the pointer Stack.Top for (Stack.Top - 1) on the stack. 761 | /// 762 | extern __unsafeIntrinsic void __toStack(); 763 | /// 764 | /// Pops two items off the stack. (signed int32, void*) 765 | /// Pops off items from the stack for (Stack.Top - 1) into the pointer Stack.Top. 766 | /// 767 | extern __unsafeIntrinsic void __fromStack(); 768 | /// 769 | /// Pops two items off the stack. (signed int32, void*) 770 | /// Performs {&Stack.Top[(Stack.Top - 1)]}.> 771 | /// 772 | /// The array item stack size.This value must be an integer literal. 773 | extern __unsafeIntrinsic void __getArrayP(const uint arraySize); 774 | /// 775 | /// Pops two items off the stack. (signed int32, void*) 776 | /// Performs {Stack.Top[(Stack.Top - 1)]}. 777 | /// Pushes one item on the stack. 778 | /// 779 | /// The array item stack size.This value must be an integer literal. 780 | extern __unsafeIntrinsic void __getArray(const uint arraySize); 781 | /// 782 | /// Pops two items off the stack. (signed int32, void*) 783 | /// Performs {&Stack.Top[(Stack.Top - 1)] = (Stack.Top - 2)}. 784 | /// 785 | /// The array item stack size.This value must be an integer literal. 786 | extern __unsafeIntrinsic void __setArray(const uint arraySize); 787 | /// 788 | /// Gets a local functon frame pointer by an index. 789 | /// Pushes the frame pointer on the stack. 790 | /// 791 | /// The index to get the frame at.This value must be an integer literal. 792 | extern __unsafeIntrinsic void __getFrameP(const uint frameIndex); 793 | /// 794 | /// Gets a local functon frame pointer by it's name. 795 | /// Pushes the frame pointer on the stack. 796 | /// 797 | /// The name of the local function frame.This value must be an string literal. 798 | extern __unsafeIntrinsic void __getNamedFrameP(const char* frameName); 799 | /// 800 | /// Gets a local functon frame by an index. 801 | /// Pushes the frame on the stack. 802 | /// 803 | /// The index to get the frame at.This value must be an integer literal. 804 | extern __unsafeIntrinsic void __getFrame(const uint frameIndex); 805 | /// 806 | /// Gets a local functon frame by it's name. 807 | /// Pushes the frame on the stack. 808 | /// 809 | /// The name of the local function frame.This value must be an string literal. 810 | extern __unsafeIntrinsic void __getNamedFrame(const char* frameName); 811 | /// 812 | /// Pops one item off the stack. (signed int32) 813 | /// Sets a local functon frame by an index. 814 | /// 815 | /// The index to set the frame at.This value must be an integer literal. 816 | extern __unsafeIntrinsic void __setFrame(const uint frameIndex); 817 | /// 818 | /// Pops one item off the stack. (signed int32) 819 | /// Sets a local functon frame by it's name. 820 | /// 821 | /// The name of the local function frame.This value must be an string literal. 822 | extern __unsafeIntrinsic void __setNamedFrame(const char* frameName); 823 | /// 824 | /// Gets a static var pointer by an index. 825 | /// Pushes the static var pointer on the stack. 826 | /// 827 | /// The index to get the static at.This value must be an integer literal. 828 | extern __unsafeIntrinsic void __getStaticP(const uint staticIndex); 829 | /// 830 | /// Gets a static var pointer by it's name. 831 | /// Pushes the static var pointer on the stack. 832 | /// 833 | /// The name of the static var.This value must be an string literal. 834 | extern __unsafeIntrinsic void __getNamedStaticP(const char* StaticName); 835 | /// 836 | /// Gets a static var by an index. 837 | /// Pushes the static var on the stack. 838 | /// 839 | /// The index to get the static at.This value must be an integer literal. 840 | extern __unsafeIntrinsic void __getStatic(const uint staticIndex); 841 | /// 842 | /// Gets a static var by it's name. 843 | /// Pushes the static var on the stack. 844 | /// 845 | /// The name of the static var.This value must be an string literal. 846 | extern __unsafeIntrinsic void __getNamedStatic(const char* StaticName); 847 | /// 848 | /// Pops one item off the stack. (signed int32) 849 | /// Sets a static var by an index. 850 | /// 851 | /// The index to set the static at.This value must be an integer literal. 852 | extern __unsafeIntrinsic void __setStatic(const uint staticIndex); 853 | /// 854 | /// Pops one item off the stack. (signed int32) 855 | /// Sets a static var by it's name. 856 | /// 857 | /// The name of the static var.This value must be an string literal. 858 | extern __unsafeIntrinsic void __setNamedStatic(const char* StaticName); 859 | /// 860 | /// Pops one item off the stack. (signed int32) 861 | /// Performs {Stack.Top + value} as a signed int32. 862 | /// Pushes one item on the stack. 863 | /// 864 | /// Right hand side of the math operation.This value must be an integer literal. 865 | extern __unsafeIntrinsic void __addImm(const uint value); 866 | /// 867 | /// Pops one item off the stack. (signed int32) 868 | /// Performs {Stack.Top * value} as a signed int32. 869 | /// Pushes one item on the stack. 870 | /// 871 | /// Right hand side of the math operation.This value must be an integer literal. 872 | extern __unsafeIntrinsic void __multImm(const uint value); 873 | /// 874 | /// Pops one item off the stack. (void*) 875 | /// Performs {Stack.Top + immediate * 4} as a signed int32. 876 | /// Pushes one item on the stack. 877 | /// 878 | /// The immediate value of a pointer.This value must be an integer literal. 879 | extern __unsafeIntrinsic void __getImmP(const uint immediate); 880 | /// 881 | /// Pops one item off the stack. (void*) 882 | /// Performs {*(Stack.Top + immediate * 4)} as a signed int32. 883 | /// Pushes one item on the stack. 884 | /// 885 | /// The immediate value of a pointer.This value must be an integer literal. 886 | extern __unsafeIntrinsic void __getImm(const uint immediate); 887 | /// 888 | /// Pops one item off the stack. (signed int32, void*) 889 | /// Performs {*(Stack.Top + immediate * 4) = (Stack.Top - 1)} as a signed int32. 890 | /// 891 | /// The immediate value of a pointer.This value must be an integer literal. 892 | extern __unsafeIntrinsic void __setImm(const uint immediate); 893 | /// 894 | /// Gets a global var pointer by an index. 895 | /// Pushes the global var pointer on the stack. 896 | /// 897 | /// The index to get the global at.This value must be an integer literal. 898 | extern __unsafeIntrinsic void __getGlobalP(const uint globalIndex); 899 | /// 900 | /// Gets a global var by an index. 901 | /// Pushes the global var on the stack. 902 | /// 903 | /// The index to get the global at.This value must be an integer literal. 904 | extern __unsafeIntrinsic void __getGlobal(const uint globalIndex); 905 | /// 906 | /// Pops one item off the stack. (signed int32) 907 | /// Sets a global var by an index. 908 | /// 909 | /// The index to set the global at.This value must be an integer literal. 910 | extern __unsafeIntrinsic void __setGlobal(const uint globalIndex); 911 | /// 912 | /// Pops one item off the stack. (signed int32) 913 | /// Switchs on Stack.Top to the case. 914 | /// This function must have a label for every case. 915 | /// 916 | /// The case of the switch.This value must be an integer literal. 917 | /// The label of the switch to jump to if Stack.Top == Case.This value must be an string literal. 918 | extern __unsafeIntrinsic void __switch(const int Case, const char* label, ...); 919 | /// 920 | /// Performs {goto label;}. 921 | /// 922 | /// The label to jump to.This value must be an string literal. 923 | extern __unsafeIntrinsic void __jump(const char* label); 924 | /// 925 | /// Pops one item off the stack. (signed int32) 926 | /// Performs {if(Stack.Top) goto label;}. 927 | /// 928 | /// The label to jump to.This value must be an string literal. 929 | extern __unsafeIntrinsic void __jumpFalse(const char* label); 930 | /// 931 | /// Pops two items off the stack. (signed int32, signed int32) 932 | /// Performs {if((Stack.Top - 1) != Stack.Top) goto label;}. 933 | /// 934 | /// The label to jump to.This value must be an string literal. 935 | extern __unsafeIntrinsic void __jumpNE(const char* label); 936 | /// 937 | /// Pops two items off the stack. (signed int32, signed int32) 938 | /// Performs {if((Stack.Top - 1) == Stack.Top) goto label;}. 939 | /// 940 | /// The label to jump to.This value must be an string literal. 941 | extern __unsafeIntrinsic void __jumpEQ(const char* label); 942 | /// 943 | /// Pops two items off the stack. (signed int32, signed int32) 944 | /// Performs {if((Stack.Top - 1) <= Stack.Top) goto label;}. 945 | /// 946 | /// The label to jump to.This value must be an string literal. 947 | extern __unsafeIntrinsic void __jumpLE(const char* label); 948 | /// 949 | /// Pops two items off the stack. (signed int32, signed int32) 950 | /// Performs {if((Stack.Top - 1) < Stack.Top) goto label;}. 951 | /// 952 | /// The label to jump to.This value must be an string literal. 953 | extern __unsafeIntrinsic void __jumpLT(const char* label); 954 | /// 955 | /// Pops two items off the stack. (signed int32, signed int32) 956 | /// Performs {if((Stack.Top - 1) >= Stack.Top) goto label;}. 957 | /// 958 | /// The label to jump to.This value must be an string literal. 959 | extern __unsafeIntrinsic void __jumpGE(const char* label); 960 | /// 961 | /// Pops two items off the stack. (signed int32, signed int32) 962 | /// Performs {if((Stack.Top - 1) > Stack.Top) goto label;}. 963 | /// 964 | /// The label to jump to.This value must be an string literal. 965 | extern __unsafeIntrinsic void __jumpGT(const char* label); 966 | /// 967 | /// Pops the amount of items off the stack that the function takes. 968 | /// Calls a function. 969 | /// 970 | /// The name of the function to call.This value must be an string literal. 971 | extern __unsafeIntrinsic void __call(const char* functionName); 972 | /// Pushes one char* to the stack. 973 | /// The string that will be referenced by the pointer.This value must be an string literal. 974 | extern __unsafeIntrinsic void __pushString(const char* value); 975 | /// 976 | /// Pops one item off the stack. (char*) 977 | /// Performs {joaat(Stack.Top);}. 978 | /// Pushes one item on the stack. 979 | /// 980 | extern __unsafeIntrinsic void __getHash(); 981 | /// 982 | /// Pops two items off the stack. (char*, char*) 983 | /// Copies (Stack.Top - 1) into Stack.Top for strLen bytes or until a 0 was hit in (Stack.Top - 1). 984 | /// 985 | /// The length of the string destination buffer.This value must be an integer literal. 986 | extern __unsafeIntrinsic void __strCopy(const uint strLen); 987 | /// 988 | /// Pops two items off the stack. (signed int32, char*) 989 | /// Copies the string representation of (Stack.Top - 1) into Stack.Top for strLen bytes or until a 0 was hit in (Stack.Top - 1). 990 | /// 991 | /// The length of the string destination buffer.This value must be an integer literal. 992 | extern __unsafeIntrinsic void __iToS(const uint strLen); 993 | /// 994 | /// Pops two items off the stack. (char*, char*) 995 | /// Appends (Stack.Top - 1) into Stack.Top for strLen bytes or until a 0 was hit in (Stack.Top - 1). 996 | /// 997 | /// The length of the string destination buffer.This value must be an integer literal. 998 | extern __unsafeIntrinsic void __strAdd(const uint strLen); 999 | /// 1000 | /// Pops two items off the stack. (signed int32, char*) 1001 | /// appends the string representation of (Stack.Top - 1) into Stack.Top for strLen bytes or until a 0 was hit in (Stack.Top - 1). 1002 | /// 1003 | /// The length of the string destination buffer.This value must be an integer literal. 1004 | extern __unsafeIntrinsic void __strAddI(const uint strLen); 1005 | /// 1006 | /// Pops three items off the stack. (signed int32, signed int32, void*) 1007 | /// Pops off items from the stack for {(Stack.Top - 2) * (Stack.Top - 1) / 4} into the pointer Stack.Top. 1008 | /// 1009 | extern __unsafeIntrinsic void __memCopy(); 1010 | /// 1011 | /// Pops one item off the stack. (void*) then pops the amount of items off the stack that the function takes. 1012 | /// Calls the function at the pointer Stack.Top. 1013 | /// 1014 | extern __unsafeIntrinsic void __pCall(); 1015 | #pragma endregion //} 1016 | 1017 | #undef __intrinsic 1018 | #undef __unsafeIntrinsic 1019 | 1020 | /// Creates a array with the first item as the size. 1021 | /// The type of array to create. 1022 | /// The name of the array to create. 1023 | /// The size of the array to create. 1024 | #define CreateSizedArray(type, name, sizein, ...)\ 1025 | struct SizedArray\ 1026 | {\ 1027 | unsigned int size;\ 1028 | type items[sizein];\ 1029 | } name = {.size = sizein, .items = {__VA_ARGS__}} 1030 | 1031 | /// Gets the size of the sized array. 1032 | /// The pointer to the sized array. 1033 | #define GetSizedArraySize(sizedarr) (*(unsigned int*)sizedarr) 1034 | 1035 | /// Gets an item of the sized array. 1036 | /// The pointer to the sized array. 1037 | /// The type of the sized array. 1038 | /// The index of the sized array item. 1039 | #define GetSizedArrayItem(sizedarr, type, index) (*(type*)((int*)sizedarr + 1 + index)) 1040 | 1041 | /// Converts an array to a sized array. 1042 | /// The pointer to the array. 1043 | /// The pointer to the sized array. 1044 | #define ArrayToSizedArray(arr, sizedarr)\ 1045 | if(sizeof(arr) == sizeof(sizedarr.items))\ 1046 | memcpy(sizedarr.items, arr, countof(arr)); 1047 | 1048 | /// Converts an sized array to a array. 1049 | /// The pointer to the sized array. 1050 | /// The pointer to the array. 1051 | #define SizedArrayToArray(sizedarr, arr)\ 1052 | if(sizeof(arr) == sizeof(sizedarr.items))\ 1053 | memcpy(arr, sizedarr.items, countof(sizedarr.items)); 1054 | 1055 | -------------------------------------------------------------------------------- /include/natives.h: -------------------------------------------------------------------------------- 1 | /*H********************************************************************** 2 | * FILENAME : natives.h START DATE : 10 Sept 16 3 | * 4 | * DESCRIPTION : 5 | * native.h file controller based on your current target and platform. 6 | * 7 | * NOTES : 8 | * This file is part of SC-CL's include library. 9 | * 10 | * LICENSE : 11 | * 12 | * Copyright 2016 SC-CL 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * * Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 20 | * * Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * * Neither SC-CL nor its contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * * Redistribution of this software in source or binary forms shall be free 28 | * of all charges or fees to the recipient of this software. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 31 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 33 | * DISCLAIMED. IN NO EVENT SHALL SC-CL BE LIABLE FOR ANY 34 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 35 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 37 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * AUTHORS : 42 | * Rocko Tompkins 43 | * Nathan James 44 | *H*/ 45 | #pragma once 46 | 47 | #if TARGET == TARGET_RDR 48 | 49 | #include "RDR/natives32.h" 50 | 51 | #elif TARGET == TARGET_GTAV 52 | 53 | #if PTRWIDTH == 64 54 | #include "GTAV/natives64.h" 55 | #else 56 | #include "GTAV/natives32.h" 57 | #endif 58 | 59 | #elif TARGET == TARGET_GTAIV 60 | 61 | #if PLATFORM == PLATFORM_PC 62 | #include "GTAIV/natives32.h"//1.0.7.0 63 | #else 64 | #include "GTAIV/natives32Old.h"//1.0.4.0 65 | #endif 66 | 67 | #endif -------------------------------------------------------------------------------- /include/types.h: -------------------------------------------------------------------------------- 1 | /*H********************************************************************** 2 | * FILENAME : types.h START DATE : 10 Sept 16 3 | * 4 | * DESCRIPTION : 5 | * Types to be used with all targets and platforms of SC-CL. 6 | * 7 | * NOTES : 8 | * This file is part of SC-CL's include library. 9 | * 10 | * LICENSE : 11 | * 12 | * Copyright 2016 SC-CL 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 17 | * * Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 20 | * * Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * * Neither SC-CL nor its contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * * Redistribution of this software in source or binary forms shall be free 28 | * of all charges or fees to the recipient of this software. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 31 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 33 | * DISCLAIMED. IN NO EVENT SHALL SC-CL BE LIABLE FOR ANY 34 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 35 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 37 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * AUTHORS : 42 | * Rocko Tompkins 43 | * Nathan James 44 | *H*/ 45 | #pragma once 46 | 47 | #ifndef _MSC_VER 48 | #define global(index) __attribute((scriptglobal(index))) 49 | #define noinline __attribute((noinline)) 50 | #define unsafe __attribute((unsafe)) 51 | #else 52 | #define _Generic(x) 0 53 | #define global(index) 54 | #define noinline 55 | #define unsafe 56 | #endif 57 | 58 | #if PLATFORM == PLATFORM_PC && TARGET == TARGET_GTAV 59 | #define int long long 60 | #define float double 61 | #endif 62 | 63 | //calculation range is -2,147,483,648 to 2,147,483,647 64 | //any value above or below that will be automatically cast to a signed int 65 | typedef unsigned int uint; 66 | typedef unsigned char byte; 67 | typedef unsigned char uchar; 68 | typedef unsigned short ushort; 69 | 70 | //Fix for intellisense nonsense 71 | #ifndef _MSC_VER 72 | typedef _Bool bool; 73 | #else 74 | typedef int bool; 75 | #endif 76 | 77 | typedef int Player; 78 | typedef int Entity; 79 | typedef Entity Ped; 80 | typedef Entity Vehicle; 81 | typedef Entity Object; 82 | typedef uint Hash; 83 | typedef int Cam; 84 | typedef int FireId; 85 | typedef int CarGenerator; 86 | typedef int Group; 87 | typedef int Train; 88 | typedef int Pickup; 89 | typedef int Object; 90 | typedef int Weapon; 91 | typedef int Interior; 92 | typedef int Blip; 93 | typedef int Texture; 94 | typedef int TextureDict; 95 | typedef int CoverPoint; 96 | typedef int Camera; 97 | typedef int TaskSequence; 98 | typedef int ColourIndex; 99 | typedef int Sphere; 100 | typedef int ScrHandle; 101 | typedef int DecisionMaker; 102 | typedef int ScriptAny; 103 | typedef int UnkInt; 104 | typedef int Actor; 105 | typedef int Controller; 106 | typedef int Layout; 107 | typedef int Iterator; 108 | typedef int IterationSet; 109 | typedef int GUIWindow; 110 | typedef float Time; 111 | 112 | typedef struct NetworkHandle 113 | { 114 | int data[13]; 115 | } NetworkHandle; 116 | 117 | typedef union vector2 118 | { 119 | struct { float x, y; }; 120 | struct { float width, height; }; 121 | struct { float w, h; }; 122 | float v[2]; 123 | } Point, Size, vector2; 124 | 125 | //GTA Coord Type = Y Depth 126 | //RDR Coord Type = Z Depth 127 | typedef union vector3 128 | { 129 | struct { float x, y, z; }; 130 | float v[3]; 131 | } vector3; 132 | 133 | typedef union quaternion 134 | { 135 | struct { float x, y, z, w; }; 136 | float v[4]; 137 | } quaternion; 138 | 139 | //Color struct where values range from 0 - 255 140 | typedef union RGBA 141 | { 142 | struct 143 | { 144 | union{int red; int r;}; 145 | union{int green; int g;}; 146 | union{int blue; int b;}; 147 | union{int opacity; int alpha; int a;}; 148 | }; 149 | int col[4]; 150 | } RGBA; 151 | 152 | //Color struct where values range from 0 - 255 153 | typedef union RGB 154 | { 155 | struct 156 | { 157 | union{int red; int r;}; 158 | union{int green; int g;}; 159 | union{int blue; int b;}; 160 | }; 161 | int col[3]; 162 | } RGB; 163 | 164 | //Color struct where values range from 0.0 - 1.0 165 | typedef union FloatRGBA 166 | { 167 | struct 168 | { 169 | union{float red; float r;}; 170 | union{float green; float g;}; 171 | union{float blue; float b;}; 172 | union{float opacity; float alpha; float a;}; 173 | }; 174 | float col[4]; 175 | } FloatRGBA; 176 | 177 | //Color struct where values range from 0.0 - 1.0 178 | typedef union FloatRGB 179 | { 180 | struct 181 | { 182 | union{float red; float r;}; 183 | union{float green; float g;}; 184 | union{float blue; float b;}; 185 | }; 186 | float col[3]; 187 | } FloatRGB; 188 | 189 | typedef union flint 190 | { 191 | int Int; 192 | float Float; 193 | } flint; 194 | 195 | typedef union any 196 | { 197 | int Int; 198 | float Float; 199 | bool Bool; 200 | char* CharP; 201 | byte* ByteP; 202 | int* IntP; 203 | float* FloatP; 204 | short* ShortP; 205 | vector3* Vector3P; 206 | quaternion* QuaternionP; 207 | byte ByteArray[4]; 208 | char CharArray[4]; 209 | short ShortArray[2]; 210 | } any; 211 | 212 | typedef enum DataType 213 | { 214 | DT_None, 215 | DT_UInt, 216 | DT_UIntP, 217 | DT_Int, 218 | DT_IntP, 219 | DT_Float, 220 | DT_FloatP, 221 | DT_Bool, 222 | DT_BoolP, 223 | DT_Char, 224 | DT_CharP, 225 | DT_Short, 226 | DT_ShortP, 227 | DT_UShort, 228 | DT_UShortP, 229 | DT_Vector3, 230 | DT_Vector3P, 231 | DT_Vector2, 232 | DT_Vector2P, 233 | DT_Quaternion, 234 | DT_QuaternionP, 235 | DT_FunctionP 236 | } DataType; 237 | 238 | //poor mans constructors 239 | 240 | /// Constructs a any type. 241 | /// The value you want to store. 242 | /// A any type. 243 | #define any(x) (any){x} 244 | 245 | /// Constructs a RGBA type. 246 | /// The red value to be initialized, in the interval [0,255] 247 | /// The green value to be initialized, in the interval [0,255] 248 | /// The blue value to be initialized, in the interval [0,255] 249 | /// The alpha value to be initialized, in the interval [0,255] 250 | /// A RGBA type. 251 | #define RGBA(R, G, B, A) (RGBA){R, G, B, A} 252 | 253 | /// Constructs a RGB type. 254 | /// The red value to be initialized, in the interval [0,255] 255 | /// The green value to be initialized, in the interval [0,255] 256 | /// The blue value to be initialized, in the interval [0,255] 257 | /// A RGB type. 258 | #define RGB(R, G, B) (RGB){R, G, B} 259 | 260 | /// Constructs a FloatRGBA type. 261 | /// The red value to be initialized, in the interval [0.0,1.0] 262 | /// The green value to be initialized, in the interval [0.0,1.0] 263 | /// The blue value to be initialized, in the interval [0.0,1.0] 264 | /// The alpha value to be initialized, in the interval [0.0,1.0] 265 | /// A FloatRGBA type. 266 | #define FloatRGBA(R, G, B, A) (FloatRGBA){R, G, B, A} 267 | 268 | /// Constructs a FloatRGB type. 269 | /// The red value to be initialized, in the interval [0.0,1.0] 270 | /// The green value to be initialized, in the interval [0.0,1.0] 271 | /// The blue value to be initialized, in the interval [0.0,1.0] 272 | /// A FloatRGB type. 273 | #define FloatRGB(R, G, B) (FloatRGB){R, G, B} 274 | 275 | /// Constructs a vector2 Point type. 276 | /// The x axis to be initialized. 277 | /// The y axis to be initialized. 278 | /// A Point type. 279 | #define Point(x, y) (Point){x, y} 280 | 281 | /// Constructs a vector2 Size type. 282 | /// The width to be initialized. 283 | /// The height to be initialized. 284 | /// A Size type. 285 | #define Size(w, h) (Size){w, h} 286 | 287 | /// Constructs a vector2 type. 288 | /// The x axis to be initialized. 289 | /// The y axis to be initialized. 290 | /// A vector2 type. 291 | #define vector2(x, y) (vector2){x, y} 292 | 293 | /// Constructs a vector3 type. 294 | /// The x axis to be initialized. 295 | /// The y axis to be initialized. 296 | /// The z axis to be initialized. 297 | /// A vector3 type. 298 | #define vector3(x, y, z) (vector3){x, y, z} 299 | 300 | /// Constructs a quaternion type. 301 | /// X component of the quaternion. 302 | /// Y component of the quaternion. 303 | /// Z component of the quaternion. 304 | /// W component of the quaternion. 305 | /// A quaternion type. 306 | #define quaternion(x, y, z, w) (quaternion){x, y, z, w} 307 | 308 | typedef void* SizedArray; 309 | 310 | -------------------------------------------------------------------------------- /include/varargs.h: -------------------------------------------------------------------------------- 1 | /*H********************************************************************** 2 | * FILENAME : varargs.h START DATE : 10 Sept 16 3 | * 4 | * DESCRIPTION : 5 | * Provides facilities for stepping through a list of function arguments of 6 | * an unknown number and type. 7 | * 8 | * NOTES : 9 | * This file is part of SC-CL's include library. 10 | * 11 | * The type used in va_arg is supposed to match the actual type 12 | * after default promotions. Thus, va_arg (..., short) is not valid. 13 | * 14 | * LICENSE : 15 | * 16 | * Copyright 2016 SC-CL 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted provided that the following conditions are met: 20 | * 21 | * * Redistributions of source code must retain the above copyright 22 | * notice, this list of conditions and the following disclaimer. 23 | * 24 | * * Redistributions in binary form must reproduce the above copyright 25 | * notice, this list of conditions and the following disclaimer in the 26 | * documentation and/or other materials provided with the distribution. 27 | * 28 | * * Neither SC-CL nor its contributors may be used to endorse or promote products 29 | * derived from this software without specific prior written permission. 30 | * 31 | * * Redistribution of this software in source or binary forms shall be free 32 | * of all charges or fees to the recipient of this software. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 35 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 36 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL SC-CL BE LIABLE FOR ANY 38 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 39 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 40 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 41 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 42 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 43 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | * 45 | * AUTHORS : 46 | * Rocko Tompkins 47 | * Nathan James 48 | *H*/ 49 | #pragma once 50 | 51 | #ifndef _VA_LIST 52 | #define _VA_LIST 53 | typedef int* va_list; 54 | #endif 55 | 56 | /// 57 | /// Amount of space required in an argument list (ie. the stack) for an 58 | /// argument of type t. 59 | /// 60 | /// The type to be evaluated. 61 | /// 62 | #define __va_argsiz(t) \ 63 | (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) 64 | 65 | /// 66 | /// Start variable argument list processing by setting AP to point to the 67 | /// argument after pN. 68 | /// 69 | /// 70 | /// Uninitialized object of type va_list. 71 | /// After the call, it carries the information needed to retrieve the additional arguments using va_arg. 72 | /// If ap has already been passed as first argument to a previous call to va_start or va_copy, it shall be passed to va_end before calling this function. 73 | /// 74 | /// 75 | /// Name of the last named parameter in the function definition. 76 | /// The arguments extracted by subsequent calls to va_arg are those after pN. 77 | /// 78 | /// 79 | #define va_start(ap, pN) \ 80 | ((ap) = (va_list)*(va_list)((char*)(&pN) + __va_argsiz(pN))) 81 | 82 | /// 83 | /// Increment ap to the next argument in the list while returing a 84 | /// pointer to what ap pointed to first, which is of type t. 85 | /// 86 | /// 87 | /// Object of type va_list carrying information about the current retrieval state of a variable argument list. 88 | /// This object shall have been initialized by an initial call to va_start or va_copy and not have been released with va_end. 89 | /// 90 | /// 91 | /// A type name.This type name is used as the type of the expression this macro expands to(i.e., its return type). 92 | /// For a type expression to be suitable for its use with va_arg, it must be such that type* produces a pointer to type. 93 | /// The type shall be compatible with type of the extracted argument(as promoted according to the default argument promotions), 94 | /// or one be the unsigned version of the other, or one be a void pointer and the other some other pointer type. 95 | /// 96 | /// 97 | #define va_arg(ap, t) \ 98 | (((ap) = (va_list)((char*)(ap) + __va_argsiz(t))), \ 99 | *((t*)((char*)(ap) - __va_argsiz(t)))) 100 | 101 | /// 102 | /// Initializes dest as a copy of src (in its current state) 103 | /// 104 | /// 105 | /// Uninitialized object of type va_list. 106 | /// After the call, it carries the information needed to retrieve the same additional arguments as src. 107 | /// If dest has already been passed as first argument to a previous call to va_start or va_copy, it shall be passed to va_end before calling this function. 108 | /// 109 | /// 110 | /// Object of type va_list that already carries information to retrieve additional arguments with va_arg 111 | /// (i.e., it has already been passed as first argument to va_start or va_copy ans has not yet been released with va_end). 112 | /// 113 | /// 114 | #define va_copy(dest, src) ((dest) = (src)) 115 | 116 | /// 117 | /// End processing of variable argument list. In this case we do nothing. 118 | /// 119 | /// 120 | /// Object of type va_list carrying information about the current retrieval state of a variable argument list. 121 | /// This object shall have been initialized by an initial call to va_start or va_copy and not have been released with va_end. 122 | /// 123 | /// 124 | #define va_end(ap) ((void)0) 125 | 126 | /// 127 | /// Gets the variable argument param count from the last argument pN 128 | /// 129 | /// 130 | /// Name of the last named parameter in the function definition. 131 | /// 132 | /// 133 | #define va_count(pN) \ 134 | (*(int*)((char*)(&pN) + __va_argsiz(pN) + sizeof(va_list))) 135 | 136 | /// 137 | /// Gets the variable argument stack count from the last argument pN 138 | /// 139 | /// 140 | /// Name of the last named parameter in the function definition. 141 | /// 142 | /// 143 | #define va_scount(pN) \ 144 | (*(int*)((char*)(&pN) + __va_argsiz(pN) + sizeof(va_list) + sizeof(int))) 145 | 146 | #define __OL_N(number) number, impossible, number 147 | #define __OL_S 1, 0, 1, 148 | #define __OL_CIP(...) , 149 | #define __OL_LP ( 150 | #define __OL_EX(...) __VA_ARGS__ 151 | #define __OL_CH(...) __OL_EX(__OL_LOG __OL_LP __VA_ARGS__ __OL_CIP __VA_ARGS__ __OL_CIP __VA_ARGS__ (), \ 152 | __OL_N(20), __OL_N(19), __OL_N(18), __OL_N(17), __OL_N(16), __OL_N(15), __OL_N(14), __OL_N(13), __OL_N(12), __OL_N(11), __OL_N(10), \ 153 | __OL_N(9), __OL_N(8), __OL_N(7), __OL_N(6), __OL_N(5), __OL_N(4), __OL_N(3), __OL_N(2), __OL_S )) 154 | #define __OL_LOG( \ 155 | arg1, arg1_0, arg1_1, \ 156 | arg2, arg2_0, arg2_1, \ 157 | arg3, arg3_0, arg3_1, \ 158 | arg4, arg4_0, arg4_1, \ 159 | arg5, arg5_0, arg5_1, \ 160 | arg6, arg6_0, arg6_1, \ 161 | arg7, arg7_0, arg7_1, \ 162 | arg8, arg8_0, arg8_1, \ 163 | arg9, arg9_0, arg9_1, \ 164 | arg10, arg10_0, arg10_1, \ 165 | arg11, arg11_0, arg11_1, \ 166 | arg12, arg12_0, arg12_1, \ 167 | arg13, arg13_0, arg13_1, \ 168 | arg14, arg14_0, arg14_1, \ 169 | arg15, arg15_0, arg15_1, \ 170 | arg16, arg16_0, arg16_1, \ 171 | arg17, arg17_0, arg17_1, \ 172 | arg18, arg18_0, arg18_1, \ 173 | arg19, arg19_0, arg19_1, \ 174 | arg20, arg20_0, arg20_1, \ 175 | arg, ...) arg 176 | 177 | #define _OVERLOAD_(name, n) name##n 178 | #define _OVERLOAD(name, n) _OVERLOAD_(name, n) 179 | #define OVERLOAD(func, ...) _OVERLOAD(func, __OL_CH(__VA_ARGS__)) (__VA_ARGS__) 180 | 181 | 182 | -------------------------------------------------------------------------------- /src/Menu.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RDR SCO 6 | Win32 7 | 8 | 9 | RDR _SC 10 | Win32 11 | 12 | 13 | 14 | {130629F0-649C-4E82-B00A-590905509FFB} 15 | Menu 16 | 10.0 17 | 18 | 19 | 20 | Utility 21 | false 22 | ClangCL 23 | true 24 | MultiByte 25 | 26 | 27 | Utility 28 | false 29 | LLVM-vs2014 30 | true 31 | MultiByte 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ..\bin\ 47 | ..\bin\ 48 | Menu 49 | ..\include;$(IncludePath) 50 | 51 | 52 | $(SolutionDir)$(Configuration)\X360\ 53 | $(Configuration)\X360\log\ 54 | 55 | 56 | 57 | Level3 58 | MaxSpeed 59 | false 60 | false 61 | false 62 | "../../include/";Include/ 63 | 4391;4392;4244;%(DisableSpecificWarnings) 64 | _MBCS;%(PreprocessorDefinitions);ENDIAN_BIG=0;ENDIAN_LITTLE=1;PLATFORM_X360=0;PLATFORM_PS3=1;PLATFORM_PC=2;TARGET_GTAIV=0;TARGET_GTAV=1;TARGET_RDR=2;FILETYPE_XSC=0;FILETYPE_YSC=1;FILETYPE_CSC=2;FILETYPE_SCO=3;SUBTARGET_TBOGT=0;SUBTARGET_TLAD=1;PTRWIDTH=32;TARGET=TARGET_RDR;FILETYPE=FILETYPE_XSC;PLATFORM=PLATFORM_X360;ENDIAN=ENDIAN_BIG 65 | 66 | 67 | false 68 | false 69 | true 70 | CompileAsC 71 | 72 | 73 | true 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | 81 | 82 | Level3 83 | MaxSpeed 84 | false 85 | false 86 | false 87 | "../../include/" 88 | 4391;4392;4244;%(DisableSpecificWarnings) 89 | _MBCS;%(PreprocessorDefinitions);ENDIAN_BIG=0;ENDIAN_LITTLE=1;PLATFORM_X360=0;PLATFORM_PS3=1;PLATFORM_PC=2;TARGET_GTAIV=0;TARGET_GTAV=1;TARGET_RDR=2;FILETYPE_XSC=0;FILETYPE_YSC=1;FILETYPE_CSC=2;FILETYPE_SCO=3;SUBTARGET_TBOGT=0;SUBTARGET_TLAD=1;PTRWIDTH=32;TARGET=TARGET_RDR;FILETYPE=FILETYPE_SCO;PLATFORM=PLATFORM_X360;ENDIAN=ENDIAN_BIG 90 | 91 | 92 | false 93 | false 94 | true 95 | CompileAsC 96 | 97 | 98 | true 99 | true 100 | 101 | 102 | false 103 | 104 | 105 | 106 | 107 | "../../bin/SC-CL.exe" -platform=X360 -target=RDR_#SC -out-dir="$(OutDir)bin\\" -vcx="$(ProjectFileName)" -- -I "../../include/" 108 | "../../bin/SC-CL.exe" -platform=X360 -target=RDR_SCO -out-dir="$(OutDir)bin\\" -vcx="$(ProjectFileName)" -- -I "../../include/" 109 | Menu.dh%(Outputs) 110 | Menu.dh%(Outputs) 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /src/Menu.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {99bf53d6-378f-413e-b921-40ff6f9d3da1} 6 | 7 | 8 | {053dd82d-826d-458a-997e-921c5a8208b1} 9 | 10 | 11 | 12 | 13 | {56e85d47-cf3e-47cd-9b83-952caed44f1c} 14 | 15 | 16 | {40e788e5-9ec8-4d99-913f-3f3eb11dba9b} 17 | 18 | 19 | {39485b75-34a8-43f9-bb94-22b872d7b48b} 20 | 21 | 22 | {456602c3-bb45-4bdb-a056-50ce76fe2906} 23 | 24 | 25 | {96d64924-cb91-4af9-b6b7-2560133ae9e6} 26 | 27 | 28 | {3be1bf3f-d698-45da-b2e9-3c0042ba89ab} 29 | 30 | 31 | {c3125bec-6181-4f66-bcef-b49b68bc59b2} 32 | 33 | 34 | 35 | 36 | include 37 | 38 | 39 | include 40 | 41 | 42 | include 43 | 44 | 45 | include\SC-CL 46 | 47 | 48 | include\SC-CL 49 | 50 | 51 | include\SC-CL 52 | 53 | 54 | include\SC-CL 55 | 56 | 57 | include\SC-CL 58 | 59 | 60 | include\SC-CL 61 | 62 | 63 | include\SC-CL\RDR 64 | 65 | 66 | include\SC-CL\RDR 67 | 68 | 69 | include\mods 70 | 71 | 72 | 73 | 74 | Source Files 75 | 76 | 77 | Source Files 78 | 79 | 80 | Source Files 81 | 82 | 83 | Source Files\mods 84 | 85 | 86 | Source Files\mods 87 | 88 | 89 | Source Files\mods 90 | 91 | 92 | Source Files\mods 93 | 94 | 95 | Source Files\mods 96 | 97 | 98 | Source Files\mods 99 | 100 | 101 | Source Files\mods 102 | 103 | 104 | Source Files\mods 105 | 106 | 107 | Source Files\mods 108 | 109 | 110 | Source Files\SC-CL 111 | 112 | 113 | 114 | 115 | Source Files 116 | 117 | 118 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #include "menu_backend.h" 2 | 3 | #include "types.h" 4 | #include "constants.h" 5 | #include "intrinsics.h" 6 | #include "natives.h" 7 | #include "common.h" 8 | 9 | #include "util.h" 10 | #include "mods/mods.h" 11 | #include "menu.h" 12 | 13 | void main() 14 | { 15 | Script_RunByPath("scripting/DesignerDefined/UI/FuiEventMonitor_o"); 16 | 17 | char welcome_msg[200]; 18 | 19 | if (NET_IS_IN_SESSION()) 20 | { 21 | NET_SET_THIS_SCRIPT_IS_NET_SCRIPT(_GET_ID_OF_THIS_SCRIPT()); 22 | } 23 | 24 | Net_RefreshPlayerlist(); 25 | 26 | net_player_names[16] = null; 27 | 28 | stradd_s(welcome_msg, "Welcome, "); 29 | stradd_s(welcome_msg, GET_LOCAL_PLAYER_NAME(0)); 30 | stradd_s(welcome_msg, ". Menu made by Fuhzbot. \n Press + to open.\n"); 31 | 32 | PRINT_BIG(welcome_msg, 4, 1, 0, 0); 33 | 34 | while (true) 35 | { 36 | HandleInput(); 37 | DrawMenu(); 38 | ExecLoopMods(); 39 | WAIT(0); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/menu.c: -------------------------------------------------------------------------------- 1 | #include "menu_backend.h" 2 | #include "menu.h" 3 | 4 | #include "mods/mods.h" 5 | 6 | #include "constants.h" 7 | #include "natives.h" 8 | #include "common.h" 9 | #include "intrinsics.h" 10 | 11 | #pragma region Scrollables 12 | char *teleport_locations[] = 13 | { 14 | "Agave Viejo", 15 | "Armadillo", 16 | "Beecher's Hope", 17 | "Benedict Point", 18 | "Blackwater", 19 | "Casa Madrugada", 20 | "Chuparosa ", 21 | "Cochinay", 22 | "Coot's Chapel", 23 | "El Matadero", 24 | "El Presidio", 25 | "Escalera", 26 | "Fort Mercer", 27 | "Gaptooth Breach", 28 | "Lake Don Julio", 29 | "Las Hermanas", 30 | "Manzanita Post", 31 | "McFarlane's Ranch", 32 | "Nosalida", 33 | "Pacific Union Camp", 34 | "Plainview", 35 | "Rathskeller Fork", 36 | "Ridgewood Farm", 37 | "Serendipity's Wreck", 38 | "Thieve's Landing", 39 | "Tumbleweed", 40 | "Tesoro Azul", 41 | "Torquemada", 42 | "Twin Rocks", 43 | null 44 | }; 45 | 46 | char *teleport_direction[] = 47 | { 48 | "Forward", 49 | "Back", 50 | "Up", 51 | "Down", 52 | null 53 | }; 54 | 55 | char *weather[] = 56 | { 57 | "Clear", 58 | "Fair", 59 | "Cloudy", 60 | "Rainy", 61 | "Stormy", 62 | "Snowy", 63 | null 64 | }; 65 | 66 | char *vehicles[] = 67 | { 68 | "Stagecoach", 69 | "Stagecoach002", 70 | "Stagecoach003", 71 | "Stagecoach004", 72 | "dlc_Vehicle01x", 73 | "StagecoachGatling01", 74 | "Cart01", 75 | "Cart02", 76 | "Cart003", 77 | "Cart004", 78 | "Cart005", 79 | "Cart006", 80 | "Canoe01", 81 | "Raft02", 82 | "Raft03", 83 | "Raft01", 84 | "Truck01", 85 | "Car01", 86 | "Wagon04", 87 | "Wagon05", 88 | "WagonPrison01", 89 | "WagonGatling01", 90 | "Wagon02", 91 | "Chuckwagon", 92 | "Chuckwagon02", 93 | "Coach01", 94 | null 95 | }; 96 | 97 | char *animals[] = 98 | { 99 | "Horse01", 100 | "Horse02", 101 | "Horse03", 102 | "Horse04", 103 | "Horse05", 104 | "Horse06", 105 | "Horse07", 106 | "Horse08", 107 | "Horse09", 108 | "Horse10", 109 | "Horse11", 110 | "Horse12", 111 | "Horse13", 112 | "Horse14", 113 | "Horse15", 114 | "Horse16", 115 | "Horse17", 116 | "Horse18", 117 | "HorseMale01", 118 | "SaddleHorse01", 119 | "HorseMangy01", 120 | "HorseMangy02", 121 | "HorseMangy03", 122 | "HorseDead01", 123 | "MEX_Mule01", 124 | "MEX_Mule02", 125 | "MEX_Mule03", 126 | "MEX_Mule04", 127 | "Buffalo", 128 | "Buffalo04", 129 | "Bull04", 130 | "Bull05", 131 | "Cow", 132 | "Cow01", 133 | "Cow02", 134 | "Cow03", 135 | "Bull", 136 | "Bull01", 137 | "Bull02", 138 | "Chicken", 139 | "Chicken01", 140 | "Chicken02", 141 | "Rooster", 142 | "Rooster01", 143 | "Pig", 144 | "Pig01", 145 | "Pig03", 146 | "Sheep", 147 | "Sheep01", 148 | "Sheep03", 149 | "Goat01", 150 | "Goat02", 151 | "Goat03", 152 | "Goat", 153 | "Dog", 154 | "Dog01", 155 | "Dog02", 156 | "CollieDog", 157 | "CollieDog01", 158 | "CollieDog02", 159 | "CollieDog03", 160 | "GermanShepDog", 161 | "GermanShepDog01", 162 | "GermanShepDog02", 163 | "GermanShepDog03", 164 | "LabDog", 165 | "LabDog01", 166 | "LabDog02", 167 | "LabDog03", 168 | "NOR_HuskyDog", 169 | "NOR_HuskyDog01", 170 | "NOR_HuskyDog02", 171 | "NOR_HuskyDog03", 172 | "Coyote", 173 | "Coyote01", 174 | "Coyote03", 175 | "Coyote04", 176 | "Fox", 177 | "Fox01", 178 | "Fox02", 179 | "Fox03", 180 | "Snake", 181 | "Snake01", 182 | "Snake02", 183 | "FRO_Wolf", 184 | "FRO_Wolf01", 185 | "FRO_Wolf02", 186 | "FRO_Wolf03", 187 | "MEX_Wolf", 188 | "MEX_Wolf01", 189 | "MEX_Wolf02", 190 | "MEX_Wolf03", 191 | "NOR_Wolf", 192 | "NOR_Wolf01", 193 | "NOR_Wolf02", 194 | "NOR_Wolf03", 195 | "NAMED_Wolf", 196 | "NOR_WildBoar", 197 | "NOR_WildBoar01", 198 | "NOR_WildBoar02", 199 | "NOR_WildBoar04", 200 | "NAMED_WildBoar", 201 | "Rabbit02", 202 | "Rabbit03", 203 | "Jackalope01", 204 | "MEX_Armadillo02", 205 | "Raccoon01", 206 | "Raccoon02", 207 | "Skunk", 208 | "Skunk01", 209 | "Skunk02", 210 | "NOR_Cougar", 211 | "FRO_Cougar", 212 | "FRO_Cougar01", 213 | "FRO_Cougar02", 214 | "NOR_Cougar01", 215 | "NOR_Cougar02", 216 | "NOR_Cougar03", 217 | "NAMED_Cougar", 218 | "NOR_Bear", 219 | "NOR_Bear01", 220 | "NOR_Bear02", 221 | "NOR_GrizzlyBear", 222 | "NOR_GrizzlyBear01", 223 | "NOR_GrizzlyBear02", 224 | "NOR_GrizzlyBear03", 225 | "NOR_SuperGrizzlyBear", 226 | "NOR_SuperGrizzlyBear01", 227 | "NOR_SuperGrizzlyBear02", 228 | "NAMED_SuperGrizzlyBear", 229 | "NOR_Beaver", 230 | "NOR_Beaver01", 231 | "NOR_Beaver02", 232 | "NOR_Elk", 233 | "NOR_Elk01", 234 | "NOR_Elk02", 235 | "MEX_BobCat", 236 | "MEX_BobCat01", 237 | "NOR_BobCat02", 238 | "NOR_BobCat03", 239 | "Buck02", 240 | "Buck03", 241 | "Deer", 242 | "Deer01", 243 | "Deer03", 244 | "BigHorn", 245 | "BigHorn01", 246 | "BigHorn02", 247 | "NOR_Buffalo", 248 | "NOR_Buffalo01", 249 | "NOR_Buffalo02", 250 | "NOR_Buffalo04", 251 | "Vulture", 252 | "Vulture01", 253 | "Vulture02", 254 | "Crow", 255 | "Crow01", 256 | "Crow02", 257 | "SongBird", 258 | "SongBird01", 259 | "SongBird02", 260 | "NOR_Owl", 261 | "NOR_Owl01", 262 | "NOR_Owl02", 263 | "FRO_Duck02", 264 | "NOR_Duck01", 265 | "Bat", 266 | "Bat01", 267 | "Bat02", 268 | "Hawk", 269 | "Hawk01", 270 | "Hawk02", 271 | "NOR_Eagle", 272 | "NOR_Eagle01", 273 | "NOR_Eagle02", 274 | "MEX_Eagle", 275 | "MEX_Eagle01", 276 | "MEX_Eagle02", 277 | "Seagull01", 278 | null 279 | }; 280 | #pragma endregion 281 | 282 | void Main_Network(); 283 | 284 | #pragma region Network 285 | void Network_ShowSlot(int slot) 286 | { 287 | SetHeader(net_player_names[slot]); 288 | 289 | net_selected_player = slot; 290 | 291 | AddItem("Teleport to", Net_TeleportToPlayer, Main_Network, "Teleported to player"); 292 | AddItem("Spectate", Net_SpectatePlayer, Main_Network, "Spectating player"); 293 | } 294 | #pragma endregion 295 | 296 | #pragma region Main 297 | void Main_Self() 298 | { 299 | SetHeader("== Self Options =="); 300 | 301 | AddBoolItem("Invincible", Self_ToggleInvincible, Main, "Toggled invincibility", self_invincible); 302 | AddBoolItem("Noclip", Self_ToggleNoclip, Main, "Toggled noclip", self_noclip); 303 | AddBoolItem("Drunk", Self_ToggleDrunk, Main, "Toggled drunk", self_drunk); 304 | } 305 | 306 | void Main_Weapons() 307 | { 308 | SetHeader("== Weapon Options =="); 309 | 310 | AddItem("Give All Weapons", Weapon_GiveAll, Main, "All weapons given"); 311 | AddBoolItem("All Weapons Gold", Weapon_ToggleAllGold, Main, "Toggled gold weapons", weapon_allgold); 312 | AddBoolItem("Infinite Ammo", Weapon_ToggleInfAmmo, Main, "Toggled infinite ammo", weapon_infammo); 313 | } 314 | 315 | void Main_World() 316 | { 317 | SetHeader("== World Options =="); 318 | 319 | AddScrollableItem("Set Weather", weather, World_SetWeather, Main, "Changed weather", &world_weather); 320 | } 321 | 322 | void Main_Teleporter() 323 | { 324 | SetHeader("== Teleporter =="); 325 | 326 | AddScrollableItem("Teleport to", teleport_locations, Teleport_Locations, Main, "Teleported", &teleport_location); 327 | AddScrollableItem("Teleport 2ft", teleport_direction, Teleport_Direction, Main, "Teleported", &teleport_dir); 328 | } 329 | 330 | void Main_Vehicles() 331 | { 332 | SetHeader("== Vehicle Options =="); 333 | 334 | AddScrollableItem("Spawn", vehicles, Vehicles_Spawn, Main, "Spawned vehicle", &vehicles_spawn); 335 | } 336 | 337 | void Main_Animals() 338 | { 339 | SetHeader("== Animal Spawner =="); 340 | 341 | AddScrollableItem("Animal", animals, nullptr, Main, "", &animals_index); 342 | 343 | AddSimpleBoolItem("Invincible", Main, "Toggled animal invincibility", &animals_invincible); 344 | AddSimpleBoolItem("Rideable", Main, "Toggled animal rideability", &animals_rideable); 345 | AddSimpleBoolItem("Bodyguard", Main, "Toggled animal bodyguard", &animals_bodyguard); 346 | 347 | AddItem("Spawn Animal", Animals_Spawn, Main, "Spawned animal"); 348 | } 349 | 350 | void Main_Network() 351 | { 352 | SetHeader("== Network Options =="); 353 | 354 | if (!NET_IS_IN_SESSION()) 355 | { 356 | AddItem("Not in multiplayer session", nullptr, Main, ""); 357 | return; 358 | } 359 | 360 | AddItem("Fix Server", Net_FixServer, Main, "Fixing server..."); 361 | 362 | AddItem("Refresh playerlist", Net_RefreshPlayerlist, Main, "Refreshed playerlist"); 363 | 364 | for (int i = 0; i < 16; i++) 365 | { 366 | if (_STRING_COMPARE(net_player_names[i], "invalid")) 367 | { 368 | continue; 369 | } 370 | 371 | char name[100]; 372 | 373 | stradd_s(name, GetColoredSlotName(i)); 374 | 375 | switch (i) 376 | { 377 | case 0: 378 | AddSubmenu(name, Net_Slot0, Main); 379 | break; 380 | case 1: 381 | AddSubmenu(name, Net_Slot1, Main); 382 | break; 383 | case 2: 384 | AddSubmenu(name, Net_Slot2, Main); 385 | break; 386 | case 3: 387 | AddSubmenu(name, Net_Slot3, Main); 388 | break; 389 | case 4: 390 | AddSubmenu(name, Net_Slot4, Main); 391 | break; 392 | case 5: 393 | AddSubmenu(name, Net_Slot5, Main); 394 | break; 395 | case 6: 396 | AddSubmenu(name, Net_Slot6, Main); 397 | break; 398 | case 7: 399 | AddSubmenu(name, Net_Slot7, Main); 400 | break; 401 | case 8: 402 | AddSubmenu(name, Net_Slot8, Main); 403 | break; 404 | case 9: 405 | AddSubmenu(name, Net_Slot9, Main); 406 | break; 407 | case 10: 408 | AddSubmenu(name, Net_Slot10, Main); 409 | break; 410 | case 11: 411 | AddSubmenu(name, Net_Slot11, Main); 412 | break; 413 | case 12: 414 | AddSubmenu(name, Net_Slot12, Main); 415 | break; 416 | case 13: 417 | AddSubmenu(name, Net_Slot13, Main); 418 | break; 419 | case 14: 420 | AddSubmenu(name, Net_Slot14, Main); 421 | break; 422 | case 15: 423 | AddSubmenu(name, Net_Slot15, Main); 424 | break; 425 | } 426 | 427 | memset(name, 0, sizeof(name)); 428 | } 429 | } 430 | 431 | void Main_ScriptLoader() 432 | { 433 | SetHeader("Script Loader"); 434 | AddScrollableIntItem("Script", Script_Run, Main, "Attempting to run script...", &script_index, 1, 10); 435 | } 436 | #pragma endregion 437 | 438 | void Main() 439 | { 440 | SetHeader("== RDR Trainer =="); 441 | AddSubmenu("Self Options", Main_Self, nullptr); 442 | AddSubmenu("Weapon Options", Main_Weapons, nullptr); 443 | AddSubmenu("World Options", Main_World, nullptr); 444 | AddSubmenu("Teleporter", Main_Teleporter, nullptr); 445 | AddSubmenu("Vehicle Spawner", Main_Vehicles, nullptr); 446 | AddSubmenu("Animal Spawner", Main_Animals, nullptr); 447 | AddSubmenu("Network Options", Main_Network, nullptr); 448 | AddSubmenu("Script Loader", Main_ScriptLoader, nullptr); 449 | } -------------------------------------------------------------------------------- /src/menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Main(); 4 | void Main_World(); 5 | void Network_ShowSlot(int slot); -------------------------------------------------------------------------------- /src/menu_backend.c: -------------------------------------------------------------------------------- 1 | #include "menu_backend.h" 2 | #include "menu.h" 3 | #include "util.h" 4 | 5 | #include "constants.h" 6 | #include "intrinsics.h" 7 | #include "natives.h" 8 | #include "common.h" 9 | 10 | char *menu_col_header = ""; 11 | char *menu_col_selected = ""; 12 | char *menu_col_unselected = ""; 13 | 14 | bool draw_menu = false; 15 | int selected_index = 1; 16 | int current_submenu_count = 1; 17 | bool menu_pressed = false; 18 | bool menu_back = false; 19 | bool menu_pressed_right = false; 20 | bool menu_pressed_left = false; 21 | int menu_first_row = 1; 22 | int menu_depth = 0; 23 | 24 | unsigned int menu_header_color = 0; 25 | 26 | int menu_prev_index[5] = { 1, 1, 1, 1, 1 }; 27 | int menu_prev_first[5] = { 1, 1, 1, 1, 1 }; 28 | 29 | void (*DrawCurrentMenu)() = Main; 30 | 31 | char menu_text[255]; 32 | 33 | float fR = 0, fG = 0, fB = 0, fH = 0, fS = 1.0, fV = 1.0; 34 | 35 | void SetHeader(char *str) 36 | { 37 | fH += .5; 38 | 39 | if (fH == 360.0) 40 | fH = 0.0; 41 | 42 | HSVtoRGB(&fR, &fG, &fB, &fH, &fS, &fV); 43 | 44 | menu_header_color = ((int)(fB * 255) & 0xFF) | (((int)(fG * 255) & 0xFF) << 8) | (((int)(fR * 255) & 0xFF) << 16); 45 | 46 | stradd_s(menu_text, "<0x"); 47 | stradd_s(menu_text, (IntToHex(menu_header_color, false) + 2)); 48 | stradd_s(menu_text, ">"); 49 | 50 | stradd_s(menu_text, str); 51 | stradd_s(menu_text, menu_col_unselected); 52 | stradd_s(menu_text, " "); 53 | } 54 | 55 | bool AddBaseItem(char *str, void *func, void *backfunc, const char *msg, bool submenu) 56 | { 57 | void (*on_pressed)() = func; 58 | void (*on_back)() = backfunc; 59 | 60 | if (current_submenu_count < menu_first_row || current_submenu_count > menu_first_row + MENU_SCROLL_HEIGHT) 61 | { 62 | current_submenu_count++; 63 | return false; 64 | } 65 | 66 | if (selected_index == current_submenu_count) 67 | stradd_s(menu_text, menu_col_selected); 68 | 69 | stradd_s(menu_text, " \n"); 70 | 71 | if (selected_index == current_submenu_count) 72 | stradd_s(menu_text, " > "); 73 | 74 | stradd_s(menu_text, str); 75 | 76 | if (selected_index == current_submenu_count) 77 | { 78 | stradd_s(menu_text, menu_col_unselected); 79 | 80 | if (menu_pressed) 81 | { 82 | menu_pressed = false; 83 | 84 | if (STRING_LENGTH(msg) > 0) 85 | { 86 | char msg_formatted[255]; 87 | 88 | stradd_s(msg_formatted, "<0x9c9c9c>[<0xffc157>Trainer<0x9c9c9c>]: "); 89 | stradd_s(msg_formatted, msg); 90 | 91 | _PRINT_CHAT(msg_formatted, 0, 0, 0, 0, 0, 0); 92 | } 93 | 94 | if (func != nullptr) 95 | { 96 | if (submenu) 97 | { 98 | menu_prev_index[menu_depth] = selected_index; 99 | menu_prev_first[menu_depth] = menu_first_row; 100 | menu_depth++; 101 | selected_index = 1; 102 | menu_first_row = 1; 103 | DrawCurrentMenu = func; 104 | } 105 | 106 | on_pressed(); 107 | } 108 | } 109 | 110 | if (menu_back) 111 | { 112 | menu_back = false; 113 | 114 | if (backfunc != nullptr) 115 | { 116 | menu_depth--; 117 | DrawCurrentMenu = backfunc; 118 | selected_index = menu_prev_index[menu_depth]; 119 | menu_first_row = menu_prev_first[menu_depth]; 120 | on_back(); 121 | } 122 | else 123 | { 124 | DrawCurrentMenu = Main; 125 | draw_menu = false; 126 | } 127 | } 128 | } 129 | 130 | current_submenu_count++; 131 | 132 | return true; 133 | } 134 | 135 | void AddItem(char *str, void *func, void *backfunc, const char *msg) 136 | { 137 | AddBaseItem(str, func, backfunc, msg, false); 138 | } 139 | 140 | void AddSubmenu(char *str, void *func, void *backfunc) 141 | { 142 | AddBaseItem(str, func, backfunc, "", true); 143 | } 144 | 145 | void AddBoolItem(char *str, void *func, void *backfunc, const char *msg, bool val) 146 | { 147 | if (AddBaseItem(str, func, backfunc, msg, false)) 148 | { 149 | val ? stradd_s(menu_text, ": On") : stradd_s(menu_text, ": Off"); 150 | stradd_s(menu_text, menu_col_unselected); 151 | } 152 | } 153 | 154 | void AddSimpleBoolItem(char *str, void *backfunc, const char *msg, bool *val) 155 | { 156 | if (AddBaseItem(str, nullptr, backfunc, msg, false)) 157 | { 158 | *val ? stradd_s(menu_text, ": On") : stradd_s(menu_text, ": Off"); 159 | stradd_s(menu_text, menu_col_unselected); 160 | 161 | *val = !(*val); 162 | } 163 | } 164 | 165 | void AddScrollableItem(char *str, char *scrollable[], void *func, void *backfunc, const char *msg, int *index) 166 | { 167 | if (AddBaseItem(str, func, backfunc, msg, false)) 168 | { 169 | stradd_s(menu_text, ": "); 170 | stradd_s(menu_text, scrollable[*index]); 171 | 172 | if (selected_index == current_submenu_count - 1) 173 | { 174 | if (menu_pressed_right) 175 | { 176 | if (scrollable[(*index) + 1] != null) 177 | { 178 | (*index)++; 179 | PLAY_SOUND_FRONTEND("HUD_MENU_NAV_UP_MASTER"); 180 | } 181 | 182 | menu_pressed_right = false; 183 | } 184 | 185 | if (menu_pressed_left) 186 | { 187 | if (*index > 0) 188 | { 189 | (*index)--; 190 | PLAY_SOUND_FRONTEND("HUD_MENU_NAV_DOWN_MASTER"); 191 | } 192 | 193 | menu_pressed_left = false; 194 | } 195 | } 196 | } 197 | } 198 | 199 | void AddScrollableIntItem(char *str, void *func, void *backfunc, const char *msg, int *index, int min, int max) 200 | { 201 | if (AddBaseItem(str, func, backfunc, msg, false)) 202 | { 203 | stradd_s(menu_text, ": "); 204 | straddi_s(menu_text, *index); 205 | 206 | if (selected_index == current_submenu_count - 1) 207 | { 208 | if (menu_pressed_right) 209 | { 210 | if (*index < max) 211 | { 212 | (*index)++; 213 | PLAY_SOUND_FRONTEND("HUD_MENU_NAV_UP_MASTER"); 214 | } 215 | 216 | menu_pressed_right = false; 217 | } 218 | 219 | if (menu_pressed_left) 220 | { 221 | if (*index > min) 222 | { 223 | (*index)--; 224 | PLAY_SOUND_FRONTEND("HUD_MENU_NAV_DOWN_MASTER"); 225 | } 226 | 227 | menu_pressed_left = false; 228 | } 229 | } 230 | } 231 | } 232 | 233 | void DrawMenu() 234 | { 235 | if (draw_menu == false) 236 | return; 237 | 238 | HUD_CLEAR_HELP_QUEUE(); 239 | 240 | DrawCurrentMenu(); 241 | HandleMenuInput(); 242 | 243 | stradd_s(menu_text, " \n== ("); 244 | straddi_s(menu_text, selected_index); 245 | stradd_s(menu_text, "/"); 246 | straddi_s(menu_text, current_submenu_count - 1); 247 | stradd_s(menu_text, ") =="); 248 | 249 | _PRINT_HELP(menu_text, 1, false, 2, 1, 0, 0, 0); 250 | 251 | current_submenu_count = 1; 252 | memset(menu_text, 0, sizeof(menu_text)); 253 | } -------------------------------------------------------------------------------- /src/menu_backend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | #define MENU_SCROLL_HEIGHT 6 6 | 7 | extern bool draw_menu; 8 | extern int selected_index; 9 | extern int current_submenu_count; 10 | extern bool menu_pressed; 11 | extern bool menu_back; 12 | extern bool menu_pressed_left; 13 | extern bool menu_pressed_right; 14 | extern int menu_first_row; 15 | 16 | extern void (*DrawCurrentMenu)(); 17 | 18 | void DrawMenu(); 19 | 20 | void SetHeader(char *str); 21 | 22 | void AddItem(char *str, void *func, void *backfunc, const char *msg); 23 | void AddSubmenu(char *str, void *func, void *backfunc); 24 | void AddBoolItem(char *str, void *func, void *backfunc, const char *msg, bool val); 25 | void AddSimpleBoolItem(char *str, void *backfunc, const char *msg, bool *toggle); 26 | void AddScrollableItem(char *str, char *scrollable[], void *func, void *backfunc, const char *msg, int *val); 27 | void AddScrollableIntItem(char *str, void *func, void *backfunc, const char *msg, int *index, int min, int max); -------------------------------------------------------------------------------- /src/mods/animals.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | int animals_index = 0; 4 | bool animals_invincible = false; 5 | bool animals_rideable = false; 6 | bool animals_bodyguard = false; 7 | bool animals_ismount = false; 8 | 9 | Actor last_spawned; 10 | 11 | void Animals_ToggleInvincible() { ToggleBool(animals_invincible); } 12 | void Animals_ToggleRideable() { ToggleBool(animals_rideable); } 13 | void Animals_ToggleBodyguard() { ToggleBool(animals_bodyguard); } 14 | void Animals_ToggleMount() { ToggleBool(animals_ismount); } 15 | 16 | void Animals_Spawn() 17 | { 18 | vector3 pos, rot; 19 | GET_POSITION(self, &pos); 20 | 21 | rot.x = 0; 22 | rot.y = 0; 23 | rot.z = 0; 24 | 25 | last_spawned = CREATE_ACTOR_IN_LAYOUT(GET_AMBIENT_LAYOUT(), "", animals_index + 976, pos, rot); 26 | 27 | SET_ACTOR_INVULNERABILITY(last_spawned, animals_invincible); 28 | 29 | SET_ACTOR_RIDEABLE(last_spawned, animals_rideable); 30 | SET_ALLOW_RIDE_BY_PLAYER(last_spawned, animals_rideable); 31 | 32 | if (animals_bodyguard) 33 | { 34 | SET_ACTOR_FACTION(last_spawned, 20); 35 | TASK_FOLLOW_ACTOR(last_spawned, self); 36 | } 37 | 38 | if (animals_ismount) 39 | { 40 | SET_ACTORS_HORSE(self, last_spawned); 41 | } 42 | 43 | RELEASE_ACTOR(last_spawned); 44 | } -------------------------------------------------------------------------------- /src/mods/mods.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | #include "../menu_backend.h" 4 | 5 | // call any functions that need to be looped here 6 | void ExecLoopMods() 7 | { 8 | Net_Loop(); 9 | } -------------------------------------------------------------------------------- /src/mods/mods.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | #include "constants.h" 5 | #include "natives.h" 6 | #include "common.h" 7 | #include "intrinsics.h" 8 | 9 | #include "../menu.h" 10 | 11 | #define ToggleBool(a) a = (a == true) ? false : true 12 | #define self GET_PLAYER_ACTOR(0) 13 | 14 | extern bool self_invincible; 15 | extern bool self_invisible; 16 | extern bool self_drunk; 17 | extern bool self_showcoords; 18 | extern bool self_noclip; 19 | 20 | void Self_ToggleInvincible(); 21 | void Self_ToggleNoclip(); 22 | void Self_ToggleDrunk(); 23 | 24 | extern bool weapon_allgold; 25 | extern bool weapon_infammo; 26 | 27 | void Weapon_ToggleAllGold(); 28 | void Weapon_ToggleInfAmmo(); 29 | void Weapon_GiveAll(); 30 | 31 | extern int world_weather; 32 | 33 | void World_SetWeather(); 34 | 35 | extern int teleport_location; 36 | extern int teleport_dir; 37 | 38 | void Teleport_Locations(); 39 | void Teleport_Direction(); 40 | 41 | extern int vehicles_spawn; 42 | 43 | void Vehicles_Spawn(); 44 | 45 | extern int animals_index; 46 | extern bool animals_invincible; 47 | extern bool animals_rideable; 48 | extern bool animals_bodyguard; 49 | extern bool animals_ismount; 50 | 51 | void Animals_ToggleInvincible(); 52 | void Animals_ToggleRideable(); 53 | void Animals_ToggleBodyguard(); 54 | void Animals_ToggleMount(); 55 | void Animals_Spawn(); 56 | 57 | extern char *net_player_names[17]; 58 | extern int net_selected_player; 59 | 60 | const char *GetColoredSlotName(int slot); 61 | 62 | void Net_FixServer(); 63 | 64 | void Net_RefreshPlayerlist(); 65 | 66 | void Net_TeleportToPlayer(); 67 | void Net_SpectatePlayer(); 68 | 69 | void Net_Loop(); 70 | 71 | // ugly, but couldn't get variadic arguments working without crashes :( 72 | void Net_Slot0() { Network_ShowSlot(0); } 73 | void Net_Slot1() { Network_ShowSlot(1); } 74 | void Net_Slot2() { Network_ShowSlot(2); } 75 | void Net_Slot3() { Network_ShowSlot(3); } 76 | void Net_Slot4() { Network_ShowSlot(4); } 77 | void Net_Slot5() { Network_ShowSlot(5); } 78 | void Net_Slot6() { Network_ShowSlot(6); } 79 | void Net_Slot7() { Network_ShowSlot(7); } 80 | void Net_Slot8() { Network_ShowSlot(8); } 81 | void Net_Slot9() { Network_ShowSlot(9); } 82 | void Net_Slot10() { Network_ShowSlot(10); } 83 | void Net_Slot11() { Network_ShowSlot(11); } 84 | void Net_Slot12() { Network_ShowSlot(12); } 85 | void Net_Slot13() { Network_ShowSlot(13); } 86 | void Net_Slot14() { Network_ShowSlot(14); } 87 | void Net_Slot15() { Network_ShowSlot(15); } 88 | 89 | void ExecLoopMods(); 90 | 91 | extern int script_index; 92 | 93 | void Script_Run(); 94 | void Script_RunByPath(const char* path); -------------------------------------------------------------------------------- /src/mods/net.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | #include "../menu_backend.h" 4 | #include "../util.h" 5 | 6 | char *net_player_names[17]; 7 | int net_selected_player = 1; 8 | 9 | bool spectating = false; 10 | 11 | bool IsSlotValid(int slot) 12 | { 13 | if (IS_SLOT_VALID(slot)) 14 | { 15 | return true; 16 | } 17 | else 18 | { 19 | _PRINT_CHAT("Error: invalid player", 0, 0, 0, 0, 0, 0); 20 | print("Error: invalid player", 2000); 21 | 22 | return false; 23 | } 24 | } 25 | 26 | const char *GetColoredSlotName(int slot) 27 | { 28 | char temp[23] = "MPPlayerNameColored_"; 29 | 30 | straddi_s(temp, slot); 31 | 32 | return UI_GET_STRING(temp); 33 | } 34 | 35 | void Net_FixServer() 36 | { 37 | Iterator iterator = CREATE_OBJECT_ITERATOR(FIND_NAMED_LAYOUT("playerlayout")); 38 | 39 | ITERATE_ON_OBJECT_TYPE(iterator, OBJECT_TYPE_Actor); 40 | 41 | START_OBJECT_ITERATOR(iterator); 42 | 43 | int matches = GET_NUM_ITERATOR_MATCHES(iterator); 44 | 45 | char temp[50]; 46 | 47 | stradd_s(temp, "Found "); 48 | straddi_s(temp, matches); 49 | stradd_s(temp, " matches."); 50 | 51 | _PRINT_CHAT(temp, 0, 0, 0, 0, 0, 0); 52 | _PRINT_CHAT("Deleting...", 0, 0, 0, 0, 0, 0); 53 | 54 | for (int i = 0; i < matches; i++) 55 | { 56 | int current = OBJECT_ITERATOR_CURRENT(iterator); 57 | 58 | if (current != self && !IS_ACTOR_PLAYER(current)) 59 | { 60 | DESTROY_ACTOR(current); 61 | } 62 | 63 | OBJECT_ITERATOR_NEXT(iterator); 64 | } 65 | 66 | DESTROY_ITERATOR(iterator); 67 | 68 | DESTROY_LAYOUT_OBJECTS(FIND_NAMED_LAYOUT("netlayout")); 69 | } 70 | 71 | void Net_RefreshPlayerlist() 72 | { 73 | for (int i = 0; i < 15; i++) 74 | { 75 | if (IS_SLOT_VALID(i)) 76 | net_player_names[i] = (char*)GET_SLOT_NAME(i); 77 | else 78 | net_player_names[i] = "invalid"; 79 | } 80 | } 81 | 82 | void Net_TeleportToPlayer() 83 | { 84 | if (!IsSlotValid(net_selected_player)) 85 | return; 86 | 87 | vector3 pos; 88 | GET_SLOT_POSITION(net_selected_player, &pos); 89 | 90 | TELEPORT_ACTOR(self, &pos, true, true, true); 91 | } 92 | 93 | // Doesn't work, might work as host though 94 | void Net_TPToMe() 95 | { 96 | if (!IsSlotValid(net_selected_player)) 97 | return; 98 | 99 | Object player = GET_OBJECT_FROM_ACTOR(GET_SLOT_ACTOR(net_selected_player)); 100 | vector3 pos; 101 | GET_POSITION(self, &pos); 102 | 103 | NET_REQUEST_OBJECT(player); 104 | 105 | SET_OBJECT_POSITION(player, pos); 106 | } 107 | 108 | void Net_SpectatePlayer() 109 | { 110 | if (!IsSlotValid(net_selected_player)) 111 | return; 112 | 113 | spectating = true; 114 | 115 | vector3 pos; 116 | GET_SLOT_POSITION(net_selected_player, &pos); 117 | 118 | vector3 oldpos; 119 | GET_POSITION(self, &oldpos); 120 | 121 | TELEPORT_ACTOR(self, &pos, 1, 1, 1); 122 | 123 | WAIT(500); 124 | 125 | // STREAMING_LOAD_BOUNDS(pos.x, pos.y, pos.z, 10.0f, 0); 126 | 127 | SET_CAMERA_FOLLOW_ACTOR(GET_SLOT_ACTOR(net_selected_player)); 128 | 129 | TELEPORT_ACTOR(self, &oldpos, 1, 1, 1); 130 | } 131 | 132 | void Net_Loop() 133 | { 134 | if (spectating) 135 | { 136 | char msg[255]; 137 | 138 | stradd_s(msg, "Spectating "); 139 | stradd_s(msg, GetColoredSlotName(net_selected_player)); 140 | stradd_s(msg, " \nPress to stop spectating."); 141 | 142 | print(msg, 200); 143 | 144 | if (IsButtonPressed(BUTTON_B)) 145 | { 146 | SET_CAMERA_FOLLOW_ACTOR(self); 147 | spectating = false; 148 | } 149 | } 150 | } -------------------------------------------------------------------------------- /src/mods/scriptloader.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | int script_index = 1; 4 | 5 | void Script_Run() 6 | { 7 | char script[100]; 8 | 9 | stradd_s(script, "$/content/scripting/"); 10 | straddi_s(script, script_index); 11 | 12 | Script_RunByPath(script); 13 | } 14 | 15 | void Script_RunByPath(const char *path) 16 | { 17 | if (DOES_SCRIPT_EXIST(path) == false) 18 | { 19 | print("Error: Script doesn't exist", 2000); 20 | return; 21 | } 22 | 23 | REQUEST_ASSET(path, ASSET_TYPE_Script); 24 | 25 | int id = GET_ASSET_ID(path, ASSET_TYPE_Script); 26 | 27 | while (STREAMING_IS_SCRIPT_LOADED(id) == false) 28 | { 29 | STREAMING_REQUEST_SCRIPT(id); 30 | print("Loading script...", 200); 31 | WAIT(0); 32 | } 33 | 34 | int scr = LAUNCH_NEW_SCRIPT(path, 0); 35 | ADD_PERSISTENT_SCRIPT(scr); 36 | 37 | _PRINT_CHAT("Launched script!", 0, 0, 0, 0, 0, 0); 38 | } -------------------------------------------------------------------------------- /src/mods/self.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | #include "../util.h" 4 | 5 | bool self_invincible = false; 6 | bool self_drunk = false; 7 | bool self_noclip = false; 8 | 9 | void Self_ToggleInvincible() 10 | { 11 | ToggleBool(self_invincible); 12 | 13 | SET_ACTOR_INVULNERABILITY(self, self_invincible); 14 | } 15 | 16 | void Self_ToggleNoclip() 17 | { 18 | ToggleBool(self_noclip); 19 | 20 | if (self_noclip) 21 | SUSPEND_MOVER(self); 22 | else 23 | ENABLE_MOVER(self); 24 | } 25 | 26 | void Self_ToggleDrunk() 27 | { 28 | ToggleBool(self_drunk); 29 | 30 | SET_ACTOR_DRUNK(self, self_drunk); 31 | } -------------------------------------------------------------------------------- /src/mods/teleport.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | int teleport_location = 0; 4 | int teleport_dir = 0; 5 | 6 | void Teleport_Locations() 7 | { 8 | vector3 loc; 9 | 10 | switch (teleport_location) 11 | { 12 | case 0: // Agave Viejo 13 | loc.x = -1545.03f; 14 | loc.y = 15.03f; 15 | loc.z = 3913.46f; 16 | break; 17 | case 1: // Armadillo 18 | loc.x = -2175.62f; 19 | loc.y = 16.31f; 20 | loc.z = 2613.50f; 21 | break; 22 | case 2: // Beecher's Hope 23 | loc.x = -83.45f; 24 | loc.y = 117.68f; 25 | loc.z = 1374.10f; 26 | break; 27 | case 3: // Benedict Point 28 | loc.x = -3686.96f; 29 | loc.y = 8.62f; 30 | loc.z = 3493.24f; 31 | break; 32 | case 4: // Blackwater 33 | loc.x = 711.18f; 34 | loc.y = 78.31f; 35 | loc.z = 1252.763f; 36 | break; 37 | case 5: // Casa Madrugada 38 | loc.x = -788.78f; 39 | loc.y = 13.04f; 40 | loc.z = 3729.81f; 41 | break; 42 | case 6: // Chuparosa 43 | loc.x = -2714.70f; 44 | loc.y = 32.37f; 45 | loc.z = 4251.90f; 46 | break; 47 | case 7: // Cochinay 48 | loc.x = -739.29f; 49 | loc.y = 179.10f; 50 | loc.z = 784.69f; 51 | break; 52 | case 8: // Coot's Chapel 53 | loc.x = -1793.48f; 54 | loc.y = 23.78f; 55 | loc.z = 2836.85f; 56 | break; 57 | case 9: // El Matadero 58 | loc.x = -455.44f; 59 | loc.y = 20.84f; 60 | loc.z = 3926.91f; 61 | break; 62 | case 10: // El Presidio 63 | loc.x = -698.10f; 64 | loc.y = 63.25f; 65 | loc.z = 3323.25f; 66 | break; 67 | case 11: // Escalera 68 | loc.x = -4279.04f; 69 | loc.y = 18.07f; 70 | loc.z = 4447.64f; 71 | break; 72 | case 12: // Fort Mercer 73 | loc.x = -2622.53f; 74 | loc.y = 68.08f; 75 | loc.z = 3390.51f; 76 | break; 77 | case 13: // Gaptooth Breach 78 | loc.x = -4461.66f; 79 | loc.y = 7.78f; 80 | loc.z = 3310.42f; 81 | break; 82 | case 14: // Lake Don Julio 83 | loc.x = -1955.07f; 84 | loc.y = 24.82f; 85 | loc.z = 3255.67f; 86 | break; 87 | case 15: // Las Hermanas 88 | loc.x = -1700.31f; 89 | loc.y = 8.08f; 90 | loc.z = 4242.14f; 91 | break; 92 | case 16: // Manzanita Post 93 | loc.x = -428.16f; 94 | loc.y = 151.34f; 95 | loc.z = 1615.59f; 96 | break; 97 | case 17: // McFarlane's Ranch 98 | loc.x = -887.08f; 99 | loc.y = 90.19f; 100 | loc.z = 2420.53f; 101 | break; 102 | case 18: // Nosalida 103 | loc.x = -4701.72f; 104 | loc.y = 3.04f; 105 | loc.z = 3958.90f; 106 | break; 107 | case 19: // Pacific Union Camp 108 | loc.x = -273.95f; 109 | loc.y = 84.31f; 110 | loc.z = 2113.30f; 111 | break; 112 | case 20: // Plainview 113 | loc.x = -3126.40f; 114 | loc.y = 43.57f; 115 | loc.z = 3724.13f; 116 | break; 117 | case 21: // Rathskeller Fork 118 | loc.x = -3661.76f; 119 | loc.y = 42.23f; 120 | loc.z = 2124.7; 121 | break; 122 | case 22: // Ridgewood Farm 123 | loc.x = -3275.14f; 124 | loc.y = 15.89f; 125 | loc.z = 2719.86f; 126 | break; 127 | case 23: // Serendipity's Wreck 128 | loc.x = 325.34f; 129 | loc.y = 74.29f; 130 | loc.z = 1939.81f; 131 | break; 132 | case 24: // Thieve's Landing 133 | loc.x = 111.55f; 134 | loc.y = 73.29f; 135 | loc.z = 2318.82f; 136 | break; 137 | case 25: // Tumbleweed 138 | loc.x = -4007.25f; 139 | loc.y = 28.46f; 140 | loc.z = 2935.45f; 141 | break; 142 | case 26: // Tesoro Azul 143 | loc.x = -3288.00f; 144 | loc.y = 38.20f; 145 | loc.z = 4547.00f; 146 | break; 147 | case 27: // Torquemada 148 | loc.x = 376.66f; 149 | loc.y = 76.30f; 150 | loc.z = 3459.57f; 151 | break; 152 | case 28: // Twin Rocks 153 | loc.x = -2425.06f; 154 | loc.y = 25.00f; 155 | loc.z = 2138.93f; 156 | break; 157 | } 158 | 159 | TELEPORT_ACTOR(self, &loc, true, true, true); 160 | } 161 | 162 | void Teleport_Direction() 163 | { 164 | vector3 loc; 165 | GET_POSITION(self, &loc); 166 | 167 | float heading = GET_HEADING(self); 168 | 169 | float dist = 2.0; 170 | 171 | float a = dist * SIN(heading); 172 | float b = dist * COS(heading); 173 | 174 | switch (teleport_dir) 175 | { 176 | case 0: // forward 177 | loc.x -= a; 178 | loc.z -= b; 179 | break; 180 | case 1: // back 181 | loc.x += a; 182 | loc.z += b; 183 | break; 184 | case 2: // up 185 | loc.y += 2.0; 186 | break; 187 | case 3: // down 188 | loc.y -= 2.0; 189 | break; 190 | } 191 | 192 | TELEPORT_ACTOR_WITH_HEADING(self, loc, heading, true, true, true); 193 | } -------------------------------------------------------------------------------- /src/mods/vehicles.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | int vehicles_spawn = 0; 4 | 5 | void Vehicles_Spawn() 6 | { 7 | Actor vehicle = vehicles_spawn + 1177; 8 | vector3 pos, rotation; 9 | 10 | rotation.x = 0; 11 | rotation.y = 0; 12 | rotation.z = 0; 13 | 14 | STREAMING_REQUEST_ACTOR(vehicle, true, false); 15 | 16 | while (!STREAMING_IS_ACTOR_LOADED(vehicle, -1)) 17 | { 18 | WAIT(0); 19 | } 20 | 21 | GET_POSITION(self, &pos); 22 | 23 | char name[25]; 24 | 25 | stradd_s(name, "vehicle"); 26 | straddi_s(name, vehicles_spawn); 27 | 28 | Actor actor = CREATE_ACTOR_IN_LAYOUT(FIND_NAMED_LAYOUT("PlayerLayout"), name, vehicle, pos, rotation); 29 | 30 | SET_VEHICLE_ALLOWED_TO_DRIVE(actor, true); 31 | ENABLE_VEHICLE_SEAT(actor, 0, true); 32 | SET_ACTOR_AUTO_TRANSITION_TO_DRIVER_SEAT(self, 1); 33 | SET_ACTOR_IN_VEHICLE(self, actor, 0); 34 | 35 | START_VEHICLE(actor); 36 | SET_VEHICLE_ENGINE_RUNNING(actor, true); 37 | } 38 | -------------------------------------------------------------------------------- /src/mods/weapon.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | bool weapon_allgold = false; 4 | bool weapon_infammo = false; 5 | 6 | void Weapon_ToggleAllGold() 7 | { 8 | ToggleBool(weapon_allgold); 9 | 10 | for (int i = 0; i <= 37; i++) 11 | { 12 | SET_WEAPON_GOLD(self, i, weapon_allgold); 13 | } 14 | } 15 | 16 | void Weapon_ToggleInfAmmo() 17 | { 18 | ToggleBool(weapon_infammo); 19 | 20 | for (int i = 0; i <= 37; i++) 21 | { 22 | _SET_ACTOR_INFINITE_AMMO(self, i, weapon_infammo); 23 | } 24 | } 25 | 26 | void Weapon_GiveAll() 27 | { 28 | for (int i = 0; i <= 37; i++) 29 | { 30 | GIVE_WEAPON_TO_ACTOR(self, i, 1, 1, 1); 31 | } 32 | 33 | HUD_CLEAR_HELP_QUEUE(); 34 | } -------------------------------------------------------------------------------- /src/mods/world.c: -------------------------------------------------------------------------------- 1 | #include "mods.h" 2 | 3 | int world_weather = 0; 4 | 5 | void World_SetWeather() 6 | { 7 | SET_WEATHER(world_weather, 0); 8 | } -------------------------------------------------------------------------------- /src/util.c: -------------------------------------------------------------------------------- 1 | #include "menu_backend.h" 2 | #include "util.h" 3 | 4 | #include "natives.h" 5 | #include "constants.h" 6 | #include "common.h" 7 | #include "intrinsics.h" 8 | 9 | void HandleInput() 10 | { 11 | if (IsButtonDown(BUTTON_L2) && IsButtonPressed(BUTTON_Y)) 12 | { 13 | if (draw_menu) 14 | draw_menu = false; 15 | else 16 | draw_menu = true; 17 | } 18 | } 19 | 20 | void HandleMenuInput() 21 | { 22 | if (IsButtonPressed(DPAD_DOWN)) 23 | { 24 | if (selected_index < current_submenu_count - 1) 25 | { 26 | selected_index++; 27 | 28 | if (selected_index > menu_first_row + MENU_SCROLL_HEIGHT) 29 | menu_first_row++; 30 | 31 | PLAY_SOUND_FRONTEND("HUD_MENU_NAV_UP_MASTER"); 32 | } 33 | 34 | menu_pressed_left = false; 35 | menu_pressed_right = false; 36 | } 37 | 38 | if (IsButtonPressed(DPAD_UP)) 39 | { 40 | if (selected_index > 1) 41 | { 42 | selected_index--; 43 | 44 | if (selected_index < menu_first_row) 45 | menu_first_row--; 46 | 47 | PLAY_SOUND_FRONTEND("HUD_MENU_NAV_DOWN_MASTER"); 48 | } 49 | 50 | menu_pressed_left = false; 51 | menu_pressed_right = false; 52 | } 53 | 54 | if (IsButtonPressed(DPAD_LEFT)) 55 | menu_pressed_left = true; 56 | 57 | if (IsButtonPressed(DPAD_RIGHT)) 58 | menu_pressed_right = true; 59 | 60 | if (IsButtonPressed(BUTTON_A)) 61 | { 62 | menu_pressed = true; 63 | PLAY_SOUND_FRONTEND("HUD_MENU_SELECT_MASTER"); 64 | } 65 | 66 | if (IsButtonPressed(BUTTON_B)) 67 | { 68 | menu_back = true; 69 | PLAY_SOUND_FRONTEND("HUD_MENU_BACK_MASTER"); 70 | } 71 | 72 | if (IsButtonPressed(BUTTON_SELECT) || IsButtonPressed(BUTTON_START)) 73 | draw_menu = false; 74 | } 75 | 76 | void HSVtoRGB(float *fR, float *fG, float *fB, float *fH, float *fS, float *fV) 77 | { 78 | float fC = *fV * *fS; // Chroma 79 | float fHPrime = fMod(*fH / 60.0, 6); 80 | 81 | float fX = fC * (1 - FABS(fMod(fHPrime, 2) - 1)); 82 | float fM = *fV - fC; 83 | 84 | if (0 <= fHPrime && fHPrime < 1) 85 | { 86 | *fR = fC; 87 | *fG = fX; 88 | *fB = 0; 89 | } 90 | else if (1 <= fHPrime && fHPrime < 2) 91 | { 92 | *fR = fX; 93 | *fG = fC; 94 | *fB = 0; 95 | } 96 | else if (2 <= fHPrime && fHPrime < 3) 97 | { 98 | *fR = 0; 99 | *fG = fC; 100 | *fB = fX; 101 | } 102 | else if (3 <= fHPrime && fHPrime < 4) 103 | { 104 | *fR = 0; 105 | *fG = fX; 106 | *fB = fC; 107 | } 108 | else if (4 <= fHPrime && fHPrime < 5) 109 | { 110 | *fR = fX; 111 | *fG = 0; 112 | *fB = fC; 113 | } 114 | else if (5 <= fHPrime && fHPrime < 6) 115 | { 116 | *fR = fC; 117 | *fG = 0; 118 | *fB = fX; 119 | } 120 | else 121 | { 122 | *fR = 0; 123 | *fG = 0; 124 | *fB = 0; 125 | } 126 | 127 | *fR += fM; 128 | *fG += fM; 129 | *fB += fM; 130 | } -------------------------------------------------------------------------------- /src/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define IsButtonPressed(btn) IS_BUTTON_PRESSED(1, btn, 4, 4) 4 | #define IsButtonDown(btn) IS_BUTTON_DOWN(1, btn, 4, 4) 5 | 6 | void HandleInput(); 7 | void HandleMenuInput(); 8 | void HSVtoRGB(float *fR, float *fG, float *fB, float *fH, float *fS, float *fV); -------------------------------------------------------------------------------- /tools/compile 360.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | echo =========================================== 4 | echo. 5 | echo Simple RDR Trainer (360) 6 | echo Made by Connor 7 | echo. 8 | echo https://github.com/connorms/RDR-Trainer 9 | echo. 10 | echo =========================================== 11 | echo. 12 | echo Press any key to build 13 | echo. 14 | echo =========================================== 15 | pause > nul 16 | cls 17 | if exist "../lib/SC-CL/bin/SC-CL.exe" ( 18 | "../lib/SC-CL/bin/SC-CL.exe" -platform=X360 -target="RDR_#SC" -out-dir="../bin/" -vcx="../src/Menu.vcxproj" -name="menu" -- -I "../include/" 19 | ) else ( 20 | echo Error: SC-CL not found! Make sure to include submodules when cloning. 21 | echo You can do this by going to the root folder and running the following 2 commands: 22 | echo - git submodule init 23 | echo - git submodule update 24 | echo. 25 | ) 26 | pause -------------------------------------------------------------------------------- /tools/compile ps3.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | echo =========================================== 4 | echo. 5 | echo Simple RDR Trainer (PS3) 6 | echo Made by Connor 7 | echo. 8 | echo https://github.com/connorms/RDR-Trainer 9 | echo. 10 | echo =========================================== 11 | echo. 12 | echo Press any key to build 13 | echo. 14 | echo =========================================== 15 | pause > nul 16 | cls 17 | if exist "../lib/SC-CL/bin/SC-CL.exe" ( 18 | "../lib/SC-CL/bin/SC-CL.exe" -platform=PS3 -target="RDR_#SC" -out-dir="../bin/" -vcx="../src/Menu.vcxproj" -name="menu" -- -I "../include/" 19 | ) else ( 20 | echo Error: SC-CL not found! Make sure to include submodules when cloning. 21 | echo You can do this by going to the root folder and running the following 2 commands: 22 | echo - git submodule init 23 | echo - git submodule update 24 | echo. 25 | ) 26 | pause --------------------------------------------------------------------------------