#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; 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 = spitspeed; ylaunch = 0.0; } else if (this->direction == 1) { // SE xlaunch = spitspeed; ylaunch = spitspeed; } else if (this->direction == 2) { // S xlaunch = 0.0; ylaunch = spitspeed; } else if (this->direction == 3) { // SW xlaunch = -spitspeed; ylaunch = spitspeed; } else if (this->direction == 4) { // W xlaunch = -spitspeed; ylaunch = 0.0; } else if (this->direction == 5) { // NW xlaunch = -spitspeed; ylaunch = -spitspeed; } else if (this->direction == 6) { // N xlaunch = 0.0; ylaunch = -spitspeed; } else if (this->direction == 7) { // NE xlaunch = spitspeed; ylaunch = -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; } } } void daFireLaser_c::endState_pewpewpew() { }