EUX adamant4 Posted January 11, 2011 Share Posted January 11, 2011 Hi there, been a while since i posted here. I have been working on this small script i have been making for a while now, and have been experimenting with ways to grab a random ped and store them to memory. This script when finished, will act as an AI controlled gun that can operate without any input from the player. (i have posted about this before, but have since made it less complicated until I get it working properly). However, the method of saving peds im using right now only works when the ped is in view of the camera, and it will crash if the ped dies while the camera is looking away. (at least thats what i think is happening, the script is really unstable so i can't be sure). Is there any other way to grab peds without the negative points of the one I'm using right now? Also, is there any utility that I can get that logs the last lines of code to be executed by the program? Anyway, here is the code- feel free to try it out. Thanks to Deji and ZAZ for the snippet: thread 'HELIGUN' Model.Load(#HUNTER):INITwait 500004C4: store_coords_to 0@ 1@ 2@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 50.0 00A5: 3@ = create_car #HUNTER at 0@ 1@ 2@072A: put_actor $PLAYER_ACTOR into_car 3@ driverseat0224: set_car 3@ health_to 10000000 32@ = 00825: set_helicopter 3@ instant_rotor_start :attackiniwait 00407: store_coords_to 12@ 13@ 14@ from_car 3@ with_offset 0.0 0.0 -3.0 //turret//0726: heli 3@ follow_actor 10@ follow_car -1 radius 25.0:TARGETCHANGEini0001: wait 0 ms 00D6: if 0256: player $PLAYER_CHAR defined 004D: jump_if_false @RAFSTEP_142 0006: 24@ = 0 :RAFSTEP_380085: 8@ = 24@ // (int) 0006: 25@ = 0 :RAFSTEP_5300D6: if and056D: actor 8@ defined 803C: not $PLAYER_ACTOR == 8@ // (int) 004D: jump_if_false @RAFSTEP_89 0002: jump @TARGETCHANGE:RAFSTEP_89000A: 8@ += 1 000A: 25@ += 1 0019: 25@ > 127 004D: jump_if_false @RAFSTEP_53 :RAFSTEP_117000A: 24@ += 256 0019: 24@ > 35584 004D: jump_if_false @RAFSTEP_38 :RAFSTEP_1420002: jump @TARGETCHANGEini:TARGETCHANGE //Start of "filter" wait 0if8118: actor 8@ dead jf @RAFSTEP_89if8449: actor 8@ in_a_car jf @RAFSTEP_8904C4: store_coords_to 0@ 1@ 2@ from_actor 8@ with_offset 0.0 0.0 0.0 0407: store_coords_to 12@ 13@ 14@ from_car 3@ with_offset 0.0 0.0 -3.0 //Turret0187: 10@ = create_marker_above_actor 8@04C4: store_coords_to 0@ 1@ 2@ from_actor 8@ with_offset 0.0 0.0 0.0jump @ATTACK :TARGETCHANGE201C2: remove_references_to_actor 8@ // Like turning an actor into a random pedestrian0164: disable_marker 10@jump @RAFSTEP_89:ATTACKwait 004C4: store_coords_to 0@ 1@ 2@ from_actor 8@ with_offset 0.0 0.0 0.00407: store_coords_to 12@ 13@ 14@ from_car 3@ with_offset 0.0 0.0 -3.0 //Turretif8118: actor 8@ dead jf @TARGETCHANGE2if06BD: no_obstacles_between 12@ 13@ 14@ and 0@ 1@ 2@ solid 1 car 1 actor 0 object 0 particle 0 jf @TARGETCHANGE2if32@ >= 15jf @ATTACK0208: 18@ = random_float_in_ranges -0.75 0.75 0208: 19@ = random_float_in_ranges -0.75 0.7502CE: 20@ = ground_z_at 0@ 1@ 2@ 04C4: store_coords_to 0@ 1@ 2@ from_actor 8@ with_offset 18@ 19@ 0.006BC: create_M4_shoot_from 12@ 13@ 14@ target 0@ 1@ 20@ energy 0064B: 23@ = create_particle "explosion_tiny" at 0@ 1@ 20@ type 4 //create the particle 064B: 21@ = create_particle "explosion_door" at 0@ 1@ 20@ type 4 //create the particle 064B: 22@ = create_particle "explosion_door" at 12@ 13@ 14@ type 4 //create the particle064F: make_temp_particle_visible_and_remove_references 21@ //make the particle visible and remove references 064F: make_temp_particle_visible_and_remove_references 22@ //make the particle visible and remove references 064F: make_temp_particle_visible_and_remove_references 23@ //make the particle visible and remove references 32@ = 0:KILLwait 0if 00FE: actor 8@ sphere 1 in_sphere 0@ 1@ 2@ radius 0.13 0.13 0.13jf @ATTACK0223: set_actor 8@ health_to 0jump @TARGETCHANGE2 Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/ Share on other sites More sharing options...
ZAZ Posted January 11, 2011 Share Posted January 11, 2011 Ah, you mean Dejis awesome method with for-to-step-Loop. Well, it can get very fast all peds and actors for the script. But it don't works for all commands. You can the actor let kill the player or follow him or create fire on actor. But doing much stuff with the actors let the game crash. You must know that it needs to get the actors in arrays, then give him a simple command and then remove their reference to can do again the same Getting the car of the actors is possible but doing something with the cars which are also readed in a multiple way let the game crash. I noticed this problem also with original R*star codes, getting multiple cars in arrays and doing something with it let the game crash. Only thing which works is to let the car explode i will show my testscripts: the first one works very well press Backspace to get the actor in arrays, create fire on actor and remove their reference press again Backspace to do again the same {$CLEO .cs}:RandomActor_for_to_step_method03A4: name_thread 'RAFSTEP' :RAFSTEP_10001: wait 0 ms 00D6: if 0256: player $PLAYER_CHAR defined 004D: jump_if_false @RAFSTEP_1if0AB0: key_pressed 8//-----------------------------press backspace 004D: jump_if_false @RAFSTEP_10050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 2500050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 2500050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 2500050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 2500050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 2500002: jump @RAFSTEP_1:RAFSTEP_110006: 31@ = 0 0006: 27@ = 0:RAFSTEP_380085: 30@ = 31@ // (int) 0006: 29@ = 0 :RAFSTEP_5300D6: if and056D: actor 30@ defined 803C: not $PLAYER_ACTOR == 30@ // (int) 004D: jump_if_false @RAFSTEP_890085: 0@(27@,12i) = 30@ // (int) //0321: kill_actor 30@0326: 13@(27@,12i) = create_actor 0@(27@,12i) fire 000A: 27@ += 10002: jump @RAFSTEP_117 :RAFSTEP_89000A: 30@ += 1 000A: 29@ += 1 0019: 29@ > 127 004D: jump_if_false @RAFSTEP_53 :RAFSTEP_117000A: 31@ += 256if or0019: 27@ > 12 0019: 31@ > 35584 004D: jump_if_false @RAFSTEP_38 :RAFSTEP_1420051: return:RAFSTEP_2000006: 27@ = 0:RAFSTEP_205wait 0if13 > 27@004D: jump_if_false @RAFSTEP_21302D1: remove_fire 13@(27@,12i)01C2: remove_references_to_actor 0@(27@,12i)000A: 27@ += 10002: jump @RAFSTEP_205:RAFSTEP_2130051: return second script is unstable because it do something with the car press Backspace to get the actor in arrays, let them jump if they are on foot, let them exit if they are in car but get first their carhandle to let car speed up {$CLEO .cs}:RandomActor_for_to_step_method03A4: name_thread 'RAFSTEP' :RAFSTEP_10001: wait 0 ms 00D6: if 0256: player $PLAYER_CHAR defined 004D: jump_if_false @RAFSTEP_1if0AB0: key_pressed 8//-----------------------------press backspace 004D: jump_if_false @RAFSTEP_10050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 10000050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 10000050: gosub @RAFSTEP_11wait 10000050: gosub @RAFSTEP_200wait 10000050: gosub @RAFSTEP_11wait 10000002: jump @RAFSTEP_1:RAFSTEP_110006: 31@ = 0 0006: 27@ = 0:RAFSTEP_380085: 30@ = 31@ // (int) 0006: 29@ = 0 :RAFSTEP_5300D6: if and056D: actor 30@ defined 803C: not $PLAYER_ACTOR == 30@ // (int) 004D: jump_if_false @RAFSTEP_89if0118: actor 30@ dead004D: jump_if_false @RAFSTEP_54009B: destroy_actor 30@0002: jump @RAFSTEP_117:RAFSTEP_540085: 0@(27@,24i) = 30@ // (int) //0321: kill_actor 30@//0326: 13@(27@,24i) = create_actor 0@(27@,24i) fireif044B: actor 0@(27@,24i) on_footjf @RAFSTEP_55083C: set_actor 0@(27@,12i) velocity_in_direction_XYZ 0.0 10.0 20.0wait 50//083C: set_actor 0@(27@,12i) velocity_in_direction_XYZ 0.0 10.0 20.0 //wait 250//05BC: AS_actor 0@(27@,12i) jump 1//0751: AS_actor 0@(27@,24i) flee_from_actor $PLAYER_ACTOR run_distance 100000.0 time 999999 unknown 1 3000 5000 away_radius 150.0 jump @RAFSTEP_65:RAFSTEP_55if00DF: actor 0@(27@,24i) drivingjf @RAFSTEP_65//0633: AS_actor 0@(27@,24i) exit_car 03C0: 26@ = actor 0@(27@,24i) carif8119: not car 26@ wreckedjf @RAFSTEP_61wait 50Car.SetSpeedInstantly(26@, 100.0)wait 50Car.SetSpeedInstantly(26@, 100.0)wait 5000633: AS_actor 0@(27@,24i) exit_car wait 250jump @RAFSTEP_6107D5: set_car 26@ velocity_in_direction_XYZ 0.0 0.0 2.0 rotation_velocitiesXY 0.0 0.0 unk 0.0wait 50020B: explode_car 26@ // versionAwait 500jump @RAFSTEP_61//Car.SetSpeedInstantly(26@, 100.0)07D5: set_car 26@ velocity_in_direction_XYZ 0.0 0.0 20.0 rotation_velocitiesXY 0.0 0.0 unk 0.0wait 5007D5: set_car 26@ velocity_in_direction_XYZ 0.0 0.0 20.0 rotation_velocitiesXY 0.0 0.0 unk 0.0wait 50Car.SetSpeedInstantly(26@, 100.0)wait 50Car.SetSpeedInstantly(26@, 100.0)wait 5000633: AS_actor 0@(27@,24i) exit_car wait 250:RAFSTEP_6101C3: remove_references_to_car 26@:RAFSTEP_65000A: 27@ += 10002: jump @RAFSTEP_117 :RAFSTEP_89000A: 30@ += 1 000A: 29@ += 1 0019: 29@ > 127 004D: jump_if_false @RAFSTEP_53 :RAFSTEP_117000A: 31@ += 256if or0019: 27@ > 23 0019: 31@ > 35584 004D: jump_if_false @RAFSTEP_38 :RAFSTEP_1420085: 28@ = 27@ // (int)0051: return:RAFSTEP_2000006: 27@ = 0:RAFSTEP_205wait 0if002D: 28@ >= 27@ // integer values004D: jump_if_false @RAFSTEP_213//02D1: remove_fire 13@(27@,24i)01C2: remove_references_to_actor 0@(27@,24i)000A: 27@ += 10002: jump @RAFSTEP_205:RAFSTEP_2130051: return Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060290670 Share on other sites More sharing options...
EUX adamant4 Posted January 11, 2011 Author Share Posted January 11, 2011 Hmm, the whole script is basically a glorified version of an actor dying if they walk into a sphere- would any of your suggestions work with that? I have managed to make my original script much more stable by adding more actor_defined checks (i noticed that a ped faded away while getting shot at which made the game crash- very strange, as it had to be assigned to a variable?), so im wondering if its just general bad scripting? Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060290719 Share on other sites More sharing options...
Deji Posted January 11, 2011 Share Posted January 11, 2011 You're actually mislead into believing getting actors through memory can cause problems. Without fully knowing what each opcode does, it's hard to determine whether it's appropriate for use. I'm trying to clear up these confusions (misnames of opcodes, mainly). And have been posting dozens of rants about it on the GTAG Forum. After GTAG v2 comes, I hope to enable the opcode database to export more original names for opcodes... Possibly keywords.txt and classes.db files which will keep scripting on Rockstars level. Our ventures into the main.scm and our judgement of Rockstar based on what we know is often pretty biased. True enough, a lot of main.scm script looks pretty "noobish" from our perspective. In the original source of the main.scm, it wouldn't appear so. The greatest thing to blame is Rockstars compiler. Other things such as this: 0006: 2@ = 0 if 0039: 2@ == 1 else_jump @HOTDOGV_77 009A: 0@ = create_actor_pedtype 4 model #MALE01 at 0.0 0.0 0.0 00A5: 1@ = create_car #HOTDOG at $tempvar_Float_1 $tempvar_Float_2 $tempvar_Float_3 :HOTDOGV_77 ("fake entity creation") could probably be explained if we still had all the debug features Rockstar had. 01C2 should be named "MARK_CHAR_AS_NO_LONGER_NEEDED", which changes the meaning completely. 01C2 shouldn't be used when the character isn't on the list of "needed chars" (the game needs to keep this list, or else it risks deleting script characters, objects etc.). Memory isn't the only time when 01C2 shouldn't be used. As you can see from the Opcode Database, 0811 also doesn't put the car on a "no longer needed" list. Ever noticed how some vehicles that you entered in SA seem to linger around longer than others? I believe this is a bug in the Hyperjump thread (that whole thread is pretty buggy). 03C0 was use instead of 0811, so if you do a stunt, the car won't be removed from the "needed list". Sorry if this came across as a rant.. When I start to write stuff about the way SA works, so many things come to mind Hence the reason I rant so much on GTAG. I'm hoping that this weird habbit I have will one day make a game company very happy and me very rich... Or I could end up working at McDonalds, which would suck.. I perfer Dominos. Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060290730 Share on other sites More sharing options...
EUX adamant4 Posted January 11, 2011 Author Share Posted January 11, 2011 Thanks for the reply deji, I have finally found the problem- i missed out an actor defined check when the target was killed by the gun, which explains everything- i always thought that the solution would be as simple as this, it always is XD it now works exactly the same as my older blackhawk script, but instead of cycling between a list of spawned targets, it now takes its targets directly from the environment, which is exactly what i need thanks guys for your support and patience, this could be extremely useful Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060290813 Share on other sites More sharing options...
EUX adamant4 Posted January 15, 2011 Author Share Posted January 15, 2011 Don't really want to start a new thread for this, but can somebody please link me to a way to logging the last label to be executed by the program? i know they exist because i have used one before, but i have forgotten what its called and where to get it. A piece of code has really got me stumped and i dont know what part is causing the problem. If somebody could tell me where to get one of these utilities please reply. Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060296435 Share on other sites More sharing options...
Deji Posted January 15, 2011 Share Posted January 15, 2011 SCMLog as found here: http://cleo.sannybuilder.com/ I've always found it useless, though. There's barely ever a crash until "wait 0" is run. Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060296725 Share on other sites More sharing options...
EUX adamant4 Posted January 15, 2011 Author Share Posted January 15, 2011 ok, ill give it a try Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060296728 Share on other sites More sharing options...
EUX adamant4 Posted March 11, 2011 Author Share Posted March 11, 2011 Hello, sorry for bumping an old topic but it is relevant The loop that cycles through actors is causing me quite a bit of grief that I still havent managed to sort out- in this OLD script in the first post of the thread (the loop hasnt been changed since though), runs perfectly IF there are peds around. If not, it slows down the game to the point of being unplayable- this is because of a "missing" wait, i know- but to function properly there needs to be no waits inside the loop, otherwise it will load peds very very very slowly and would be nearly useless. This gives me a problem that i havent been able to solve since i started this topic several months ago. I believe I will be able to finish the rest of this script by myself if this is fixed- if any experienced modders know how to fix this, please post a reply- or at least post an alternative that is more suitable for the job Thanks for your time, and if this is fixed I'll probably stop bothering you as I will be busy working on things I actually understand xD Link to comment https://gtaforums.com/topic/467259-saving-random-peds-to-variables/#findComment-1060376520 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