Jump to content
Guest madforce

New question

Recommended Posts

Guest madforce

When trying to relocate/add new parking for police units, is there something specific I need to do in regards to the virtual objects. I've managed to add and update the script for up to 7 total spaces for units to return to instead of going on patrol and clogging up the map with traffic jams. They don't look out of place, but the issue I'm seeing is in regard to positioning when the units get to that location.

I've cloned the exact virtual objects from the original VOs at the LAPD HQ, and created my own of varying sizes and shapes, but the units basically hit some corner of the object and thats where they park, or they'll bug out for a short bit trying to readjust in the spot, but they never make it in the position or orientation of the virtual object they are expected to sit in.

How are they constrained? Should the entire car fit in the object box? part of the box? Is there something specific that i need to do to set the orientation? From what i could tell from the script.

Basically, I've added the VO's, added them to the script, the game executes them perfectly, the units go to their designated standby parking , with the exception that they are turned every which way and position.

I noticed the ToDonut and Turnto and I've forced todonut to remain false trying to see if all were affected by the PD Vector TURNTO segments, but regardless they still park like the handicapped at every degree angle, and the 3 units at HQ line right up to the curb as expected.

Any ideas would be appreciated, I'm a bit perplexed atm on getting the positioning right...

Link to comment
Share on other sites

Guest madforce
Post your script here would help.

Have you made a turnto vo?

Atm, no, I'm not quite sure of it's orientation and how exactly that part works. I understand it's TURNTO and x,y,z using the Vector i believe, but currently everything I would have thought would be riding on the turnto that applies to the cars at the 'PD' since todonut is explicitly set false so the PD2 isn't applied. My expectation was to see all the units turn to the same orientation as the units at HQ, but what I see is \|/-- and all kinds of screwyness even if the cloned VOs are all set to the same orientation, size and shape on the map as the original. I was anticipating seeing the same result if all fit the same turnto vector conditions, but im not, so that's where I'm a bit confused. If they did as I expected, then I would be able to apply it to one object and note the rotation to get the position. But when HQ is perfect, and the rest are all over the place, it confuses my trial and error thoughts.

I mispoke, currently 6 spots, not 7. The only edits are highlighted...not much, the only other added benefit to ToDonut=false is that any unit can use those spots, as where previously park04 and park05 would only house the CV. 9Which of course, im not sure if by design but they wouldn't get called out cause they were excluded from the BCcall script file too which is another easy edit in. So unless you specifically selected the units, they were permant stationary and the BC would ignore that they were even there.)

const char CMD_SIREN[]				= "VcmdSiren";
const char CMD_AUTOSIREN_OFF[] = "VcmdAutoSirenOff";
const char CMD_WARNINGLIGHTS_OFF[] = "VcmdWarningLightsOff";
const char CMD_WARNINGLIGHTS_ON[] = "VcmdWarningLightsOn";
const char CMD_FLOODLIGHTS_OFF[] = "VcmdFloodLightsOff";
const char CMD_FLOODLIGHTS_ON[] = "VcmdFloodLightsOn";
const char CMD_GOHOME[] = "GoHome";
const char CMD_TOPOLICESTATION[] = "VcmdToPoliceStation";
const char CMD_PATROL[] = "VcmdPatrol";
const char CMD_STANDBY_ON[] = "VcmdStandbyOn";
const char CMD_STANDBY_OFF[] = "VcmdStandbyOff";
const char DUMMY_DISABLE[] = "DummyDisableSiren";
const char DUMMY_HASSIREN[] = "DummyHasSiren";
const char DUMMY_GOHOME[] = "DummyGoHome";
const char DUMMY_PATROL[] = "DummyPatrol";
const char OBJ_HELIPAD[] = "policestation_helipad";
const char VO_ENTRY[] = "policestation_entry";
const char VO_ENTRY_HELIPAD[] = "policestation_entry2";
const char VO_TURNTO[] = "policestation_turnto";
const char VO_PARK01[] = "policestation_park01";
const char VO_PARK02[] = "policestation_park02";
const char VO_PARK03[] = "policestation_park03";
const char VO_PARK04[] = "policestation_park04";
[color="#FF0000"]const char VO_PARK05[] = "policestation_park05";
const char VO_PARK06[] = "policestation_park06";[/color]
const char VO_HELI[] = "policestation_heli";
const char VO_SPAWN[] = "policestation_spawn";
const char SND_TOSTATION[] = "mod:Audio/FX/radio/1019.wav";
const char HINT_HELICOPTER[] = "Another helicopter is blocking the helipad! The helicopter will return to base!";
const char PROTO_CV_LAPD[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lapd.e4p";

int DummyGroup = 32;

object VcmdToPoliceStation : CommandScript
{
VcmdToPoliceStation()
{
SetCursor("topolicestation");
SetIcon("topolicestation");
SetGroupID(DummyGroup);
SetGroupLeader(true);
SetRestrictions(RESTRICT_SELFEXECUTE);
}

bool CheckPossible(GameObject *Caller)
{
if (!Caller->IsValid())
return false;

if (!Game::IsFreeplay() && !Game::IsMultiplayer())
return false;

Vehicle v(Caller);
if (v.IsCollidingWithVirtualObject(VO_HELI))
return false;

ActorList l1 = Game::GetActors(VO_PARK01);
if (l1.GetNumActors() == 0)
return false;

return true;
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if (!Caller->IsValid() || !Target->IsValid() || (Caller->GetID() != Target->GetID()))
return false;

Vehicle v(Caller);
SetPriority(0);
if (v.GetNumTransported() > 0)
SetPriority(110);

return true;
}

void PushActions(GameObject *Caller, Actor *Target, int ChildID)
{
Vehicle v(Caller);
bool Donut = false;
ActorList d = Game::GetActors(VO_PARK04);
if (StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD) == 0 && d.GetNumActors() > 0)
Donut = false;

if(ChildID == 0)
{
if (v.GetVehicleType() != VT_POLICE_PHC)
{
if (v.IsBlueLightEnabled())
v.EnableBlueLights(false);
if (v.HasCommand("DummyFollow"))
v.RemoveCommand("DummyFollow");
if (v.HasCommand(CMD_STANDBY_OFF))
{
v.RemoveCommand(CMD_STANDBY_OFF);
v.AssignCommand(CMD_STANDBY_ON);
}
if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
{
v.EnableBlinker(BLT_NONE);
v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
v.AssignCommand(CMD_WARNINGLIGHTS_ON);
}
if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
{
v.EnableSpecialLights(false);
v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
v.AssignCommand(CMD_FLOODLIGHTS_ON);
}
if (v.HasObjectPath(NULL))
Game::ExecuteCommand(DUMMY_PATROL, &v, &v);
if (v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF))
Game::ExecuteCommand(DUMMY_DISABLE, &v, &v);

bool ParkinglotFound = false;
bool ToDonut = false;
ActorList l1;
if (!ParkinglotFound)
{
GameObjectList l2;
Game::CollectObstaclesOnVirtualObject(VO_PARK01, l2, ACTOR_VEHICLE);
if(l2.GetNumObjects() == 0)
{
l1 = Game::GetActors(VO_PARK01);
ParkinglotFound = true;
}
}
if (!ParkinglotFound)
{
GameObjectList l3;
Game::CollectObstaclesOnVirtualObject(VO_PARK02, l3, ACTOR_VEHICLE);
if(l3.GetNumObjects() == 0)
{
l1 = Game::GetActors(VO_PARK02);
ParkinglotFound = true;
}
}
if (!ParkinglotFound)
{
GameObjectList l4;
Game::CollectObstaclesOnVirtualObject(VO_PARK03, l4, ACTOR_VEHICLE);
if(l4.GetNumObjects() == 0)
{
l1 = Game::GetActors(VO_PARK03);
ParkinglotFound = true;
}
}
if (!ParkinglotFound)
{
GameObjectList l5;
Game::CollectObstaclesOnVirtualObject(VO_PARK04, l5, ACTOR_VEHICLE);
if (!l5.ContainsSquad())
{
l1 = Game::GetActors(VO_PARK04);
ParkinglotFound = true;
ToDonut = [color="#FF0000"]false;[/color]
}
}
[color="#FF0000"] if (!ParkinglotFound)
{
GameObjectList l6;
Game::CollectObstaclesOnVirtualObject(VO_PARK05, l6, ACTOR_VEHICLE);
if (!l6.ContainsSquad())
{
l1 = Game::GetActors(VO_PARK05);
ParkinglotFound = true;
ToDonut = false;
}
}
if (!ParkinglotFound)
{
GameObjectList l7;
Game::CollectObstaclesOnVirtualObject(VO_PARK05, l7, ACTOR_VEHICLE);
if (!l7.ContainsSquad())
{
l1 = Game::GetActors(VO_PARK05);
ParkinglotFound = true;
ToDonut = false;
}
}
[/color] if (!ParkinglotFound)
{
v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_PATROL, Caller, 0, false);
return;
}
else
{
Vector PD = l1.GetActor(0)->GetPosition();
Vector PD2 = l1.GetActor(0)->GetPosition() + Vector(280,-280,0);

ActorList l8 = Game::GetActors(VO_TURNTO);
Vector TurnTo = l8.GetActor(0)->GetPosition();

Game::FindFreePosition(Caller, PD);
Audio::PlaySample3D(SND_TOSTATION, v.GetPosition());

if (!ToDonut)
{
v.PushActionMove(ACTION_NEWLIST, PD);
v.PushActionTurnTo(ACTION_APPEND, TurnTo);
} else
{
v.PushActionMove(ACTION_NEWLIST, PD2);
v.PushActionTurnTo(ACTION_APPEND, PD + Vector(320,-320,0));
v.PushActionWait(ACTION_APPEND, 0.5f);
v.PushActionMove(ACTION_APPEND, PD);
}
v.PushActionWait(ACTION_APPEND, 1.5f);
v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 2, false);
PersonList transports = v.GetTransports();
if (!ToDonut && transports.GetNumPersons() > 0)
v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);
}
} else
{
Audio::PlaySample3D(SND_TOSTATION, v.GetPosition());
ActorList l1 = Game::GetActors(OBJ_HELIPAD);
if(l1.GetNumActors() > 0)
{
Actor policestation = *l1.GetActor(0);
Vector Policestation = policestation.GetPosition();
}
if (Game::IsSquadInVirtualObject(VO_HELI))
{
GameObjectList l2;
Game::CollectObstaclesOnVirtualObject(VO_HELI, l2, ACTOR_VEHICLE);
for (int i = 0; i < l2.GetNumObjects(); i++)
{
Vehicle m = l2.GetObject(i);
m.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_GOHOME, &m, 1, false);
Mission::PlayHint(HINT_HELICOPTER);
}
}
Game::FindFreePosition(Caller, Policestation);
GameObject obj(&policestation);
float landingDirection = v.GetValidLandingAngle(&obj, Policestation);
v.PushActionFlyTo(ACTION_NEWLIST, Policestation, true, landingDirection);
PersonList transports = v.GetTransports();
if (transports.GetNumPersons() > 0)
v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);
}
}
if(ChildID == 1)
{
if (v.GetVehicleType() != VT_POLICE_PHC)
{
ActorList l1 = Game::GetActors(VO_SPAWN);
if (l1.GetNumActors() > 0)
Vector TargetPos = l1.GetActor(0)->GetPosition();
PersonList transports = v.GetTransports();
for(int i = 0; i < transports.GetNumPersons(); i++)
{
transports.GetPerson(i)->PushActionLeaveCar(ACTION_NEWLIST, Caller);
if(transports.GetPerson(i)->GetRole() == ROLE_GANGSTER)
{
transports.GetPerson(i)->SetRole(ROLE_CIVILIAN);
transports.GetPerson(i)->SetBehaviour(BEHAVIOUR_CIVILIAN_NORMAL);
}
transports.GetPerson(i)->PushActionWait(ACTION_APPEND, 0.5f);
transports.GetPerson(i)->PushActionMove(ACTION_APPEND, TargetPos, true);
transports.GetPerson(i)->PushActionDeleteOwner(ACTION_APPEND);
}
} else
{
ActorList l1 = Game::GetActors(VO_ENTRY_HELIPAD);
if (l1.GetNumActors() > 0)
Vector TargetPos = l1.GetActor(0)->GetPosition();
PersonList transports = v.GetTransports();
for(int i = 0; i < transports.GetNumPersons(); i++)
{
transports.GetPerson(i)->PushActionLeaveCar(ACTION_NEWLIST, Caller);
if(transports.GetPerson(i)->GetRole() == ROLE_GANGSTER)
{
transports.GetPerson(i)->SetRole(ROLE_CIVILIAN);
transports.GetPerson(i)->SetBehaviour(BEHAVIOUR_CIVILIAN_NORMAL);
}
transports.GetPerson(i)->PushActionWait(ACTION_APPEND, 0.5f);
transports.GetPerson(i)->PushActionMove(ACTION_APPEND, TargetPos, true);
transports.GetPerson(i)->PushActionDeleteOwner(ACTION_APPEND);
}
}
}
if(ChildID == 2)
{
Vehicle v(Caller);
v.EnableBlinker(BLT_NONE);
bool ToPoliceStation = false;
if (v.IsCollidingWithVirtualObject(VO_PARK01))
return;
else
ToPoliceStation = true;
if (v.IsCollidingWithVirtualObject(VO_PARK02))
return;
else
ToPoliceStation = true;
if (v.IsCollidingWithVirtualObject(VO_PARK03))
return;
else
ToPoliceStation = true;
if (v.IsCollidingWithVirtualObject(VO_PARK04))
return;
else
ToPoliceStation = true;
if (v.IsCollidingWithVirtualObject(VO_PARK05))
return;
else
ToPoliceStation = true;
[color="#FF0000"] if (v.IsCollidingWithVirtualObject(VO_PARK06))
return;
else
ToPoliceStation = true;[/color]

if(ToPoliceStation)
v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_TOPOLICESTATION, Caller, 0, false);
}
}
};

I do understand atm that with ToDonut set to false, the script will try to unload detainee's at any spot the unit parks in, but thats the easy part to fix (!ToDonut && transports.GetNumPersons() > 0) ;/

Link to comment
Share on other sites

Well it seems your only telling the units to recognize the turn to vo for the pd station parking. Not the actual turn to vo for each extra parking space. I would suggest actually doing the stand by points with its own script rather then the to police station script. I could be wrong, but I would think by doing it this way your telling the officers to there parking spot regardless of weather they have one in custody. That would result in the officer walking the suspect to the station from there parking spot on the map. What your doing would be sufficient to increase the parking capacity from 3 to 5 or X should you place the vos in front of the station.

Something to consider as well would be to script the separate script to check if the spots are full. Something with an if statement like(basic example of course)

if (v.IsCollidingWithVirtualObject(VO_PARK04))

return;

else

ToVO_PARK04 = true;

return;

else

ToVO_PARK05 =true;

You get the idea I am sure.

Link to comment
Share on other sites

Guest madforce

I realize currently they'll try to walk a detainee to the station from wherever' the VO is they are parking, but I've had that fixed before and I can just add it again by adding something like

bool ParkinglotFound = false;

bool ToDonut = false;

bool Awayfromstation = false

ActorList l1;

......

Then when it gets to checking the spots not at HQ, 04,05,06 etc..

......

if (!ParkinglotFound)

{

GameObjectList l5;

Game::CollectObstaclesOnVirtualObject(VO_PARK04, l5, ACTOR_VEHICLE);

if(l2.GetNumObjects() == 0)

{

11 = Game::GetActors(VO_PARK04);

ParkinglotFound = true;

Awayfromstation = true;

}

}

......

Then when it checks for transports...

......

if (!Awayfromstation && transports.GetNumPersons() > 0)

......

Then it responds just as the original spots, and holds onto the detainees it's transporting. It would be nice if all cars, regardless of position, if they had someone to take to jail so to speak, would go to HQ, even if in the parkinglot, dump them off, then proceed to find a standby location. As it is now, even in the original code, an LAPD Crown Vic (#03) would report directly to Randy's donuts and never dump the detainee's. Once I get positioning right for the standby units, then I'll play around and see if I can't get them to report to a dump spot for detainees before going on standby.

......

But as far as the turnto, right now, just as you would say is exactly what I was expecting to see, all units recognizing the turnto for the pd station parking, but even with that, 04,05,06 spots in different locations the cars do not have that same orientation. 04 is 180 degrees, but squared. 05 and 06 just drive right up and grab a corner of the VO but park in any general direction. So I guess that's what's confusing me atm, cause I'm not quite seeing what's causing 04,05,06 to orientate different than 01,02,03, and that 04,05,06 all 3 orientate different than each other at that...

Well it seems your only telling the units to recognize the turn to vo for the pd station parking. Not the actual turn to vo for each extra parking space. I would suggest actually doing the stand by points with its own script rather then the to police station script. I could be wrong, but I would think by doing it this way your telling the officers to there parking spot regardless of weather they have one in custody. That would result in the officer walking the suspect to the station from there parking spot on the map. What your doing would be sufficient to increase the parking capacity from 3 to 5 or X should you place the vos in front of the station.

Something to consider as well would be to script the separate script to check if the spots are full. Something with an if statement like(basic example of course)

if (v.IsCollidingWithVirtualObject(VO_PARK04))

return;

else

ToVO_PARK04 = true;

return;

else

ToVO_PARK05 =true;

You get the idea I am sure.

Link to comment
Share on other sites

I realize currently they'll try to walk a detainee to the station from wherever' the VO is they are parking, but I've had that fixed before and I can just add it again by adding something like

bool ParkinglotFound = false;

bool ToDonut = false;

bool Awayfromstation = false

ActorList l1;

......

Then when it gets to checking the spots not at HQ, 04,05,06 etc..

......

if (!ParkinglotFound)

{

GameObjectList l5;

Game::CollectObstaclesOnVirtualObject(VO_PARK04, l5, ACTOR_VEHICLE);

if(l2.GetNumObjects() == 0)

{

11 = Game::GetActors(VO_PARK04);

ParkinglotFound = true;

Awayfromstation = true;

}

}

......

Then when it checks for transports...

......

if (!Awayfromstation && transports.GetNumPersons() > 0)

......

As long as you define Awayfromstation, yes your right. I would be interested in something like your describing here as well as others are to Im sure to. I have some idea of how to accomplish this so I will PM you about this.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...