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; } } };