As I have explained in my comments: you can have a central entity which the other nodes can query and then make sending decision based on that. This central entity can be another node in the sensor network or simply a class which the nodes can instantiate.
For example:
class BatteryMonitor: public cSimpleModule
{
public:
BatteryMonitor();
void report_battery(const std::string& nodeID, float batteryLevel,)
double check_battery(const std::string& nodeID);
protected:
std::map<std::string, double> batteryLevels;
};
You can set a self-message every 1 second to your sensor nodes, to make sure that they report the most recent battery level .
In your nodes you can do something similar to your code:
if (batteryMonitor->check_battery(this->myID) >= batteryMonitor->check_battery(otherNodeID)) {
send(thisMessage, otherNode);
}