//Modifiziertes Enter House Script //ermöglicht "Innenangriff" mit Schlauch im Hausinneren //Originalscript von EM4 angepasst von Heros object EnterHouse : CommandScript { Vector EntrancePos; bool moveOut, fromDLK; int h0; EnterHouse() { SetDeselectCaller(false); SetPossibleCallers(ACTOR_PERSON); //SetPossibleExists(CPE_ACCESSIBLE_HOUSE); SetValidTargets(ACTOR_OPEN_HOUSE | ACTOR_HOUSE); SetPriority(110); } bool CheckPossible(GameObject *Caller) { return Person(Caller).GetEnteredHouseID() == -1; } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { GameObject obj(Target); GameObjectList ol = Game::GetSelectedGameObjects(); if(Caller->HasCommand("DrawWeapon")) { if(obj.HasCommand("PolEinsatz") && obj.HasCommand("PolEinsatzAktiv") && (ol.GetNumObjects() == 1||Game::IsMultiplayer())) ) return true; else if(obj.GetType() == ACTOR_OPEN_HOUSE) return true; }else{ if(Caller->HasCommand("Heim") && obj.HasCommand("HeimAktiv") && (ol.GetNumObjects() == 1||Game::IsMultiplayer())) ) return true; if(Caller->HasCommand("PcmdStretcherVehicle") && obj.HasCommand("KTEinsatz")) return true; if(Target->HasName("kellerbrand")) return true; OpenHouse targetHouse(Target); Person person(Caller); if(!targetHouse.IsValid())return false; if (person.GetEnteredCarID() != -1 && !targetHouse.HasGroundEntrance() && person.CanEnterHouseFromDLK(&targetHouse)) { fromDLK = true; return true; } if(person.CanEnterHouseFromDLK(&targetHouse)) { fromDLK = true; return true; } if(true||Game::IsMultiplayer()) { moveOut = false; fromDLK = false; if(person.IsInDLKBasket()) { return true; fromDLK = true; } if(person.GetEquipment()!=EQUIP_FIREAXE) return true; return false; } if(Caller->HasNamePrefix("p_")) { if(!Caller->IsValid() || !Target->IsValid() || Caller->GetType()!=ACTOR_PERSON || Target->GetType()!=ACTOR_OPEN_HOUSE) return false; if (!targetHouse.HasGroundEntrance()&&person.CanEnterHouseFromDLK(&targetHouse)) { fromDLK = true; return true; } fromDLK = false; // check if house can be entered if (!targetHouse.IsValid() || targetHouse.IsOpen() || !targetHouse.HasGroundEntrance() || !targetHouse.IsFlagSet(OF_ACCESSIBLE)) { /*if ( !targetHouse.IsValid() ) System::Print("EnterHouse: target house is not valid"); if ( targetHouse.IsOpen() ) System::Print("EnterHouse: door is open"); if ( !targetHouse.HasGroundEntrance() ) System::Print("EnterHouse: !targetHouse.HasGroundEntrance()"); if ( !targetHouse.IsFlagSet(OF_ACCESSIBLE) ) System::Print("EnterHouse: !targetHouse.IsFlagSet(OF_ACCESSIBLE)");*/ return false; } if(targetHouse.GetEntranceDoorID() == 0) { //System::Print("EnterHouse: target house has no entrance door."); return false; } if (person.GetEnteredCarID() != -1) return false; // if house is locked and caller carries an axe, ignore EnterHouse Command so that UseEquipment is the only available command if (targetHouse.IsLocked() && person.GetEquipment() == EQUIP_FIREAXE) return false; // check if inside house if (person.GetEnteredHouseID() != -1) { // check if source house has ground entrance Actor ha = Game::GetActor(person.GetEnteredHouseID()); OpenHouse sourceHouse(&ha); if (!sourceHouse.HasGroundEntrance() || sourceHouse.GetEntranceDoorID() == 0) { // System::Print("EnterHouse: source house has no ground entrance"); return false; } moveOut = true; h0 = sourceHouse.GetID(); EntrancePos = sourceHouse.GetEntrancePosition(false); } else { moveOut = false; } return true; } } return false; } void PushActions(GameObject *Caller, Actor *Target, int childID) { Person p(Caller); GameObject house(Target); if(house.HasName("PolEinsatz") || house.HasName("KH_KT") || house.HasName("Heim")) { Vector childPos; if(house.HasName("KH_KT")) { ActorList al = Game::GetActors("Notaufnahme"); childPos = al.GetActor(0)->GetPosition(); }else if(house.HasName("Heim")) { childPos = house.GetChildPosition("Heimrauchmelder"); }else{ childPos = house.GetChildPosition("PolEinsatz"); } int wait = Math::rand() % 60; p.PushActionMove(ACTION_NEWLIST, childPos); p.PushActionWait(ACTION_APPEND, wait); if(house.HasCommand("KTEinsatz")){ p.PushActionExecuteCommand(ACTION_APPEND, "KTAufnehmen", Target, 0, false); }else if(house.HasCommand("Heim")){ p.PushActionExecuteCommand(ACTION_APPEND, "heimrauchmelderAbschliessen", Target, 0, false); }else{ OpenHouse targetHouse(Target); p.PushActionExecuteCommand(ACTION_APPEND, "ruhestoerungAbschliessen", &targetHouse, 0, false); } p.SetCommandable(false); return; } OpenHouse targetHouse(Target); if(p.IsInDLKBasket()) { if(targetHouse.HasGroundEntrance()||!p.CanEnterHouseFromDLK(&targetHouse)) { Mission::PlayHint("BHint_61"); return; } } else { if(!targetHouse.HasGroundEntrance()) { Mission::PlayHint("BHint_62"); return; } } if(p.GetEnteredHouseID() != -1) { Actor ha = Game::GetActor(p.GetEnteredHouseID()); OpenHouse sourceHouse(&ha); moveOut = true; h0 = sourceHouse.GetID(); EntrancePos = sourceHouse.GetEntrancePosition(false); } System::Log("Enter House!"); if(Target->HasName("kellerbrand")) { Target->Hide(); return; } Vector DoorFront, DoorBack; Vector DoorFront = targetHouse.GetEntrancePosition(true); Vector DoorBack = targetHouse.GetEntrancePosition(false); if (fromDLK) { Caller->PushActionEnterHouse(ACTION_NEWLIST, Target); Caller->PushActionExecuteCommand(ACTION_APPEND,"ZZ_Schnitt",&Game::GetActor(p.GetEnteredCarID()),101,false); if(Caller->HasCommand("in_dlk")) { Caller->RemoveCommand("in_dlk"); } return; } if (moveOut) { Actor thouse = Game::GetActor(h0); Caller->PushActionMove(ACTION_NEWLIST, EntrancePos, true); Caller->PushActionLeaveHouse(ACTION_APPEND, &thouse); Caller->PushActionMove(ACTION_APPEND, DoorFront, true); Caller->PushActionTurnTo(ACTION_APPEND, DoorBack); Caller->PushActionEnterHouse(ACTION_APPEND, Target); } else { Person p(Caller); p.PushActionMove(ACTION_NEWLIST, DoorFront, true); p.PushActionTurnTo(ACTION_APPEND, DoorBack); p.PushActionExecuteCommand(ACTION_APPEND, "DummyCheckDoor", &targetHouse,0,false); } } }; object DummyCheckDoor : CommandScript { DummyCheckDoor() { } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { return true; } void PushActions(GameObject *Caller, Actor *Target, int childID) { Person p(Caller); OpenHouse targetHouse(Target); if(childID == 0) { if(!targetHouse.HasCommand("DummyIsLocked")) { p.PushActionEnterHouse(ACTION_APPEND, Target); }else if(targetHouse.HasCommand("DummyIsLocked") && p.HasCommand("DummyHasZiehFix")){ p.SetCommandable(false); p.PushActionRemoveEquipment(ACTION_APPEND); p.PushActionExecuteCommand(ACTION_APPEND, "DummyCheckDoor", &targetHouse, 3, false); p.PushActionSwitchAnim(ACTION_APPEND, "scout_sitdown"); p.PushActionWait(ACTION_APPEND, 2.0f); p.PushActionSwitchAnim(ACTION_APPEND, "scout_work"); p.PushActionWait(ACTION_APPEND, 9.0f); p.PushActionExecuteCommand(ACTION_APPEND, "DummyCheckDoor", &targetHouse, 1, false); p.PushActionSwitchAnim(ACTION_APPEND, "scout_standup"); p.PushActionWait(ACTION_APPEND, 2.0f); p.PushActionExecuteCommand(ACTION_APPEND, "DummyCheckDoor", &targetHouse, 2, false); p.PushActionExecuteCommand(ACTION_APPEND, "DummyCheckDoor", &targetHouse, 4, false); p.PushActionGetEquipment(ACTION_APPEND, &targetHouse, EQUIP_THW_CASE); p.PushActionEnterHouse(ACTION_APPEND, Target); }else if(targetHouse.IsDoorLocked(0)){ Mission::PlayHint("BHint_63"); }else if(targetHouse.HasCommand("DummyIsLocked") && !p.HasCommand("DummyHasZiehFix")){ Mission::PlayHint("BHint_64"); } }else if(childID == 1){ targetHouse.OpenDoor(0); }else if(childID == 2){ targetHouse.RemoveCommand("DummyIsLocked"); }else if(childID == 3){ char name[16]; snprintf(name, 16, "%i_ziehfix", p.GetID()); Vector pos = p.GetPosition(); GameObject equip = Game::CreateObject("mod:Prototypes/Objects/Equipment/thwbag.e4p", name); equip.SetRotation(&p); float rot[9]; p.GetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]); Vector offset(10.f,-40.f,10.f); Math::RotateVector(offset.x, offset.y, offset.z, rot); equip.SetPosition(pos+offset); equip.SetSelectable(false); equip.SetPlayerMP(p.GetPlayerMP()); }else if(childID == 4){ char name[16]; snprintf(name, 16, "%i_ziehfix", p.GetID()); GameObjectList gol = Game::GetGameObjects(name); GameObject equip(gol.GetObject(0)); equip.PushActionDeleteOwner(ACTION_NEWLIST); p.SetCommandable(true); }else if(childID==5){ OpenHouse house(Target); house.RemoveCommand("DummyIsLocked"); } } };