|
本帖最后由 【游骑兵】天涯 于 2012-4-14 08:56 编辑
翻译:【游骑兵】天涯
原帖地址:http://www.gtaforums.com/index.php?showtopic=403594
初次接触翻译 纰漏之处 在所难免 望指正
建议前往英文站看英文原文 便于理解
注:目前正在汉化中,没有审核已汉化部分,所以请勿过分相信已翻译部分 待翻译完毕+后期审核完毕后请再次查看
由于小道时间不够 手机上论坛常挂 所以正在使用手机Word编辑软件编辑要翻译的内容(汗 手机打字翻译好辛苦)--意思是 近期 此贴将不会更新 完工后更新 sorry for my bad chinese
未经许可 谢绝转载
______________________________________________________________________________________
______________________________________________________________________________________
使用Sanny Builder(以下简称SB)进行CLEO脚本编写的第一步:
下载最新版本的Sanny Builder: http://sannybuilder.com/
或者下载【下载】SB汉化版+最小启动包 有汉化版SB
下载地址:http://game.55660.net/thread-138-1-1.html
安装SB并为你的脚本文件创建一个目录
因此你可以选择到你的游戏目录(此句不明)
然后启动SB
打开一个新的空白页面
复制如下脚本源码并把它插入到新的页面
CODE | {$CLEO .cs}
:DEMOTEXT
03A4: name_thread "DEMO"
wait 1000
:DEMOTEXT_1
wait 0
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @DEMOTEXT_1
if
00E1: key_pressed 0 17
004D: jump_if_false @DEMOTEXT_1
00BA: text_styled 'FEM_OK' 1000 ms 1
0A93: end_custom_thread |
把它保存到你刚才创建的脚本文件文件存放目录并且重命名
编译这个脚本 点击菜单上奔跑的人形图标来执行编译+复制操作
如果已经安装过CLEO library 这个脚本文件会被编译并且复制到游戏目录/CLEO目录(前提是安装过CLEO主程序)
{$CLEO .cs} = Cleo 指令会被编译为 以*.cs为后缀的格式文件
而DEMOTEXT.txt 会被保存 并且编译为 DEMOTEXT.cs
______________________________________________________________________________________
如果CLEO主程序没有安装,在SB的右下角处会有红色的安装提示.点击此处SB会快速安装完成.(此处不明 不知道是什么情况 SB自动安装CLEO主程序?)
也可以前往 http://cleo.sannybuilder.com下载最新版CLEO主程序安装器
______________________________________________________________________________________
如果编译成功完成,你会看到如下提示框
点击OK确定
最下面的部分 Largest Script显示的是脚本文件大小
其他的部分属于Main.scm的编译信息
进入游戏测试此脚本,点击0键或Ctrl键按键来显示TEXT的文本信息
这个脚本执行结束,会被收起(不明)因为此脚本是以opcode 0A93: end_custom_thread
而结束。
______________________________________________________________________________________
______________________________________________________________________________________
编辑器
主要的功能可以在菜单栏的相关按钮处找到
1. 汇编: SB打开如下几种脚本文件扩展名 .CS, .CM or .SCM
2. 编译: SB 编译 通过默认(不明)一个 [Name]main.SCM
SB自动编译CLEO脚本文件, 如果这个脚本 有一个 Cleo-Direktive 作为入口
{$CLEO .cs} = Cleo-Direktive, 会被编译为 .CS后缀名的文件
{$CLEO .cm} = Cleo-Direktive, 会被编译为.CM后缀名的文件
有用的小工具
选择菜单栏上的Tools选项 IDE tools--Coords Manager
读取X Y Z coordinate(不明)和主角CJ的当前方位的方位角(前提是游戏运行)
选择菜单栏上的Tools选项 IDE tools--Opcode Search
来搜索Opcode
输入任何字符来寻找包含这个字符的句子
或者输入Opcode来搜索这类型的句子
搜索结果存在于原版main.scm中
这个Opcode搜索工具需要在 Sanny Builder 3\data\sa folder下创建一个Opcode.txt文本
用SB加载汇编的原版 main 然后选择SB的工具栏, 制作Opcode.txt.
行号
选择Tools(工具)--Option(选项)
在选项 编辑栏 你可以找到开关行号显示的选项
行号是编辑器的一部分,不是脚本的内容。
SB帮助文本
选择菜单栏的帮助文本, 然后按照需要查找信息。,
比如键位, 武器编号, 身体部分等等..
______________________________________________________________________________________
______________________________________________________________________________________
选项: different view of the decompiled code
选择 TOOLS(工具), option(选项)
Option(选项)整体 你可以看见不同的编译方法(不明)
1. 编写Opcode
所有条目以Opcode显示
Opcode是脚本功能的程序编码
他们看起来就像是命令指令
带有Opcode的脚本:
CODE | :CARSL_6439
00D6: if
00E1: player 0 pressed_key 16
004D: jump_if_false @CARSL_6535
010B: 5@ = player $PLAYER_CHAR money
00D6: if
002D: 5@ >= 14@ // (int)
004D: jump_if_false @CARSL_6512
0012: 14@ *= -1
0109: player $PLAYER_CHAR money += 14@
0002: jump @CARSL_6700 |
2. 不使用Opcode
脚本更加小, 可能更加清晰
特别是004D: jump_if_false 可以简写为jf
但并不是所有Opcode不使用. 更多编码会被广泛的使用以此运行相应的功能
Script without opcodes:
CODE | :CARSL_6439
if
00E1: player 0 pressed_key 16
jf @CARSL_6535
5@ = Player.Money($PLAYER_CHAR)
if
002D: 5@ >= 14@ // (int)
jf @CARSL_6512
14@ *= -1
Player.Money($PLAYER_CHAR) += 14@
jump @CARSL_6700 |
你使用还是不使用Opcode并不会有什么影响
SB还是会正常编译
一个不使用Opcode汇编额特殊方法是把Opcode Based命令翻译为
Classes 和 Keywords
详情参阅Sannybuilder-帮助主题文件: Coding >> Classes
下面是使用Opcode编译的代码:
00AB: put_car 22@ at -1577.942 52.6333 40.0
此句不使用Opcode就如下显示:
Car.PutAt(22@, -1577.942, 52.6333, 40.0)
编码的意义 by the class entries(不清楚)
Car= 类-name
PutAt= 类-member
name and member are combined with a dot in the middle(不明)
22@ = class-owner
class-owner and parameters are placed in brackets and separated with comma
(parameter = needed information for the command)--此段不清晰 望翻译
SB可以使用Keywords(关键词)来替代Opcode
Opcode = Keyword
_____________
0001: = wait
00d6: = if
004d: = else_jump
004d: = jf
0002: = jump
0051: = return
0050: = gosub
016a: = fade
01B6: = set_weather
03a4: = thread
04BB: = select_interior
0417: = start_mission
00d8: = mission_cleanup
0317: = increment_mission_attempts
004D: jump_if_false @MAIN_6
可以写为
jf @MAIN_6
或者else_jump @MAIN_6
你还可以合并为
004D: jf @MAIN_6
______________________________________________________________________________________
______________________________________________________________________________________
Data types(数据类型)
: (doublepoint) marks a Label (adress)--不明
@ 有2种不同功能
1. 跳转到相应的标签
CODE | 004D: jump_if_false @SAVE_5
0050: gosub @SAVE_14
0002: jump @SAVE_1 |
2.链接局部变量
游戏中的物件需要 一个类似身份登记的办法 来处理
执行
这个身份登记可以理解为 变量,
局部变量由@和数字组合而成
0@, 1@, ... 30@ 从
0@ 到 31@ 是允许的 , 32@ 和33@ are for timers, thats maximum in an .cs file(不懂此处作用 等kami)
如下
1@ 定义 一个车辆的创建产生
CODE | 014B: 1@ = init_parked_car_generator #PCJ600 0 17 1 alarm 0 door_lock 0 0 10000 at 2490.0 -1682.0 13.5 angle 90.0 |
1@ 还可以用作局部变量名称(此处指代替这辆车) CODE | 014C: set_parked_car_generator 1@ cars_to_generate_to 101 |
$ 用来链接全局变量
游戏中的物件需要 一个类似身份登记的办法 来处理
执行
这个身份登记可以理解为 变量
全局变量是以$ 为标志和一些单词,数字之类组成的
在CLE脚本中使用全局变量会导致游戏BUG和崩溃
只有 $PLAYER_CHAR, $PLAYER_ACTOR, $ONMISSION 才是有效地
全局, 局部, 何解?
全局变量运用于Mani.scm中以此在不同游戏线程中相互连接
局部变量同样也是运用于main.scm中但是他们不能在不同游戏线程中相互连接
你可以在线程中用局部变量创建一辆汽车标记为1@同时在main.scm的其他线程中使用1@
1@ = create_car
你有2种不同的车辆,存在于不同的线程命令中
你可以在一个线程中使用全局变量创建一辆汽车但是不在其他线程中再次使用同一个全局变量来创建这辆汽车
$mycar5 = create_car
但是你可以从main.scm的其他线程中调用这辆汽车
全局变量是可储存的,而局部变量则不行
但是在CLEO脚本中使用全局变量会导致游戏BUG和崩溃
只有 $PLAYER_CHAR, $PLAYER_ACTOR, $ONMISSION 才不会
#作为加载模型名称的接入口标志
CODE | 0247: load_model #BMYCG
0247: load_model #HMYCM
0247: load_model #SWATVAN
0247: load_model #M4
0247: load_model #COLT45 |
CLEO只能调用已经定义存储于vehicles.ide, peds.ide or default.ide的内容
其他的模型需要使用他们的ID编号
'...' 短型字符串是用来插入字母或编号 就像GTX entrynames 或者 特殊 IPL entries的名称
CODE | 03A4: name_thread 'MAIN'
0917: audio_zone 'BEACH' enable_sound 0
00BA: show_text_styled GXT 'INTRO_1' time 1000 style 2
0299: activate_garage 'MODLAST'
07FB: set_interior 'GYM1' access 1 // Ganton Gym
0390: load_txd_dictionary 'LD_BEAT'
076C: set_zone 'GAN1' gang 1 density_to 25 |
"..."长型字符串是用来插入字母或编号比如动作- IFP 文件名称, 身体部位名称, particel 名称, 等待 CODE | 087B: set_player $PLAYER_CHAR clothes_texture "PLAYER_FACE" model "HEAD" body_part 1
038F: load_texture "DOWN" as 1 // Load dictionary with 0390 first
0605: actor -1 perform_animation_sequence "DAN_LOOP_A" IFP_file "DANCING" 4.0 loop 1 0 0 0 time -1 // versionA
0674: set_car_model #GREENWOO numberplate "GROVE4L_"
0245: set_actor 5@ walk_style_to "GANG2"
064B: 25@ = create_particle "EXPLOSION_MOLOTOV" at 2010.0 -1610.0 16.5 type 1 |
To set entries of strings equal to variable names must be used special opcodes and extended variable signs设定线程接入口(或者说变量名称)必须使用特殊的Opcode和扩展变量标志( extended variable signs)------不确定
05AA:
05A9:
06D2:
06D1:
furthermore can strings also replaced with variables by using extended variable signs
此外线程可以取代变量通过使用扩展变量标志--(不确定)
@s - local-string-variable(局部线程变量)
CODE | 05AA: 5@s = 'FEM_OK'
00BC: show_text_highpriority GXT 5@s time 10000 flag 1 |
s$ - global-string-variable(全局线程变量)
注意在CLEO脚本中使用全局变量 会导致游戏BUG或者崩溃 CODE | 05A9: s$Actor_Speech_GXT_Reference = 'CATX_UA' // ~z~Carl, you are a f*cking idiota!
00BC: show_text_highpriority GXT s$Actor_Speech_GXT_Reference time 10000 flag 1
05AA: 5@s = s$Actor_Speech_GXT_Reference
00BC: show_text_highpriority GXT 5@s time 10000 flag 1 |
@v - local-long-string-variable(局部长型线程变量)
CODE | 06D2: 28@v = "LAPDAN1" // @v = string
0812: AS_actor $PLAYER_ACTOR perform_animation "LAPDAN_P" IFP_file 28@v 1000.0 loopA 0 lockX 0 lockY 0 lockF 1 time -1 |
v$ - global-long string-variable(全局长型变量)
注意在CLEO脚本中使用全局变量 会导致游戏BUG或者崩溃 CODE | 06D1: v$1225 = "Bat_block"// 16-byte strings
0605: actor $PLAYER_ACTOR perform_animation_sequence v$1225 from_file "BASEBALL" 4.0 1 0 0 0 -1 ms |
______________________________________________________________________________________
______________________________________________________________________________________
Scripting/Writing a Thread(不明)
在游戏中运行的脚本叫做线程
他们是用create_thread命令或者一个定义任务的脚本定义于Main.scm中作为线程
The cleo programm checks if there is .cs file in the Cleo folder
and if yes, it start this script as threadCLEO程序会扫描CLEO目录是否存在CS文件
如果存在,游戏就会加载这个CLEO脚本。
Script structur / short version:(不知道)
首先,在开头,会以CLEO指令开始
First Label (adress)
然后给线程定义一个名称 CODE | 03A4: name_thread 'AKT' |
现在写入一个代码然后用end_custom_thread 结束线程
一切OK后进游戏测试
CODE | {$CLEO .cs}
:Akt
03A4: name_thread 'AKT'
08B2: toggle_thermal_vision 1
0A93: end_custom_thread |
Script above activates the Infrarot view unless in cutscenes(不知道)
脚本会以opcode 0A93: end_custom_thread结束
The script will be started by each loading of savegame or by start new game
这个脚本会在每次加载存档运行或者开启新游戏后运行
______________________________________________________________________________________
下一步/使用环境条件检查
一个环境条件检查需要最少3个Opcode
1. IF 条件
2. 真正情况
3. 反向跳转设置
1. if
2. 0AB0: key_pressed 8
3. 004D: jump_if_false @akt_01
我们再次使用先前的脚步但是现在我们想要切换到正常模式因此我们使用一个环境检查,建立一个循环
Loop means that a jump instruction can send the reading process to a previous adress
I call such an adress "Loop-adress"循环意味着一个跳转命令可以传达信息到先前的地址 我把它叫做循环地址(Loop-adress)--不确定
在这样一个循环跳转后必须等待XXX毫秒
跳转指令可以是反向跳转或者正向跳转
CODE | 004D: jump_if_false @akt_01 |
or
对于如下脚本的按键环境检查是通过按Backspace键执行的
- CODE
- {$CLEO .cs}:Akt03A4: name_thread 'AKT'08B2: toggle_thermal_vision 1:Akt_01//----------------------------Loop adresse0001: wait 0 msif0AB0: key_pressed 8004D: jump_if_false @Akt_01//--------jump instruction by negation08B2: toggle_thermal_vision 00A93: end_custom_thread
复制代码
Script above activates the Infrarot view and toggle back to normal view by key_press
The reading process is looping as long as BACKSPACE is not pressed
the jump instruction by negation sends the reading process allways to the label :Akt_01
1000 times per second
______________________________________________________________________________________
The IF - Variation
- CODE
- if00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2493.5 -1682.5 13.35 radius 1.0 1.0 1.0004D: jump_if_false @Teleport_2
复制代码
By more than one question in an conditional check requires to determine,
if it means if or or if and
CODE | if and
00DF: actor $PLAYER_ACTOR driving
8119: NOT car 0@ wrecked
004D: jump_if_false @AD_5 |
CODE | if or
00E1: key_pressed 0 0
00E1: key_pressed 0 1
00E1: key_pressed 0 14
00E1: key_pressed 0 18
004D: jump_if_false @AD_7 |
CODE | if or
8118: NOT actor 7@ dead
8118: NOT actor 8@ dead
004D: jump_if_false @AD_25
0002: jump @AD_12 |
The most question codes can be changed into the opposite question
by changing the ciro of the opcode into 8 and insert "not" into the code line
exemble:
CODE | 00E1: key_pressed 0 10 |
and
CODE | 80E1: NOT key_pressed 0 11 |
______________________________________________________________________________________
Next Step/ Script structure simple
The previous scripts ended because of the opcode 0A93: end_custom_thread
Instead let the script ending we use a jump instruction at script end to the 1.Loop adress
So the reading process is permanent looping
And since now we add a check in our loop which we add allways after a Loop adress.
It is:
CODE | if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @Akt_01 |
It should prevent crashes if the player dies or gets arrested
The "IF Player- Defined-check" should allway be the first check in a loop
Script structure simple with 1 Loop:
-Script head
-1.Loop-Adress
-wait code
-IF player_defined-check
-Conditional Check
-Event
-Normal jump instruction to 1.LoopAdress
CODE | {$CLEO .cs}
:Akt
03A4: name_thread 'AKT'
:Akt_01
0001: wait 0 ms
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @Akt_01
if
0AB0: key_pressed 8//-----------------key = Backspace
004D: jump_if_false @Akt_01
08B2: toggle_thermal_vision 1
0001: wait 3000 ms
08B2: toggle_thermal_vision 0
0002: jump @Akt_01//--------Normal jump instruction to 1.LoopAdress |
Script above activates the Infrarot view after key_press
and toggle back to normal view after 3 seconds
______________________________________________________________________________________
Next Step/ Script structure extended
To start an event with our script will change the game state and the conditions.
This needs to redirect the reading process to prevent that the same code will be read again.
Therefore we add a second Loop in the script
Loop 1 - before the event
Loop 2 - after the event
Script structure extended with 2 Loops:
-Script head
-1.Loop-Adress
-wait code
-IF player_defined-check
-Conditional Check
-Event
-2.Loop-Adress
-wait code
-IF player_defined-check
-Conditional Check
-Normal jump instruction to 1.LoopAdress
CODE | {$CLEO .cs}
:akt
03A4: name_thread 'AKT'
:akt01//----------------------------1.Loop Adress
0001: wait 0 ms
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @akt01
if
00DF: actor $PLAYER_ACTOR driving
004D: jump_if_false @akt01
03C0: 1@ = actor $PLAYER_ACTOR car
0229: set_car 1@ color_to 17 0
02AC: set_car 1@ immunities BP 1 FP 1 EP 1 CP 1 MP 1
053F: set_car 1@ tires_vulnerability 0
:akt03//----------------------------2.Loop Adress
0001: wait 0 ms
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @akt03
if
80DF: not actor $PLAYER_ACTOR driving
004D: jump_if_false @akt03
01C3: remove_references_to_car 1@
0002: jump @akt01//--------Normal jump instruction to 1.LoopAdress |
The script above makes the player_car undestructable as soon as a car is entered
Therefore we must registrate the instance of the car and define it with a variable name
03C0: 1@ = actor $PLAYER_ACTOR car
Then we can use this variable name 1@ to make the car immun
After player has left the car, the reading process jumps back into the first Loop.
Youre not restricted by 2 Loops and there are also other kinds of script structure
But I recommand to build your scripts with this structure as long as you have not much experience
______________________________________________________________________________________
Script exemble: Slowmotion
The script toggle by key_press between slowmotion and normal speed
set_gamespeed .3 make the game slow and also the reading process
wait 50 milliseconds needs ca. 1 second
A "if_player_defined"-check is not nessesary because the script dont have any codes which belongs to the player
After a passed key_press check it makes sense to set a wait of one second otherwise the key_press check will be repeated to fast.
CODE | {$CLEO .cs}
:slow_0
03A4: name_thread 'SLW'
:slow_1
0001: wait 0 ms
if
0AB0: key_pressed 8//-----------------key = Backspace
004D: jump_if_false @slow_1
015D: set_gamespeed .3
0001: wait 50 ms
:slow_2
0001: wait 0 ms
if
0AB0: key_pressed 8//-----------------key = Backspace
004D: jump_if_false @slow_2
015D: set_gamespeed 1.0
0001: wait 1000 ms
0002: jump @slow_1 |
______________________________________________________________________________________
Next Step/ Spawn a 3D model
Using models requires 5 steps by applying with models and their definition in its variable name
1. first step to load the model
CODE | 0247: request_model #INFERNUS |
2. second step to prove if the model is loaded in an extra "load-model-check-Loop"
CODE | :Load_Model_Check
0001: wait 0 ms
00D6: if 0
0248: model #INFERNUS available
004D: jump_if_false @Load_Model_Check |
3. The model can be created as soon as the model file is loaded and define it with a variable name
CODE | 00A5: 1@ = create_car #INFERNUS at 2487.5 -1660.5 13.35
0175: set_car 1@ z_angle_to 90.0 |
4. release the loaded model file if it not needed anymore
CODE | 0249: release_model #INFERNUS |
5. Release the defined item from script when the script has done its work
The script can then go to the status quo by jumping back into the first Loop
CODE | 01C3: remove_references_to_car 1@ // Like turning a car into any random car |
Releasing a spawned car by using 01C3: remove_references_to_car deletes the instance of the car for our script
but its still available in the game but can not used anymore in our script.
An other way to release the car is to delete it complete:
CODE | 00A6: destroy_car 1@ |
This 2 different kinds for releasing exist for vehicles, actors and objects each with own opcodes
CODE | {$CLEO .cs}
:3dModels_1
03A4: name_thread 'MODL'
:3dModels_2
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @3dModels_2
00D6: if 0
00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2491.5 -1667.5 13.35 radius 1.0 1.0 1.0
004D: jump_if_false @3dModels_2
0247: request_model #INFERNUS
:Load_Model_Check
0001: wait 0 ms
00D6: if 0
0248: model #INFERNUS available
004D: jump_if_false @Load_Model_Check
00A5: 1@ = create_car #INFERNUS at 2487.5 -1660.5 13.35
0175: set_car 1@ z_angle_to 90.0
0249: release_model #INFERNUS
:3dModels_3
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @3dModels_3
00D6: if 0
80FF: NOT actor $PLAYER_ACTOR 0 ()near_point_on_foot 2491.5 -1667.5 13.35 radius 2.0 2.0 2.0
004D: jump_if_false @3dModels_3
01C3: remove_references_to_car 1@ // Like turning a car into any random car
0002: jump @3dModels_2 |
Script above spawns the car Infernus in Grovestreet if player goes into red marker(sphere)
If player leave the spot the car will be released from script and the reading process jumps back into 1.Loop
# marks the connected entry as filename of a loadable model
For Cleo can only be used models which are defined in vehicles.ide, peds.ide or default.ide
Other models needs to use their ID number
For exemble to spawn the object 1655, waterjumpx2 of data\maps\generic\multiobj.ide
CODE | {$CLEO .cs}
:JumpR00
03A4: name_thread 'JPR'
:JumpR01
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @JumpR01
00D6: if 0
00E1: key_pressed 0 10//--------- No key
004D: jump_if_false @JumpR01
0247: request_model 1655
:JumpR02
0001: wait 0 ms
00D6: if 0
0248: model 1655 available
004D: jump_if_false @JumpR02
0172: 2@ = actor $PLAYER_ACTOR z_angle
04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset 0.0 14.5 -1.8
0107: 1@ = create_object 1655 at 11@ 12@ 13@
0177: set_object 1@ z_angle_to 2@
0001: wait 0 ms
0249: release_model 1655
0001: wait 1000 ms
01C4: remove_references_to_object 1@ // This object will now disappear when the player looks away
0002: jump @JumpR01 |
Script above spawns a jumpramp by key_press
You can allways use the ID number to spawn models, also for cars and actors
As next we use 120 intead #TRIBOSS to spawn an actor
CODE | {$CLEO .cs}
:Actor_1
03A4: name_thread 'Actor'
:Actor_2
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @Actor_2
00D6: if 0
00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2491.5 -1667.5 13.35 radius 1.0 1.0 1.0
004D: jump_if_false @Actor_2
0247: request_model 120
0247: request_model #AK47
:Load_models_check
0001: wait 0 ms
00D6: if and
0248: model 120 available
0248: model #AK47 available
004D: jump_if_false @Load_models_check
009A: 1@ = create_actor 24 120 at 2486.5 -1664.5 13.45
0173: set_actor 1@ z_angle_to 180.0
01B2: give_actor 1@ weapon 30 ammo 99999 // Load the weapon model before using this
02E2: set_actor 1@ weapon_accuracy_to 100
0223: set_actor 1@ health_to 1000
05E2: AS_actor 1@ kill_actor $PLAYER_ACTOR
0249: release_model 120
:Loop_1
0001: wait 0 ms
00D6: if 0
8118: NOT actor 1@ dead
004D: jump_if_false @Cleanup_1
00D6: if 0
0104: actor $PLAYER_ACTOR near_actor 1@ radius 80.0 80.0 10.0 sphere 0
004D: jump_if_false @Cleanup_1
0002: jump @Loop_1
:Cleanup_1
01C2: remove_references_to_actor 1@ // Like turning an actor into a random pedestrian
0002: jump @Actor_2 |
Script above spawns the actor Triboss with gun in Grovestreet
If player leave the area with radius 80.0 80.0 or if the actor is dead,
the actor will be released from script and the reading process jumps back into 1.Loop
To give the actor or the player a weapon requires also to load first the model file
But to give it then really into his hands needs to insert a special weapon number which is not documented in any game file.
To find the right weapon number look in Sannybuilder HELP: SCM Documentation >> GTA SA >> Weapon numbers
Weapon given to actors are not created in same sense like the other models,
so it dont it to release them from script like other items
The spawned actors have predefined execodet behaviors which is dependent by the pedtype parameter of the create_actor opcode.
Look for pedtypes in Sannybuilder HELP: SCM Documentation >> GTA SA >> PedTypes
An actor with pedtype 8 is recruitable like a homie
CODE | 009A: 1@ = create_actor 8 #TRIBOSS at 2486.5 -1664.5 13.45 |
An actor with pedtype 7 is agressive like an enemy gangmember
CODE | 009A: 1@ = create_actor 7 #TRIBOSS at 2486.5 -1664.5 13.45 |
______________________________________________________________________________________
Placing cars by using parked_car_generator
Init parked_car_generators or pickups need to insert the Cleo opcode:
0A95: enable_thread_saving
Read the discription about enable_thread_saving in the theme:
Special Particularities in Cleo >> Registrate (store) the Script State
The placing of cars by using parked_car_generator dont allows the using of its variable name in vehicle associated opcodes
because its not a car but a car_generator
CODE | {$CLEO .cs}
:PaCar_1
03A4: name_thread "PACR"
0001: wait 1000 ms
0A95: enable_thread_saving
014B: 1@ = init_parked_car_generator #BANSHEE -1 -1 1 alarm 0 door_lock 0 0 10000 at 920.1994 2020.546 11.79 angle 100.0
014C: set_parked_car_generator 1@ cars_to_generate_to 101
032B: 2@ = create_weapon_pickup #MINIGUN 15 ammo 5000 at 2113.373 1520.674 10.82
0A93: end_custom_thread |
Script above adds a parked_car_generator to spawn the car Banshee
and a weapon pickup with MINIGUN
generate_to 101 means that the car will be spawned again and again
generate_to 0 deactivates the car_generator
the two parameters after the model name -1 -1 gives the secondary and primary color
by setting -1 -1the game choose the colors randomly
by setting 0 17 it give black (0) to primary and red (17) to secondary color
alarm 0 can be a value between 0 and 100 and means the probable chance to execute an alarm
door_lock 0 can be a value between 0 and 100 and means the probable chance to execute a door lock
For pickups exist 2 different opcodes for 2 different kinds of pickups
032B: for weapons with ammo and for the Jetpack
0213: for melee weapons and objects like parachute (GUN_PARA) or bodyarmour (1242, bodyarmour)
the parameter after the model ID #MINIGUN 15 is the pickup-typ
Typ 15 is a pickup, which appears again and again
Typ 3 is a pickup, which appears only for one time
______________________________________________________________________________________
______________________________________________________________________________________
Special Particularities in Cleo
The extra-Cleo opcodes can be found in Sannybuilder-HELP
CLEO 3 Code Library >> CLEO 3: opcodes CLEO 3 Code Library>> CLEO 3: opcodes
______________________________________________________________________________________
Two major codes to start scripts are those which already exist in the main.scm and have been re-created for Cleo:
1.) 004F: create_thread @SAVEGAME starts an ordinary thread in the main.scm.
We dont need it in Cleo because it will be allready started from Cleo programm
To start an other thread of a cleo script, started from a cleo script needs following opcode:
0A92: create_custom_thread "New_Test_thread.cs"
The code needs to insert the name of the script file which should get started inclusiv dot and extension
The Cleo script file get then the file extension, which is written in the Cleo Script directive at the beginning of the script
{$CLEO .cs} = Cleo directive will be compiled to *.cs
As New_Test_thread.txt saved and compiled as New_Test_thread.cs
The script get then started at second once. Once from Cleo programm and once from the 0A92: create_custom_thread
It needs to set a conditional check at script beginn to let the script ending when it was started from Cleo programm.
An other chance is to give the script the extension .s
This needs to insert following:
0A92: create_custom_thread "New_Test_thread.s"
The Cleo script file which should get started, must have {$CLEO .cs} as directive and will be compiled as *.cs
You must change the extension manual by renaming from *.cs into *.s
In this case the Cleo script will only run if it was started with 0A92: create_custom_thread from an other Cleo script.
The opcode 0A92: create_custom_thread can transport more information to the script which should be started
This opcode can be extended with up to 30 values or variables as parameters
exemble:
CODE | 0A92: create_custom_thread "PimpmyCarFULL2A1.cs" 1 2 0 3@ 4@ 5@ 6@ 29@ 8@ 9@ 10@ |
The started thread recieves these parameter values with following rule
0@ get value of 1.parameter
1@ get value of 2.parameter
2@ get value of 3.parameter
3@ get value of 4.parameter
4@ get value of 5.parameter
etc...
Its also possible to start much threads in one and the same Cleo script, started from the same script which recieve the create_thread commands.
2.)
0417: start_mission 3
starts a mission script of the main.scm. It needs to insert the number which the mission script get from the listing of the mission table
In Cleo dont exist a mission table and its listing.
But it needs allways a Cleo mission starter script with following command:
0A94: start_custom_mission "DriftMission"
The code needs to insert the name of the script file which should get started but without extension
The Cleo script file get then the file extension, which is written in the Cleo Script directive at the beginning of the script
{$CLEO .cm} = Cleo directive will be compiled to *.cm
As DriftMission.txt saved and compiled as DriftMission.cm
______________________________________________________________________________________
0A93: end_custom_thread let a script ending. Its disabled then.
The original version of this code of the main.scm is 004E: end_thread
And this original version must be used furthermore in Cleo mission scripts (*.cm)
004E: end_thread
Again:
0A93: end_custom_thread in normal Cleo scripts, compiled to a *.cs file
CODE | {$CLEO .cs}
0A93: end_custom_thread |
004E: end_thread in mission scripts, compiled to a *.cm file
CODE | {$CLEO .cm}
004E: end_thread |
______________________________________________________________________________________
Cleo creates extra save files if a save was done,
stored in folder CLEO\Cleo_save
By loading a save file must taken care to check that the presence of the scripts in Cleo folder
is the same as it was as the save was done.
Special attention in this case are going to those scripts which includes the Cleo opcode
to registrate and store the Script State
______________________________________________________________________________________
Registrate (store) the Script State
The Cleo scripts with extension .cs are started allways from new by loading a save game or start new game,
If such a script includes for exemble a parked car generator and execute it and after this a save game is made,
and then this save game is loaded,
will be created a duplicate of the item, in this case a duplicate of a parked car generator.
This happens with parked car generator, pickups as well as placed objects.
To prevent this or to read the script state by using special special Cleo-variable
must be used following Cleo opcode:
CODE | 0A95: enable_thread_saving |
This instruct Cleo to store the script state by making a savegame
______________________________________________________________________________________
Special Global Cleo Variable
This theme requires the understanding of the description about Local Variables and Global Variables
of the previous theme Datatype
especially this part which tells why there exist Local Variables and Global Variables
Global Variables are used in main.scm to communicate between different scripts and they are storable.
Using Global Variables in Cleo scripts can cause bugs and crashes
To realize Global Variables for Cleo scripts exist following Cleo opcode connected with a special expression:
Opcode 0AB3: and 0AB4:
The expression var together with a number, <var><space><number> is builing the Special Global Cleo Variable
CODE | 0AB3: var 0 = 10
or
0006: 13@ = 10 // integer values
0AB3: var 0 = 13@
and
0AB4: 0@= var 0 |
var 0 up to var 999 will be stored, in exemble var 0 is stored with 10
to get then stored value into your script needs to submit into a local:
CODE | 0AB4: 13@ = var 44
if
0039: 13@ == 1 // integer values
004D: jump_if_false @nextlabel |
______________________________________________________________________________________
______________________________________________________________________________________
Script Exemble by using Special Global Cleo Variable/ Store a car at any place
(requires to understand all previous themes of this tut)
Script below saves a car at any place
If player is in car and key F7 is pressed, it stores x,y,z coords and angle, also the car ID, its primary and secondary color and its paintjob.
The player exit then the car and car will be locked and made immun
If player leave the location and the distance to the car will be greater then 100.0
the car will be released from script and the reading process jumps back into an other Loop
If player then comes back to the location, near 80.0 the car will be spawned as new
Only to store the car settings by making savegame needs to give the values into the Special Global Cleo Variable
As I wrote in the theme "Registrate (store) the Script State"
is the Carstore script running from new by loading a save game or start new game"...
...and checks first if var 955 is ciro
its only not ciro if a car was stored in the loaded savegame
If var 955 is ciro, the script starts with the 1.Loop
If var 955 is not ciro, the reading process jumps into the 3.Loop with the check if player is near the car store location
A special side effect of this kind of car store is that the storable entries then available in memory for all savefiles.
Only by shut down the game and start again is the stored car only stored in the savegame which was done to store the car.
CODE | {$CLEO .cs}
:CARSTORE
03A4: name_thread 'CARSTOR'
0001: wait 1000 ms
0AB4: 7@ = var 955
00D6: if
8039: not 7@ == 0
004D: jump_if_false @CARSTOR_150
0AB4: 3@ = var 951
0AB4: 4@ = var 952
0AB4: 5@ = var 953
0AB4: 6@ = var 954
0AB4: 7@ = var 955
0AB4: 8@ = var 956
0AB4: 9@ = var 957
0AB4: 10@ = var 958
0093: 3@ = integer 3@ to_float
0093: 4@ = integer 4@ to_float
0093: 5@ = integer 5@ to_float
0093: 6@ = integer 6@ to_float
0001: wait 1000 ms
0002: jump @CARSTOR_555
:CARSTOR_150
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @CARSTOR_150
00D6: if and
00DF: actor $PLAYER_ACTOR driving
0AB0: key_pressed 118//-------------------key F7
004D: jump_if_false @CARSTOR_150
01B4: set_player $PLAYER_CHAR can_move 0
03C0: 2@ = actor $PLAYER_ACTOR car
00AA: store_car 2@ position_to 3@ 4@ 5@
0174: 6@ = car 2@ Z_angle
0441: 7@ = car 2@ model
0988: get_car 2@ paintjob 8@
03F3: get_car 2@ primary_color_to 9@ secondary_color_to 10@
020A: set_car 2@ door_status_to 0
02AC: set_car 2@ immunities BP 1 FP 1 EP 1 CP 1 MP 1
0519: set_car 2@ locked 1
0633: AS_actor $PLAYER_ACTOR exit_car
0092: 13@ = float 3@ to_integer
0092: 14@ = float 4@ to_integer
0092: 15@ = float 5@ to_integer
0092: 16@ = float 6@ to_integer
0AB3: var 951 = 13@
0AB3: var 952 = 14@
0AB3: var 953 = 15@
0AB3: var 954 = 16@
0AB3: var 955 = 7@
0AB3: var 956 = 8@
0AB3: var 957 = 9@
0AB3: var 958 = 10@
0001: wait 2000 ms
01B4: set_player $PLAYER_CHAR can_move 1
0002: jump @CARSTOR_403
:CARSTOR_403
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @CARSTOR_550
00D6: if
82BF: not car 2@ sunk
004D: jump_if_false @CARSTOR_738
00D6: if
8119: not car 2@ wrecked
004D: jump_if_false @CARSTOR_550
00D6: if
0202: actor $PLAYER_ACTOR near_car 2@ radius 100.0 100.0 flag 0
004D: jump_if_false @CARSTOR_550
00D6: if
00DF: actor $PLAYER_ACTOR driving
004D: jump_if_false @CARSTOR_403
00D6: if
00DB: actor $PLAYER_ACTOR in_car 2@
004D: jump_if_false @CARSTOR_403
02AC: set_car 2@ immunities BP 0 FP 0 EP 0 CP 0 MP 0
0519: set_car 2@ locked 0
0002: jump @CARSTOR_738
:CARSTOR_550
01C3: remove_references_to_car 2@ // Like turning a car into any random car
:CARSTOR_555
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @CARSTOR_555
00D6: if
00FE: actor $PLAYER_ACTOR sphere 0 in_sphere 3@ 4@ 5@ radius 80.0 80.0 50.0
004D: jump_if_false @CARSTOR_555
0002: jump @CARSTOR_624
:CARSTOR_624
0247: load_model 7@
:CARSTOR_629
0001: wait 0 ms
00D6: if
0248: model 7@ available
004D: jump_if_false @CARSTOR_629
0001: wait 0 ms
00A5: 2@ = create_car 7@ at 3@ 4@ 5@
0175: set_car 2@ Z_angle_to 6@
06ED: set_car 2@ paintjob 8@
0229: set_car 2@ primary_color_to 9@ secondary_color_to 10@
020A: set_car 2@ door_status_to 0
02AC: set_car 2@ immunities BP 1 FP 1 EP 1 CP 1 MP 1
0519: set_car 2@ locked 1
0249: release_model 7@
0002: jump @CARSTOR_403
:CARSTOR_738
01C3: remove_references_to_car 2@ // Like turning a car into any random car
0AB3: var 955 = 0
0002: jump @CARSTOR_150 |
______________________________________________________________________________________
______________________________________________________________________________________
Template for Cleo Mission Script
(requires to understand all previous themes of this tut)
To run a Cleo mission script requires allways 2 Cleo script files
1. A .cs file to start the Cleo mission script file
2. The Cleo mission script file itself with extension .cm
The mission starter thread below is done with a conditional check to check if the player is near a specified point,
which must passed to start the mission.
The coordinates of the near_point check are the location in San Fierro/Carlton Heights near savehouse
Edit the coordinates to set your own location for starting
The parameter 1 of the near_point opcode 00FE: actor $PLAYER_ACTOR 1 (in-sphere)near_point
is displaying a red marker (sphere).
If the parameter is ciro 00FE: actor $PLAYER_ACTOR 0 (in-sphere)near_point does not displaying a red marker.
To display a red marker in this way needs to set 0ms as maximum in the wait code of this Loop
CODE | {$CLEO .cs}
:Test_M_Start_1
03A4: name_thread 'TSTM'
:Test_M_Start_2
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @Test_M_Start_2
00D6: if 0
0038: $ONMISSION == 0 // integer values
004D: jump_if_false @Test_M_Start_2
:Test_M_Start_6
00D6: if 0
00FE: actor $PLAYER_ACTOR 1 (in-sphere)near_point 2480.1343 -1665.475 13.3348 radius 3.5 3.5 5.5
004D: jump_if_false @Test_M_Start_2
00BA: text_styled 'STAD_02' 1000 ms 2
0004: $ONMISSION = 1 // integer values
0A94: start_custom_mission "TestMission" //
0002: jump @Test_M_Start_2 |
The mission starter script includes the following Cleo opcode to start the Cleo mission script:
0A94: start_custom_mission "TestMission"
The code needs to insert the name of the script file which should get started but without extension
The Cleo script file get then the file extension, which is written in the Cleo Script directive at the beginning of the script
{$CLEO .cm} = Cleo directive will be compiled to *.cm
As TestMission.txt saved and compiled as TestMission.cm
CODE | {$CLEO .cm}
:TestMiss_1
03A4: name_thread "TESTM"
0050: gosub @TestMiss_main_1
00D6: if 0
0112: wasted_or_busted
004D: jump_if_false @TestMiss_end_1
0050: gosub @TestMiss_fail_1
:TestMiss_end_1
0050: gosub @TestMiss_clep_1
004E: end_thread
:TestMiss_main_1
0317: increment_mission_attempts//here starts the missionscript
0004: $ONMISSION = 1
054C: use_GXT_table 'MENU2P'
00BC: text_highpriority 'MENU_18' 5000 ms 1
:TestMiss_11
0001: wait 0 ms
if and
02D8: actor $PLAYER_ACTOR currentweapon == 0
00E1: key_pressed 0 17
004D: jump_if_false @TestMiss_11
:TestMiss_pass_1
00BA: text_styled 'M_PASS' 5000 ms 1
0051: return
:TestMiss_fail_1
00BA: text_styled 'M_FAIL' 5000 ms 1
0051: return
:TestMiss_clep_1
0004: $ONMISSION = 0
00D8: mission_cleanup
0051: return |
When the mission script from above is running it can be completed by pressing fire key while player have weapon 0/naked fist.
The secret of the onmission mode
$ONMISSION is not only a variable to check if a mission script is running or not.
Set $ONMISSION to 1 activates a special mission mode if some important conditions are accomplished.
R*s mission scripts run allways in a subroutine which will be cancled from the exe if player is wasted or busted like reading a return code in the script.
1. At first it needs to set $ONMISSION equal to on_mission_flag
CODE | 0180: set_on_mission_flag_to $ONMISSION// Note: your missions have to use the variable defined here |
This code is set by default in the main part of the original main.scm
2. By starting the mission script must sended the reading precess with a gosub command into a subroutine for the main part of the mission script.
It must be the first gosub of the mission script.
CODE | 0050: gosub @TestMiss_main_1 |
3. By starting the mission script must be activated the onmission mode with
CODE | 0004: $ONMISSION = 1
0317: increment_mission_attempts//here starts the missionscript |
Then the mission is running in a subroutine and dont needs to check if player is defined or dead or busted.
If player dies or get busted, the exe cancels the subroutine as like as a return code of our script is readed
The rest of the mission script is just a cunning gosub construct.
______________________________________________________________________________________
______________________________________________________________________________________
gosub
The gosub command leads the reading process to an excluded subscript.
Excluded means the codes of the subscript are not binded in code following of our thread.
CODE | 0050: gosub @MODLSUBROUTINE |
The subscript must end with return
If the subscript ends with 0051: return, our thread then continues with reading the codes after the 0050: gosub command
Exemble:
CODE | {$CLEO .cs}
:MODLSUB_1
03A4: name_thread 'MODLSUB'
:MODLSUB_2
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @MODLSUB_2
00D6: if 0
00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2491.5 -1667.5 13.35 radius 1.0 1.0 1.0
004D: jump_if_false @MODLSUB_2
0050: gosub @MODLSUBROUTINE
:Loop_1
0001: wait 0 ms
00D6: if 0
8118: NOT actor 1@ dead
004D: jump_if_false @Cleanup_1
00D6: if 0
0104: actor $PLAYER_ACTOR near_actor 1@ radius 80.0 80.0 10.0 sphere 0
004D: jump_if_false @Cleanup_1
0002: jump @Loop_1
:Cleanup_1
01C2: remove_references_to_actor 1@ // Like turning an actor into a random pedestrian
0002: jump @MODLSUB_2
:MODLSUBROUTINE
0005: 1@ = 2473.25
0005: 2@ = -1657.79
0005: 3@ = 13.4
0005: 4@ = 2501.12
0005: 5@ = -1676.5
0005: 6@ = 13.4
0208: 7@ = random_float_in_ranges 1@ 4@
0208: 8@ = random_float_in_ranges 2@ 5@
0208: 9@ = random_float_in_ranges 3@ 6@
0247: request_model #TRIBOSS
0247: request_model #AK47
:Load_MODLSUB_Check
0001: wait 0 ms
00D6: if and
0248: model #TRIBOSS available
0248: model #AK47 available
004D: jump_if_false @Load_MODLSUB_Check
009A: 1@ = create_actor 24 #TRIBOSS at 7@ 8@ 9@
0173: set_actor 1@ z_angle_to 180.0
01B2: give_actor 1@ weapon 30 ammo 99999 // Load the weapon model before using this
02E2: set_actor 1@ weapon_accuracy_to 100
0223: set_actor 1@ health_to 1000
05E2: AS_actor 1@ kill_actor $PLAYER_ACTOR
0249: release_model #TRIBOSS
0051: return |
Script above spawns the actor Triboss with gun in Grovestreet at different places
The coords are generated random
The part with the coords generation and actor spawn is excluded in a subscript
If player leave the area with radius 80.0 80.0 or if the actor is dead,
the actor will be released from script and the reading process jumps back into 1.Loop
______________________________________________________________________________________
______________________________________________________________________________________
Additional Themes
Create a FXT file to show your own text message
Load a special actor
Tuning parts
Animations
Music, wave and sounds of Audio folder
Give access with math coding
______________________________________________________________________________________
______________________________________________________________________________________
Create a FXT file to show your own text message
Cleo makes possible to use a custom file to store text for using ingame
its called fake XT, according to the gxt file of the game
This requires to install the GxtHook.cleo in Cleo folder and an extra folder for the fxt files
Much users make it wrong, so again the explanation:
GxtHook.cleo must be placed in Cleo folder, not in a sub folder
Cleo_text folder must be a sub folder of Cleo folder
The fxt file must be placed in Cleo_text folder
GTASA game dir
- Cleo:GxtHook.cleo
- Cleo\Cleo_text: text.fxt
The fxt file will be read by game start.
If you have modified your fxt file it needs first to close the game complete
and then start again to apply the changes.
To create a fxt file needs to insert an entry name for the script and the real text to show, in a normal txt file
Then rename the file by chaning the extension from .txt into .fxt
Or create it directly with Sannybuilder and save it as .fxt , choose Any file (*.*) as extension
Entry name for the script and the real text to show must be done in this way:
<Entryname><space><text message>
only 1 space between Entryname and text message
Important:
only 1 space between words of the text message are allowed and NO space at the end
Maximum 7 symbols as entry name are allowed
Exemble:
Copy this line into a blanc page and save it as anyname.fxt
CODE | TXT_01 This is text of Cleo fxt file |
Then use the script below to show the text by key_press
CODE | {$CLEO .cs}
:FXT
03A4: name_thread 'FXT'
:FXT_01
0001: wait 0 ms
if
0AB0: key_pressed 84//--------- key = T
004D: jump_if_false @FXT_01
00BA: text_styled 'TXT_01' 1000 ms 1
0A93: end_custom_thread |
The opcodes to show text are the same like to show text of american.gxt
There exist several opcodes to show text in different kinds. Look in opcode search tool.
Or look in Dutchys coding tut
If you wonna use entry names of american.gxt to use its text messages,
so look for a complete translation txt file in Sanny Install directory:
Sanny Builder 3\help\GXT Strings\GTASA.text
______________________________________________________________________________________
______________________________________________________________________________________
Load a special actor
There exist 2 kinds of actor models in the game.
One kind are models which are defined with a ID number in peds.ide and must be loaded with opcode 0247:
The other kind of actor models are not defined in peds.ide and must be loaded with opcode 023C:
These are called special actors and there are ID numbers reserved in peds.ide. From 290 up to 299
So 10 different special actors can be spawned at same time.
According to the theme Spawn a 3D model we need also 5 steps but with other opcodes
1. first step to load the special actor needs to insert the model name as short string
CODE | 023C: load_special_actor 'ogloc' as 1 |
2. second step to prove if the model is loaded in an extra "load-model-check-Loop"
CODE | :Load_Model_Check
0001: wait 0 ms
00D6: if 0
023D: special_actor 1 loaded
004D: jump_if_false @Load_Model_Check |
3. The model can be created as soon as the model file is loaded and define it with a variable name
CODE | 009A: 0@ = create_actor_pedtype 24 model #SPECIAL01 at 2491.5 -1667.5 13.35 |
4. release the loaded special actor model file if it not needed anymore
CODE | 0296: unload_special_actor 1 |
5. Release the defined item from script when the script has done its work
same like other actors
CODE | 01C2: remove_references_to_actor 0@ |
The script below spawns a special actor by key_press at 4 virtual meters infront of the player
The script reads also the current interior to can spawn everywhere by using opcode 0860:
If the actor is dead he will be released from script und the reading process jumps back into 1.Loop
CODE | {$CLEO .cs}
:SPLACTOR_1
03A4: name_thread 'SPACTOR'
:SPACTOR_11
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @SPACTOR_11
00D6: if
0AB0: key_pressed 57//--------------------------------- key 9
004D: jump_if_false @SPACTOR_11
077E: get_active_interior_to 29@
023C: load_special_actor 'ogloc' as 1 // models 290-299
:SPACTOR_51
0001: wait 0 ms
00D6: if
823D: not special_actor 1 loaded
004D: jump_if_false @SPACTOR_90
023C: load_special_actor 'OGLOC' as 1 // models 290-299
0002: jump @SPACTOR_51
:SPACTOR_90
04C4: store_coords_to 11@ 12@ 13@ from_actor $PLAYER_ACTOR with_offset 0.0 4.0 0.2
009A: 0@ = create_actor_pedtype 24 model #SPECIAL01 at 11@ 12@ 13@
0223: set_actor 0@ health_to 10000
0860: link_actor 0@ to_interior 29@
0296: unload_special_actor 1
:SPACTOR_158
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @SPACTOR_201
00D6: if
8118: not actor 0@ dead
004D: jump_if_false @SPACTOR_201
0002: jump @SPACTOR_158
:SPACTOR_201
01C2: remove_references_to_actor 0@ // Like turning an actor into a random pedestrian
0002: jump @SPACTOR_11 |
The opcode to create the actor is the same like for a normal ped.
Instead of inserting the peds model name will be used the entry #SPECIAL01
SPECIAL01 represent the ID 290 which the actor then get from the script
Its also possible to use the ID numbers instead of SPECIAL01
By creating more different special actors needs to give it then entries with numbers in ascending order
#SPECIAL01 and #SPECIAL02 or 290 and 291
The script below spawns 5 special actors
If one actor is dead all actors will be released from script und the reading process jumps back into 1.Loop
An advantage of special actors is to can add a new actor model with new model name without editing data files
Important: Maximum 7 symbols are allowed as model name
CODE | {$CLEO .cs}
:SPLACTOR_1
03A4: name_thread 'SPACMOR'
:SPACMOR_11
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @SPACMOR_11
00D6: if
0AB0: key_pressed 57//--------------------------------- key 9
004D: jump_if_false @SPACMOR_11
077E: get_active_interior_to 29@
023C: load_special_actor 'OGLOC' as 1 // models 290-299
023C: load_special_actor 'SMOKE' as 2 // models 290-299
023C: load_special_actor 'SWEET' as 3 // models 290-299
023C: load_special_actor 'RYDER2' as 4 // models 290-299
023C: load_special_actor 'CESAR' as 5 // models 290-299
:SPACMOR_116
0001: wait 0 ms
00D6: if or
823D: not special_actor 1 loaded
823D: not special_actor 2 loaded
823D: not special_actor 3 loaded
823D: not special_actor 4 loaded
823D: not special_actor 5 loaded
004D: jump_if_false @SPACMOR_223
023C: load_special_actor 'OGLOC' as 1 // models 290-299
023C: load_special_actor 'SMOKE' as 2 // models 290-299
023C: load_special_actor 'SWEET' as 3 // models 290-299
023C: load_special_actor 'RYDER2' as 4 // models 290-299
023C: load_special_actor 'CESAR' as 5 // models 290-299
0002: jump @SPACMOR_116
:SPACMOR_223
04C4: store_coords_to 11@ 12@ 13@ from_actor $PLAYER_ACTOR with_offset -2.0 2.0 0.2
009A: 0@ = create_actor_pedtype 24 model #SPECIAL01 at 11@ 12@ 13@
0223: set_actor 0@ health_to 10000
0860: link_actor 0@ to_interior 29@
04C4: store_coords_to 11@ 12@ 13@ from_actor $PLAYER_ACTOR with_offset 0.0 2.0 0.2
009A: 1@ = create_actor_pedtype 24 model 291 at 11@ 12@ 13@
0223: set_actor 1@ health_to 10000
0860: link_actor 1@ to_interior 29@
04C4: store_coords_to 11@ 12@ 13@ from_actor $PLAYER_ACTOR with_offset 2.0 2.0 0.2
009A: 2@ = create_actor_pedtype 24 model #SPECIAL03 at 11@ 12@ 13@
0223: set_actor 2@ health_to 10000
0860: link_actor 2@ to_interior 29@
04C4: store_coords_to 11@ 12@ 13@ from_actor $PLAYER_ACTOR with_offset -2.0 4.0 0.2
009A: 3@ = create_actor_pedtype 24 model 293 at 11@ 12@ 13@
0223: set_actor 3@ health_to 10000
0860: link_actor 3@ to_interior 29@
04C4: store_coords_to 11@ 12@ 13@ from_actor $PLAYER_ACTOR with_offset 2.0 4.0 0.2
009A: 4@ = create_actor_pedtype 24 model #SPECIAL05 at 11@ 12@ 13@
0223: set_actor 4@ health_to 10000
0860: link_actor 4@ to_interior 29@
0296: unload_special_actor 1
0296: unload_special_actor 2
0296: unload_special_actor 3
0296: unload_special_actor 4
0296: unload_special_actor 5
:SPACMOR_563
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @SPACMOR_626
00D6: if and
8118: not actor 0@ dead
8118: not actor 1@ dead
8118: not actor 2@ dead
8118: not actor 3@ dead
8118: not actor 4@ dead
004D: jump_if_false @SPACMOR_626
0002: jump @SPACMOR_563
:SPACMOR_626
01C2: remove_references_to_actor 0@ // Like turning an actor into a random pedestrian
01C2: remove_references_to_actor 1@ // Like turning an actor into a random pedestrian
01C2: remove_references_to_actor 2@ // Like turning an actor into a random pedestrian
01C2: remove_references_to_actor 3@ // Like turning an actor into a random pedestrian
01C2: remove_references_to_actor 4@ // Like turning an actor into a random pedestrian
0002: jump @SPACMOR_11 |
______________________________________________________________________________________
______________________________________________________________________________________
Tuning parts
According to the theme Spawn a 3D model we need in this case only 4 steps and with other opcodes
1. first step to load the tuning part
CODE | 06E9: request_car_component #hydralics
06E9: request_car_component #NTO_B_S
06E9: request_car_component 1115 |
2. second step to prove if the model is loaded in an extra "load-model-check-Loop"
CODE | :Load_Model_Check
0001: wait 0 ms
if and
06EA: car_component_available #hydralics
06EA: car_component_available #NTO_B_S
06EA: car_component_available 1115
004D: jump_if_false @Load_Model_Check |
3. The tuning part can be created as soon as the model file is loaded by attaching to the car
CODE | 06E7: 1@ = add_car_component #NTO_B_S to_car 0@
06E7: 2@ = add_car_component #hydralics to_car 0@
06E7: 3@ = add_car_component 1115 to_car 0@ |
4. release the loaded tuning part model file if it is not needed anymore
CODE | 06EB: release_car_component #hydralics
06EB: release_car_component #NTO_B_S
06EB: release_car_component 1115 |
To release the defined item from script is not nessesary
The script below spawns the car SLAMVAN with nitro, hydraulics and front bumper
and the paintjob 1 in Grovestreet if player goes into red marker
Adding paintjobs needs first to give the car white colors
Painjobs requires existing paintjob textures
These are additional txd files which have the same name like the dff model and its basic txd with an additional number
slamvan.dff and slamvan.txd as basic model files
slamvan1.txd as paintjob 0, slamvan2.txd as paintjob 1, etc...
If player leave the spot the car will be released from script and the reading process jumps back into 1.Loop
CODE | {$CLEO .cs}
:TuneP_1
03A4: name_thread 'TuneP'
:TuneP_2
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @TuneP_2
00D6: if 0
00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2491.5 -1667.5 13.35 radius 1.0 1.0 1.0
004D: jump_if_false @TuneP_2
0247: request_model #SLAMVAN
06E9: request_car_component #hydralics
06E9: request_car_component #NTO_B_S
06E9: request_car_component 1115
:Load_Model_Check
0001: wait 0 ms
if and
0248: model #SLAMVAN available
06EA: car_component_available #hydralics
06EA: car_component_available #NTO_B_S
06EA: car_component_available 1115
004D: jump_if_false @Load_Model_Check
00A5: 0@ = create_car #SLAMVAN at 2487.5 -1660.5 13.35
0175: set_car 0@ z_angle_to 180.0
06E7: 1@ = add_car_component #NTO_B_S to_car 0@
06E7: 2@ = add_car_component #hydralics to_car 0@
06E7: 3@ = add_car_component 1115 to_car 0@
0229: set_car 0@ color_to 1 1
06ED: set_car 0@ paintjob 1
06EB: release_car_component #hydralics
06EB: release_car_component #NTO_B_S
06EB: release_car_component 1115
0249: release_model #SLAMVAN
:TuneP_4
0001: wait 0 ms
00D6: if 0
0256: player $PLAYER_CHAR defined
004D: jump_if_false @TuneP_4
00D6: if 0
80FF: NOT actor $PLAYER_ACTOR 0 ()near_point_on_foot 2491.5 -1667.5 13.35 radius 2.0 2.0 2.0
004D: jump_if_false @TuneP_4
01C3: remove_references_to_car 0@ // Like turning a car into any random car
0002: jump @TuneP_2 |
______________________________________________________________________________________
______________________________________________________________________________________
Animations
To use animations exist 2 opcodes, 0605: and 0812:
CODE | 0605: actor $PLAYER_ACTOR perform_animation_sequence "TAI_CHI_IN" IFP_file "PARK" 4.0 loop 0 1 1 0 time -1
0812: AS_actor $PLAYER_ACTOR perform_animation "SWIM_BREAST" IFP_file "SWIM" 1.0 loopA 1 lockX 1 lockY 1 lockF 1 time -2 |
The animations are embeded in the IFP files
Important:
The IFP file ped.ifp is placed in GTASA\anim folder and all animations of ped.ifp are loaded by gamestart
It dont need to load the animation for the script. Never load the ifp file "ped" !!
The other IFP files are archived in gta3.img
It needs first to load the IFP file before using an animation of its file
The script below is an exemble to assign an animation of IFP file "ped" by key_press to player actor
CODE | {$CLEO .cs}
:IFP_PED
03A4: name_thread 'IFP_PED'
:IFP_PED_01
0001: wait 0 ms
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @IFP_PED_01
if and
0AB0: key_pressed 8//-----------------key = Backspace
80DF: not actor $PLAYER_ACTOR driving
004D: jump_if_false @IFP_PED_01
0605: actor $PLAYER_ACTOR perform_animation_sequence "CAR_ROLLOUT_RHS" IFP_file "PED" 4.0 loop 0 1 1 0 time -1
0001: wait 2000 ms
0002: jump @IFP_PED_01 |
Several animations are defined as extra opcodes
Some exembles:
05C7: AS_actor $PLAYER_ACTOR use_atm
05C2: AS_actor $PLAYER_ACTOR show_the_finger
05C9: AS_actor $PLAYER_ACTOR on_guard 2000 ms
05C4: AS_actor $PLAYER_ACTOR hands_up 15000 ms
0729: AS_actor $PLAYER_ACTOR hold_cellphone 1// requires to load first the model #cellphone
0729: AS_actor $PLAYER_ACTOR hold_cellphone 0
05BC: AS_actor $PLAYER_ACTOR jump 1
05C3: AS_actor $PLAYER_ACTOR hands_cower
05C5: AS_actor $PLAYER_ACTOR cower 3000 ms
The other IFP files are archived in gta3.img and needs first to load the IFP file before using an animation of its file
According to the theme Spawn a 3D model we need also 5 steps but with other opcodes
1. first step to load the IFP file needs to insert the IFP file name as long string
CODE | 04ED: load_animation "PARK" |
2. second step to prove if the file is loaded in an extra "load-model-check-Loop"
CODE | :Load_Model_Check
0001: wait 0 ms
00D6: if 0
04EE: animation "PARK" loaded
004D: jump_if_false @Load_Model_Check |
3. The animation can now assigned to an actor as soon as the IFP file is loaded and the actor is available.
It requires to insert animation name and name of IFP file as long string
CODE | 0812: AS_actor $PLAYER_ACTOR perform_animation "TAI_CHI_IN" IFP_file "PARK" 1.0 loopA 1 lockX 1 lockY 1 lockF 1 time -2 |
4. release the loaded IFP file if it is not needed anymore
CODE | 04EF: release_animation "PARK" |
5. Release a defined item is not possible but in some cases it needs to remove the animation from actor
CODE | 0792: disembark_instantly_actor $PLAYER_ACTOR |
In addition by using animation packs, it needs to release the pack
CODE | 061B: remove_references_to_AS_pack 0@ |
The script below is an exemble to assign an animation of IFP file "PARK" by key_press to player actor
The animation will be repeated as long as the key is not pressed again, because of the value 1 in the parameter of loopA
CODE | {$CLEO .cs}
:IFP_PARK
03A4: name_thread 'IFPPARK'
:IFP_PARK_11
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @IFP_PARK_11
00D6: if
0AB0: key_pressed 8//-----------------key = Backspace
004D: jump_if_false @IFP_PARK_11
04ED: load_animation "PARK"
:IFP_PARK_54
0001: wait 0 ms
00D6: if
04EE: animation "PARK" loaded
004D: jump_if_false @IFP_PARK_54
0812: AS_actor $PLAYER_ACTOR perform_animation "TAI_CHI_IN" IFP_file "PARK" 1.0 loopA 1 lockX 1 lockY 1 lockF 1 time -2 // versionB
0001: wait 1000 ms
:IFP_PARK_141
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @IFP_PARK_141
00D6: if and
8AB0: not key_pressed 8//-----------------key = Backspace
80E1: not player 0 pressed_key 15
004D: jump_if_false @IFP_PARK_221
0002: jump @IFP_PARK_141
:IFP_PARK_221
0792: disembark_instantly_actor $PLAYER_ACTOR
04EF: release_animation "PARK"
0001: wait 1000 ms
0002: jump @IFP_PARK_11 |
Combine several animation to an AS_pack
The script below assigns sevaral animations of different IFP files combined in an AS_pack by key_press to player actor
CODE | {$CLEO .cs}
:AMPAK_00
03A4: name_thread 'APK'
0001: wait 2000 ms
:AMPAK_1
0001: wait 50 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @AMPAK_1
if
0AB0: key_pressed 8//-----------------key = Backspace
004D: jump_if_false @AMPAK_1
04ED: load_animation "STRIP"
04ED: load_animation "DANCING"
:AMPAK_12
0001: wait 0 ms
if and
04EE: animation "STRIP" loaded
04EE: animation "DANCING" loaded
004D: jump_if_false @AMPAK_13
0002: jump @AMPAK_14
:AMPAK_13
04ED: load_animation "STRIP"
04ED: load_animation "DANCING"
0002: jump @AMPAK_12
:AMPAK_14
0615: define_AS_pack_begin 0@
0605: actor -1 perform_animation_sequence "STR_B2C" from_file "STRIP" 4.0 0 0 0 1 -1 ms
0605: actor -1 perform_animation_sequence "DNCE_M_A" from_file "DANCING" 4.0 0 0 0 1 -1 ms
0605: actor -1 perform_animation_sequence "STR_B2C" from_file "STRIP" 4.0 0 0 0 1 -1 ms
0605: actor -1 perform_animation_sequence "DNCE_M_A" from_file "DANCING" 4.0 0 0 0 1 -1 ms
0605: actor -1 perform_animation_sequence "STR_B2C" from_file "STRIP" 4.0 0 0 0 1 -1 ms
0605: actor -1 perform_animation_sequence "DAN_LOOP_A" from_file "DANCING" 4.0 0 0 0 1 -1 ms
0605: actor -1 perform_animation_sequence "DNCE_M_D" from_file "DANCING" 4.0 0 0 0 1 -1 ms
0643: set_AS_pack 0@ loop 1
0616: define_AS_pack_end 0@
0618: assign_actor $PLAYER_ACTOR to_AS_pack 0@
0001: wait 1000 ms
:AMPAK_21
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @AMPAK_end
if
80E1: not key_pressed 0 15
004D: jump_if_false @AMPAK_end
if or
0611: actor $PLAYER_ACTOR animation == "STR_B2C"
0611: actor $PLAYER_ACTOR animation == "DNCE_M_A"
0611: actor $PLAYER_ACTOR animation == "STR_B2C"
0611: actor $PLAYER_ACTOR animation == "DNCE_M_D"
004D: jump_if_false @AMPAK_end
0002: jump @AMPAK_21
:AMPAK_end
061B: remove_references_to_AS_pack 0@
04EF: release_animation "STRIP"
04EF: release_animation "DANCING"
0002: jump @AMPAK_1 |
Animation in air needs to move the actor with opcode 083C: and to use animation code 0812: with -2 as last parameter
Script below let the player swimming in air by key_press
CODE | {$CLEO .cs}
:Airswim
03A4: name_thread 'Airswim'
:AIRSWIM_11
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @AIRSWIM_11
00D6: if
0AB0: key_pressed 8//-----------------key = Backspace
004D: jump_if_false @AIRSWIM_11
04ED: load_animation "SWIM"
:AIRSWIM_54
0001: wait 0 ms
00D6: if
04EE: animation "SWIM" loaded
004D: jump_if_false @AIRSWIM_54
083C: set_actor $PLAYER_ACTOR velocity_in_direction_XYZ 0.0 0.0 20.0
0001: wait 1000 ms
0812: AS_actor $PLAYER_ACTOR perform_animation "SWIM_BREAST" IFP_file "SWIM" 1.0 loopA 1 lockX 1 lockY 1 lockF 1 time -2 // versionB
:AIRSWIM_141
0001: wait 0 ms
00D6: if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @AIRSWIM_141
083C: set_actor $PLAYER_ACTOR velocity_in_direction_XYZ 0.0 2.0 2.0
00D6: if and
8AB0: not key_pressed 8
0611: actor $PLAYER_ACTOR performing_animation "SWIM_BREAST"
004D: jump_if_false @AIRSWIM_221
0002: jump @AIRSWIM_141
:AIRSWIM_221
0792: disembark_instantly_actor $PLAYER_ACTOR
04EF: release_animation "SWIM"
0001: wait 1000 ms
0002: jump @AIRSWIM_11 |
How to find Animations:
use Ryosukes Animation Manager
The animations are stored in *.ifp files
One ifp file is the GTASA\anim\ped.ifp
(GTASA\anim\anim.img is unused)
The other ifp files are in gta3.img like colt45.ifp, python.ifp, rifle.ifp, tec.ifp, weapons.ifp
Import these and play these with Animation Manager
Deji provides a list of the animation names: List of animations in San Andreas
______________________________________________________________________________________
______________________________________________________________________________________
Music, wave and sounds of Audio folder
GTASA\AUDIO\Streams includes *.ogg files for music in vehicle, interiors, some missions and for cutscene
GTASA\AUDIO\SFX includes *.wav files for sounds and dialoge
look at GTA: SA SFX Directory
The Radio Music files can only be played in vehicles:
There is no chance for scripting to play them on foot
For radio exist only these codes to set radio station, to get radio staion number and to set to favourites station
CODE | 041E: set_radio_station 3
051E: 1@ = get_current_radio_station
0A26: set_radio_to_favorite_station |
Music of GTASA\AUDIO\Streams\BEAT and AMBIENCE can be played with other opcodes
CODE | 0953: get_soundtrack_status_to 17@
if
0039: 17@ == 0;; integer values
004D: jump_if_false @
//
0952: load_soundtrack 12
//
0954: start_playing_loaded_soundtrack
//
0955: end_playing_loaded_soundtrack
//use following track numbers: 1, 2, 3, 4, 8, 9, 10, 12, 13
|
Play titel song
CODE | 0394: play_music 1
//or
0394: play_music 2 |
its mostly used as flourish by mission comlete
find the song file in GTASA\AUDIO\Streams\BEAT
Sounds or speeches of GTASA\AUDIO\SFX are used for "wav"- or "sound"- playing
But the sounds of GENRL can not be played with scripting
A part of them are documented in data\AudioEvents.txt
These for the story dialoges and sounds for gameplay
///////SOUNDS/////
A small part of the listed sounds in AudioEvents can be startet with play sound opcodes: 018C: 097A: 09F1:
Find sounds in the range from SOUND_1002 to SOUND_1191. Not all worked by me. It seems that someone only can used from the exe
Someone of these sounds are durable and must be started with 018D: and stoped with 018E:
Some other ones of these sounds have a replay mode (music for minigames) and can be stoped with a stop sound
SOUND_PILOT_AWARD_TRACK_START 1187 start sound
SOUND_PILOT_AWARD_TRACK_STOP 1188 stop sound
///////WAVE/////
The most part of AudioEvents.txt includes waves and must used with
CODE | 03CF: load_wav 1828 as 1
00D6: if 0
03D0: wav 1 loaded
004D: jump_if_false @
03D1: play_wav 1 |
can be attached to actor or object
CODE | 0949: link_wav 1 to_actor 0@ |
if wave is finish should be unloaded
in original is usual to unload wav before loading a wav
CODE | :AUDIOL_33
00D6: if 0
0039: 4@ == 0 // integer values
004D: jump_if_false @AUDIOL_38
040D: unload_wav 3@
03CF: load_wav 7@ as 3@ |
you can also check if the sound is finish
CODE | 00D6: if 0
03D2: wav 1 ended
004D: jump_if_false @ |
The sounds which are used with 03CF: load_wav 1828 as 1
are mostly dialog sounds of missions
The names of these waves, listed in AudioEvents.txt are the entry names from gxt dialog texts
exemble:
SOUND_MAN5_BK 24412
search in american.gxt for MAN5_BK
and find the dialog text:
~z~You got ice cold gangstas running through your veins!
The sound numbers have NO association with Audio file numbers, folder, banks
Only way I know to find sounds is to write a sound test script
///autom. phrases///////
Other way to let actor speak which is not written in AudioEvents.txt is
CODE | 09D5: play_sound_of_actor $PLAYER_ACTOR soundslot 342 flags 1 1 1 as 2@ |
first param, $PLAYER_ACTOR is the actor variable name
second param (342) is a slot with some different phrases sounds
third, fourth, fift param of flags are unknown
last param, 2@ is variable name of this sound function, isnt need to release or deload it in any way
and cant used further more in any other opcode.
Note: the soundslots includes more sounds which are changed automaticly if the same soundslot runs again
The soundslot with same number includes different sounds for different actors
PLAYER_ACTOR, special actors, Females and males have different sounds
only with the special girlfriends actors (GANGRL2) is it possible to play the sex voices of GFSEX script
The shop sellers have own sounds and can not played with other actors
opcode 09D5 is the only way to play these voice sounds which are also mostly used from exe for random peds on street
like pain sounds, breathing, coughing ect...
presumable uses PAIN_A SFX, SPC_FA SFX, SPC_PA SFX Archive Directory,
look at GTA: SA SFX Directory
______________________________________________________________________________________
______________________________________________________________________________________
|
评分
-
查看全部评分
|