Jump to content
Hoppah

[Released] Limited Water Supply Logic

Recommended Posts

dyson created this!

 


//******************************************************************************************

// #Version 1.6#

// Script by Dyson - Use in other mods is permited but credit is required

//

//******************************************************************************************

int DummyGroup = 20;

const char NAME_WATERCON[] = "hose_connection";

const char NAME_HYDRANT[] = "hydrant";

const char CMD_DUMMYATTACHFH[] = "DummyAttachFirehose";

const char CMD_REMOVEFH[] = "RemoveFirehose";

const char DUMMY_CHANGE[] = "DummyChange";

const char AUDIO_HOSE[] = "mod:Audio/FX/equipment/hosecoupling.wav";

const char PROTO_UFL[] = "mod:Prototypes/Objects/Equipment/firehose02.e4p";

const char PROTO_SROHR[] =  "mod:Prototypes/Objects/Street/hydrant01.e4p";

 

 

object AttachFHVehicle : CommandScript

{

AttachFHVehicle()

{

SetValidTargets(ACTOR_OBJECT | ACTOR_VEHICLE);

SetPossibleCallers(ACTOR_PERSON);

SetPossibleEquipment(EQUIP_FIREHOSE);

SetIcon("AttachFireHose");

SetCursor("AttachFireHose");

SetPriority(120);

}

 

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)

{

if(!Caller->IsValid() || !Target->IsValid() || (Caller->GetID()==Target->GetID()))

return false;

 

Person c(Caller);

if (c.GetEnteredCarID() != -1)

return false;

 

if(Target->GetType() != ACTOR_VEHICLE)

        return false;

 

 

                Vehicle v(Target);

                if(v.HasCommand(DUMMY_CHANGE))

                    return false;

 

if(v.GetEnergy() > 0.1f * v.GetMaxEnergy() && v.HasChild(NAME_WATERCON))

return true;

       return false;

}

 

void PushActions(GameObject *Caller, Actor *Target, int childID)

{

                         Vehicle v(Target);

                         Caller->PushActionMove(ACTION_NEWLIST, v.GetChildPosition(NAME_WATERCON));

                         Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYATTACHFH, Target, 2, false);

}

};

 

object DummyAttachFirehose : CommandScript

{

DummyAttachFirehose()

{

            SetGroupID(DummyGroup);

}

 

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)

{

}

 

void PushActions(GameObject *Caller, Actor *Target, int childID)

{

   Person p(Caller);

            switch(childID)

            {

              case 1 :

              {

                 char wstring[5];

                 snprintf(wstring, 5, "%s", Target->GetName());

                 if(wstring[0]!='v' || wstring[1]!='e' || wstring[2]!='r' || wstring[3]!='t')

                 {

                        p.RemoveObjectInRightHand();

                        if(Target->GetType() == ACTOR_OBJECT || Target->HasName(NAME_HYDRANT))

                                p.AssignCommand("AttachFHVehicle");

                        p.EnableAutoTarget(false);

                        

                  }

                  else

                  {

                        p.PlaceObjectInRightHand("mod:Models/Objects/Equipment/firehose02.v3o");

                        p.EnableAutoTarget(true);

                  }

                }

                break;

 

                case 2 :

                {

                        Vehicle v(Target);

                        if(p.GetBoundingRadiusDistXYToObject(&v) > 50.f)

                        {

                            Game::ShowHelpTextWindow("Vehicle too far away!");

                            return;

                        }

                        float r[9];

                        v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

                        p.SetPosition(v.GetChildPosition(NAME_WATERCON));

                        p.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

                        p.SetAnimation("none");

                p.EnableAutoTarget(false);

//p.Deselect();

p.SetFlag(OF_HIDDEN);

//p.SetCommandable(true);

Audio::PlaySample3D(AUDIO_HOSE, v.GetChildPosition(NAME_WATERCON));

p.SetResistance(INJUREREASON_UNKNOWN, 100000.0f);

p.SetResistance(INJUREREASON_CONTAM_ATOM, 100000.0f);

p.SetResistance(INJUREREASON_CONTAM_CHEM, 100000.0f);

p.SetResistance(INJUREREASON_CONTAM_BIO, 100000.0f);

p.SetUserData(v.GetID());

Person n = Game::CreatePerson(p.GetPrototypeFileName(), Caller->GetName());

p.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

Vector PerPos = p.GetPosition();

if (n.IsValid())

{

Game::FindFreePosition(&n, PerPos, 100.f);

n.SetPosition(PerPos);

//n.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

n.SetPlayerMP(p.GetPlayerMP());

n.SetHealth(p.GetHealth());

n.SetUpgradeLevel(3);

if(p.IsSelected())

{

                                     n.Select();

                                     p.Deselect();

                                }

                                char wstring[6];

                                snprintf(wstring, 6, "%s", v.GetName());

                                wstring[0] = '0';

                                int vID = atoi(wstring);

                       char nstring[9];

                               snprintf(nstring, 9, "vert%i", vID);

                                GameObjectList list = Game::GetGameObjects(nstring);

                                for(int i = 0; i < list.GetNumObjects(); i++)

       {

    list.GetObject(i)->AssignCommand(CMD_DUMMYATTACHFH);

       }

}

Game::ShowHelpTextWindow("Engine Hooked Up to Hydrant");

                 }

                 break;

 

                 case 3 :

                 {

                

                      Vehicle v(Target);

                      Person p(Caller);

                      float r[9];

                      p.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

                      GameObjectList list = p.GetObjectsInRange(400.0f, ACTOR_PERSON);

     for(int i = 0; i < list.GetNumObjects(); i++)

     {

                              Person n = list.GetObject(i);

      if (n.GetUserData() == v.GetID())

{

n.ClearFlag(OF_HIDDEN);

n.PushActionSwitchAnim(ACTION_NEWLIST, "idle");

if (p.IsSelected())

n.Select();

n.SetUserData(0);

if(StrCompare(n.GetPrototypeFileName(), p.GetPrototypeFileName())!=0)

{

    n.ChangeModel(p.GetModelFileName());

    n.AssignCommand(DUMMY_CHANGE);

                                        }

n.SetResistance(INJUREREASON_UNKNOWN, 0.0f);

n.SetResistance(INJUREREASON_CONTAM_ATOM, 0.0f);

n.SetResistance(INJUREREASON_CONTAM_CHEM, 0.0f);

n.SetResistance(INJUREREASON_CONTAM_BIO, 0.0f);

n.SetPosition(p.GetPosition());

n.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

p.PushActionDeleteOwner(ACTION_NEWLIST);

n.PushActionExecuteCommand(ACTION_APPEND, CMD_REMOVEFH, &n, 0, false);

char wstring[6];

                                        snprintf(wstring, 6, "%s", v.GetName());

                                        wstring[0] = '0';

                                        int vID = atoi(wstring);

                               char nstring[9];

                                       snprintf(nstring, 9, "vert%i", vID);

                                        GameObjectList list = Game::GetGameObjects(nstring);

                                        for(int i = 0; i < list.GetNumObjects(); i++)

               {

                                              Vehicle vert = list.GetObject(i);

             vert.RemoveCommand(CMD_DUMMYATTACHFH);

             if(vert.GetNumUsedConnectors()>1)

             {

                                                    Game::ShowHelpTextWindow("Water Supply Needed");

                                                    /*GameObjectList list2 = vert.GetObjectsInRange(3000.0f, ACTOR_PERSON);

                                                    for(int a = 0; a < list2.GetNumObjects(); a++)

                                   {

                                                         Person ff = list2.GetObject(i);

                                                         GameObject hydrant = ff.GetHydrant();

                                                         if(hydrant.GetID() == vert.GetID());

                                                              ff.PushActionExecuteCommand(ACTION_NEWLIST, CMD_REMOVEFH, &ff, 0, false);

                                                    } */

                                              }

               }

                      }

     }

                 }

                 break;

 

                 case 4 :

                 {

                     Vehicle v(Target);

                     if(v.GetNumUsedConnectors()>0 && !v.HasCommand(CMD_DUMMYATTACHFH) && !v.HasName(NAME_SROHR))

                             Game::ShowHelpTextWindow("Water Supply Needed");

                     else

                     {

                             Caller->PushActionCheckFreeConnector(ACTION_APPEND, Target);

                    Caller->PushActionUseEquipment(ACTION_APPEND, Target, childID, 1.0f);

            Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYATTACHFH, Target, 1, false);

                     }

                  }

                  break;

 

                  case 5 :

                  {

                     Vehicle v(Target);

                     if(v.GetNumUsedConnectors()==0)

                     {

                             Caller->PushActionCheckFreeConnector(ACTION_APPEND, Target);

                   Caller->PushActionUseEquipment(ACTION_APPEND, Target, childID, 1.0f);

                   p.PlaceObjectInRightHand("mod:Models/Objects/Equipment/firehose02.v3o");

                     }

 

                  }

                  break;

 

                  case 6 :

                  {

                        GameObject g(Target);

                        float r[9];

                        g.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

                        System::Log("wFreeplayLog: Placing Standrohr");

                        Vehicle s = Game::CreateVehicle(PROTO_SROHR, NAME_SROHR);

                        if (s.IsValid())

{

   s.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);

                   s.SetPosition(Target->GetPosition());

                        }

int PlayerID = Caller->GetPlayerMP();

s.SetPlayerMP(PlayerID);

Caller->PushActionUseEquipment(ACTION_APPEND, &s, childID, 1.0f);

       Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYATTACHFH, &s, 1, false);

                     }

                     break;

            }

}

};


Link to comment
Share on other sites

 

dyson created this!
 
//******************************************************************************************
// #Version 1.6#
// Script by Dyson - Use in other mods is permited but credit is required
//
//******************************************************************************************
int DummyGroup = 20;
const char NAME_WATERCON[] = "hose_connection";
const char NAME_HYDRANT[] = "hydrant";
const char CMD_DUMMYATTACHFH[] = "DummyAttachFirehose";
const char CMD_REMOVEFH[] = "RemoveFirehose";
const char DUMMY_CHANGE[] = "DummyChange";
const char AUDIO_HOSE[] = "mod:Audio/FX/equipment/hosecoupling.wav";
const char PROTO_UFL[] = "mod:Prototypes/Objects/Equipment/firehose02.e4p";
const char PROTO_SROHR[] =  "mod:Prototypes/Objects/Street/hydrant01.e4p";
 
 
object AttachFHVehicle : CommandScript
{
AttachFHVehicle()
{
SetValidTargets(ACTOR_OBJECT | ACTOR_VEHICLE);
SetPossibleCallers(ACTOR_PERSON);
SetPossibleEquipment(EQUIP_FIREHOSE);
SetIcon("AttachFireHose");
SetCursor("AttachFireHose");
SetPriority(120);
}
 
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if(!Caller->IsValid() || !Target->IsValid() || (Caller->GetID()==Target->GetID()))
return false;
 
Person c(Caller);
if (c.GetEnteredCarID() != -1)
return false;
 
if(Target->GetType() != ACTOR_VEHICLE)
        return false;
 
 
                Vehicle v(Target);
                if(v.HasCommand(DUMMY_CHANGE))
                    return false;
 
if(v.GetEnergy() > 0.1f * v.GetMaxEnergy() && v.HasChild(NAME_WATERCON))
return true;
       return false;
}
 
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
                         Vehicle v(Target);
                         Caller->PushActionMove(ACTION_NEWLIST, v.GetChildPosition(NAME_WATERCON));
                         Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYATTACHFH, Target, 2, false);
}
};
 
object DummyAttachFirehose : CommandScript
{
DummyAttachFirehose()
{
            SetGroupID(DummyGroup);
}
 
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
}
 
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
   Person p(Caller);
            switch(childID)
            {
              case 1 :
              {
                 char wstring[5];
                 snprintf(wstring, 5, "%s", Target->GetName());
                 if(wstring[0]!='v' || wstring[1]!='e' || wstring[2]!='r' || wstring[3]!='t')
                 {
                        p.RemoveObjectInRightHand();
                        if(Target->GetType() == ACTOR_OBJECT || Target->HasName(NAME_HYDRANT))
                                p.AssignCommand("AttachFHVehicle");
                        p.EnableAutoTarget(false);
                        
                  }
                  else
                  {
                        p.PlaceObjectInRightHand("mod:Models/Objects/Equipment/firehose02.v3o");
                        p.EnableAutoTarget(true);
                  }
                }
                break;
 
                case 2 :
                {
                        Vehicle v(Target);
                        if(p.GetBoundingRadiusDistXYToObject(&v) > 50.f)
                        {
                            Game::ShowHelpTextWindow("Vehicle too far away!");
                            return;
                        }
                        float r[9];
                        v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
                        p.SetPosition(v.GetChildPosition(NAME_WATERCON));
                        p.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
                        p.SetAnimation("none");
                p.EnableAutoTarget(false);
//p.Deselect();
p.SetFlag(OF_HIDDEN);
//p.SetCommandable(true);
Audio::PlaySample3D(AUDIO_HOSE, v.GetChildPosition(NAME_WATERCON));
p.SetResistance(INJUREREASON_UNKNOWN, 100000.0f);
p.SetResistance(INJUREREASON_CONTAM_ATOM, 100000.0f);
p.SetResistance(INJUREREASON_CONTAM_CHEM, 100000.0f);
p.SetResistance(INJUREREASON_CONTAM_BIO, 100000.0f);
p.SetUserData(v.GetID());
Person n = Game::CreatePerson(p.GetPrototypeFileName(), Caller->GetName());
p.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
Vector PerPos = p.GetPosition();
if (n.IsValid())
{
Game::FindFreePosition(&n, PerPos, 100.f);
n.SetPosition(PerPos);
//n.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
n.SetPlayerMP(p.GetPlayerMP());
n.SetHealth(p.GetHealth());
n.SetUpgradeLevel(3);
if(p.IsSelected())
{
                                     n.Select();
                                     p.Deselect();
                                }
                                char wstring[6];
                                snprintf(wstring, 6, "%s", v.GetName());
                                wstring[0] = '0';
                                int vID = atoi(wstring);
                       char nstring[9];
                               snprintf(nstring, 9, "vert%i", vID);
                                GameObjectList list = Game::GetGameObjects(nstring);
                                for(int i = 0; i < list.GetNumObjects(); i++)
       {
    list.GetObject(i)->AssignCommand(CMD_DUMMYATTACHFH);
       }
}
Game::ShowHelpTextWindow("Engine Hooked Up to Hydrant");
                 }
                 break;
 
                 case 3 :
                 {
                
                      Vehicle v(Target);
                      Person p(Caller);
                      float r[9];
                      p.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
                      GameObjectList list = p.GetObjectsInRange(400.0f, ACTOR_PERSON);
     for(int i = 0; i < list.GetNumObjects(); i++)
     {
                              Person n = list.GetObject(i);
      if (n.GetUserData() == v.GetID())
{
n.ClearFlag(OF_HIDDEN);
n.PushActionSwitchAnim(ACTION_NEWLIST, "idle");
if (p.IsSelected())
n.Select();
n.SetUserData(0);
if(StrCompare(n.GetPrototypeFileName(), p.GetPrototypeFileName())!=0)
{
    n.ChangeModel(p.GetModelFileName());
    n.AssignCommand(DUMMY_CHANGE);
                                        }
n.SetResistance(INJUREREASON_UNKNOWN, 0.0f);
n.SetResistance(INJUREREASON_CONTAM_ATOM, 0.0f);
n.SetResistance(INJUREREASON_CONTAM_CHEM, 0.0f);
n.SetResistance(INJUREREASON_CONTAM_BIO, 0.0f);
n.SetPosition(p.GetPosition());
n.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
p.PushActionDeleteOwner(ACTION_NEWLIST);
n.PushActionExecuteCommand(ACTION_APPEND, CMD_REMOVEFH, &n, 0, false);
char wstring[6];
                                        snprintf(wstring, 6, "%s", v.GetName());
                                        wstring[0] = '0';
                                        int vID = atoi(wstring);
                               char nstring[9];
                                       snprintf(nstring, 9, "vert%i", vID);
                                        GameObjectList list = Game::GetGameObjects(nstring);
                                        for(int i = 0; i < list.GetNumObjects(); i++)
               {
                                              Vehicle vert = list.GetObject(i);
             vert.RemoveCommand(CMD_DUMMYATTACHFH);
             if(vert.GetNumUsedConnectors()>1)
             {
                                                    Game::ShowHelpTextWindow("Water Supply Needed");
                                                    /*GameObjectList list2 = vert.GetObjectsInRange(3000.0f, ACTOR_PERSON);
                                                    for(int a = 0; a < list2.GetNumObjects(); a++)
                                   {
                                                         Person ff = list2.GetObject(i);
                                                         GameObject hydrant = ff.GetHydrant();
                                                         if(hydrant.GetID() == vert.GetID());
                                                              ff.PushActionExecuteCommand(ACTION_NEWLIST, CMD_REMOVEFH, &ff, 0, false);
                                                    } */
                                              }
               }
                      }
     }
                 }
                 break;
 
                 case 4 :
                 {
                     Vehicle v(Target);
                     if(v.GetNumUsedConnectors()>0 && !v.HasCommand(CMD_DUMMYATTACHFH) && !v.HasName(NAME_SROHR))
                             Game::ShowHelpTextWindow("Water Supply Needed");
                     else
                     {
                             Caller->PushActionCheckFreeConnector(ACTION_APPEND, Target);
                    Caller->PushActionUseEquipment(ACTION_APPEND, Target, childID, 1.0f);
            Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYATTACHFH, Target, 1, false);
                     }
                  }
                  break;
 
                  case 5 :
                  {
                     Vehicle v(Target);
                     if(v.GetNumUsedConnectors()==0)
                     {
                             Caller->PushActionCheckFreeConnector(ACTION_APPEND, Target);
                   Caller->PushActionUseEquipment(ACTION_APPEND, Target, childID, 1.0f);
                   p.PlaceObjectInRightHand("mod:Models/Objects/Equipment/firehose02.v3o");
                     }
 
                  }
                  break;
 
                  case 6 :
                  {
                        GameObject g(Target);
                        float r[9];
                        g.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
                        System::Log("wFreeplayLog: Placing Standrohr");
                        Vehicle s = Game::CreateVehicle(PROTO_SROHR, NAME_SROHR);
                        if (s.IsValid())
{
   s.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
                   s.SetPosition(Target->GetPosition());
                        }
int PlayerID = Caller->GetPlayerMP();
s.SetPlayerMP(PlayerID);
Caller->PushActionUseEquipment(ACTION_APPEND, &s, childID, 1.0f);
       Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYATTACHFH, &s, 1, false);
                     }
                     break;
            }
}
};

 

 

I believe he took it the majority from another modification, but oh well, what's your point of posting this? If I'm not mistaken, this script has a command to attach a supply line to a vehicle, while in my demo mod this feature is entirely incorporated in and merged with the 'attach hose' script.

Link to comment
Share on other sites

I believe he took it the majority from another modification, but oh well, what's your point of posting this? If I'm not mistaken, this script has a command to attach a supply line to a vehicle, while in my demo mod this feature is entirely incorporated in and merged with the 'attach hose' script.

 

Yeah most of the logic used was borrowed from a few scripts combined, I believe its possible to acheive (although its not something that interests me).

 

You'd just need to edit the script to allow a hydrant or vehicle to be used as the original hook up and then the same logic will be used to attach to the second rig. 

 

However getting this script to accept limited water is a whole heap of sh*t I'd avoid. The question is: is the effort worth the reward?

Link to comment
Share on other sites

yes, in many countries there trucks tank trucks that supply smaller, such as a tank that goes fast in the forest, and a large truck that does not enter or jamming in the mud, it would be more realistic in the game! Another good thing is that it would be acabace truck in the water tank and fill the small car combat fast!

Link to comment
Share on other sites

So i have every thing working but!....

 

I can't get the supply line to un hook form the truck.... It all goes together fine but when the fires out and where cleaning up 

 

that craps stuck! 

 

any ideas?

 

 ( P.S. It shows the get in car icon instead of the unhook hose icon )

 

 

 

Edit.....! I got it to work! 

Thanks though!

Edited by NathanDollinger
Link to comment
Share on other sites

Okay, for setting up LA engines with hoses and cannon based on your two NYFD engines in the test.

 

Set type to GTF.

Have four connectors under the "superstructures" list (labeled "connector0-3"?).

For child-objects list, have a cannon (must be labeled "cannon"?), and then the connection named "water_supply". Also need an object named "controller", is that where the person put on top of the vehicle goes?

 

And then some semi-complicated script modifications afterwards.

Link to comment
Share on other sites

Okay, for setting up LA engines with hoses and cannon based on your two NYFD engines in the test.

 

Set type to GTF.

Have four connectors under the "superstructures" list (labeled "connector0-3"?).

For child-objects list, have a cannon (must be labeled "cannon"?), and then the connection named "water_supply". Also need an object named "controller", is that where the person put on top of the vehicle goes?

 

And then some semi-complicated script modifications afterwards.

 

Correct, as for the water cannon, you also need an entirely invisible TLF vehicle with the water cannon superchild. That's the proto that spawns over the engine. Check out the folder Prototypes/Vehicles/06 Objects/ for the demo mod's example. :)

Link to comment
Share on other sites

So i have every thing working but!....

 

I can't get the supply line to un hook form the truck.... It all goes together fine but when the fires out and where cleaning up 

 

that craps stuck! 

 

any ideas?

 

 ( P.S. It shows the get in car icon instead of the unhook hose icon )

 

 

 

Edit.....! I got it to work! 

Thanks though!

Try this!!

 

const char DUMMY_CHANGE[] = "DummyChange";
const char CMD_DUMMYATTACHFH[] = "DummyAttachFirehose";
const char CMD_DUMMYREMOVEFH[] = "DummyRemoveFirehose";
const char NAME_WATERCON[] = "hose_connection";
const char NAME_HYDRANT[] = "hydrant";
const char PROTO_FF[] = "mod:Prototypes/Persons/Feuerwehr/fwm.e4p";
const char PROTO_PA[] = "mod:Prototypes/Persons/Feuerwehr/fwm_pa.e4p";
const char DUMMY_HOSESON[] = "DummyHosesAreOn";
 
object RemoveFirehose2 : CommandScript
{
RemoveFirehose2()
{
                            SetIcon("install");
SetCursor("install");
SetValidTargets(ACTOR_PERSON|ACTOR_VEHICLE|ACTOR_OBJECT);
SetGroupID(CGROUP_FIREHOSE);
SetPriority(100);
}
 
bool CheckGroupVisibility(GameObject *Caller)
{
if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
return false;
return (Caller->GetFirehoseID() != 0 || Caller->GetEquipment()==EQUIP_NONE);
}
 
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if(!Caller->IsValid() || !Target->IsValid())
return false;
 
GameObject obj(Target);
if(Caller->GetEquipment()==EQUIP_NONE)
{
                        if (obj.GetType() == ACTOR_VEHICLE && obj.HasChild(NAME_WATERCON))
                           return true;
                        return false;
                }
 
if (Caller->GetEquipment()==EQUIP_FIREHOSE && Caller->GetType() == ACTOR_PERSON && Caller->GetFirehoseID() != 0)
{
if (Caller->GetID()==Target->GetID())
return true;
if (obj.GetType() == ACTOR_OBJECT && obj.IsHydrant() && obj.IsHydrantInUse() && (Caller->GetFirehoseID() == obj.GetFirehoseID()))
return true;
else if (obj.GetType() == ACTOR_VEHICLE)
{
Vehicle v(Target);
if (v.IsUsingConnector(Caller))
return true;
}
return false;
}
 
return false;
}
 
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
                if(Caller->GetEquipment()==EQUIP_FIREHOSE)
{
    GameObject hydrant = Caller->GetHydrant();
    if (!hydrant.IsValid())
return;
    Vector TargetPos;
    if (hydrant.GetType() == ACTOR_OBJECT)
TargetPos = hydrant.GetTargetPoint(Caller, TARGET_FIREHOSE_HOOKUP);
    else if (hydrant.GetType() == ACTOR_VEHICLE)
    {
Vehicle v(&hydrant);
if (!v.GetUsedConnectorPosition(Caller, TargetPos))
return;
     }
     Person p(Caller);
     if (p.GetEnteredHouseID() != -1)
     {
   Actor ha = Game::GetActor(p.GetEnteredHouseID());
   OpenHouse sourceHouse(&ha);
   if (!sourceHouse.HasGroundEntrance() || sourceHouse.GetEntranceDoorID() == 0)
return false;
   int h0 = sourceHouse.GetID();
   Vector EntrancePos = sourceHouse.GetEntrancePosition(false);
   Actor house = Game::GetActor(h0);
   Caller->PushActionMove(ACTION_NEWLIST, EntrancePos, true);
   Caller->PushActionLeaveHouse(ACTION_APPEND, &house);
     }
 
Caller->PushActionMoveWithHose(ACTION_NEWLIST, TargetPos);
Caller->PushActionUseEquipment(ACTION_APPEND, &hydrant, childID, 10.0f);
if (hydrant.GetType() == ACTOR_VEHICLE && hydrant.HasCommand(DUMMY_HOSESON))
Caller->PushActionExecuteCommand(ACTION_APPEND, "AttachFireHose", &hydrant, 3, false);
                      else
                      {
                             char wstring[5];
                             snprintf(wstring, 5, "%s", hydrant.GetName());
                             if(wstring[0]!='v' || wstring[1]!='e' || wstring[2]!='r' || wstring[3]!='t')   
                             {
                                  //Caller->PushActionWait(ACTION_APPEND, 0.3f);
                                  Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYREMOVEFH, Target, 1, false);
                             }
 
                      }
                }
                else
                {
                       Vehicle v(Target);
                       Caller->PushActionMove(ACTION_NEWLIST, v.GetChildPosition(NAME_WATERCON));
                       Caller->PushActionExecuteCommand(ACTION_APPEND, CMD_DUMMYATTACHFH, Target, 3, false);
                }
}
};
 
object DummyRemoveFirehose : CommandScript
{
DummyRemoveFirehose()
{
}
 
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
}
 
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
             if(childID == 0)
             {
                        if(Target->HasName(NAME_HYDRANT))
                        {
                             Vehicle s(Target);
                             if(s.GetNumUsedConnectors()==0)
                                 s.PushActionDeleteOwner(ACTION_NEWLIST);
                        }
                        Vector Pos;
                        float r[9];
                        Person p;
                        Person t(Caller);
                        Pos = Caller->GetPosition();
                        bool select = false;
                        Caller->GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
               int PlayerID = Caller->GetPlayerMP();
               if(Caller->HasCommand(DUMMY_CHANGE))
               {
                   if(StrCompare(Caller->GetPrototypeFileName(), PROTO_PA)==0)
                      p = Game::CreatePerson(PROTO_FF, Caller->GetName());
                            if(StrCompare(Caller->GetPrototypeFileName(), PROTO_FF)==0)
                      p = Game::CreatePerson(PROTO_PA, Caller->GetName());
                        }
                        else
                            p = Game::CreatePerson(Caller->GetPrototypeFileName(), Caller->GetName());
                        if(Caller->IsSelected())
                              p.Select();
                        p.SetHealth(t.GetHealth());
                        Caller->PushActionDeleteOwner(ACTION_APPEND);
               p.SetPlayerMP(PlayerID);
               p.SetUpgradeLevel(3);
               p.SetEquipment(EQUIP_FIREHOSE);
                        p.SetPosition(Pos);
                        p.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
             }
             if(childID == 1)
             {
                        Caller->SetEquipment(EQUIP_NONE);
             }
             if(childID == 2)
             {
                        Person p(Caller);
                        p.RemoveObjectInRightHand();
             }
}
};
Link to comment
Share on other sites

Correct, as for the water cannon, you also need an entirely invisible TLF vehicle with the water cannon superchild. That's the proto that spawns over the engine. Check out the folder Prototypes/Vehicles/06 Objects/ for the demo mod's example. :)

Will give this a shot!

Link to comment
Share on other sites

Will give this a shot!

 

 

Okay, for setting up LA engines with hoses and cannon based on your two NYFD engines in the test.

 

Set type to GTF.

Have four connectors under the "superstructures" list (labeled "connector0-3"?).

For child-objects list, have a cannon (must be labeled "cannon"?), and then the connection named "water_supply". Also need an object named "controller", is that where the person put on top of the vehicle goes?

 

And then some semi-complicated script modifications afterwards.

 Okay so i tryed this out and got it working to the point of the fire fighter setting on the truck, the icons for cool and extinguish show up, and i believe the invisible vehicle shows up 

however i get no water flow nor will the script deactivate 

 

Thoughts?

Link to comment
Share on other sites

 Okay so i tryed this out and got it working to the point of the fire fighter setting on the truck, the icons for cool and extinguish show up, and i believe the invisible vehicle shows up 

however i get no water flow nor will the script deactivate 

 

Thoughts?

 

I'm in troubleshoot mode also.

 

My vehicle is set up just like the NY engines,, and I have an invisible vehicle set up for the switch command to use.

The water level looks to be activating on it correctly, as the 100% icon shows up, however pressing it does not bring up the message about water level, so something has to be wrong.

The waterswitch command activates, person ends up on top of vehicle, vehicle gains the cool and extinguish commands, but will not spray water. nor will it deactivate.

The rapiddeployment command activates, four people exit vehicle and grab hoses, one connects hose to hydrant and then to vehicle, but hoses cannot be attached to the vehicle, and there seems to be glitches with the people equipped with hoses (they don't have drop or attach/remove commands).

 

Here are my scripts.

Command.rar

Link to comment
Share on other sites

I'm in troubleshoot mode also.

 

My vehicle is set up just like the NY engines,, and I have an invisible vehicle set up for the switch command to use.

The water level looks to be activating on it correctly, as the 100% icon shows up, however pressing it does not bring up the message about water level, so something has to be wrong.

The waterswitch command activates, person ends up on top of vehicle, vehicle gains the cool and extinguish commands, but will not spray water. nor will it deactivate.

The rapiddeployment command activates, four people exit vehicle and grab hoses, one connects hose to hydrant and then to vehicle, but hoses cannot be attached to the vehicle, and there seems to be glitches with the people equipped with hoses (they don't have drop or attach/remove commands).

 

Here are my scripts.

attachicon.gifCommand.rar

 

Well i have solved 75% of that so i will try to help!

Did you give the truck the water supply command in the editor ? If so thats wrong it should appear automatically!

You have water_supply_main as a object on your map?

You have supper structure prototypes for hose connections named connector0-3?

You have child-object names water_supply?

You have all engines set to GTF?

( The above is what would cause issues with the water level script showing up and giving the correct display along with any bug with the rapid deployment script such as not hooking to the truck, )

 

If your doing this with the LA mod 

You have water_supply_main as a object on your map?

You have supper structure prototypes for hose connections named connector0-3?

You have added attachfirehose command to personal in the editor?

You have deleted the LAEquipmentCommand.script ( For some reason this cause a issue )

You have also removed all Get(W/E).script other then the GetExtinguisher.script ( Also cause issue )

( Should fix bugs with FF's with hoses and hooking to truck! )

 

 

As for the Waterswitch script im stuck in the same spot as you! Hopefully hoppah will be kind and lend us some helpful advise! 

Link to comment
Share on other sites

Yes, I can kind if I want to.  :happy:

 

To get the cannon to deactivate you will have to add a little 'fake' animation to the vehicle. Open the main .v3o file of the vehicle (fire_engine1.V3O / fire_engine2.V3O) and add the following at the bottom of the file:

M, activate0, 1M, deactivate0, 1

That's all. The script uses the animation to check if the watercannon is either activated or not. The animation itself doesn't do anything visually, it's just another check.

 

Hereweard Fyning's WaterSwitch.script seems to look fine. :)

 

As for the disappearing attachhose/removehose commands. Open up LAEquipmentCommands.script and delete all lines that involve those 2 commands.

Link to comment
Share on other sites

Well i have solved 75% of that so i will try to help!

Did you give the truck the water supply command in the editor ? If so thats wrong it should appear automatically!

You have water_supply_main as a object on your map?

You have supper structure prototypes for hose connections named connector0-3?

You have child-object names water_supply?

You have all engines set to GTF?

( The above is what would cause issues with the water level script showing up and giving the correct display along with any bug with the rapid deployment script such as not hooking to the truck, )

 

If your doing this with the LA mod 

You have water_supply_main as a object on your map?

You have supper structure prototypes for hose connections named connector0-3?

You have added attachfirehose command to personal in the editor?

You have deleted the LAEquipmentCommand.script ( For some reason this cause a issue )

You have also removed all Get(W/E).script other then the GetExtinguisher.script ( Also cause issue )

( Should fix bugs with FF's with hoses and hooking to truck! )

 

 

As for the Waterswitch script im stuck in the same spot as you! Hopefully hoppah will be kind and lend us some helpful advise! 

 

Vehicle doesn't have command in editor, so that's fine.

A "water_supply_main" object was placed on map.

Four superstruct connectors named connector0-3, and child "water_supply", yep.

Vehicle type set to GTF, yep.

As for the equipment command, Hoppah had an idea...

I guess I need to add the attach command (remove also?).

 

Yes, I can kind if I want to.  :happy:

 

To get the cannon to deactivate you will have to add a little 'fake' animation to the vehicle. Open the main .v3o file of the vehicle (fire_engine1.V3O / fire_engine2.V3O) and add the following at the bottom of the file:

M, activate0, 1M, deactivate0, 1

That's all. The script uses the animation to check if the watercannon is either activated or not. The animation itself doesn't do anything visually, it's just another check.

 

Hereweard Fyning's WaterSwitch.script seems to look fine. :)

 

As for the disappearing attachhose/removehose commands. Open up LAEquipmentCommands.script and delete all lines that involve those 2 commands.

I'll edit the model file and comment out the hose commands in the LA file, and see how it goes.

 

Edit: Yes, cannon is working now.

 

A quick question about the LA Brush Truck. If I set max connectors for those prototypes to 1 in the rapiddeployment script, will it work correctly?

 

Edit2: Ok, added attachfirehose to my people, and hovering over the vehicle brings up the icon and a click will activate, but the person just moves to near the back of the truck and nothing happens. Rapiddeployment also fails to work. Do the connector prototypes need to have a specific filename, or do the superstructs just need to have the connector name? For some reason the names did save on the connectors and they were named pump0-3. They connect now, though I have to add removefirehose to them still, but that should solve that problem.

 

Also, limitedwater doesn't seem to be working, at least with the cannon. The vehicle shows the waterlevel icon, so it gets the command added by the scripts, but the water never depletes and no message shows when I click on the command. That last seems to indicate it's not just a deal with it not recognizing the cannon.

Link to comment
Share on other sites

A quick question about the LA Brush Truck. If I set max connectors for those prototypes to 1 in the rapiddeployment script, will it work correctly?

 

 

Also, limitedwater doesn't seem to be working, at least with the cannon. The vehicle shows the waterlevel icon, so it gets the command added by the scripts, but the water never depletes and no message shows when I click on the command. That last seems to indicate it's not just a deal with it not recognizing the cannon.

 

As for the brush truck, yes you will have to set the max to 1 in the script, just like it's kinda done in the older rapid deployment script.

 

Does the limited water at least work for the hose connections?

 

Can you post your edited scripts here? I'll take a quick look. :)

Link to comment
Share on other sites

Another thing about the brush truck. Since I've got a crew of two, how can it be worked so that they both get out, one hooks a hose while the other just connects a supply?

 

Also, is there a way to limit the amount of people who get out with rapiddeployment when you have less crew than hose connections? I've got my tender with three seats (since it isn't an extended cab), and 4 hose connections, but I'd like to keep the 3rd guy inside for the water cannon command.

 

So far, the water isn't working at all. Vehicles that get spawned on startup at least have the water level icon, but I sent more onto the map and they didn't get assigned that dummy.

 

Noticed this is my logfile for the startup, too. Something's amiss.

 

?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
?Tried to assign unknown command 'DummyUpdateWaterLevel' to object U
!WATER, Start DummyCheckWaterSupply

 

Scripts here: Command.rar fp_freeplay.rar

 

Maybe my use of proto compares instead of vehicletype is messing up something?

 

Edit: Just noticed something. I don't have the correct file for "GameObject mDummy = Game::CreateObject("mod:Prototypes/06 Objects/Misc/empty.e4p", "WaterTankDummy");", though I noticed your test mod doesn't either and it worked. Added proto and corrected path, but no change.

Link to comment
Share on other sites

Another thing about the brush truck. Since I've got a crew of two, how can it be worked so that they both get out, one hooks a hose while the other just connects a supply?

 

Also, is there a way to limit the amount of people who get out with rapiddeployment when you have less crew than hose connections? I've got my tender with three seats (since it isn't an extended cab), and 4 hose connections, but I'd like to keep the 3rd guy inside for the water cannon command.

 

So far, the water isn't working at all. Vehicles that get spawned on startup at least have the water level icon, but I sent more onto the map and they didn't get assigned that dummy.

 

Noticed this is my logfile for the startup, too. Something's amiss.

 

 

Scripts here: attachicon.gifCommand.rar attachicon.giffp_freeplay.rar

 

Maybe my use of proto compares instead of vehicletype is messing up something?

 

Edit: Just noticed something. I don't have the correct file for "GameObject mDummy = Game::CreateObject("mod:Prototypes/06 Objects/Misc/empty.e4p", "WaterTankDummy");", though I noticed your test mod doesn't either and it worked.

 

It says the command 'DummyUpdateWaterLevel' is unknown, so that probably means the commandscript cannot be loaded because of mistakes in it which are caused by your personal changes. However, I've taken a look at the script and noticed that there's at least missing symbols in the script.

 

 

Make sure to add a ; after the following 4 lines (lines 72-81 AND lines 208-217).

WaterLevel = MAX_WATER_TENDERWaterLevel = MAX_WATER_LADDERWaterLevel = MAX_WATER_ENGINEWaterLevel = MAX_WATER_ENGINE2

You forgot to add that symbol in at least two locations in the script.

 

Other than that, the script seems to look good (I may have missed other things).

 

 

Hoppah

Link to comment
Share on other sites

Make sure to add a ; after the following 4 lines:
WaterLevel = MAX_WATER_TENDERWaterLevel = MAX_WATER_LADDERWaterLevel = MAX_WATER_ENGINEWaterLevel = MAX_WATER_ENGINE2

 

Ah, missed that. Hopefully that will be it, or at least let me hit any other errors on the way.

 

Edit: Nope, no change, still the same errors in the log and nothing working. All missing semi-colons were added, so it's something else that isn't actually bringing up an error.

WaterSupplyFreeplay.rar

 

Link to comment
Share on other sites

My current position - absolutely everything works great, not using the deck gun at all, just deactivated it. The water supply works a treat. However my only bug is rapid deploy. The 4 guys get out, 3 hook up just fine, the 4th gets the hose, hooks it up fine, then gets the second hose, however he cant attatch, and has no attatch command.

 

Now personally Ithink I'd prefer him to just stay and monitor pump pressure so I may edit it myself, but just a heads up in case anyone else was having this issue me too :)

 

Awesome work Hop, this is another great addition to the world of Em4 :)

Link to comment
Share on other sites

My current position - absolutely everything works great, not using the deck gun at all, just deactivated it. The water supply works a treat. However my only bug is rapid deploy. The 4 guys get out, 3 hook up just fine, the 4th gets the hose, hooks it up fine, then gets the second hose, however he cant attatch, and has no attatch command.

 

Man, if we aren't opposites... My rapiddeploy works flawlessly with the new hookups, but I've got a FUBAR watersupply.

 

My rapiddeployment script was attached a few posts back if you want to peek at it. But your idea for that last guy is kind of intriguing, though I think I'll keep mine as is.

Link to comment
Share on other sites

Haha, how peculiar? Whats up with your supply monitor? Mine works great :) although I'm not using the deck gun :)

 

Edit, having some issues trying to stop the 4th guy hooking up again after he adds the supply line. Any help would be appreciated, I'm guessing it's something to do with child 3 of the attatch firehose script, but I'm dumbfounded haha

Link to comment
Share on other sites

I think it's one of those pushactions that would control it. Comment out one of the lines and see what effect it has.

 

As for another problem of mine, my tender waterswitch doesn't want to work correctly. It activates and deactivates fine, but it won't extinguish or cool. I wonder if setting the cannon vehicle it creates to the LPF type instead of TLF is causing issues. I'd like the tender and my crash engines to have the more powerful deck gun so they have a difference between the regular engines.

 

And Hoppah, since you were asking for a water supply truck for use with some vehicle to vehicle supply functionality in the future, Freakinmusket did make one for his LA County submod.

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