JohnDoe4444 Posted June 28, 2021 Share Posted June 28, 2021 The title says most of my problem with the code. Basically the only opcode I found was 0457: player $PLAYER_CHAR aiming_at_actor [email protected] However my problem is, I need to get the actor's handle, and since the actor can be anyone in the world, including script-created characters, getting just one specific random or nearest character through opcodes like 08E5 is not exactly an option. Since the rest of my script handles the death of that actor, I thought about just getting the actor's data through its death, which is essentially caused by the player as well, however there is no specific opcode or opcodes I could find, nor any other set of code that comes to my mind. It all comes back to the same question: how to get any actor in the game world, be it script-created, world-generated, etc., through exceptionally tough means above my skills or even some of Cleo's limitations. For the sake of being more specific here's a short segment of my own code: 0652: [email protected] = integer_stat 121 // "People Wasted by the Player" stat //Followed by a little bit of more code 0652: [email protected] = integer_stat 121 wait 0 if 001C: [email protected] > [email protected] // (int) else_jump @noname_2 if and 0457: player $PLAYER_CHAR aiming_at_actor [email protected] // Note: the actor and the actor handle have not been specified at all. I need it to be anyone in the game world the player aims at else_jump @noname_70 0084: [email protected] = [email protected] // (int) //Do the stuff that needs doing after the death of whoever the player was aiming at/killing Link to comment Share on other sites More sharing options...
ZAZ Posted June 28, 2021 Share Posted June 28, 2021 R*'s opcode 08E5 didn't catch every peds, especially no gang members, no cops, no script actors The Cleo4 opcode 0AE1: works better, but also not perfect. Test the first script below, that kills the aimed ped. You will see that it doesn't catch every ped. Also, killing the aimed ped isn't a suitable option, so test also the second script that puts the camera view and blood_gush infront of the aimed ped. First script with opcode 0AE1: that kills the aimed ped Spoiler {$CLEO .cs} :RandomActor_Cleo4 thread 'RANDACT' while true wait 0 if 0256: player $PLAYER_CHAR defined then if and 044B: actor $PLAYER_ACTOR on_foot 00E1: player 0 pressed_key 6//--- aim key then 04C4: store_coords_to 10@ 11@ 12@ from_actor $PLAYER_ACTOR with_offset 0.0 2.0 0.0 if 0AE1: 7@ = random_actor_near_point 10@ 11@ 12@ in_radius 12.0 find_next 0 pass_deads 1 // CLEO 4 opcode then if 8118: not actor 7@ dead then if 0457: player $PLAYER_CHAR aiming_at_actor 7@ then 0321: AS_actor 7@ die_headshotted end end end end end end Second script with opcode 0AE1: that puts the camera view and blood_gush infront of the aimed ped. Spoiler {$CLEO .cs} :RandomActor_Cleo4 thread 'RANDAIM' wait 5000 :RANDAIM wait 0 ms if Player.Defined($PLAYER_CHAR) else_jump @RANDAIM if and 09E7: player $PLAYER_CHAR not_frozen 84AD: not actor $PLAYER_ACTOR in_water not Actor.Driving($PLAYER_ACTOR) 00E1: player 0 pressed_key 6 else_jump @RANDAIM 04C4: store_coords_to 10@ 11@ 12@ from_actor $PLAYER_ACTOR with_offset 0.0 2.0 0.0 if 0AE1: 7@ = random_actor_near_point 10@ 11@ 12@ in_radius 8.0 find_next 0 pass_deads 1 // CLEO 4 opcode else_jump @RANDAIM if 8118: not actor 7@ dead else_jump @RANDAIM_end if 0457: player $PLAYER_CHAR aiming_at_actor 7@ else_jump @RANDAIM_end 067C: 7@ 0.0 1.5 0.7 0.0 0.0 0.7 0.0 2//put_camera_on_actor 04C4: create_coordinate 10@ 11@ 12@ from_actor 7@ offset 0.0 0.3 0.5 09B8: create_blood_gush_at 10@ 11@ 12@ with_offset 0.2 0.2 0.7 density 90 on_actor 7@ wait 1000 0373: set_camera_directly_behind_player 02EB: restore_camera_with_jumpcut wait 1000 :RANDAIM_end 01C2: remove_references_to_actor 7@ // Like turning an actor into a random pedestrian wait 100 jump @RANDAIM Third script works better, it works by a strange method, which was an idea of Deji The script checks a huge amount of values if any of it is identical with the handle of any ped {$CLEO .cs} :RandomActor_AIM_RAFSTEP2 thread 'RACTAIM' :RACTAIM_11 wait 0 if Player.Defined($PLAYER_CHAR) jf @RACTAIM_11 31@ = 0 :RACTAIM_155 0085: 30@ = 31@ // (int) 29@ = 0 :RACTAIM_170 if and 056D: actor 30@ defined 803C: not $PLAYER_ACTOR == 30@ // (int) 8118: not actor 30@ dead jf @RACTAIM_302 if 0457: player $PLAYER_CHAR aiming_at_actor 30@ jf @RACTAIM_302 if and 00DF: actor 30@ driving 847A: not actor 30@ driving_a_motorbike jf @RACTAIM_171 0321: kill_actor 30@ wait 0 jump @RACTAIM_302 :RACTAIM_171 13@ = Marker.CreateAboveActor(30@) :RACTAIM_180 wait 0 if Player.Defined($PLAYER_CHAR) jf @RACTAIM_185 if and 8118: not actor 30@ dead 0457: player $PLAYER_CHAR aiming_at_actor 30@ jf @RACTAIM_185 jump @RACTAIM_180 :RACTAIM_185 Marker.Disable(13@) Actor.RemoveReferences(30@) jump @RACTAIM_11 :RACTAIM_302 30@ += 1 29@ += 1 29@ > 127 jf @RACTAIM_170 :RACTAIM_330 31@ += 256 if 31@ > 35584 jf @RACTAIM_155 jump @RACTAIM_11 JohnDoe4444 1 CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
JohnDoe4444 Posted June 28, 2021 Author Share Posted June 28, 2021 (edited) Greetings to the generous ZAZ, the legend of the subforum. I actually tinkered a little bit myself after I posted the topic, went with something along the lines of your second script. I also checked some of your and Ryosuke's bullet time/kill cam type mods, pretty fascinating, but too complex for me to understand. What I did was an algorithm with that exact random actor opcode you mentioned, then it ran an if statement with the 0457, if it indeed was the random actor, then the code would go with the rest of it, if it didn't it would jump back until it finally gets to a point it is the actor. For the most part it did get the job done, there are some imperfections along the way, but it works with scripted actors which is pretty awesome. Now what I found was this 0457 should be well-timed, otherwise it creates room for crashes. If the ped with the random actor handle I aim at is not dead, then the actor handle would belong to that same ped until they die, and it won't go to the next ped I aim at. Sometimes it also crashes the game, presumably because the actor, before my code gets a chance to do its thing, is destroyed by the game and its other scripts, not just scripted actors, but even game-world generated peds that go off the draw range limit. Fortunately the timing of the 0457 check and its placement in the right place has solved it. I assume regular "if actor defined" checks would also solve a lotta problems. Also with the 0AE1 and the argument "find next 0," are you sure it's best to have it on 0 rather than 1? It seemed to me that it works better with 1, not too sure if it's for better or worse though. I appreciate the massive amount of time you seem to have put on these scripts, definitely will check 'em out, probably will work better than my own. Edited June 28, 2021 by JohnDoe4444 Link to comment Share on other sites More sharing options...
ZAZ Posted June 28, 2021 Share Posted June 28, 2021 On 6/28/2021 at 8:51 PM, JohnDoe4444 said: Also with the 0AE1 and the argument "find next 0," are you sure it's best to have it on 0 rather than 1? It seemed to me that it works better with 1, not too sure if it's for better or worse though. I don't know, my script just crashed, when i tried other settings. That wasn't funny and i didn't check out more. Use it in your way, what works fine Quote I appreciate the massive amount of time you seem to have put on these scripts, definitely will check 'em out, probably will work better than my own. Just old scripts on my hard drive. I made nearly hundred different scripts about random actors Below one of my favourite scripts, that can indicate 24 peds at same time by showing red smoke above of their head {$CLEO .cs} :RandomActor_CounterCheck_SMOKE_LowLV thread 'RACTSMK' :RACTSMK_11 wait 0 if 0256: player $PLAYER_CHAR defined jf @RACTSMK_11 0@ = -1 1@ = -1 2@ = -1 3@ = -1 4@ = -1 5@ = -1 6@ = -1 7@ = -1 8@ = -1 9@ = -1 10@ = -1 11@ = -1 12@ = -1 13@ = -1 14@ = -1 15@ = -1 16@ = -1 17@ = -1 18@ = -1 19@ = -1 20@ = -1 21@ = -1 22@ = -1 23@ = -1 24@ = -1 gosub @RACTSMK_175 wait 0 gosub @RACTSMK_336 jump @RACTSMK_11 :RACTSMK_175 31@ = 0 27@ = 0 :RACTSMK_189 0085: 30@ = 31@ // (int) 29@ = 0 :RACTSMK_204 if and 056D: actor 30@ defined 803C: not $PLAYER_ACTOR == 30@ // (int) jf @RACTSMK_270 0085: 0@(27@,32i) = 30@ // (int) 04C4: create_coordinate 25@ 26@ 28@ from_actor 30@ offset 0.0 0.0 1.2 095C: create_smoke_at 25@ 26@ 28@ velocity 0.0 0.0 1.0 RGBA 1.0 0.0 0.0 1.0 size 0.5 last_factor 0.1//red 095C: create_smoke_at 25@ 26@ 28@ velocity 0.0 0.0 3.0 RGBA 1.0 0.0 0.0 1.0 size 0.5 last_factor 0.1//red 095C: create_smoke_at 25@ 26@ 28@ velocity 0.0 0.0 5.0 RGBA 1.0 0.0 0.0 1.0 size 0.5 last_factor 0.1//red 27@ += 1 jump @RACTSMK_298 :RACTSMK_270 30@ += 1 29@ += 1 29@ > 127 jf @RACTSMK_204 :RACTSMK_298 31@ += 256 if or 27@ > 24 31@ > 35584 jf @RACTSMK_189 return :RACTSMK_336 27@ = 0 :RACTSMK_343 wait 0 if 25 > 27@ jf @RACTSMK_397 if not 0@(27@,32i) == -1 jf @RACTSMK_345 01C2: remove_references_to_actor 0@(27@,32i) // Like turning an actor into a random pedestrian :RACTSMK_345 27@ += 1 jump @RACTSMK_343 :RACTSMK_397 return JohnDoe4444 1 CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
In45do Posted June 29, 2021 Share Posted June 29, 2021 So I read through the replies and it seems no one tried opcode 0AD2. The script below simply detect if aimed ped get killed specifically by the player: {$CLEO .cs} thread 'test_killd' :Test wait 0 0AD2: [email protected] = player $PLAYER_CHAR targeted_actor //IF and SET if 056D: actor [email protected] defined jf @Test if 051A: actor [email protected] damaged_by_actor $PLAYER_ACTOR jf @Test if 0118: actor [email protected] dead jf @Test 0ACA: show_text_box "KILL DETECTED" 0467: clear_actor [email protected] last_weapon_damage 054E: clear_actor [email protected] damage jump @Test JohnDoe4444 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now