/** * @brief Sets a jump's known state. * * @usage j:setKnown( false ) -- Makes jump unknown. * @luaparam j Jump to set known. * @luaparam b Whether or not to set as known (defaults to true). * @luafunc setKnown( j, b ) */ static int jumpL_setKnown( lua_State *L ) { int b, offset, changed; JumpPoint *jp; jp = luaL_validjumpSystem(L, 1, &offset, NULL); /* True if boolean isn't supplied. */ if (lua_gettop(L) > offset) b = lua_toboolean(L, 1 + offset); else b = 1; changed = (b != (int)jp_isKnown(jp)); if (b) jp_setFlag( jp, JP_KNOWN ); else jp_rmFlag( jp, JP_KNOWN ); /* Update outfits image array. */ if (changed) outfits_updateEquipmentOutfits(); return 0; }
/** * @brief Check to see if a jump point is in sensor range of the pilot. * * @param p Pilot who is trying to check to see if the jump point is in sensor range. * @param target Jump point to see if is in sensor range. * @return 1 if they are in range, 0 if they aren't. */ int pilot_inRangeJump( const Pilot *p, int i ) { double d; JumpPoint *jp; double sense; double hide; /* pilot must exist */ if ( p == NULL ) return 0; /* Get the jump point. */ jp = &cur_system->jumps[i]; /* We don't want exit-only or unknown hidden jumps. */ if ((jp_isFlag(jp, JP_EXITONLY)) || ((jp_isFlag(jp, JP_HIDDEN)) && (!jp_isKnown(jp)) )) return 0; sense = sensor_curRange * p->ew_jumpDetect; hide = jp->hide; /* Get distance. */ d = vect_dist2( &p->solid->pos, &jp->pos ); if (d * hide < sense) return 1; return 0; }
/** * @brief Checks to see if a jump is known by the player. * * @usage b = j:known() * * @luaparam s Jump to check if the player knows. * @luareturn true if the player knows the jump. * @luafunc known( j ) */ static int jumpL_isKnown( lua_State *L ) { JumpPoint *jp; jp = luaL_validjump(L,1); lua_pushboolean(L, jp_isKnown(jp)); return 1; }