GTA Modification Forums
[REL|SA] Spooky-style SCM Hook
 |
|
 |
| |
ceedj  |
|
PEDS Creator

Group: Members
Joined: May 21, 2005



|
Ok, I'm doing something "sort-of" similar. I don't know how you're going about it in your main thread, but let's say you have three: DWORD __stdcall MainThread(SCMThread *threadDesc) DWORD __stdcall Mission1Thread(SCMThread *threadDesc) DWORD __stdcall Mission2Thread(SCMThread *threadDesc) You might try something like this (really, REALLY pseudo-code): | CODE | DWORD __stdcall MainThread(SCMThread *threadDesc) {
MyMissionCountCheckThread() { if (blah == blah) MissionVar1 = 1; if (blah == blah) MissionVar2 = 1; if (blah == blah) MissionVar3 = 1; }
THREAD_EXIT(); return 0; } DWORD __stdcall Mission1Thread(SCMThread *threadDesc) { THREAD_INIT(); for(;;) { while(MissionVar1 != 1) SCRIPT_WAIT(500); SCRIPT_WAIT(500); //Do mission 1 here //When mission is done, reset MissionVar1 to 0 }
THREAD_EXIT(); return 0; } DWORD __stdcall Mission2Thread(SCMThread *threadDesc) { THREAD_INIT(); for(;;) { while(MissionVar2 != 1) SCRIPT_WAIT(500); SCRIPT_WAIT(500); //Do mission 2 here //When mission is done, reset MissionVar2 to 0 }
THREAD_EXIT(); return 0; |
Etc, etc. Of course, make sure those MissionVar's are only set when you want that mission to happen, and reset it when you are finished. There is probably a much more elegant way of doing this, but I only have a few threads that do this, so it works for me. EDIT: What he ^ said. This post has been edited by ceedj on Monday, Mar 3 2008, 20:46
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
Carnage_C  |
|
Player Hater

Group: Members
Joined: Mar 3, 2007

|
How can I create and then reference (in a var) a vehicle. So like this code: | CODE | THREAD_INIT(); SCRIPT_WAIT(1000); pGame->CreateCarGenerator(1669.162, -2113.085, 14.301, 270.0, 492, 10, 0, 1, 0, 0, 1, 1); pGame->CreateCarGenerator(2011.469, -1413.152, 16.74655, 270.0, 416, 0, 3, 1, 0, 0, 1, 1); // AMBULANCE pGame->SetGeneratedCars(2); pPlayerChar->WaitUntilDefined(); pPlayerActor->PutAt(1667.449,-2107.221,14.07227); pPlayerActor->SetActorZAngle(180.0); SCRIPT_WAIT(1000); pGame->Fade(1500, 1); SCRIPT_WAIT(1500); pGame->TextNow("AMBU1", 6000, 2); THREAD_EXIT();
|
I'd like to be able to identify the vehicle (Ambulance) for checking later on so I can check if CJ is driving it. I know about OC : is_actor_driving_car, 0x00DB, "vv" but I don't know howto give the vehicle a variable ID so I can use the above OC like: | CODE | if (CallOpcode(&is_actor_driving_car, pPlayerActor???, theAmbulanceID???) {}
|
Is there any chance I could get an example from anyone or point me to a post where I can study and read about such methods ? Oh while I'm being a cheeky ***** I may aswell ask, is there any documentation which could assist me learning this, I'd really like to learn off my own back and not have to ask all the time (I have many questions) as people have better things to do than help me (newblet). Thanks if you can help, I'm just trying to learn and don't mean to be annoying. Edit>> Sorry about the double post, I didn't think to be honest until I saw I was the last reply.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
ceedj  |
|
PEDS Creator

Group: Members
Joined: May 21, 2005



|
1) Why use a generator? Why not just create a car that has a handle of its own? That way you have a handle to work with for opcodes like checking for driving a specific vehicle and what not. Remember, the is_actor_driving opcodes ONLY check if an actor is actually in a vehicle; it doesn't care if you are a driver or a passenger (see my "seat" code a few posts up if you need to get seat information.) 2) Your CreateCarGenerator code is wrong; you MUST have a handle to reference. You need this somewhere (I do it in my declarations, at the top of the CustomScript.cpp file) ScriptObject *pCarGenrator1 Then you can do this: pCarGenrator1->CreateCarGenerator(1669.162, -2113.085, 14.301, 270.0, 492, 10, 0, 1, 0, 0, 1, 1); Just so you know, pCarGenerator is NOT THE HANDLE OF THE CAR. So many people get this wrong; it is the handle of the GENERATOR. To get/create the handle of the car generated there, use one of the range opcodes or create a check to see what kind of vehicle and model the player is driving. 3) There really is no documentation for this, other than learning mission coding. One thing to remember is that a LOT of creation opcodes in Mission Builder/Sanny Builder put the handle FIRST, which is right by those compiler standards (the ini file corrects this) but WRONG for this kind of thing; all handles for creating stuff (actors, cars, objects, etc) are generally LAST in the parameter order. Opcodes that reference handles usually have the handle first. If ever in doubt, open the SASCM.ini file from one of the builders and look at the param order for the opcodes. I think between JGS, Spookie and myself, we have the most important ones covered. 4) Speaking of opcodes, it's been a while since I've updated my list: | CODE | DEFINE_OPCODE(nis_veh_pass_seat_free, 0x8431, "vi"); DEFINE_OPCODE(is_valid_actor_handle, 0x056D, "v"); DEFINE_OPCODE(is_valid_vehicle_handle, 0x056E, "v"); DEFINE_OPCODE(is_valid_object_handle, 0x03CA, "v"); DEFINE_OPCODE(nis_valid_actor_handle, 0x856D, "v"); DEFINE_OPCODE(nis_valid_vehicle_handle, 0x856E, "v"); DEFINE_OPCODE(nis_valid_object_handle, 0x83CA, "v"); DEFINE_OPCODE(AT_driver_action, 0x06C7, "vvii"); DEFINE_OPCODE(is_actor_in_car, 0x0448, "vv"); DEFINE_OPCODE(print_entered_vehicle_name_enabled, 0x09B9, "i"); DEFINE_OPCODE(print_entered_zone_name_enabled, 0x09BA, "i"); DEFINE_OPCODE(set_night_vision_enabled, 0x08B1, "i"); DEFINE_OPCODE(set_thermal_vision_enabled, 0x08B2, "i"); DEFINE_OPCODE(set_menu_access_in_widescreen_mode_enabled, 0x0A48, "i"); DEFINE_OPCODE(set_aircraft_traffic_enabled, 0x0923, "i"); DEFINE_OPCODE(set_traffic_density_multiplier_to, 0x01EB, "f"); DEFINE_OPCODE(set_helicopters_traffic_enabled, 0x096A, "i"); DEFINE_OPCODE(set_police_patrols_traffic_enabled, 0x099E, "i"); DEFINE_OPCODE(set_police_motobikes_traffic_enabled, 0x072C, "i"); DEFINE_OPCODE(set_pedestrians_density_multiplier_to, 0x03DE, "f"); DEFINE_OPCODE(set_ambulances_and_firetrucks_enabled, 0x06D0, "i"); DEFINE_OPCODE(random_vehicle_generator_enable_modelID, 0x0733, "i"); DEFINE_OPCODE(random_vehicle_generator_disable_modelID, 0x0732, "i"); DEFINE_OPCODE(trailer_to_cab, 0x0893, "vv"); DEFINE_OPCODE(get_veh_paint_to, 0x0988, "vv"); DEFINE_OPCODE(set_veh_paint_to, 0x06ED, "vi"); DEFINE_OPCODE(set_veh_headlights, 0x067F, "vi"); DEFINE_OPCODE(set_veh_parklights, 0x0919, "vi"); DEFINE_OPCODE(set_veh_engine, 0x0918, "vi"); DEFINE_OPCODE(actor_attack_veh, 0x0672, "vv"); DEFINE_OPCODE(actor_flee_panic, 0x05DA, "vffffi"); DEFINE_OPCODE(is_actor_swimming, 0x0965, "v"); DEFINE_OPCODE(set_actor_swim_speed, 0x0A28, "vf"); DEFINE_OPCODE(actor_swim_to, 0x07E1, "vfff"); DEFINE_OPCODE(is_actor_performing_anim, 0x0611, "vs"); DEFINE_OPCODE(put_actor_in_veh_turret, 0x0464, "vvfffifi"); DEFINE_OPCODE(actor_disem_veh_and_freeze, 0x09C9, "vv"); DEFINE_OPCODE(actor_disem_instantly, 0x0792, "v"); DEFINE_OPCODE(remove_actor_from_turret, 0x0465, "v"); DEFINE_OPCODE(get_actor_anim_progress_to, 0x0613, "vsv"); DEFINE_OPCODE(UNK_actor_actor, 0x0859, "vv"); DEFINE_OPCODE(actor_weapon_drop, 0x087E, "vi"); DEFINE_OPCODE(set_actor_walk, 0x0245, "vs"); DEFINE_OPCODE(set_FPS_view, 0x0A2F, "i"); DEFINE_OPCODE(actor_no_inturupt_by_weapons_fire, 0x0946, "vi"); DEFINE_OPCODE(actor_fight_style, 0x07FE, "vii"); DEFINE_OPCODE(get_car_speed, 0x02E3, "vv"); DEFINE_OPCODE(get_actor_modelID, 0x0665, "vv"); DEFINE_OPCODE(get_actor_act_interior, 0x09E8, "vv"); DEFINE_OPCODE(set_actor_RCMode, 0x0715, "vv"); DEFINE_OPCODE(exit_RCMode, 0x04DB, ""); DEFINE_OPCODE(is_player_RCMode, 0x0241, "v"); DEFINE_OPCODE(set_veh_visible, 0x0338, "vi"); DEFINE_OPCODE(disable_rc_explode_A, 0x048A, "i"); DEFINE_OPCODE(disable_rc_explode_B, 0x04D6, "i"); DEFINE_OPCODE(set_vehicle_cam_to, 0x09AD, "i"); DEFINE_OPCODE(is_veh_non_civ, 0x0969, "v"); DEFINE_OPCODE(is_veh_emerg, 0x0975, "v"); DEFINE_OPCODE(actor_owner, 0x0A32, "v"); DEFINE_OPCODE(actor_owner_of_veh, 0x0A33, "vv"); DEFINE_OPCODE(actor_tele_veh_driver, 0x072A, "vv"); DEFINE_OPCODE(actor_tele_veh_pass_seat, 0x072B, "vvi"); DEFINE_OPCODE(actor_visible, 0x0337, "vi"); DEFINE_OPCODE(is_special_slot_loaded, 0x023D, "i"); DEFINE_OPCODE(set_actor_anim_progress_to, 0x0614, "vsf"); DEFINE_OPCODE(is_modelID_valid, 0x07DE, "i"); DEFINE_OPCODE(set_veh_open_comp, 0x0657, "vi"); DEFINE_OPCODE(set_veh_comp_rot, 0x08A6, "vif");
//Object Stuff DEFINE_OPCODE(object_liftable, 0x08E9, "vi"); DEFINE_OPCODE(object_model_scale, 0x08D2, "vf"); DEFINE_OPCODE(object_instant_damage_type, 0x0723, "vi"); DEFINE_OPCODE(toggle_object_in_moving_list, 0x0392, "vi"); DEFINE_OPCODE(object_targetable, 0x035D, "vi"); DEFINE_OPCODE(object_indestructable, 0x07F7, "vi"); DEFINE_OPCODE(set_object_act_int, 0x0566, "vi"); DEFINE_OPCODE(set_object_collision, 0x0382, "vi"); DEFINE_OPCODE(get_object_pos, 0x01BB, "vvvv"); DEFINE_OPCODE(set_object_pos, 0x01BC, "vfff"); DEFINE_OPCODE(get_object_zangle, 0x0176, "vv"); |
Ask away if you have questions! This post has been edited by ceedj on Sunday, Mar 9 2008, 12:05
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
ceedj  |
Posted: Wednesday, Aug 26 2009, 10:25
|
PEDS Creator

Group: Members
Joined: May 21, 2005



|
Ok, so it's a big bump, but it's relevant as someone recently asked about a good C++ hook, and useful too.  Want to disable ALL pickups? Saves too? So did I, as now I can film ANYWHERE without those silly pickups mocking me with their spin in my shots. Here's what to do: In Opcodes.h, add this: | CODE | | DEFINE_OPCODE(end_thread_named, 0x0459, "s"); |
In CustomScript.cpp, we're going to use Gunther's awesome readSCMVar function to "get" the Global vars that create the pickups in the original main.scm. I've already done the work here, but if I missed anything, let me know here and I'll update the post. I used spaceeinstiens SA Global Variables list, and Craig K's SA_opened up source (which is what I always use to reference the original script, since it's just a text file) to find all the pickups. This takes care of the flowers, weapons, armor, cameras, and collection rewards, including the weapons you get at Torino's ranch for completing "Vertical Bird." I even got rid of the asset pickups. Nifty! What I did was use FOR loops, since most (but not all, obviously) of the entries in the script are sequential; the FOR loop is ideal for this. | CODE | //Disable pickups DWORD dwPickup; //collections weapons for (int i = 803; i < 815; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} //toreno's ranch weapons for (int i = 2873; i < 2877; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} //weapons 1 for (int i = 3032; i < 3170; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} //weapons 2 for (int i = 3171; i < 3230; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} //weapons 3 for (int i = 3231; i < 3248; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} //flowers for (int i = 3257; i < 3262; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} //more flowers, body armor and bribes for (int i = 3263; i < 3395; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} //Oddballs //Camera dwPickup = readSCMVar(2512); CallOpcode(&destroy_pickup, &dwPickup); //Millie's Toy dwPickup = readSCMVar(820); CallOpcode(&destroy_pickup, &dwPickup); //Emmets Gun dwPickup = readSCMVar(32); CallOpcode(&destroy_pickup, &dwPickup); //asset pickups dwPickup = readSCMVar(55); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(66); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(527); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(710); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(1908); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(1931); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(1933); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(1938); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(1996); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(1998); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(2000); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(5271); CallOpcode(&destroy_pickup, &dwPickup); dwPickup = readSCMVar(7512); CallOpcode(&destroy_pickup, &dwPickup); |
Even though there are several lines of code for the oddball stuff, the FOR loops really saved time and coding. The weapons are split up because of the gaps in certain parts of the script; also looks like there might have been an extra flower that was eventually taken out. Here's what I did to remove the save function and icons: | CODE | CallOpcode(&end_thread_named, "PSAVE1"); for (int i = 865; i < 883; i++) {dwPickup = readSCMVar(i); CallOpcode(&destroy_pickup, &dwPickup);} |
The save thread in the script (PSAVE1) is now disabled, and the icons stay gone as well. Hope this is useful to someone!  EDIT: Changed the "more flowers" to add one I missed. EDIT2: There are 5 weapon pickups in the game done via IPL that this does NOT remove. Just a heads up. This post has been edited by ceedj on Sunday, Aug 30 2009, 02:15
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
MicroD  |
|
Player Hater

Group: Members
Joined: Mar 6, 2012

|
Link of this file is down, please re-upload it
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Pages:
(3) 1 2 [3]
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|