bennie900 Posted February 12, 2008 Report Share Posted February 12, 2008 //**************************************************************************************************// #Version 2.0# ****// ****// Includes: all Sirens ****// ****// 1.0| VCmdSiren ****// 1.1| DUMMYUpdatePos ****// 1.2| DUMMYDisableSiren ****// 1.3| DUMMYFindPath ****// 1.4| DUMMYHasSiren ****// ****// childID 1 for disabling bluelights. ****// ****// ****//**************************************************************************************************const char IMG[] = "sosi";const char EACTION_FINDPATH[] = "EActionFindPath";const char DUMMY_HASSIREN[] = "DUMMYHasSiren";const char DUMMY_UPDATEPOS[] = "DUMMYUpdatePos";const char DUMMY_FINDPATH[] = "DUMMYFindPath";const char CMD_MOVETO[] = "MoveTo";const char NAME_DUMMYOBJECT[] = "HelpingObjekt_Roger";// Paths to vehicle prototypes:const char PROTO_C_PD[] = "mod:Prototypes/Vehicles/Police/City PD.e4p";int DummyGroup = 20;object VCmdSiren : CommandScript{ VCmdSiren() { SetIcon(IMG); SetCursor(IMG); SetRestrictions(RESTRICT_SELFEXECUTE); } bool CheckPossible(GameObject *Caller) { if (!Caller->IsValid()) return false; if (Caller->GetType() == ACTOR_VEHICLE) { return true; } return false; } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { if (!Target->IsValid() || Target->GetID() != Caller->GetID()) return false; if (!Caller->HasCommand(CMD_MOVETO) || Caller->GetType() != ACTOR_VEHICLE) return false; return true; } void PushActions(GameObject *Caller, Actor *Target, int childID) { Vehicle v(Caller); if (!v.HasCommand(DUMMY_HASSIREN) && (childID != 2 && childID != 1)) { int soundID; v.EnableBlueLights(true); Vector CarPos = v.GetPosition(); // Paths to .wav files if (StrCompare(v.GetPrototypeFileName(), PROTO_C_PD) == 0) { soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Police.wav", CarPos, true); } GameObject mDummy = Game::CreateObject("mod:Prototypes/Objects/Misc/empty.e4p", NAME_DUMMYOBJECT); mDummy.Hide(); mDummy.SetPosition(CarPos); mDummy.SetUserData(soundID); mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, &v, soundID, false); v.SetUserData(soundID); v.AssignCommand(DUMMY_HASSIREN); return; } if (v.HasCommand(DUMMY_HASSIREN)) { if (childID == 1) { v.EnableBlueLights(false); } if (v.HasCommand(DUMMY_HASSIREN)) { int ref = Caller->GetUserData(); Audio::StopSample(ref); GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT); for(int i=0; i<list.GetNumObjects(); i++) { GameObject *obj = list.GetObject(i); if (obj->GetUserData() == ref) { int mSirTest = i; } } GameObject *obj = list.GetObject(mSirTest); obj->PushActionDeleteOwner(ACTION_NEWLIST); v.RemoveCommand(DUMMY_HASSIREN); } return; } }};// 01.1object DUMMYUpdatePos : CommandScript{ DUMMYUpdatePos() { SetGroupID(DummyGroup); } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { } void PushActions(GameObject *Caller, Actor *Target, int childID) { Vehicle v(Target); GameObject mDummy(Caller); Vector CarPos = v.GetPosition(); if (v.IsDestroyed() || !v.IsValid()) { int ref = mDummy.GetUserData(); Audio::StopSample(ref); mDummy.PushActionDeleteOwner(ACTION_NEWLIST); } else { mDummy.SetPosition(CarPos); Audio::UpdatePos(childID, CarPos, true); if (v.IsCurrentAction(EACTION_FINDPATH)) { if (!v.HasCommand(DUMMY_FINDPATH)) { v.AssignCommand(DUMMY_FINDPATH); } } mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, Target, childID, false); } if (v.HasCommand(DUMMY_FINDPATH)) { if (!v.IsCurrentAction(EACTION_FINDPATH) && v.GetNumActions() == 0) { v.RemoveCommand(DUMMY_HASSIREN); v.RemoveCommand(DUMMY_FINDPATH); int ref = Caller->GetUserData(); Audio::StopSample(ref); GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT); for(int i = 0; i < list.GetNumObjects(); i++) { GameObject *obj = list.GetObject(i); if (obj->GetUserData() == ref) { int mSirTest = i; GameObject *obj = list.GetObject(mSirTest); obj->PushActionDeleteOwner(ACTION_NEWLIST); v.RemoveCommand(DUMMY_HASSIREN); if (v.HasCommand(DUMMY_FINDPATH)) { v.RemoveCommand(DUMMY_FINDPATH); } } } } } }};// 01.2object DUMMYDisableSiren : CommandScript{ DUMMYDisableSiren() { SetGroupID(DummyGroup); } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { } void PushActions(GameObject *Caller, Actor *Target, int childID) { Vehicle v(Caller); if (childID == 1) { v.EnableBlueLights(false); } int ref = Caller->GetUserData(); Audio::StopSample(ref); GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT); for(int i = 0; i < list.GetNumObjects(); i++) { GameObject *obj = list.GetObject(i); if (obj->GetUserData() == ref) { int mSirTest = i; GameObject *obj = list.GetObject(mSirTest); obj->PushActionDeleteOwner(ACTION_NEWLIST); v.RemoveCommand(DUMMY_HASSIREN); if (v.HasCommand(DUMMY_FINDPATH)) { v.RemoveCommand(DUMMY_FINDPATH); } } } }};// 01.3object DUMMYFindPath : CommandScript{ DUMMYFindPath() { SetGroupID(DummyGroup); } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { return false; } void PushActions(GameObject *Caller, Actor *Target, int childID) { }};// 01.4object DUMMYHasSiren : CommandScript{ DUMMYHasSiren() { SetGroupID(DummyGroup); } bool CheckGroupVisibility(GameObject *Caller) { return false; } bool CheckPossible(GameObject *Caller) { return false; } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { return false; } void PushActions(GameObject *Caller, Actor *Target, int childID) { }};Im wanting the siren on the car but it does not work, the siren does not run when you move the car and it only works when you hold the horn button, pleas helpBen Quote Link to comment Share on other sites More sharing options...
Guest Oliwerko Posted February 12, 2008 Report Share Posted February 12, 2008 Have you overwritten the prototype files? Quote Link to comment Share on other sites More sharing options...
bennie900 Posted February 12, 2008 Author Report Share Posted February 12, 2008 overwritten with what? Quote Link to comment Share on other sites More sharing options...
Guest Oliwerko Posted February 13, 2008 Report Share Posted February 13, 2008 Are you using complete SoSi mod or just the script?Because you have to use also edited prototypes, not just the scripts. Quote Link to comment Share on other sites More sharing options...
Stan Posted February 13, 2008 Report Share Posted February 13, 2008 edited prototypesThats new for me, you only ened the script and give the vehicle the commands thats all. Biut i tested his mod, it is working fine, there's no bug at all. Or he is wrongly using it or it's his pc Quote Link to comment Share on other sites More sharing options...
Guest Oliwerko Posted February 13, 2008 Report Share Posted February 13, 2008 Well, I tried only scripts and the when I clicked the button nothing happened. I had to overwrite the prototypes with the ones packed with the mod.But maybe there are more versions of the mod?EDIT:const char PROTO_C_PD[] = "mod:Prototypes/Vehicles/Police/City PD.e4p";See? I guess this plays a role. Quote Link to comment Share on other sites More sharing options...
Stan Posted February 13, 2008 Report Share Posted February 13, 2008 But maybe there are more versions of the mod?It's the version I have and it's working 100%, even the script is 100% correct. The only thing not working is the autosiren script and I supose that's why he posted here, because the sirenes didn't play when he moved the car. If you click on the Sosi button the siren will just work.Case resolved Quote Link to comment Share on other sites More sharing options...
bennie900 Posted February 13, 2008 Author Report Share Posted February 13, 2008 "Case resolved " I know you said that but Hoppah do you have a take on this? Quote Link to comment Share on other sites More sharing options...