#include #include #include class daFireLaser_c : public dEn_c { int onCreate(); int onDelete(); int onExecute(); int onDraw(); static daFireLaser_c *build(); int timer; float spitspeed; char direction; u64 eventFlag; USING_STATES(daFireLaser_c); DECLARE_STATE(pewpewpew); }; daFireLaser_c *daFireLaser_c::build() { void *buffer = AllocFromGameHeap1(sizeof(daFireLaser_c)); return new(buffer) daFireLaser_c; } extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer); CREATE_STATE(daFireLaser_c, pewpewpew); struct EventTable_t { u64 events; // ... }; extern EventTable_t *EventTable; int daFireLaser_c::onCreate() { OSReport("Creating a fiery laser"); this->timer = 0; this->direction = this->settings & 0xF; this->spitspeed = 8.0; char eventNum = (this->settings >> 16) & 0xFF; this->eventFlag = (u64)1 << (eventNum - 1); doStateChange(&StateID_pewpewpew); this->onExecute(); return true; } int daFireLaser_c::onDelete() { return true; } int daFireLaser_c::onExecute() { acState.execute(); return true; } int daFireLaser_c::onDraw() { return true; } // Pew Pew State void daFireLaser_c::beginState_pewpewpew() { OSReport("Firin' mah lazer."); this->timer = 0; } void daFireLaser_c::executeState_pewpewpew() { if (EventTable->events & this->eventFlag) { this->timer = this->timer + 1; if (this->timer < 20) { OSReport("Pew pew pew!"); float xlaunch; float ylaunch; if (this->direction == 0) { xlaunch = this->spitspeed; ylaunch = 0.0; } else if (this->direction == 1) { // SE xlaunch = this->spitspeed; ylaunch = this->spitspeed; } else if (this->direction == 2) { // S xlaunch = 0.0; ylaunch = this->spitspeed; } else if (this->direction == 3) { // SW xlaunch = -this->spitspeed; ylaunch = this->spitspeed; } else if (this->direction == 4) { // W xlaunch = -this->spitspeed; ylaunch = 0.0; } else if (this->direction == 5) { // NW xlaunch = -this->spitspeed; ylaunch = -this->spitspeed; } else if (this->direction == 6) { // N xlaunch = 0.0; ylaunch = -this->spitspeed; } else if (this->direction == 7) { // NE xlaunch = this->spitspeed; ylaunch = -this->spitspeed; } dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0); spawner->speed.x = xlaunch; spawner->speed.y = ylaunch; } if (this->timer > 60) { this->timer = 0; } } else { this->timer = 0; } } void daFireLaser_c::endState_pewpewpew() { }