Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #option SHORT_CIRCUIT on
- #option HEADER_GUARD on
- #option BINARY_32BIT off
- #include "std.zh"
- /**
- * Setup:
- * REQUIRES: `ZScript>>Quest Script Settings>>Objects` - `Weapons Live One Extra Frame With WDS_DEAD` must be checked.
- * InitD[]:
- * -d0 = turn rate (degrees per frame)
- * -d1 = wind drop rate (every x frames, drop wind visual effect)
- * Sprites[]:
- * -0 = sprite for the weapon
- * -1 = sprite for the wind visual effect
- */
- lweapon script GaleBRang
- {
- typedef const int DEFINE;
- typedef const int CONFIG;
- typedef const bool CONFIGB;
- CONFIG CF_BRANG_BOUNCE = CF_SCRIPT20;
- CONFIGB BOUNCE_OFF_FLAGS_ON_LAYERS_1_AND_2 = true;
- CONFIGB STOPS_WHEN_GRABBING_ITEMS = true;
- CONFIG DEFAULT_SPRITE = 5;
- CONFIG DEFAULT_WIND_SPRITE = 13;
- CONFIG DEFAULT_SFX = 4;
- DEFINE ROTATION_RATE = 20; //degrees
- CONFIG SFX_DELAY = 5;
- void run(int turnRate, int wind_drop_rate)
- {
- itemdata parent;
- int wind_sprite;
- int wind_clk;
- int sfx_clk;
- int sfx;
- if(this->Parent > -1) //Initialize with data from the item that created this.
- {
- parent = Game->LoadItemData(this->Parent);
- this->UseSprite(parent->Sprites[0]);
- wind_sprite = parent->Sprites[1];
- sfx = parent->UseSound;
- }
- else //If this weapon was created by a script, instead of an item, initialize with defaults.
- {
- parent = NULL;
- this->UseSprite(DEFAULT_SPRITE);
- wind_sprite = DEFAULT_WIND_SPRITE;
- sfx = DEFAULT_SFX;
- }
- this->Angular = true;
- this->Angle = DirRad(this->Dir);
- int radTurnRate = DegtoRad(turnRate);
- bool controlling = (Input->Button[CB_A] || Input->Button[CB_B]);
- itemsprite dragging = NULL;
- bool collided = false;
- until(this->DeadState == WDS_DEAD || collided)
- {
- if(dragging)
- {
- dragging->X = this->X;
- dragging->Y = this->Y;
- }
- if(controlling)
- {
- if(Input->Button[CB_LEFT])
- {
- this->Angle -= radTurnRate;
- }
- else if(Input->Button[CB_RIGHT])
- {
- this->Angle += radTurnRate;
- }
- }
- int pos = ComboAt(this->X + 8, this->Y + 8);
- for(int q = 0; q <= (BOUNCE_OFF_FLAGS_ON_LAYERS_1_AND_2 ? 2 : 0); ++q)
- {
- mapdata m = Game->LoadTempScreen(q);
- if(m->ComboF[pos] == CF_BRANG_BOUNCE || m->ComboI[pos] == CF_BRANG_BOUNCE)
- {
- collided = true;
- }
- }
- for(int q = Screen->NumItems(); q > 0; --q)
- {
- itemsprite it = Screen->LoadItem(q);
- unless(it->Pickup & IP_TIMEOUT) continue;
- if(Collision(it, this))
- {
- dragging = it;
- collided = STOPS_WHEN_GRABBING_ITEMS;
- }
- }
- if(controlling)
- ++Hero->Stun;
- wind_clk = (wind_clk + 1) % wind_drop_rate;
- sfx_clk = (sfx_clk + 1) % SFX_DELAY;
- unless(wind_clk) drop_sparkle(this->X, this->Y, wind_sprite);
- unless(sfx_clk) Audio->PlaySound(sfx);
- this->Rotation = WrapDegrees(this->Rotation + ROTATION_RATE);
- Waitframe();
- if(controlling) controlling = (Input->Button[CB_A] || Input->Button[CB_B]);
- }
- while(true)
- {
- this->DeadState = WDS_ALIVE;
- this->Angle = TurnTowards(this->X, this->Y, Hero->X, Hero->Y, this->Angle, 1); //Turn directly towards the Hero.
- if(Collision(this)) //touching the Hero
- {
- this->DeadState = WDS_DEAD;
- if(dragging)
- {
- dragging->X = Hero->X;
- dragging->Y = Hero->Y;
- }
- return;
- }
- if(dragging)
- {
- dragging->X = this->X;
- dragging->Y = this->Y;
- }
- wind_clk = (wind_clk + 1) % wind_drop_rate;
- sfx_clk = (sfx_clk + 1) % SFX_DELAY;
- unless(wind_clk) drop_sparkle(this->X, this->Y, wind_sprite);
- unless(sfx_clk) Audio->PlaySound(sfx);
- this->Rotation = WrapDegrees(this->Rotation + ROTATION_RATE);
- Waitframe();
- }
- }
- void drop_sparkle(int x, int y, int sprite)
- {
- lweapon sparkle = Screen->CreateLWeapon(LW_SPARKLE);
- sparkle->X = x;
- sparkle->Y = y;
- sparkle->UseSprite(sprite);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement