Jump to content
Kookas

Editing the Move Command

Recommended Posts

I'm starting to get a feel for the scripting of EM4 now, so I'm now moving onto creating my own chase command out of the Move command (the one for Siren Script by Hoppah). I know how to control vectors, and how to send vehicles to given vectors now. The issue I'm having, however, is that in-game, the Move command will not work on people, despite the fact that I have added ACTOR_PERSON to the SetValidTargets. Here is my script so far:

//**************************************************************************************************
// #Version 2.0# ****
// ****
// Changes: - Disables Sirens after arriving targetpoint. ****
// - Enables Sirens if vehicle has VCmdAutoSirenOff. ****
// ****
// ****
// DO NEVER REPLACE ORIGINAL SCRIPTS USED BY EM4 IN YOUR DATA-FOLDER! ****
//**************************************************************************************************

const char CMD_SIREN[] = "VCmdSiren";
const char CMD_AUTOSIREN_OFF[] = "VCmdAutoSirenOff";
const char DUMMY_HASSIREN[] = "DummyHasSiren";
const char DUMMY_DISABLE[] = "DummyDisableSiren";

object MoveTo : CommandScript
{
MoveResult mr;

MoveTo()
{
SetValidTargets( ACTOR_FLOOR | ACTOR_OBJECT | ACTOR_VIRTUAL | ACTOR_HOUSE | ACTOR_OPEN_HOUSE | ACTOR_PERSON );
SetHighlightingEnabled(false);
SetDeselectCaller(false);
//SetActivationByLeftClick(true);
}

bool CheckPossible(GameObject *Caller)
{

if( Caller->GetType()==ACTOR_VEHICLE )
{

Vehicle v = Caller;

if( v.GetNumPassengers() == 0 )
return false;
else
return true;

}
else
{

return true;

}

}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
mr = Commands::CheckMoveConditions(Caller, Target, childID);
if ( mr.Mode == MOVE_ABORT )
return false;

return true;
}

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

// test variable
Vector personpos = Target->GetPosition();

if (mr.Mode == MOVE_ABORT)
return;

if( Target->GetType()==ACTOR_PERSON )
{

System::Log("Human target found.");

}

switch(mr.Mode)
{
case MOVE_TO_POSITION:
{
if (Caller->GetFirehoseID() > 0)
{
Caller->PushActionMoveWithHose(ACTION_NEWLIST, mr.Target);
return;
}
if (Caller->GetType()==ACTOR_VEHICLE && Target->GetType()==ACTOR_PERSON)
{
Caller->PushActionMove(ACTION_NEWLIST, personpos, true);
return;
}
Caller->PushActionMove(ACTION_NEWLIST, mr.Target, true);
//Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_DISABLE, Caller, 2, false);
break;
}

case MOVE_INTO_HOUSE:
{
Caller->PushActionMove(ACTION_NEWLIST, mr.Intermediate1, true);
Caller->PushActionEnterHouse(ACTION_APPEND, &mr.EnterHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Target, true);
break;
}

case MOVE_HOUSE_TO_HOUSE:
{
Caller->PushActionMove(ACTION_NEWLIST, mr.Intermediate1, true);
Caller->PushActionLeaveHouse(ACTION_APPEND, &mr.LeaveHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Intermediate2, true);
Caller->PushActionEnterHouse(ACTION_APPEND, &mr.EnterHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Target, true);
break;
}

case MOVE_HOUSE_TO_POSITION:
{
Caller->PushActionMove(ACTION_NEWLIST, mr.Intermediate1, true);
Caller->PushActionLeaveHouse(ACTION_APPEND, &mr.LeaveHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Target, true);
break;
}
}

if (Caller->GetType() == ACTOR_VEHICLE)
{
Vehicle v(Caller);
if (v.IsLightOn())
{
Caller->PushActionLightOn(ACTION_INSERT, false);
}
if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF))
{
Game::ExecuteCommand(CMD_SIREN, &v, &v);
}
}

// Special code for fgrr (Bergefahrzeug). Deinstalls itself automatically
if (mr.UnInstall)
{
Vehicle v(Caller);
if (v.GetVehicleType() == VT_THW_FGRR_BKF)
{
//System::Print("FGRR: Mode 1 - DeInstall");
Caller->PushActionDeinstall(ACTION_INSERT);
}

else if (v.GetVehicleType() == VT_FIREFIGHTERS_DLK)
{
if (mr.BasketDown && mr.UnInstall)
{
Caller->PushActionDeinstall(ACTION_INSERT);
Caller->PushActionBasketDown(ACTION_INSERT, Vector(0.f, 0.f, 0.f));
}
else if (mr.BasketDown)
Caller->PushActionBasketDown(ACTION_INSERT, Vector(0.f, 0.f, 0.f));
else if (mr.UnInstall)
Caller->PushActionDeinstall(ACTION_INSERT);
}
}
//Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_DISABLE, Caller, 2, false);
}
};

I will be very grateful for any help :)

Link to comment
Share on other sites

Here's another thing that's really really annoying me. For some reason, it says VehicleList can't be called in the current scope. I've been looking at other scripts, and they have no problem with it! -.-

Link to comment
Share on other sites

Hmm, I'm not sure how the groups work.

Although now it's complaining that I'm using the wrong member access operator. I tried both . and ->. I think it's just the same thing as when they say "Expected ;", just a way of saying it doesn't know quite what's wrong but something is :\

//**************************************************************************************************
// #Version 2.0# ****
// ****
// Changes: - Disables Sirens after arriving targetpoint. ****
// - Enables Sirens if vehicle has VCmdAutoSirenOff. ****
// ****
// ****
// DO NEVER REPLACE ORIGINAL SCRIPTS USED BY EM4 IN YOUR DATA-FOLDER! ****
//**************************************************************************************************

/*

const char CMD_SIREN[] = "VCmdSiren";
const char CMD_AUTOSIREN_OFF[] = "VCmdAutoSirenOff";
const char DUMMY_HASSIREN[] = "DummyHasSiren";
const char DUMMY_DISABLE[] = "DummyDisableSiren";

object MoveTo : CommandScript
{
MoveResult mr;

MoveTo()
{
SetValidTargets( ACTOR_FLOOR | ACTOR_OBJECT | ACTOR_VIRTUAL | ACTOR_HOUSE | ACTOR_OPEN_HOUSE | ACTOR_PERSON );
SetHighlightingEnabled(false);
SetDeselectCaller(false);
//SetActivationByLeftClick(true);
}

bool CheckPossible(GameObject *Caller)
{

if( Caller->GetType()==ACTOR_VEHICLE )
{

Vehicle v = Caller;

if( v.GetNumPassengers() == 0 )
return false;
else
return true;

}
else
{

return true;

}

}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
mr = Commands::CheckMoveConditions(Caller, Target, childID);
if ( mr.Mode == MOVE_ABORT )
return false;

return true;
}

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

// test variable
Vector personpos = Target->GetPosition();

if (mr.Mode == MOVE_ABORT)
return;

if( Target->GetType()==ACTOR_PERSON )
{

System::Log("Human target found.");

}

switch(mr.Mode)
{
case MOVE_TO_POSITION:
{
if (Caller->GetFirehoseID() > 0)
{
Caller->PushActionMoveWithHose(ACTION_NEWLIST, mr.Target);
return;
}
if (Caller->GetType()==ACTOR_VEHICLE && Target->GetType()==ACTOR_PERSON)
{
Caller->PushActionMove(ACTION_NEWLIST, personpos, true);
return;
}
Caller->PushActionMove(ACTION_NEWLIST, mr.Target, true);
//Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_DISABLE, Caller, 2, false);
break;
}

case MOVE_INTO_HOUSE:
{
Caller->PushActionMove(ACTION_NEWLIST, mr.Intermediate1, true);
Caller->PushActionEnterHouse(ACTION_APPEND, &mr.EnterHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Target, true);
break;
}

case MOVE_HOUSE_TO_HOUSE:
{
Caller->PushActionMove(ACTION_NEWLIST, mr.Intermediate1, true);
Caller->PushActionLeaveHouse(ACTION_APPEND, &mr.LeaveHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Intermediate2, true);
Caller->PushActionEnterHouse(ACTION_APPEND, &mr.EnterHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Target, true);
break;
}

case MOVE_HOUSE_TO_POSITION:
{
Caller->PushActionMove(ACTION_NEWLIST, mr.Intermediate1, true);
Caller->PushActionLeaveHouse(ACTION_APPEND, &mr.LeaveHouse);
Caller->PushActionMove(ACTION_APPEND, mr.Target, true);
break;
}
}

if (Caller->GetType() == ACTOR_VEHICLE)
{
Vehicle v(Caller);
if (v.IsLightOn())
{
Caller->PushActionLightOn(ACTION_INSERT, false);
}
if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF))
{
Game::ExecuteCommand(CMD_SIREN, &v, &v);
}
}

// Special code for fgrr (Bergefahrzeug). Deinstalls itself automatically
if (mr.UnInstall)
{
Vehicle v(Caller);
if (v.GetVehicleType() == VT_THW_FGRR_BKF)
{
//System::Print("FGRR: Mode 1 - DeInstall");
Caller->PushActionDeinstall(ACTION_INSERT);
}

else if (v.GetVehicleType() == VT_FIREFIGHTERS_DLK)
{
if (mr.BasketDown && mr.UnInstall)
{
Caller->PushActionDeinstall(ACTION_INSERT);
Caller->PushActionBasketDown(ACTION_INSERT, Vector(0.f, 0.f, 0.f));
}
else if (mr.BasketDown)
Caller->PushActionBasketDown(ACTION_INSERT, Vector(0.f, 0.f, 0.f));
else if (mr.UnInstall)
Caller->PushActionDeinstall(ACTION_INSERT);
}
}
//Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_DISABLE, Caller, 2, false);
}
}; */

const char CMD_SIREN[] = "VCmdSiren";
const char CMD_AUTOSIREN_OFF[] = "VCmdAutoSirenOff";
const char DUMMY_HASSIREN[] = "DummyHasSiren";
const char DUMMY_DISABLE[] = "DummyDisableSiren";

object MoveTo : CommandScript
{

MoveTo()
{
SetValidTargets( ACTOR_FLOOR | ACTOR_OBJECT | ACTOR_VIRTUAL | ACTOR_HOUSE | ACTOR_OPEN_HOUSE );
SetIcon("dispatch");
SetHighlightingEnabled(false);
SetDeselectCaller(false);
SetPossibleCallers( ACTOR_PERSON );
}

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


return true;
}

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

Vector gotoTarget = Game::GetCommandPos();

Vehicle *kingCar = NULL;

VehicleList carPol(VT_POLICE_MTW, VT_POLICE_STW);

for (int i = 0; i < carPol.GetNumVehicles(); i++)
{

Vehicle *ourCar = carPol.GetVehicle(i);

float Distance = Math::dist(gotoTarget.x, gotoTarget.y, ourCar->GetPosition().x, ourCar->GetPosition().y);

if(kingCar == NULL || (Distance < Math::dist(gotoTarget.x, gotoTarget.y, kingCar->GetPosition().x, kingCar->GetPosition().y)))
kingCar = ourCar;

}

kingCar.PushActionMove(ACTION_NEWLIST, gotoTarget, true);

}
};

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