Jump to content
bennie900

SoSi script not working..

Recommended Posts

//********************************************************************************
******************
// #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.1
object 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.2
object 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.3
object DUMMYFindPath : CommandScript
{
DUMMYFindPath()
{
SetGroupID(DummyGroup);
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
return false;
}

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

// 01.4
object 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 help

Ben

Link to comment
Share on other sites

Guest Oliwerko

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.

Link to comment
Share on other sites

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

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