Jump to content
FireBeast24

Park at Base Script

Recommended Posts

Hello,

Looking for help with a script I've just found.

Quote

// ParkAtBase-Script (c) a-rescue | its not allowed to remove this line

const char IMG[] = "gowache";
int DummyGroup = "90";
const char AlarmSound[] = "mod:Audio/Sounds/park.wav";

object ParkAtBase : CommandScript
{
ParkAtBase()
{
SetIcon(IMG);
SetCursor(IMG);
SetValidTargets(ACTOR_VEHICLE);
SetRestrictions(RESTRICT_SELFEXECUTE);
SetPossibleCallers(ACTOR_VEHICLE);
SetGroupID(DummyGroup);
}

bool CheckGroupVisibility(GameObject *Caller)
{
return true;
}

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

Vehicle v(Caller);

if (v.IsValid() && !v.IsDestroyed())
{
return true;
}

PersonList pl = v.GetPassengers();
for(int i=0; i < pl.GetNumPersons(); i++)
{
    Person p = pl.GetPerson(i);
    if(!p.IsCarryingPerson())
    {
        return true;
    }
    else
    {
        return false;
    }
}

return false;
}

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

Vehicle v(Caller);

if (v.IsValid() && !v.IsDestroyed())
{
return true;
}

return false;
}

    void PushActions(GameObject *Caller, Actor *Target, int childID)
    {
        Vehicle v(Caller);
        
        if (v.HasCommand("VcmdWarningLightsOn"))
        {
            Game::ExecuteCommand("VCmdWarningLightsOff", &v, &v);
        }
        
        if (v.HasCommand("DUMMY_HASBELICHTING"))
        {
             v.EnableSpecialLights(false);
             v.RemoveCommand(DUMMY_HASBELICHTING);
        }
        
        if (v.IsBlueLightEnabled())
        {
            Game::ExecuteCommand("VCmdBlueLightsOff", &v, &v);
        }
        
        if (v.HasCommand("DUMMYHasSiren"))
        {
            Game::ExecuteCommand("DUMMYDisableSiren", &v, &v);
        }
        
        if (v.HasCommand("DUMMYHasAutoSiren"))
        {
            Game::ExecuteCommand("VCmdAutoSirenOff", &v, &v);
        }
                if(v.IsInstalled())
            {            
            return;        // Wenn DLK aufgebaut ist, oder ein Schlauch am Fahrzeug angeschlossen ist!
            }    


        Vehicle v(Caller);
        ActorList al;
        Actor parkplatz;
        Vector parkpos;
        Vector anfahrpos;
        Vector wendepos;
        PersonList pl;
{
Audio::PlaySample(AlarmSound);
}

// car detection, parking place detection and approach and turn settings

/////// Car1 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
if (v.HasName("Car1"))     // * car-name
{
al=Game::GetActors("Car1"); // * parking place name (virtual object)
anfahrpos = Vector (0,300,0);
wendepos  = Vector (0,600,0);
v.EnableBlueLights(false);
v.SetSpeed(12.5f);
}
else
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
Mission::PlayHint("Can't find the parking place for this car - Coordinates");
return;
}

// Parking position detection

if(al.GetNumActors() > 0)
{
parkplatz = *al.GetActor(0);
parkpos = parkplatz.GetPosition();
}
else
{
Mission::PlayHint("Can't find the parking place for this car - Virtual object");
return;
}

// Parking
Game::FindFreePosition(&v, parkpos);
if (v.HasName("lifeliner1"))     
{
GameObject obje(Target);
float VUmc = v.GetValidLandingAngle(&obje, parkpos);
Caller->PushActionFlyTo(ACTION_NEWLIST, parkpos, true, VUmc);
}
else
{
v.PushActionMove(ACTION_NEWLIST, parkpos+anfahrpos);
v.PushActionTurnTo(ACTION_APPEND, parkpos+wendepos);
v.PushActionMove(ACTION_APPEND, parkpos);
}

v.RemoveCommand("DummyBeschikbaar");
v.PushActionExecuteCommand(ACTION_APPEND, "VcmdDelete", Caller, 1, true);
v.PushActionExecuteCommand(ACTION_APPEND, "Beschikbaar", Caller, 0, false);
//v.PushActionExecuteCommand(ACTION_APPEND, "Beschikbaar", Caller, 0, false);

}
};

I have named the vehicle "Car1", placed a virtual object called "Car1" and have assigned the command "ParkatBase" to the vehicle.

But the vehicle doesn't drive to the virtual object, it just parks wherever it is on the map. 

 

What have I missed?

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...