void Teleport( int pulse ) { struct char_data *ch; struct obj_data *obj_object, *temp_obj; int or; if(DEBUG) dlog("Teleport"); if (pulse < 0) return; if(MOUNTED(ch)) { FallOffMount(ch,MOUNTED(ch)); Dismount(ch,MOUNTED(ch),POSITION_SITTING); } else if(RIDDEN(ch)) { FallOffMount(RIDDEN(ch),ch); Dismount(RIDDEN(ch),ch,POSITION_SITTING); } for (ch = character_list; ch; ch = ch->next) { if (ch->in_room != NOWHERE) { if (real_roomp(ch->in_room)->tele_targ > 0) { if (real_roomp(ch->in_room)->tele_time > 0) { if ((pulse % real_roomp(ch->in_room)->tele_time)==0) { obj_object = real_roomp(ch->in_room)->contents; while (obj_object) { temp_obj = obj_object->next_content; obj_from_room(obj_object); obj_to_room(obj_object, real_roomp(ch->in_room)->tele_targ); obj_object = temp_obj; } or = ch->in_room; char_from_room(ch); char_to_room(ch, real_roomp(or)->tele_targ); if (real_roomp(or)->tele_look) { do_look(ch, "\0",15); } } } } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAI_FuncTankBehavior::EndScheduleSelection() { if ( m_bMounted ) { Dismount(); } }
bool DISKS::GetSize4KB(int n, int* adr) { bool bMount = false; if (fDisks[n] == INVALID_HANDLE_VALUE) { if (!Mount(n)) return false; bMount = true; } dword dwSizeLo = 0; if (!bFloppy[n]) { dwSizeLo = GetFileSize(fDisks[n], NULL); if (dwSizeLo != 0xFFFFFFFF) *adr = (int)(dwSizeLo / (4*K)); } else { dword SectorsPerCluster = 0; dword BytesPerSector = 0; dword TotalNumberOfClusters = 0; dwSizeLo = GetFloppySize4KB(n, SectorsPerCluster, BytesPerSector, TotalNumberOfClusters); if (dwSizeLo != 0xFFFFFFFF) *adr = dwSizeLo; } if (bMount) Dismount(n); return dwSizeLo != 0xFFFFFFFF; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAI_FuncTankBehavior::UpdateOnRemove( void ) { if ( m_hFuncTank ) { Dismount(); } BaseClass::UpdateOnRemove(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAI_FuncTankBehavior::Event_Killed( const CTakeDamageInfo &info ) { if ( m_hFuncTank ) { Dismount(); } Assert( !m_hFuncTank ); BaseClass::Event_Killed( info ); }
DISKS::~DISKS() { for (int i = 0; i < nDiskCount; ++i) { GlobalFreePtr(fName[i]); fName[i] = NULL; nMount[i] = 0; Dismount(i); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CAI_FuncTankBehavior::SelectSchedule() { // This shouldn't get called with an m_hFuncTank, see CanSelectSchedule. Assert( m_hFuncTank ); // If we've been told to dismount, or we are out of ammo - dismount. if ( HasCondition( COND_FUNCTANK_DISMOUNT ) || m_hFuncTank->GetAmmoCount() == 0 ) { if ( m_bMounted ) { Dismount(); } return BaseClass::SelectSchedule(); } // If we are not mounted to a func_tank look for one. if ( !IsMounted() ) { return SCHED_MOVE_TO_FUNCTANK; } // If we have an enemy, it's in the viewcone & we have LOS to it if ( GetEnemy() ) { // Tell the func tank whenever we see the player for the first time since not seeing him for a while if ( HasCondition( COND_NEW_ENEMY ) && GetEnemy()->IsPlayer() && !m_bSpottedPlayerOutOfCover ) { m_bSpottedPlayerOutOfCover = true; m_hFuncTank->NPC_JustSawPlayer( GetEnemy() ); } // Fire at the enemy. return SCHED_FIRE_FUNCTANK; } else { // Scan for enemies. return SCHED_SCAN_WITH_FUNCTANK; } return SCHED_IDLE_STAND; }
bool DISKS::Write(int n, int sectorno, byte* adr, int len) { // trace("write(%d, %d, %08X, %d)\n", n, sectorno, adr, len); bool bMount = false; if (fDisks[n] == INVALID_HANDLE_VALUE) { if (!Mount(n)) return false; bMount = true; } dword nWritten = 0; if ((int)SetFilePointer(fDisks[n], sectorno*512, NULL, FILE_BEGIN) >= 0) { if (!WriteFile(fDisks[n], adr, len, &nWritten, NULL)) nWritten = 0; } if (bMount) Dismount(n); return len == (int)nWritten; }
bool DISKS::Read(int n, int sectorno, byte* adr, int len) { // trace("read(%d, %d, %08X, %d)\n", n, sectorno, adr, len); bool bMount = false; if (fDisks[n] == INVALID_HANDLE_VALUE) { if (!Mount(n)) return false; bMount = true; } dword nRead = 0; if ((int)SetFilePointer(fDisks[n], sectorno*512, NULL, FILE_BEGIN) >= 0) { if (!ReadFile(fDisks[n], adr, len, &nRead, NULL)) nRead = 0; } if (bMount) Dismount(n); return (int)nRead == len; }
int DISKS::GetFloppySize4KB(int n, dword &SectorsPerCluster, dword &BytesPerSector, dword &TotalNumberOfClusters) { // unless we close the "\\.\A:" file and iterate // direcotry on the floppy disk // GetDiskFreeSpace() will return -1 if this is // first access. This will make Excelsior to think // there is no floppy in the bay bool bNeedToMount = false; if (fDisks[n] != INVALID_HANDLE_VALUE) { Dismount(n); bNeedToMount = true; } WIN32_FIND_DATA findFileData; HANDLE hNiceTry = FindFirstFile("A:\\*.*", &findFileData); if (hNiceTry != INVALID_HANDLE_VALUE) { ::FindClose(hNiceTry); hNiceTry = INVALID_HANDLE_VALUE; } int size = -1; DWORD NumberOfFreeClusters = 0; if (::GetDiskFreeSpace("A:\\", &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters)) { size = TotalNumberOfClusters * SectorsPerCluster * BytesPerSector; size = (int)(size / (4*K)); } else size = -1; if (bNeedToMount) Mount(n); return size; }
void VehicleKit::RemovePassenger(Unit *passenger, bool dismount) { SeatMap::iterator seat; for (seat = m_Seats.begin(); seat != m_Seats.end(); ++seat) if (seat->second.passenger == passenger) break; if (seat == m_Seats.end()) return; seat->second.passenger = NULL; passenger->clearUnitState(UNIT_STAT_ON_VEHICLE); passenger->m_movementInfo.ClearTransportData(); passenger->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT); if (seat->second.IsProtectPassenger()) if (passenger->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); if (seat->second.seatInfo->m_flags & SEAT_FLAG_CAN_CONTROL) { passenger->SetCharm(NULL); passenger->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE); m_pBase->SetCharmerGuid(ObjectGuid()); m_pBase->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); m_pBase->clearUnitState(UNIT_STAT_CONTROLLED); if (passenger->GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)passenger; player->SetClientControl(m_pBase, 0); player->RemovePetActionBar(); } if(!(((Creature*)m_pBase)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_KEEP_AI)) ((Creature*)m_pBase)->AIM_Initialize(); } if (passenger->GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)passenger; player->GetCamera().ResetView(); WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4); data << passenger->GetPackGUID(); data << uint32(2); passenger->SendMessageToSet(&data, true); player->SetMover(player); } UpdateFreeSeatCount(); if (m_pBase->GetTypeId() == TYPEID_UNIT) { if (((Creature*)m_pBase)->AI()) ((Creature*)m_pBase)->AI()->PassengerBoarded(passenger, seat->first, false); } if (dismount) { Dismount(passenger, seat->second.seatInfo); // only for flyable vehicles if (m_pBase->m_movementInfo.HasMovementFlag(MOVEFLAG_FLYING)) m_pBase->CastSpell(passenger, 45472, true); // Parachute } }
void VehicleKit::RemovePassenger(Unit* passenger, bool dismount) { SeatMap::iterator seat; for (seat = m_Seats.begin(); seat != m_Seats.end(); ++seat) if (seat->second.passenger == passenger->GetObjectGuid()) break; if (seat == m_Seats.end()) return; seat->second.passenger.Clear(); passenger->clearUnitState(UNIT_STAT_ON_VEHICLE); UnBoardPassenger(passenger); // Use TransportBase to remove the passenger from storage list passenger->m_movementInfo.ClearTransportData(); passenger->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT); if (seat->second.IsProtectPassenger()) if (passenger->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); if (seat->second.seatInfo->m_flags & SEAT_FLAG_CAN_CONTROL) { passenger->SetCharm(NULL); passenger->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE); GetBase()->SetCharmerGuid(ObjectGuid()); GetBase()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); GetBase()->clearUnitState(UNIT_STAT_CONTROLLED); if (passenger->GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)passenger; player->SetClientControl(GetBase(), 0); player->RemovePetActionBar(); } if(!(((Creature*)GetBase())->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_KEEP_AI)) ((Creature*)GetBase())->AIM_Initialize(); } if (passenger->GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)passenger; player->SetViewPoint(NULL); passenger->SetRoot(false); player->SetMover(player); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ROOT); if ((GetBase()->HasAuraType(SPELL_AURA_FLY) || GetBase()->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED)) && (!player->HasAuraType(SPELL_AURA_FLY) && !player->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED))) { WorldPacket data; data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); data << player->GetPackGUID(); data << (uint32)(0); GetBase()->SendMessageToSet(&data,false); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_FLYING); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_CAN_FLY); } } UpdateFreeSeatCount(); if (GetBase()->GetTypeId() == TYPEID_UNIT) { if (((Creature*)GetBase())->AI()) ((Creature*)GetBase())->AI()->PassengerBoarded(passenger, seat->first, false); } if (passenger->GetTypeId() == TYPEID_UNIT) { if (((Creature*)passenger)->AI()) ((Creature*)passenger)->AI()->EnteredVehicle(GetBase(), seat->first, false); } if (dismount && seat->second.b_dismount) { Dismount(passenger, seat->second.seatInfo); // only for flyable vehicles if (GetBase()->m_movementInfo.HasMovementFlag(MOVEFLAG_FLYING)) GetBase()->CastSpell(passenger, 45472, true); // Parachute } }
/* Extract a ch completely from the world, and leave his stuff behind */ void extract_char_smarter(struct char_data *ch, int save_room) { struct obj_data *i; struct char_data *k, *next_char; struct descriptor_data *t_desc; int l, was_in, j; extern long mob_count; extern struct char_data *combat_list; void do_save(struct char_data *ch, char *argument, int cmd); void do_return(struct char_data *ch, char *argument, int cmd); void die_follower(struct char_data *ch); if(IS_SET(ch->specials.act, ACT_FIGURINE) && ch->link) extract_obj(ch->link); if(!IS_NPC(ch) && !ch->desc) { for(t_desc = descriptor_list; t_desc; t_desc = t_desc->next) if(t_desc->original==ch) do_return(t_desc->character, "", 0); } if (ch->in_room == NOWHERE) { logE("NOWHERE extracting char. (handler.c, extract_char)"); /* ** problem from linkdeath */ char_to_room(ch, 4); /* 4 == all purpose store */ } if (ch->followers || ch->master) die_follower(ch); if(ch->desc) { /* Forget snooping */ if ((ch->desc->snoop.snooping) && (ch->desc->snoop.snooping->desc)) ch->desc->snoop.snooping->desc->snoop.snoop_by = 0; if (ch->desc->snoop.snoop_by) { send_to_char("Your victim is no longer among us.\n\r", ch->desc->snoop.snoop_by); if (ch->desc->snoop.snoop_by->desc) ch->desc->snoop.snoop_by->desc->snoop.snooping = 0; } ch->desc->snoop.snooping = ch->desc->snoop.snoop_by = 0; } if (ch->carrying) { /* transfer ch's objects to room */ if (!IS_IMMORTAL(ch)) { while(ch->carrying) { i=ch->carrying; obj_from_char(i); obj_to_room(i, ch->in_room); check_falling_obj(i, ch->in_room); } } else { send_to_char("Here, you dropped some stuff, let me help you get rid of that.\n\r",ch); /* equipment too */ for (j=0; j<MAX_WEAR; j++) { if (ch->equipment[j]) obj_to_char(unequip_char(ch, j), ch); } while (ch->carrying) { i = ch->carrying; obj_from_char(i); extract_obj(i); } } } if (ch->specials.fighting) stop_fighting(ch); for (k = combat_list; k ; k = next_char) { next_char = k->next_fighting; if (k->specials.fighting == ch) stop_fighting(k); } if (MOUNTED(ch)) { Dismount(ch, MOUNTED(ch), POSITION_STANDING); } if (RIDDEN(ch)) { Dismount(RIDDEN(ch), ch, POSITION_STANDING); } /* Must remove from room before removing the equipment! */ was_in = ch->in_room; char_from_room(ch); /* clear equipment_list */ for (l = 0; l < MAX_WEAR; l++) if (ch->equipment[l]) obj_to_room(unequip_char(ch,l), was_in); if (IS_NPC(ch)) { for (k=character_list; k; k=k->next) { if (k->specials.hunting) if (k->specials.hunting == ch) { k->specials.hunting = 0; } if (Hates(k, ch)) { RemHated(k, ch); } if (Fears(k, ch)) { RemFeared(k, ch); } if (k->orig == ch) { k->orig = 0; } } } else { for (k=character_list; k; k=k->next) { if (k->specials.hunting) if (k->specials.hunting == ch) { k->specials.hunting = 0; } if (Hates(k, ch)) { ZeroHatred(k, ch); } if (Fears(k, ch)) { ZeroFeared(k, ch); } if (k->orig == ch) { k->orig = 0; } } } /* pull the char from the list */ if (ch == character_list) character_list = ch->next; else { for(k = character_list; (k) && (k->next != ch); k = k->next); if(k) k->next = ch->next; else { logE("Trying to remove ?? from character_list.(handler.c,extract_char)"); exit(0); } } if (ch->specials.gname) free(ch->specials.gname); GET_AC(ch) = 100; if (ch->desc) { if (ch->desc->original) do_return(ch, "", 0); if (!strcmp(GET_NAME(ch), "Odin's heroic minion")) { free(GET_NAME(ch)); GET_NAME(ch) = strdup("111111"); } save_char(ch, save_room); } t_desc = ch->desc; if(ch->term) { ScreenOff(ch); ch->term = 0; } if (IS_NPC(ch)) { if (ch->nr > -1) /* if mobile */ mob_index[ch->nr].number--; FreeHates(ch); FreeFears(ch); mob_count--; free_char(ch); } if (t_desc) { t_desc->connected = CON_SLCT; SEND_TO_Q(MENU, t_desc); } }
void VehicleKit::RemovePassenger(Unit* passenger, bool dismount /*false*/) { SeatMap::iterator seat; for (seat = m_Seats.begin(); seat != m_Seats.end(); ++seat) { if (seat->second.passengerGuid == passenger->GetObjectGuid()) break; } if (seat == m_Seats.end()) return; seat->second.passengerGuid.Clear(); passenger->clearUnitState(UNIT_STAT_ON_VEHICLE); UnBoardPassenger(passenger); // Use TransportBase to remove the passenger from storage list passenger->m_movementInfo.ClearTransportData(); if (seat->second.IsProtectPassenger()) { if (passenger->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } if (passenger->GetTypeId() == TYPEID_UNIT) { if (seat->second.seatInfo->m_flags & SEAT_FLAG_NOT_SELECTABLE) passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } if (seat->second.seatInfo->m_flags & SEAT_FLAG_CAN_CONTROL && GetBase()->GetTypeId() == TYPEID_UNIT) { passenger->SetCharm(NULL); passenger->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE); GetBase()->SetCharmerGuid(ObjectGuid()); GetBase()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); GetBase()->clearUnitState(UNIT_STAT_CONTROLLED); GetBase()->StopMoving(); if (passenger->GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)passenger; player->SetClientControl(GetBase(), 0); player->RemovePetActionBar(); } // Allow to keep AI of controlled vehicle with CREATURE_FLAG_EXTRA_KEEP_AI extra-flag if (!(((Creature*)GetBase())->GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_KEEP_AI)) ((Creature*)GetBase())->AIM_Initialize(); } if (passenger->GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)passenger; player->SetViewPoint(NULL); ((Player*)passenger)->SetGravity(true); passenger->SetRoot(false); player->SetMover(player); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ROOT); // restore player's walk mode if (GetBase()->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE) && !GetBase()->IsWalking()) player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_WALK_MODE); if ((GetBase()->HasAuraType(SPELL_AURA_FLY) || GetBase()->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED) || (GetBase()->GetTypeId() == TYPEID_UNIT && ((Creature*)GetBase())->CanFly())) && (!player->HasAuraType(SPELL_AURA_FLY) && !player->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED))) { WorldPacket data; GetBase()->BuildMoveSetCanFlyPacket(&data, false, 0); GetBase()->SendMessageToSet(&data, false); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_FLYING); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_CAN_FLY); } if (GetBase()->IsLevitating()) { player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_LEVITATING); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_HOVER); } // group update if (player->GetGroup()) player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_VEHICLE_SEAT); } UpdateFreeSeatCount(); if (GetBase()->GetTypeId() == TYPEID_UNIT) { if (((Creature*)GetBase())->AI()) ((Creature*)GetBase())->AI()->PassengerBoarded(passenger, seat->first, false); } if (passenger->GetTypeId() == TYPEID_UNIT) { if (((Creature*)passenger)->AI()) { ((Creature*)passenger)->AI()->EnteredVehicle(GetBase(), seat->first, false); ((Creature*)passenger)->AI()->SetCombatMovement(true, true); } } if (dismount && seat->second.b_dismount) { Dismount(passenger, seat->second.seatInfo); // only for flyable vehicles if (GetBase()->m_movementInfo.HasMovementFlag(MOVEFLAG_FLYING)) GetBase()->CastSpell(passenger, 45472, true); // Parachute } else { // Force update passenger position to base position WorldLocation const& pos = GetBase()->GetPosition(); passenger->SetPosition(pos); } }