DarkflameServer/dScripts/PrSeagullFly.cpp

20 lines
644 B
C++
Raw Normal View History

#include "PrSeagullFly.h"
#include "Entity.h"
2022-07-28 13:39:57 +00:00
void PrSeagullFly::OnStartup(Entity* self) {
self->SetVar<int32_t>(u"playersNear", 0);
2022-07-28 13:39:57 +00:00
self->SetProximityRadius(15, "birdMonitor");
}
2022-07-28 13:39:57 +00:00
void PrSeagullFly::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
if (!entering->IsPlayer()) return;
2022-07-28 13:39:57 +00:00
if (status == "ENTER") {
self->SetVar<int32_t>(u"playersNear", self->GetVar<int32_t>(u"playersNear") + 1);
2022-07-28 13:39:57 +00:00
} else if (status == "LEAVE") {
self->SetVar<int32_t>(u"playersNear", self->GetVar<int32_t>(u"playersNear") - 1);
2022-07-28 13:39:57 +00:00
}
2022-07-28 13:39:57 +00:00
self->SetNetworkVar(u"BirdLanded", self->GetVar<int32_t>(u"playersNear") == 0);
}