//******************************************************************************************// #Version 2.6# // // Includes: All MP5 Commands // // - PcmdMP5Get // - PcmdMP5Remove // - PcmdMP5Shoot // - PcmdMP5Aim // - PcmdMP5AimEnd // - PcmdMP5MoveTo // - DummyMP5// // Script by Hoppah// // Usage of this script in other mods is NOT allowed without permission of Hoppah////****************************************************************************************** const char CMD_GETMP5[] = "PcmdMP5Get";const char CMD_REMOVEMP5[] = "PcmdMP5Remove";const char CMD_SHOOTMP5[] = "PcmdMP5Shoot";const char CMD_AIMMP5[] = "PcmdMP5Aim";const char CMD_AIMENDMP5[] = "PcmdMP5AimEnd";const char CMD_MOVEMP5[] = "PcmdMP5MoveTo";const char DUMMY_MP5[] = "DummyMP5";const char CMD_DOORS[] = "OpenCloseDoor";const char OBJ_MP5_IDLE[] = "01 LA Equipment/mp5_idle.V3O";const char OBJ_MP5_AIM[] = "01 LA Equipment/mp5_aim.V3O";const char SND_GETMP5[] = "mod:Audio/FX/Misc/mp5_get.wav";const char SND_FIREMP5[] = "mod:Audio/FX/Misc/mp5_shoot.wav";const char SND_UNLOCK[] = "mod:Audio/FX/Misc/unlock_weapon.wav";const char PARTICLE_FLASH[] = "mod:Prototypes/Objects/05 LA Particles/muzzleflash04.e4p";const char NAME_FLASH[] = "MuzzleFlash"; int DummyGroup = 20; object PcmdMP5Get : CommandScript{ PcmdMP5Get(){ SetIcon("mp5"); SetCursor("mp5");SetPriority(190);SetValidTargets(ACTOR_VEHICLE | ACTOR_OBJECT);SetGroupID(CGROUP_GETEQUIPMENT);SetRestrictions(RESTRICT_NOTDESTROYED | RESTRICT_NOTBURNING | RESTRICT_HASFLASHGRENADE);SetPossibleCallers(ACTOR_PERSON);SetNeedsCarWithFlagSet(OF_HAS_FLASHGRENADE);} bool CheckTarget(GameObject *Caller, Actor *Target, int childID){if(!Caller->IsValid() || !Target || !Target->IsValid() || Target->GetType()!=ACTOR_VEHICLE)return false; if(Caller->GetObjectType()==TYPE_PERSON){Person p(Caller); Vehicle v(Target); if (v.IsDestroyed())return false; if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1)) return false; Vehicle v(Target);if ((v.HasCommand("FlyTo") || v.HasCommand("VcmdDeInstallRope")) && !v.IsOnGround())return false; if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck01_lapd.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_armoured_vehicle.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_truck.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/09 Government/fbi_suv.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_suv.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/09 Government/fbi_command.e4p") == 0) StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/dodge_charger_lapd.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapd_slicktop.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_umpc.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/bpat_dodge_charger.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapd.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/lapd_impala.e4p") == 0 ||{return true;} else if(v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/ATF_cv.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/atf_mcp.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/as350_lapd.e4p") == 0){return true;} return false;}} void PushActions(GameObject *Caller, Actor *Target, int childID){Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);Caller->PushActionMove(ACTION_NEWLIST, TargetPos);Caller->PushActionTurnTo(ACTION_APPEND, Target);Caller->PushActionGetEquipment(ACTION_APPEND, Target, EQUIP_NONE);Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_MP5, Target, 1, false);}}; object PcmdMP5Remove : CommandScript{ PcmdMP5Remove(){ SetIcon("mp5remove"); SetCursor("mp5remove");SetValidTargets(ACTOR_VEHICLE | ACTOR_OBJECT);SetRestrictions(RESTRICT_NOTDESTROYED | RESTRICT_NOTBURNING | RESTRICT_HASFLASHGRENADE);SetPossibleCallers(ACTOR_PERSON);SetNeedsCarWithFlagSet(OF_HAS_FLASHGRENADE);} bool CheckTarget(GameObject *Caller, Actor *Target, int childID){if(!Caller->IsValid() || !Target || !Target->IsValid() || Target->GetType()!=ACTOR_VEHICLE)return false; if(Caller->GetObjectType()==TYPE_PERSON){Person p(Caller);Vehicle v(Target); if (v.IsDestroyed())return false; if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1)) return false; Vehicle v(Target);if ((v.HasCommand("FlyTo") || v.HasCommand("VcmdDeInstallRope")) && !v.IsOnGround())return false; if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck01_lapd.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_armoured_vehicle.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_truck.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/09 Government/fbi_suv.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_suv.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/09 Government/fbi_command.e4p") == 0) StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/dodge_charger_lapd.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapd_slicktop.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_umpc.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/bpat_dodge_charger.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapd.e4p") == 0 || StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/lapd_impala.e4p") == 0 ||{return true;} else if(v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/ATF_cv.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/atf_mcp.e4p") == 0 ||StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/as350_lapd.e4p") == 0){return true;} return false;}} void PushActions(GameObject *Caller, Actor *Target, int childID){Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);Caller->PushActionMove(ACTION_NEWLIST, TargetPos);Caller->PushActionTurnTo(ACTION_APPEND, Target);Caller->PushActionGetEquipment(ACTION_APPEND, Target, EQUIP_NONE);Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_MP5, Target, 2, false);}}; object PcmdMP5Shoot : CommandScript{float Range; PcmdMP5Shoot(){ SetIcon("shoot"); SetCursor("aim");SetValidTargets(ACTOR_PERSON | ACTOR_VEHICLE);SetRestrictions(RESTRICT_SHOOTABLE | RESTRICT_NOTINJURED);//SetActivationByLeftClick(true);SetDeselectCaller(false);SetKeepAsCurrentCommand(true);SetPossibleCallers(ACTOR_PERSON);Range = 900.f;} bool CheckPossible(GameObject *Caller){/*if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)return false;*/Person p(Caller);if (!p.IsValid())return false;return true;} bool CheckTarget(GameObject *Caller, Actor *Target, int childID){if(!Caller->IsValid() || !Target->IsValid() || Target->GetID() == Caller->GetID())return false; Person p(Caller);if(p.GetBoundingRadiusDistXYToObject(Target) > Range)return false; if(Target->GetType()==ACTOR_PERSON){ Person t(Target);if (t.IsValid() && t.GetEnteredHouseID() == p.GetEnteredHouseID()){if(p.IsAiming()){Game::ActivateSceneLens(true);}return true;}} if(Target->GetType()==ACTOR_VEHICLE){Vehicle v(Target);if (!v.IsCivilCar())SetPriority(-700); if (v.IsValid() && !v.IsDestroyed() && v.IsFlagSet(OF_SHOOTABLE) && p.GetEnteredHouseID() == -1){if ((v.GetVehicleType() == VT_POLICE_PHC || v.GetVehicleType() == VT_AMBULANCE_RHC || v.GetVehicleType() == VT_THW_FGRT_BH) && !v.IsOnGround())return false;if(p.IsAiming()){Game::ActivateSceneLens(true);}return true;}} return false; } void PushActions(GameObject *Caller, Actor *Target, int childID){Person p(Caller);if(!p.IsAiming()){Vector Pos = p.GetPosition();Audio::PlaySample3D(SND_UNLOCK, Pos);p.PlaceObjectInRightHand(OBJ_MP5_AIM);p.PushActionPrepareAim(ACTION_NEWLIST);p.AssignCommand(CMD_AIMENDMP5); p.AssignCommand(CMD_MOVEMP5);p.RemoveCommand(CMD_REMOVEMP5);p.RemoveCommand(CMD_AIMMP5);} else{Vector Pos = p.GetPosition();Audio::PlaySample3D(SND_FIREMP5, Pos); float r[9];p.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]); GameObject f = Game::CreateObject(PARTICLE_FLASH, NAME_FLASH);f.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);f.SetPosition(Pos);f.PushActionWait(ACTION_NEWLIST, 0.5f);f.PushActionDeleteOwner(ACTION_APPEND); if (Target->GetType() == ACTOR_PERSON){Person t(Target);if (t.IsValid() && !t.IsDead()){if (p.GetBoundingRadiusDistXYToObject(&t) < 50.f){t.Kill(INJUREREASON_SHOT);}else if (p.GetBoundingRadiusDistXYToObject(&t) < 100.f){t.Injure(INJUREREASON_SHOT);}else if(p.GetBoundingRadiusDistXYToObject(&t) < 200.f){t.Hurt(INJUREREASON_SHOT, 600.f);}else if(p.GetBoundingRadiusDistXYToObject(&t) < 300.f){t.Hurt(INJUREREASON_SHOT, 500.f);}else if(p.GetBoundingRadiusDistXYToObject(&t) < 400.f){t.Hurt(INJUREREASON_SHOT, 400.f);}else if(p.GetBoundingRadiusDistXYToObject(&t) < 500.f){t.Hurt(INJUREREASON_SHOT, 300.f);}else if(p.GetBoundingRadiusDistXYToObject(&t) < 600.f){t.Hurt(INJUREREASON_SHOT, 200.f);}else if(p.GetBoundingRadiusDistXYToObject(&t) < 1000.f){t.Hurt(INJUREREASON_SHOT, 100.f);}}} if (Target->GetType() == ACTOR_VEHICLE){Vehicle v(Target);if (v.IsValid() && !v.IsDestroyed()){if(p.GetBoundingRadiusDistXYToObject(&v) < 300.f){v.Damage(330.f);}else if(p.GetBoundingRadiusDistXYToObject(&v) < 500.f){v.Damage(230.f);}else if(p.GetBoundingRadiusDistXYToObject(&v) < 700.f){v.Damage(140.f);} else if(p.GetBoundingRadiusDistXYToObject(&v) < 1000.f){v.Damage(100.f);}}}} }}; object PcmdMP5Aim : CommandScript{float Range; PcmdMP5Aim(){ SetIcon("aim"); SetCursor("aim");SetValidTargets(ACTOR_PERSON);SetPriority(220);SetDoubleClickable(true);} bool CheckTarget(GameObject *Caller, Actor *Target, int childID){if(!Caller->IsValid() || Caller->IsAiming() || !Target->IsValid() || Caller->GetID() != Target->GetID())return false; return true; } void PushActions(GameObject *Caller, Actor *Target, int childID){Person p(Caller);Vector Pos = p.GetPosition();Audio::PlaySample3D(SND_UNLOCK, Pos);p.PlaceObjectInRightHand(OBJ_MP5_AIM);p.PushActionPrepareAim(ACTION_NEWLIST);p.AssignCommand(CMD_AIMENDMP5); p.AssignCommand(CMD_MOVEMP5);p.RemoveCommand(CMD_REMOVEMP5); p.RemoveCommand(CMD_AIMMP5); }}; object PcmdMP5AimEnd : CommandScript{ PcmdMP5AimEnd(){ SetIcon("aimend"); SetCursor("aimed");SetValidTargets(ACTOR_PERSON);SetDoubleClickable(true);SetRestrictions(RESTRICT_SELFEXECUTE);SetPossibleCallers(ACTOR_PERSON);SetPriority(600);} bool CheckPossible(GameObject *Caller){/*if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)return false;*/return Caller->IsAiming();} bool CheckTarget(GameObject *Caller, Actor *Target, int childID){if(!Caller->IsValid() || (Caller->GetID() != Target->GetID()) || !Caller->IsAiming())return false; return true; } void PushActions(GameObject *Caller, Actor *Target, int childID){Person p(Caller);p.PlaceObjectInRightHand(OBJ_MP5_IDLE);p.PushActionAimEnd(ACTION_NEWLIST);p.RemoveCommand(CMD_AIMENDMP5); p.RemoveCommand(CMD_MOVEMP5);p.AssignCommand(CMD_AIMMP5);p.AssignCommand(CMD_REMOVEMP5);p.PushActionSwitchAnim(ACTION_APPEND, "idleequipped2");}}; object PcmdMP5MoveTo : CommandScript{MoveResult mr; PcmdMP5MoveTo(){ SetIcon("moveto"); SetCursor("moveto");SetValidTargets(ACTOR_FLOOR | ACTOR_OBJECT | ACTOR_VIRTUAL | ACTOR_HOUSE | ACTOR_OPEN_HOUSE);SetHighlightingEnabled(false);SetDeselectCaller(false);//SetActivationByLeftClick(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){Person p(Caller);if(p.IsAiming() || p.IsCurrentAnimation("shootrifle")){p.PlaceObjectInRightHand(OBJ_MP5_IDLE);p.PushActionAimEnd(ACTION_NEWLIST);p.PushActionWait(ACTION_APPEND, 1.5f);p.PushActionExecuteCommand(ACTION_APPEND, DUMMY_MP5, Caller, 3, false);p.PushActionMove(ACTION_APPEND, mr.Target);p.RemoveCommand(CMD_AIMENDMP5);p.RemoveCommand(CMD_MOVEMP5);p.AssignCommand(CMD_AIMMP5);p.AssignCommand(CMD_REMOVEMP5);}}}; object DummyMP5 : CommandScript{DummyMP5(){ 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){if(childID == 1){Person p(Caller);p.PlaceObjectInRightHand(OBJ_MP5_IDLE);p.PushActionSwitchAnim(ACTION_APPEND, "idleequipped2");p.AssignCommand(CMD_AIMMP5);p.AssignCommand(CMD_SHOOTMP5);p.AssignCommand(CMD_REMOVEMP5);p.RemoveCommand(CMD_GETMP5);p.RemoveCommand("Arrest");p.RemoveCommand("ReleaseArrested");p.RemoveCommand("DrawWeapon");p.RemoveCommand("PutInCar");p.RemoveCommand("AskPerson");p.RemoveCommand("Halt");p.RemoveCommand("HaltVehicle");p.RemoveCommand("Redirect");p.RemoveCommand("GetFlashgrenade");p.RemoveCommand("PickUp");p.RemoveCommand("Lift");p.RemoveCommand("UnloadPerson");if(StrCompare(p.GetPrototypeFileName(), "mod:Prototypes/Persons/03 LA Police/lapd_swat.e4p") == 0 || StrCompare(p.GetPrototypeFileName(), "mod:Prototypes/Persons/03 LA Police/atf_swat.e4p") == 0){p.RemoveCommand("GetExtinguisher");p.RemoveCommand("PcmdBallisticShieldGet");p.RemoveCommand("PcmdBarricadeGet");p.RemoveCommand("PcmdTrafficConeGet");p.RemoveCommand("PcmdFlareGet");p.RemoveCommand("GetRoadBlock");p.RemoveCommand("PcmdCallPatrolCar");p.RemoveCommand("PcmdCallAmbulance");p.RemoveCommand("PcmdCallPoliceHelicopter"); }if(StrCompare(p.GetPrototypeFileName(), "mod:Prototypes/Persons/09 Government/fbi_agent_tac.e4p") == 0){p.RemoveCommand("CheckVictim");p.RemoveCommand("Negotiate");p.RemoveCommand("PcmdRemoveTacVest");p.RemoveCommand("PcmdPSGGet");} Vector Pos = p.GetPosition();Audio::PlaySample3D(SND_GETMP5, Pos); Vehicle v(Target);v.PushActionExecuteCommand(ACTION_APPEND, CMD_DOORS, Caller, 1, false);}if(childID == 2){Person p(Caller);p.RemoveObjectInRightHand();p.PushActionSwitchAnim(ACTION_APPEND, "idle");p.RemoveCommand(CMD_SHOOTMP5);p.RemoveCommand(CMD_REMOVEMP5);p.RemoveCommand(CMD_AIMMP5);p.AssignCommand(CMD_GETMP5);p.AssignCommand("Arrest");p.AssignCommand("ReleaseArrested");p.AssignCommand("DrawWeapon");p.AssignCommand("PutInCar");p.AssignCommand("AskPerson");p.AssignCommand("Halt");p.AssignCommand("HaltVehicle");p.AssignCommand("Redirect");p.AssignCommand("GetFlashgrenade");p.AssignCommand("PickUp");p.AssignCommand("Lift");p.AssignCommand("UnloadPerson");if(StrCompare(p.GetPrototypeFileName(), "mod:Prototypes/Persons/03 LA Police/lapd_swat.e4p") == 0 || StrCompare(p.GetPrototypeFileName(), "mod:Prototypes/Persons/03 LA Police/atf_swat.e4p") == 0){p.AssignCommand("PcmdCallPatrolCar");p.AssignCommand("PcmdCallAmbulance");p.AssignCommand("PcmdCallPoliceHelicopter"); p.AssignCommand("GetExtinguisher");p.AssignCommand("PcmdBallisticShieldGet");p.AssignCommand("PcmdBarricadeGet");p.AssignCommand("PcmdTrafficConeGet");p.AssignCommand("PcmdFlareGet");p.AssignCommand("GetRoadBlock");}if(StrCompare(p.GetPrototypeFileName(), "mod:Prototypes/Persons/09 Government/fbi_agent_tac.e4p") == 0){p.AssignCommand("CheckVictim");p.AssignCommand("Negotiate");p.AssignCommand("PcmdRemoveTacVest");p.AssignCommand("PcmdPSGGet");} Vehicle v(Target);v.PushActionExecuteCommand(ACTION_APPEND, CMD_DOORS, Caller, 1, false);}if(childID == 3){Person p(Caller);p.PlaceObjectInRightHand(OBJ_MP5_IDLE);} }}; Especially be aware at the begginging, i changed things in vehicles, so there might be a problem