summaryrefslogtreecommitdiff
path: root/src/thundercloud.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/thundercloud.cpp')
-rwxr-xr-xsrc/thundercloud.cpp43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/thundercloud.cpp b/src/thundercloud.cpp
index 9b3fa1f..0f7b63d 100755
--- a/src/thundercloud.cpp
+++ b/src/thundercloud.cpp
@@ -31,6 +31,7 @@ class dThunderCloud : public dEn_c {
float leader;
pointSensor_s below;
+ bool usingEvents;
u64 eventFlag;
ActivePhysics Lightning;
@@ -218,6 +219,9 @@ int dThunderCloud::onCreate() {
allocator.unlink();
+
+ scale = (Vec){1.2f, 1.2f, 1.2f};
+
// Scale and Physics
ActivePhysics::Info Cloud;
Cloud.xDistToCenter = 0.0;
@@ -227,8 +231,8 @@ int dThunderCloud::onCreate() {
Cloud.bitfield1 = 0x4F;
Cloud.bitfield2 = 0xffba7ffe;
- Cloud.xDistToEdge = 18.0;
- Cloud.yDistToEdge = 12.0;
+ Cloud.xDistToEdge = 18.0f * scale.x;
+ Cloud.yDistToEdge = 12.0f * scale.y;
Cloud.unkShort1C = 0;
Cloud.callback = &dEn_c::collisionCallback;
@@ -247,7 +251,9 @@ int dThunderCloud::onCreate() {
this->pos.z = 5750.0f; // sun
stationary = this->settings & 0xF;
+
char eventNum = (this->settings >> 16) & 0xFF;
+ usingEvents = (stationary != 0) && (eventNum != 0);
this->eventFlag = (u64)1 << (eventNum - 1);
@@ -372,7 +378,6 @@ void dThunderCloud::executeState_Wait() {
if ((this->settings >> 16) & 0xFF) {
if (dFlagMgr_c::instance->flags & this->eventFlag) {
- dFlagMgr_c::instance->flags = dFlagMgr_c::instance->flags ^ this->eventFlag;
this->doStateChange(&StateID_Lightning);
}
}
@@ -411,7 +416,6 @@ void dThunderCloud::lightningStrike() {
}
void dThunderCloud::beginState_Lightning() {
- this->timer = 0;
this->speed.x = 0.0;
float backupY = pos.y, backupYSpeed = speed.y;
@@ -438,6 +442,14 @@ void dThunderCloud::beginState_Lightning() {
pos.y = backupY;
speed.y = backupYSpeed;
+
+ if (usingEvents) {
+ timer = 2;
+ this->bindAnimChr_and_setUpdateRate("thundershoot", 1, 0.0, 1.0);
+ lightningStrike();
+ } else {
+ timer = 0;
+ }
}
void dThunderCloud::executeState_Lightning() {
@@ -474,15 +486,24 @@ void dThunderCloud::executeState_Lightning() {
}
if(this->anm.isAnimationDone() && this->anm.getCurrentFrame() != 0.0) {
- this->timer += 1;
- if (timer == 2) {
- this->bindAnimChr_and_setUpdateRate("thundershoot", 1, 0.0, 1.0);
- lightningStrike();
+ if (timer == 2 && usingEvents) {
+ if (dFlagMgr_c::instance->flags & eventFlag) {
+ } else {
+ doStateChange(&StateID_Wait);
+ }
+ } else {
+ timer++;
+ if (timer == 2) {
+ this->bindAnimChr_and_setUpdateRate("thundershoot", 1, 0.0, 1.0);
+ lightningStrike();
+ } else if (timer == 3) {
+ this->bindAnimChr_and_setUpdateRate("cloud_wait", 1, 0.0, 1.0);
+ }
}
- if (timer == 3) { this->bindAnimChr_and_setUpdateRate("cloud_wait", 1, 0.0, 1.0); }
- this->anm.setCurrentFrame(0.0); }
-
+ this->anm.setCurrentFrame(0.0);
+ }
}
+
void dThunderCloud::endState_Lightning() {
this->timer = 0;
}