Jump to content
mtloya

LAToPoliceStation / Station Parking Coding For Specific Vehicles

Recommended Posts

Hi all,

First and foremost, I am making alterations to Hoppah's LA Mod.

Original idea/post:

Quote

What I am trying to do is create specific parking spaces in the parking lot of the police station, that a specific vehicle will go to, much like how the fire units work.
The vehicles in particular that I am trying to make spaces for are the Bomb Squad SUV, SWAT Truck 1 & 2, and the Tech Engineer's Van. I currently have VOs already made for each of them, but I'm not sure how to go about coding each specific vehicle to go to a certain parking spot.

I'm assuming I can use a bit of the ToPoliceStation code, particularly the Heli part, and just rename the VO_HELI to "VO_BOMBSQ" for instance... But then, I see there is a v.GetVehicleType function...

Can anyone give me a good starting place or any suggestions? Any help is appreciated!

Thanks in advance!!

What I've got working thus far:

* Brush truck & Heavy Equip. truck park as intended.
* I have VOs in the parking lots that the vehicles in question drive to correctly. When parked, the vehicles point towards the original PD station TurnTo VO. Not desirable. I want each vehicle to be parked correctly in their assigned spot.
* I have also cleared an area and began to set up VOs for a Tech station. This will house 3 rollback trucks and 1 crane.
* I have decided to create my own script / command to send the vehicles to their designated spots. See my post from 4/2 for beginning info on this.

Edited by mtloya
Development on idea
Link to comment
Share on other sites

On my end, I copied the logic from the ToFireStation code. Here's my example.

Ignore the 'facingWest' variables becuase those are specific things I did for my mod.

StrCompare is the line where the game checks the prototype name of the vehicle.

ParkingLotFound is the variable that is checked to ensure that the virtual object is actually on the map.

The GameObjectList checks if the virtual object has any vehicle inside it.

"l1" acts as the ActorList for the specific virtual object assigned to the vehicle. Later down the script, the game decares 'l1' as a position (a Vector) in the game which is where vehicles will go to.

http://www.emergency-planet.com/uploads/monthly_2018_01/Untitled.thumb.png.967c8781f34e2ed5148cf1450b8f8908.png

Untitled.png

Link to comment
Share on other sites

Thanks for the reply and the explanations, Itchboy. I'll try piecing it together the next time I'm able to get around to coding. Quick additional question: is there any real difference for using the .GetNumObjects() vs the .ContainsSquad()? What exactly do both refer to?

Link to comment
Share on other sites

GetNumObjects()

This function counts the number of objects in the gameObject list regardless of type or usability.

ContainsSquad()

This checks if there are any playable units such as vehicles and personnel within the gameObject list.

ContainsSquad is faster because it checks fewer objects and therefore consumes less memory having to store fewer objects. Only use it if you're checking for squads (playable units) within the list. It wont count random props, buildings, and NPC's.

If you're gonna count all other objects, then you need to use GetNumObjects.

Link to comment
Share on other sites

Thanks again for your explanations, @itchboy. I'll poke around and see what I can come up with.

Edit:

Alright, so after a bit of troubleshooting, I got my code to work. Sort of. Added the commands to the proper vehicles and all that jazz, but whenever I get in game, spawn the vehicle and command it to park, it'll do so, but much like the issue I was having with my ToFireStation script, it won't park correctly in the spot. I've already moved all of the civilian vehicles out of the way, so there is nothing around the VOs except for the actual police station and the fence, as seen in the screenshot:

Spoiler

tBmeElV.png

Are the fence/police station objects causing this? Would I be better off moving the VOs to the middle rows of parking spaces?

 

Furthermore, I have an additional issue: After the vehicle is parked in it's spot, a second/tick will pass and then the command will run itself again, sending the vehicle either back to HQ or to a different parking spot. I have a feeling that when the vehicle moves to the spots I created, it isn't counting it as actually being parked there, causing the command to check again for another open spot.

Addl edit: Moving the VOs to the middle and switching the civ cars did nothing. Issue persists... Added my script file.

LAToPoliceStation.script

Edited by mtloya
Added script file, screenshot, more info.
Link to comment
Share on other sites

The command running itself again is check intended to 're park' the car if it gets stuck or misaligned. Its a feature, not a bug.

In order to stop the thing doing it over and over again, you need to add the new virtual objects to childID 2 of the police station code.

For parking, all of your vehicles need to be one slot away from each other for them to park correctly.

72hY6SF.png

http://www.emergency-planet.com/uploads/monthly_2018_01/Untitled.png.37705844b651712843271b64136e62b3.png

Untitled.png

Link to comment
Share on other sites

Alright, thanks once more for your help. Adding each new spot under the ChildID=2 section obviously helped. The vehicles still aren't parking normally however, even when spaced apart. I'll try to move the VOs to different locations and see if that helps at all.

Link to comment
Share on other sites

Moderators, please pardon me bumping a 3-year old topic. I'm picking back up where I left off and have some updates!

@nbrown8568 I took your thought into consideration and increased the size of all my VOs. Thanks! Sadly, although each vehicle stays correctly in its own spot, they are still angled to the southwest. I have a feeling this might actually have something to do with a 'turnto' VO, and they're probably pointing towards the one for the original PD parking. I haven't confirmed this yet, but the direction makes sense...

As for my FD station parking with the heavy equipment & brush trucks, they still angle at random with no rhyme or reason, even with their own 'turnto' VOs for each spot. It would be nice to be able to get them to park like the battalion chief's SUV, nicely in their assigned spots pointing toward the parking lot. That's my end goal there.

I've also decided to attempt to create a 'tec' station for the tec van in order to move it out of PD parking, plus to house a couple rollback trucks on the map. That's certainly going to be much more complicated as I'll have to use the original scripts as templates and piece it together on my own. Plus, I'd like to make it so that if the rollback truck is carrying a wreck, once back at the station, the wreck is removed and the truck is ready for redeployment. Wishful thinking, eh?

Edit/Update (4/3/21): Here's a screenshot to confirm that the vehicles in the police lot are all pointing to "policestation_turnto" (VO_TURNTO): Note: The VO is in front of where the Charger is in spot #1.

Spoiler

 

kCbH7ee.png

 

In order to remedy this, I've copied the policestation_turnto VO and created a unique one for each additional parking spot:

Spoiler

FDGaSye.png

Now, it's time to figure out how to properly insert this into the script... I was thinking of copying the following highlighted section and pasting it within each 'if' statement after the "Parkinglotfound" line for each particular parking assignment and just renaming the turnto VO....

obyoLll.png 

...but this probably won't work as every 'toPoliceStation' command would also try to run the highlighted section as per the normal script. Right? Hopefully I'm explaining that correctly. Despite me taking multiple years of coding in college, I'm still pretty garbage at it, haha.

Progress is slowly being made!

Even more information: Digging around, I see that Tim Derks/timmiej93 is/was doing nearly the exact same thing that I'm currently trying to accomplish, more or less. His topic here: https://www.emergency-planet.com/topic/19245-working-policestation-that-functions-like-a-fire-station/

As for my FD station 2 parking, I've got it working like a charm. See below:

 

 

Another update (4/4/21):

I've decided to try and create a standalone script/command for these extra vehicles to be sent to a parking spot, vaguely named "LAToStation". It's based off of the LAToFireStation script (mainly because my alterations to this script actually worked, lol), and it SORTA works. Every vehicle (minus the rollback truck, bear with me, I'll explain in a sec) recognizes its own spot, but immediately decides that there's no space in its spot, and gets sent back to HQ. Not ideal. This is with the exception of the bomb squad, which just sits in front of its spot. Now for the rollback truck(s): I created three spots for them and tried to work out how the ambulances at station 1 work and base my code off of this. Sadly, this doesn't work at all. The code errors out and claims that TurnTo isn't defined within the scope, however where it's specifically pointing to in the code, it IS defined. (at least, in my novice mind it is) I'll attach what I've got done so far below for anyone to poke around with, and insert some pictures for context. I highly recommend comparing my script to the original ToFireStation script to see if anyone can identify where I'm going wrong.

BTW: If a custom script isn't showing up as a command in the in-game UI after assigning it in the editor, change the dummyGroup ID in the script ;) Found that Itchy gave that advice a few years ago and decided to give it a try. Since I was basing my script off of the fire station script, they had the same dummyGroup ID which caused my script to not appear in the UI, even if that particular vehicle (crane/rollback) didn't have a command with that same ID. Also, I decided that custom UI icons would be a nice touch, haha. 

Here's some screenshots and a video for context of this particular issue:

Spoiler

ps_squad01 - includes from left to right: swat rescue truck 2, swat rescue truck 1, bomb squad suv, PD parking spot #4, tech van. The latter two aren't considered in this particular script - at least not yet.

FA7Ef4j.png

ps_squad02 - includes LAPP Crown Vic.

KaHPyH2.png

ts_squad - Includes 3 spots for the 3 rollback trucks, and 1 spot for a crane.

nMz2b5j.png

Here's a video of what currently happens in-game. I don't know why my cursor is there twice... I didn't feel like rerecording it, though.. 

 

 

LAToStation.script

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...