Jump to content
Fr33z3x

Hospital script problem

Recommended Posts

I everybody,

I have a problem witch "to hospital script". I install this. I create virtual objects. (hosp_entry, hosp_entrance and hosp_park1,2,3)
I add command "vcmd to hospital" at my ambulance in my personnal mod.

But in game, my ambulance go to hospital entrance but my paramadic don't come to hospital_entry

Help me please

 

(Sorry for my bad english)

Thank's

Link to comment
Share on other sites

Check the physics of the hospital building.

The yellow physics boxes are "invisible walls". If a model wall is not lined with a physics box, vehicles/personnel will walk right though it. What's probably happening is that there is just a large box over your hospital. The personnel park...then walk right into the invisible wall defined by the physics, realize they can't go any further and quit there. You need to line your building walls with physics boxes and leave the "doorway" that you want them to enter through uncovered.

 

It's a little hard to explain, but I'll post a picture up of what I mean later.

Link to comment
Share on other sites

This is my script :
 

 

//******************************************************************************************
// #Version 1.3#
//
//         Includes: Hospital command for ambulances.
//
//    - VcmdToHospital
//    - DummyAtHospital
//    - DummyGoHome
//
//        Script by Hoppah
//        
//        Usage of this script in other mods is NOT allowed without permission of Hoppah
//
//******************************************************************************************

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_TOFIRESTATION[]             = "VcmdToFireStation";
const char CMD_GOHOME[]             = "GoHome";
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_HOSPITAL[]             = "DummyAtHospital";
const char DUMMY_PATROL[]             = "DummyPatrol";
const char DUMMY_GOHOME[]             = "DummyGoHome";
const char OBJ_HELIPAD[]             = "hospital_helipad";
const char VO_ENTRANCE[]             = "hospital_entrance"; (Hi create this VO)
const char VO_ENTRY[]                 = "hospital_entry"; (Hi create this VO)
const char VO_ENTRY_HELIPAD[]             = "hospital_entry2";
const char VO_HELI[]                 = "hospital_heli";
const char VO_SQUAD01[]                = "fs_squad01";
const char VO_SQUAD02[]                = "fs_squad02";
const char HINT_NOTRANSPORTS[]             = "No transports!";
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!";

int DummyGroup = 33;

object VcmdToHospital : CommandScript (Hi add this command in my ambulance)
{
    VcmdToHospital()
    {
        SetCursor("tohospital");
        SetIcon("tohospital");
        SetGroupID(DummyGroup);
         SetGroupLeader(true);
        SetRestrictions(RESTRICT_SELFEXECUTE);
    }

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

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

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

         Vehicle v(Caller);
        if (v.IsCollidingWithVirtualObject(VO_SQUAD01) || v.IsCollidingWithVirtualObject(VO_SQUAD02))
            return false;

        if (v.IsCollidingWithVirtualObject(VO_ENTRANCE))
            return false;

        if (v.IsCollidingWithVirtualObject(VO_HELI))
            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(115);

        return true;
    }

    void PushActions(GameObject *Caller, Actor *Target, int ChildID)
    {
        Vehicle v(Caller);
        if (v.GetVehicleType() == VT_AMBULANCE_RTW)
        {
            ActorList l1 = Game::GetActors(VO_ENTRANCE);
                if (l1.GetNumActors() > 0)
                {    
                Vector Hospital = l1.GetActor(0)->GetPosition();
                Game::FindFreePosition(Caller, Hospital);
            }
            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.IsBlueLightEnabled())
                v.EnableBlueLights(false);
            PersonList transports = v.GetTransports();
            if (transports.GetNumPersons() > 0)
            {
                if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF))
                    Game::ExecuteCommand(CMD_SIREN, &v, &v);
            }
            if (transports.GetNumPersons() > 0)
            {
                Caller->PushActionMove(ACTION_NEWLIST, Hospital);
                if (v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF))
                    Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_DISABLE, Caller, 2, false);
                Caller->PushActionWait(ACTION_APPEND, 1.0f);
                Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_HOSPITAL, Caller, 0, false);
            } else
            {
                Mission::PlayHint(HINT_NOTRANSPORTS);
                return;
            }
        } else
        {
            Audio::PlaySample3D(SND_TOSTATION, Caller->GetPosition());
            ActorList l1 = Game::GetActors(OBJ_HELIPAD);
            if(l1.GetNumActors() > 0)
            {
                Actor hospital = *l1.GetActor(0);
                Vector Hospital = hospital.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, Hospital);
            GameObject obj(&hospital);
            float landingDirection = v.GetValidLandingAngle(&obj, Hospital);
            Caller->PushActionFlyTo(ACTION_NEWLIST, Hospital, true, landingDirection);
            Caller->PushActionWait(ACTION_APPEND, 1.0f);
            PersonList transports = v.GetTransports();
            if (transports.GetNumPersons() > 0)
                Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_HOSPITAL, Caller, 0, false);
        }
    }
};

object DummyAtHospital : CommandScript
{
    DummyAtHospital()
    {
        SetGroupID(DummyGroup);
    }

    bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID)
    {
    }

    void PushActions(GameObject *Caller, Actor *Target, int ChildID)
    {
        Vehicle v(Target);
        v.PushActionWait(ACTION_NEWLIST, 1.0f);        
        if (v.GetVehicleType() == VT_AMBULANCE_RTW)
        {
            ActorList l1 = Game::GetActors(VO_ENTRY);
                if (l1.GetNumActors() > 0)
                Vector TargetPos  = l1.GetActor(0)->GetPosition();
        } else
        {
            ActorList l1 = Game::GetActors(VO_ENTRY_HELIPAD);
                if (l1.GetNumActors() > 0)
                Vector TargetPos = l1.GetActor(0)->GetPosition();
        }
        PersonList transports = v.GetTransports();
        PersonList passengers;
        passengers = v.GetPassengers();
        for(int i=0; i<passengers.GetNumPersons(); i++)
        {
            Person p (passengers.GetPerson(i));
            if (p.IsParamedicTeam() && p.IsCarryingPerson())
            {
                p.PushActionLeaveCar(ACTION_NEWLIST, Target);
                p.PushActionMove(ACTION_APPEND, TargetPos, true);
                p.PushActionPutInBase(ACTION_APPEND);
                p.PushActionWait(ACTION_APPEND, 3.0f);
                p.PushActionMove(ACTION_APPEND, &v, TARGET_REARDOOR);
                p.PushActionTurnTo(ACTION_APPEND, &v);
                p.PushActionEnterCar(ACTION_APPEND, &v);
                p.PushActionWait(ACTION_APPEND, 1.0f);
                if (v.GetVehicleType() == VT_AMBULANCE_RTW)
                    p.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GOHOME, &v, 2, false);
            }
        }
    }
};

object DummyGoHome : CommandScript
{
    DummyGoHome()
    {
        SetGroupID(20);
    }

    bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID)
    {
    }

    void PushActions(GameObject *Caller, Actor *Target, int ChildID)
    {
        if(ChildID == 1)
        {
            Vehicle v(Target);
            Game::ExecuteCommand(CMD_GOHOME, &v, &v);
        }
        if(ChildID == 2)
        {
            Vehicle v(Target);
            Game::ExecuteCommand(CMD_TOFIRESTATION, &v, &v);
        }
    }
};

 

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