void Hex::setAttackObject(const AttackObject &attack) { attackable = true; if (getMech() == nullptr) return; getMech()->setAttackObject(attack); }
static int Leave_DS_Bay(MAP * map, MECH * ds, MECH * mech, dbref frombay) { MECH *car = NULL; StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1); MechLOSBroadcast(mech, "has left the bay."); /* We escape confines of the bay to open air/land! */ mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", ds->mapindex)); if(MechCarrying(mech) > 0) car = getMech(MechCarrying(mech)); if(car) mech_Rsetmapindex(GOD, (void *) car, tprintf("%d", ds->mapindex)); DOCHECKMA0(mech->mapindex == map->mynum, "Fatal error: Unable to find the map 'ship is on."); loud_teleport(mech->mynum, mech->mapindex); if(car) loud_teleport(car->mynum, mech->mapindex); mech_notify(mech, MECHALL, "You have left the bay."); DS_Place(ds, mech, frombay); if(car) MirrorPosition(mech, car, 0); MechLOSBroadcasti(mech, ds, "has left %s's bay."); mech_notify(ds, MECHALL, tprintf("%s has left the bay.", GetMechID(mech))); ContinueFlying(mech); if(In_Character(mech->mynum) && Location(MechPilot(mech)) != mech->mynum) { mech_notify(mech, MECHALL, "%ch%cr%cf%ciINTRUDER ALERT! INTRUDER ALERT!%c"); mech_notify(mech, MECHALL, "%ch%cr%cfAutomatic self-destruct sequence initiated.%c"); mech_shutdown(GOD, (void *) mech, ""); } return 1; }
static int Find_Single_DS_In_MechHex(MECH * mech, long *ref, long *bayn) { MAP *map = FindObjectsData(mech->mapindex); int loop; MECH *tempMech; int count = 0; *ref = 0; if(!map) return 0; for(loop = 0; loop < map->first_free; loop++) if(map->mechsOnMap[loop] >= 0) { if(!(tempMech = getMech(map->mechsOnMap[loop]))) continue; if(!IsDS(tempMech)) continue; if(!Landed(tempMech)) continue; /* This might break midflight-aero-DS-docking. But aeros are broken anyway. */ if(Find_DS_Bay_In_MechHex(mech, tempMech, bayn)) { if(count++) *ref = -1; else *ref = tempMech->mynum; } } return count; }
void ShutDownMap(dbref player, dbref mapnumber) { XCODE *xcode_obj; MAP *map; MECH *mech; int j; xcode_obj = rb_find(xcode_tree, (void *)mapnumber); if (xcode_obj) { map = (MAP *)xcode_obj; for(j = 0; j < map->first_free; j++) if(map->mechsOnMap[j] != -1) { mech = getMech(map->mechsOnMap[j]); if(mech) { notify_printf(player, "Shutting down Mech #%d and resetting map index to -1....", map->mechsOnMap[j]); mech_shutdown(GOD, (void *) mech, ""); MechLastX(mech) = 0; MechLastY(mech) = 0; MechX(mech) = 0; MechY(mech) = 0; remove_mech_from_map(map, mech); } } map->first_free = 0; notify(player, "Map Cleared"); return; } }
static void mech_enterbay_event(MUXEVENT * e) { MECH *mech = (MECH *) e->data, *ds, *tmpm = NULL; long ref = (long) e->data2; long bayn; int x = 5, y = 5; MAP *tmpmap; if(!Started(mech) || Uncon(mech) || Jumping(mech) || (MechType(mech) == CLASS_MECH && (Fallen(mech) || Standing(mech))) || OODing(mech) || (fabs(MechSpeed(mech)) * 5 >= MMaxSpeed(mech) && fabs(MMaxSpeed(mech)) >= MP1) || (MechType(mech) == CLASS_VTOL && AeroFuel(mech) <= 0)) return; tmpmap = getMap(ref); if(!(ds = getMech(tmpmap->onmap))) return; if(!Find_DS_Bay_In_MechHex(mech, ds, &bayn)) return; /* whee */ ref = AeroBay(ds, bayn); StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1); mech_notify(mech, MECHALL, "You enter the bay."); MechLOSBroadcast(mech, tprintf("has entered %s at %d,%d.", GetMechID(ds), MechX(mech), MechY(mech))); MarkForLOSUpdate(mech); if(MechType(mech) == CLASS_MW && !In_Character(ref)) { enter_mw_bay(mech, ref); return; } if(MechCarrying(mech) > 0) tmpm = getMech(MechCarrying(mech)); mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", ref)); mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", x, y)); MechLOSBroadcast(mech, "has entered the bay."); loud_teleport(mech->mynum, ref); if(tmpm) { mech_Rsetmapindex(GOD, (void *) tmpm, tprintf("%d", ref)); mech_Rsetxy(GOD, (void *) tmpm, tprintf("%d %d", x, y)); loud_teleport(tmpm->mynum, ref); } }
int Leave_DS(MAP * map, MECH * mech) { MECH *car; DOCHECKMA0(!(car = getMech(map->onmap)), "Invalid : No parent object?"); DOCHECKMA0(!DS_Bay_Is_Open(mech, car, map->mynum), "The door has been jammed!"); DOCHECKMA0(!Landed(car) && !FlyingT(mech), "The 'ship is still airborne!"); DOCHECKMA0(Zombie(car->mynum), "You don't feel leaving right now would be prudent.."); return Leave_DS_Bay(map, car, mech, map->mynum); }
/* * Read in autopilot data */ static int load_autopilot_data(void *key, void *data, int depth, void *arg) { XCODE *const xcode_obj = data; if (xcode_obj->type == GTYPE_AUTO) { AUTO *const autopilot = (AUTO *)xcode_obj; int i; /* Save the AI Command List */ /* auto_load_commands(f, autopilot); */ autopilot->commands = dllist_create_list(); /* Reset the Astar Path */ autopilot->astar_path = NULL; /* Reset the weaplist */ autopilot->weaplist = NULL; /* Reset the profile */ for(i = 0; i < AUTO_PROFILE_MAX_SIZE; i++) { autopilot->profile[i] = NULL; } /* Check to see if the AI is in a mech */ /* Need to make this better, check if its got a target whatnot */ if(!autopilot->mymechnum || !(autopilot->mymech = getMech(autopilot->mymechnum))) { DoStopGun(autopilot); } else { if(Gunning(autopilot)) DoStartGun(autopilot); } } return 1; }
MECH *getMechInTempNetwork(int wIdx, dbref * myNetwork, int networkSize) { MECH *tempMech; dbref refOtherMech; if((wIdx > networkSize) || (wIdx < 0)) return NULL; refOtherMech = myNetwork[wIdx]; if(refOtherMech > 0) { tempMech = getMech(refOtherMech); if(!tempMech) return NULL; if(Destroyed(tempMech)) return NULL; return tempMech; } return NULL; }
void mech_enterbay(dbref player, void *data, char *buffer) { char *args[3]; int argc; dbref ref = -1, bayn = -1; MECH *mech = data, *ds; MAP *map; cch(MECH_USUAL); DOCHECK(MechType(mech) == CLASS_VTOL && AeroFuel(mech) <= 0, "You lack fuel to maneuver in!"); DOCHECK(Jumping(mech), "While in mid-jump? No way."); DOCHECK(MechType(mech) == CLASS_MECH && (Fallen(mech) || Standing(mech)), "Crawl inside? I think not. Stand first."); DOCHECK(OODing(mech), "While in mid-flight? No way."); DOCHECK((argc = mech_parseattributes(buffer, args, 2)) == 2, "Hmm, invalid number of arguments?"); if(argc > 0) DOCHECK((ref = FindTargetDBREFFromMapNumber(mech, args[0])) <= 0, "Invalid target!"); if(ref < 0) { DOCHECK(!Find_Single_DS_In_MechHex(mech, &ref, &bayn), "No DS bay found in your hex!"); DOCHECK(ref < 0, "Multiple enterable things found ; use the id for specifying which you want."); DOCHECK(!(ds = getMech(ref)), "You sense wrongness in fabric of space."); } else { DOCHECK(!(ds = getMech(ref)), "You sense wrongness in fabric of space."); DOCHECK(!Find_DS_Bay_In_MechHex(mech, ds, &bayn), "You see no bays in your hex."); } DOCHECK(IsDS(mech) && !(MechSpecials2(mech) & CARRIER_TECH), "Your craft can't enter bays."); DOCHECK(!DS_Bay_Is_Open(mech, ds, AeroBay(ds, bayn)), "The door has been jammed!"); DOCHECK(IsDS(mech), "Your unit is a bit too large to fit in there."); DOCHECK((fabs((float) (MechSpeed(mech) - MechSpeed(ds)))) > MP1, "Speed difference's too large to enter!"); DOCHECK(MechZ(ds) != MechZ(mech), "Get to same elevation before thinking about entering!"); DOCHECK(abs(MechVerticalSpeed(mech) - MechVerticalSpeed(ds)) > 10, "Vertical speed difference is too great to enter safely!"); DOCHECK(MechType(mech) == CLASS_MECH && !MechIsQuad(mech) && (IsMechLegLess(mech)), "Without legs? Are you kidding?"); ref = AeroBay(ds, bayn); map = getMap(ref); DOCHECK(!map, "You sense wrongness in fabric of space."); DOCHECK(EnteringHangar(mech), "You are already entering the hangar!"); if(!can_pass_lock(mech->mynum, ref, A_LENTER)) { char *msg = silly_atr_get(ref, A_FAIL); if(!msg || !*msg) msg = "You are unable to enter the bay!"; notify(player, msg); return; } DOCHECK(!DS_Bay_Is_EnterOK(mech, ds, AeroBay(ds, bayn)), "Someone else is using the door at the moment."); DOCHECK(!(map = getMap(mech->mapindex)), "You sense a wrongness in fabric of space."); HexLOSBroadcast(map, MechX(mech), MechY(mech), "The bay doors at $h start to open.."); MECHEVENT(mech, EVENT_ENTER_HANGAR, mech_enterbay_event, 12, ref); }
void mech_c3i_join_leave(dbref player, void *data, char *buffer) { MECH *mech = (MECH *) data, *target; MAP *objMap; char *args[2]; dbref refTarget; int LOS = 1; float range = 0.0; cch(MECH_USUALO); DOCHECK(mech_parseattributes(buffer, args, 2) != 1, "Invalid number of arguments to function!"); DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!"); DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!"); DOCHECK(AnyECMDisturbed(mech), "Your C3i system is not currently operational!"); validateC3iNetwork(mech); /* Clear our C3i Network */ if (!strcmp(args[0], "-")) { if (MechC3iNetworkSize(mech) <= 0) { mech_notify(mech, MECHALL, "You are not connected to a C3i network!"); return; } clearC3iNetwork(mech, 1); mech_notify(mech, MECHALL, "You disconnect from the C3i network."); return; } /* Well, if we're here then we wanna connect to a network */ /* Let's check to see if we're already in one... can't be in two at the same time */ DOCHECK(MechC3iNetworkSize(mech) > 0, "You are already in a C3i network!"); objMap = getMap(mech->mapindex); /* Find who we're trying to connect to */ refTarget = FindTargetDBREFFromMapNumber(mech, args[0]); target = getMech(refTarget); if (target) { LOS = InLineOfSight(mech, target, MechX(target), MechY(target), range); } else refTarget = 0; DOCHECK((refTarget < 1) || !LOS, "That is not a valid targetID. Try again."); DOCHECK(MechTeam(mech) != MechTeam(target), "You can't use the C3i network of unfriendly units!"); DOCHECK(mech == target, "You can't connect to yourself!"); DOCHECK(Destroyed(target), "That unit is destroyed!"); DOCHECK(!Started(target), "That unit is not started!"); DOCHECK(!HasC3i(target), "That unit does not appear to be equipped with C3i!"); /* validate the network of our target */ validateC3iNetwork(target); DOCHECK(MechC3iNetworkSize(target) >= C3I_NETWORK_SIZE, "That unit's C3i network is operating at maximum capacity!"); /* Connect us up */ mech_notify(mech, MECHALL, tprintf("You connect to %s's C3i network.", GetMechToMechID(mech, target))); addMechToC3iNetwork(target, mech); }
void Hex::setMech(MechEntity *mech) { this->mech = mech; getMech()->setMechPosition(this); }
void Hex::removeAttackObject() { attackable = false; if (getMech() != nullptr) getMech()->removeAttackObject(); }
bool Hex::hasAttackObject() const { return getMech() != nullptr && getMech()->hasAttackObject(); }
AttackObject Hex::getAttackObject() const { return getMech()->getAttackObject(); }
MECH *getOtherMechInNetwork(MECH * mech, int wIdx, int tCheckECM, int tCheckStarted, int tCheckUncon, int tIsC3) { MECH *tempMech; dbref refOtherMech; int networkSize; networkSize = (tIsC3 ? MechC3NetworkSize(mech) : MechC3iNetworkSize(mech)); if((wIdx >= networkSize) || (wIdx < 0)) return NULL; refOtherMech = (tIsC3 ? MechC3NetworkElem(mech, wIdx) : MechC3iNetworkElem(mech, wIdx)); if(refOtherMech > 0) { tempMech = getMech(refOtherMech); if(!tempMech) return NULL; if(MechTeam(tempMech) != MechTeam(mech)) return NULL; if(tempMech->mapindex != mech->mapindex) return NULL; if(Destroyed(tempMech)) return NULL; if(tIsC3) { if(!HasC3(tempMech)) /* Sanity check */ return NULL; if(C3Destroyed(tempMech)) return NULL; } else { if(!HasC3i(tempMech)) /* Sanity check */ return NULL; if(C3iDestroyed(tempMech)) return NULL; } if(tCheckECM) if(AnyECMDisturbed(tempMech)) return NULL; if(tCheckStarted) if(!Started(tempMech)) return NULL; if(tCheckUncon) if(Uncon(tempMech)) return NULL; return tempMech; } return NULL; }
void LogisticsMechIcon::update() { bJustSelected = 0; if ( !pMech ) return; long x = userInput->getMouseX(); long y = userInput->getMouseY(); for ( int i = 0; i < ICON_ANIM_COUNT; i++ ) { animations[i].update(); } if ( outline.pointInside( x, y ) ) { if ( (userInput->isLeftClick() || userInput->isLeftDoubleClick()) && getMech() ) { for ( int i = 0; i < ICON_ANIM_COUNT; i++ ) { animations[i].setState( aAnimGroup::PRESSED ); } bJustSelected = true; if ( state != aListItem::SELECTED ) soundSystem->playDigitalSample( LOG_SELECT ); state = aListItem::SELECTED; } else if ( state == aListItem::ENABLED || state == aListItem::HIGHLITE ) { for ( int i = 0; i < ICON_ANIM_COUNT; i++ ) { animations[i].setState( aAnimGroup::HIGHLIGHT ); } if ( state != aListItem::HIGHLITE ) { soundSystem->playDigitalSample( LOG_HIGHLIGHTBUTTONS ); } state = aListItem::HIGHLITE; } ::helpTextID = helpID; } else if ( state != aListItem::SELECTED ) { for ( int i = 0; i < ICON_ANIM_COUNT; i++ ) { animations[i].setState( aAnimGroup::NORMAL ); } state = aListItem::ENABLED; } }