Jump to content
timmiej93

Dropping off vehicles on a specific location

Recommended Posts

Hey guys,

 

Sorry for the vague title, but it was the best I could come up with.

What I'm trying to achieve is having a rollback towtruck backup to a dedicated space, and then unload the loaded vehicle, which then should be placed inside a VO.

Now I've thought of two methods of achieving this:

 

1. Unloading directly onto the specific VO from the rollback by editing the unload script.

I've tried to achieve this by copying parts from the unload script into the script that is doing all the backing up and such, but that didn't work at all.

 

2. Unloading like normal (which will drop the car in the VO at least partially), then move (or remove/spawn) the car to the center of the VO.

This probably is the easiest, but I couldn't get that to work either.

Unfortunately, I so far haven't been able to get either method to work. 

Could anyone help me with this?

Link to comment
Share on other sites

You require a dummy car to drop as the wreck, the vehicle which was picked up isnt able to be dropped back off without a complicated script and load on the game.  Instead make a dummy car to ditch. How I would do this is have the truck take place within a VO, directly behind it there will be another VO for the vehicle to drop within.  When loaded tow shows up, kill loaded tow and replace it with an empty one, and create the dead car in the 2nd vo behind the tow.  You could have it animated and all that mess but really to test the concept above is probably the cleanest way to do it.

Link to comment
Share on other sites

Yerp, when the tow picks it up it doesnt actually pick up that car... Such is why on the tow models you see a covered representation of said car there.. It aint because we were being lazy, it is because the car doesnt exist to be on the truck as a child.  This could be corrected, but would need an extensive script to fix that.

Link to comment
Share on other sites

Yeah I get that, but when you unload the rollback, the same car as you picked up gets dropped off. Isn't it possible to incorporate this in the script in some way, like the VO "picking up" the car and dropping it in the right position, using the same car?

Link to comment
Share on other sites

Not in the system I described above, when you kill the vehicle it will lose the cargo held on it as well, now if you ran the unload script when the vehicle was in position in the VO it may work and drop it correctly, but generally the car doesnt unload consistent from the rear of the tow to ensure it "seats" into the VO as intented.  The easiest way would be a generic replacement for the wrecked car, but in theory it probably could be done with more work to leave the original car.  In either case you would want to have the wreck disappear after X time, because otherwise you would run out of car storage fast since you can't really micro-manage the drop off point to stack the cars or anything like that, not without alotta scripty work, and if you cant get the basic ver to work there isnt much odds the complex one will.

Link to comment
Share on other sites

IF a vehicle other than a towtruck is detected in there, of any of the the wrecked car's types kill it and replace it with a new one in the center of the VO... This is kinda importante because if u just drop the car onto the spot it will still be active on the map, it must be removed from the map to be counted as cleared.

Link to comment
Share on other sites

See the startup scripts of the LA or NY and probrably a bunch other mods since most use the LA scripts as a base, you will find info on the cmd to create a vehicle in the VO.

 

Pos = f1.GetActor(0)->GetPosition();
    v = Game::CreateVehicle(PROTO_LADDER01, UNNAMED);
    v.EnableBlueLights(false);
    v.SetPosition(Pos);
    v.SetRotation(gate1);
    v.UpdatePlacement();
    v.SetMaxPassengers(4);
    v.SetMaxTransports(0);
    v.SetSpeed(12.0f);

 

For ex, the create vehicle is the important part.

Link to comment
Share on other sites

So thinking about everything, I've decided to replace the unload action with a (replace loaded rollback for empty) script, and then have something like 5 to 10 wrecked vehicles that spawn in the VO randomly. The only problem is that I don't have any experience with randomness in scripting, and I haven't seen any examples of it.. Does anyone know an example of howto create randomness in a script?

Link to comment
Share on other sites

So thinking about everything, I've decided to replace the unload action with a (replace loaded rollback for empty) script, and then have something like 5 to 10 wrecked vehicles that spawn in the VO randomly. The only problem is that I don't have any experience with randomness in scripting, and I haven't seen any examples of it.. Does anyone know an example of howto create randomness in a script?

From Hoppah's search house script:

 

const int MAX_POOL = 15;const char *CivilPool[MAX_POOL];object DummySearchHouse : CommandScript{ 	DummySearchHouse() 	{		CivilPool[0] = "mod:Prototypes/Persons/Civil/civilman01_white.e4p";		CivilPool[1] = "mod:Prototypes/Persons/Civil/civilminister01.e4p";		CivilPool[2] = "mod:Prototypes/Persons/Civil/dealer01.e4p";		CivilPool[3] = "mod:Prototypes/Persons/Civil/dealer02.e4p";		CivilPool[4] = "mod:Prototypes/Persons/Civil/civilwoman06_yellow.e4p";		CivilPool[5] = "mod:Prototypes/Persons/Civil/civilman01_red.e4p";		CivilPool[6] = "mod:Prototypes/Persons/Civil/civilman02_silver.e4p";		CivilPool[7] = "mod:Prototypes/Persons/Civil/civilmanold01.e4p";		CivilPool[8] = "mod:Prototypes/Persons/Civil/civilmanold02.e4p";		CivilPool[9] = "mod:Prototypes/Persons/Civil/civilwoman03_blue.e4p";		CivilPool[10] = "mod:Prototypes/Persons/Civil/civilwoman01_yellow.e4p";		CivilPool[11] = "mod:Prototypes/Persons/Civil/civilwoman05.e4p";		CivilPool[12] = "mod:Prototypes/Persons/Civil/civilwomanold01.e4p";		CivilPool[13] = "mod:Prototypes/Persons/Civil/civilboy02_green.e4p";		CivilPool[14] = "mod:Prototypes/Persons/Civil/civilgirl02_blue.e4p"; 	}

I think this is called an array in C programming. Dont know for sure, but this is basically a selectable pool of persons.

It is activated by this:

Person t = Game::CreatePerson(CivilPool[RandomPerson], "Unnamed");

CivilPool is the name of the group

RandomPerson is any number from 1 to 15

Link to comment
Share on other sites

Thank you ItchBoy, very helpful. 
 
Now I've been trying all kinds of things, and it's starting to work. The problem I'm facing right now, is the wrecked car and new rollback are spawning immediately when I click the ToTechStation button.
 
Scripted like this atm:

					v.PushActionMove(ACTION_NEWLIST, Park);					v.PushActionTurnTo(ACTION_APPEND, Turnto);					v.PushActionWait(ACTION_APPEND, 1.0f);										v.PushActionDeleteOwner(ACTION_APPEND);					Vehicle m = Game::CreateVehicle(OBJ_ROLLBACK, "Unnamed");						m.EnableBlueLights(false);						m.SetPosition(Park);						m.SetRotation(gate6);						m.UpdatePlacement();						m.SetMaxPassengers(1);						m.SetSpeed(8.0f);					m.PushActionWait(ACTION_APPEND, 5.0f);						int RandomWreck = Math::rand()%MAX_POOL;						GameObject w = Game::CreateObject(WreckPool[RandomWreck], "Unnamed");						w.SetPosition(Dropoff);						w.SetRotation(gate6);

 
Anyone got any ideas?
 
Tim
 
 
PS. I know why it's happening, I just don't know how to prevent it. 
Could it be possible to re-use the v. caller, instead of using the m.?
 
----------------------------------
 
So, the sollution:

				else	//	Dropoff space found				{					if(l1.GetNumActors() > 0)						Vector Park = l1.GetActor(0)->GetPosition();					if(l2.GetNumActors() > 0)						Vector Turnto = l2.GetActor(0)->GetPosition();										if(l3.GetNumActors() > 0)						Vector Dropoff = l3.GetActor(0)->GetPosition();					Audio::PlaySample3D(SND_TOSTATION, Caller->GetPosition());						Radio = true;										v.PushActionMove(ACTION_NEWLIST, Park);					v.PushActionTurnTo(ACTION_APPEND, Turnto);					v.PushActionWait(ACTION_APPEND, 1.0f);					v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_TECHSTATION, Caller, 0, false);					}				

And the dummy

object DummyAtTechStation : CommandScript{	DummyAtTechStation()	{		SetGroupID(DummyGroup);	}	bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID)	{	}	void PushActions(GameObject *Caller, Actor *Target, int ChildID)	{				Vehicle v(Caller);		if(v.IsCollidingWithVirtualObject(VO_DROPOFF1))		{						ActorList l1 = Game::GetActors(VO_DROPOFF1);			ActorList l3 = Game::GetActors(VO_DROPOFF1_R);			Vector Park = l1.GetActor(0)->GetPosition();			Vector Dropoff = l3.GetActor(0)->GetPosition();		}		if(v.IsCollidingWithVirtualObject(VO_DROPOFF2))		{			ActorList l1 = Game::GetActors(VO_DROPOFF2);			ActorList l3 = Game::GetActors(VO_DROPOFF2_R);			Vector Park = l1.GetActor(0)->GetPosition();			Vector Dropoff = l3.GetActor(0)->GetPosition();		}				GameObjectList gate06a = Game::GetGameObjects(NAME_GATE06A);		for(int i=0; i < gate06a.GetNumObjects(); i++)			GameObject *gate6 = gate06a.GetObject(i);		if(ChildID == 0)		{			v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_TECHSTATION, Caller, 1, false);				v.PushActionDeleteOwner(ACTION_APPEND);		}		if(ChildID == 1)		{			Vehicle v = Game::CreateVehicle(OBJ_ROLLBACK, "Unnamed");				v.SetPosition(Park);				v.SetRotation(gate6);				v.UpdatePlacement();				v.SetMaxPassengers(1);				v.SetSpeed(8.0f);			int RandomWreck = Math::rand()%MAX_POOL;			GameObject w = Game::CreateObject(WreckPool[RandomWreck], "Unnamed");			w.SetPosition(Dropoff);			w.SetRotation(gate6);			w.UpdatePlacement();			w.PushActionWait(ACTION_NEWLIST, 30.0f);			w.PushActionDeleteOwner(ACTION_APPEND);			GameObject x = Game::CreateObject(CivilPool[RandomWreck], "Unnamed");								}		v.PushActionWait(ACTION_APPEND, 3.0f);		v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOTECHSTATION, Caller, 0, false);		}}; 

Link to comment
Share on other sites

Thanks mate!

About the script, I have got it working. Check my previous post in this topic for the sollution.

I do have another problem now. I'm trying to spawn civil cars inside the tech station (to replace the wrecks) and make them drive off like regular cars. Anyone got an idea how to do this?

Link to comment
Share on other sites

Wow I just checked the post that I commented in and saw this. I'm not a scripter I know where to put this. I saw Xplorer's to tech script, and his is based on the to hospital script and cutting and pasting this into that may not work.

Edited by nbrown8568
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...