brutalis11 Posted June 7, 2013 Share Posted June 7, 2013 (edited) I wanna know if it's somehow possible to detect when CJ walks in a door. A CLEO script I've been working on involves a ped following me around constantly. I've managed to detect when CJ walks in a door by doing the following (part of my script. INTERIOR_1 was defined in the beginning of the script, when the ped spawns): :SOFY_322077E: get_active_interior_to $INTERIOR_2 if and803A: not $INTERIOR_2 == $INTERIOR_1 // (int) $SOFY_WAITING == 0 not Actor.Driving($PLAYER_ACTOR)else_jump @SOFY_522 04C4: store_coords_to $X_1 $Y_1 $Z_1 from_actor $PLAYER_ACTOR with_offset 15.0 15.0 15.0 04C4: store_coords_to $X_2 $Y_2 $Z_2 from_actor $PLAYER_ACTOR with_offset -15.0 -15.0 -15.0 :SOFY_416wait 0 80A4: not actor $PLAYER_ACTOR sphere 0 in_cube_cornerA $X_1 $Y_1 $Z_1 cornerB $X_2 $Y_2 $Z_2 else_jump @SOFY_416 0860: link_actor $SOFY to_interior $INTERIOR_2 077E: get_active_interior_to $INTERIOR_1 04C4: store_coords_to $X $Y $Z from_actor $PLAYER_ACTOR with_offset 0.0 1.0 0.0 02CE: $GROUND = ground_z_at $X $Y $Z 0362: remove_actor $SOFY from_car_and_place_at $X $Y $GROUND So as you can see... Once CJ enters a door, the script will make a rectangle around CJ. Once CJ is outside the rectangle, Sofy (the ped ) will get warped in front of CJ & linked to the new interior. When you enter a safehouse or something like that, you're suddenly far away from where you were before entering the door, which causes CJ to be outside the rectangle. However, this doesn't seem to work with the safehouse at Verdant Meadows, since I think you're actually at the same coordinates after entering the door, but in a different interior. I recall having police forces outside the safehouse at Verdant Meadows, & I could still hear them from inside. The policemen, their cars... So, to sum it up... Is there any way to directly detect when CJ walks in a door, so Sofy will still follow CJ inside the house even at Verdant Meadows? Or another solution? Help appreciated. Edited June 7, 2013 by brutalis11 Link to comment Share on other sites More sharing options...
[µT] Posted June 7, 2013 Share Posted June 7, 2013 Instead of going through all that, I'd just make an invisible sphere at the entering spawn coordinates that teleports the actor to your interior near you somewhere and another invisible sphere at the exit spawn of the house that teleports him back outside near you. Link to comment Share on other sites More sharing options...
brutalis11 Posted June 7, 2013 Author Share Posted June 7, 2013 Thanks for your input, but right now it seems that I actually found a solution. You know, once entering a door leading to another interior, CJ becomes uncontrollable. So I thought why not check if the interior has changed (which happens immediately once you enter a door & the camera changes), & then check when CJ's controllable again. I tried doing this instead of making a rectangle & check if CJ's outside the rectangle, & guess what... It works perfectly! Now Sofy follows CJ into the Verdant Meadows safehouse, too. I can't believe it was that easy. If anyone's having a problem with detecting when CJ's walking in a door, here's what I did: :SOFY_39wait 0 Player.Defined($PLAYER_CHAR)else_jump @SOFY_39 // Model load, actor create blabla077E: get_active_interior_to $INTERIOR_1 // Model destroy blabla// Later:SOFY_322077E: get_active_interior_to $INTERIOR_2 if and803A: not $INTERIOR_2 == $INTERIOR_1 // (int) $SOFY_WAITING == 0 not Actor.Driving($PLAYER_ACTOR)else_jump @SOFY_444 :SOFY_358wait 0 Player.Controllable($PLAYER_CHAR)else_jump @SOFY_358 0860: link_actor $SOFY to_interior $INTERIOR_2 077E: get_active_interior_to $INTERIOR_1 04C4: store_coords_to $X $Y $Z from_actor $PLAYER_ACTOR with_offset 0.0 1.0 0.0 02CE: $GROUND = ground_z_at $X $Y $Z 0362: remove_actor $SOFY from_car_and_place_at $X $Y $GROUND Link to comment Share on other sites More sharing options...
ceedj Posted June 7, 2013 Share Posted June 7, 2013 Always nice to find a R* way to do it, with a minimum of fuss. Well done! I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets Link to comment Share on other sites More sharing options...
brutalis11 Posted June 7, 2013 Author Share Posted June 7, 2013 Thanks. Gotta find alternate ways since there's no Actor.WalkingInDoor opcode. xP Link to comment Share on other sites More sharing options...
Wesser Posted June 7, 2013 Share Posted June 7, 2013 (edited) It has been known since ages here. This check should work: const INTERIOR_ENTERING_STATUS_PICKUP_SHOWN = 0 INTERIOR_ENTERING_STATUS_WALKING = 1 INTERIOR_ENTERING_STATUS_DOOR_OPENED = 2 INTERIOR_ENTERING_STATUS_SPAWNED = 3end0A8D: [email protected] = read_memory 0x0096A7CC size 4 virtual_protect 0 // iInteriorEnteringStatusif or [email protected] == INTERIOR_ENTERING_STATUS_WALKING [email protected] == INTERIOR_ENTERING_STATUS_DOOR_OPENEDthen // Player is walking or entering (after opening the door).end Edited June 7, 2013 by Wesser 012 345 678 9A BCD EFG HIJK LMN OPQR STUV WX YZ Link to comment Share on other sites More sharing options...
brutalis11 Posted June 7, 2013 Author Share Posted June 7, 2013 Oh, thanks. I did search & go through a couple of topics before starting this one, but I couldn't find what I wanted. This works, too. This should be better since it actually detects when CJ walks in a door. Link to comment Share on other sites More sharing options...
ZAZ Posted June 7, 2013 Share Posted June 7, 2013 Oh, thanks. I did search & go through a couple of topics before starting this one, but I couldn't find what I wanted. This works, too. This should be better since it actually detects when CJ walks in a door. make 2 loops, first loop to check if player leave interior 0, then code runs into second loop which check if player leave the current interior, then code jumps back to first loop :Exteriorwait 0077E: get_active_interior_to [email protected]: NOT [email protected] == 0 jf @Exterior04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 0.0 2.2 0.200A1: put_actor [email protected] at [email protected] [email protected] [email protected]: link_actor [email protected] to_interior [email protected]:Interiorwait 0077E: get_active_interior_to [email protected]: [email protected] == 0 jf @Interior04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 0.0 2.2 0.200A1: put_actor [email protected] at [email protected] [email protected] [email protected]: link_actor [email protected] to_interior [email protected] @Exterior consider that this only work for changing between exterior/interior and not between interiorA/interiorB like entering wardrope CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
brutalis11 Posted June 8, 2013 Author Share Posted June 8, 2013 Hi ZAZ. Thanks for your input, & for your scripting tutorial which taught me how to make CLEO scripts in Sannybuilder. But what Wesser posted is exactly what I wanted, it detects when CJ interacts with a door, which means it also teleports actor $SOFY inside wardrobes etc. This also worked with my first code, but I experienced that if I just checked if the active interior was changed, then actor $SOFY would get teleported to inconvenient locations during certain missions etc. Afaik (& as far as I have tested, 'cause I've only bothered trying one mission so far), the memory address which Wesser posted also fixes this. 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