Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Saffith, Antifairy
- // import "std.zh"
- // import "string.zh"
- // import "ghost.zh"
- // npc->Attributes[] indices
- const int WB_ATTR_TILE_WIDTH = 2;
- const int WB_ATTR_TILE_HEIGHT = 3;
- const int WB_ATTR_IGNORE_WATER = 4;
- const int WB_ATTR_IGNORE_PITS = 5;
- //Magic powder settings.
- const int WEAP_MAGIC_POWDER_SPRITE = 60; //Set this to the sprite ID that you wish to use.
- const int WEAP_MAGIC_POWDER_DIST = 4; //The distance away from Link to create the weapon.
- const int WEAP_MAGIC_POWDER_MISC_INDEX = 1; //The misc index to use for lweapon flag storage.
- const int WEAP_MAGIC_POWDER_MISC_FLAG = 000100b; //The flag for the magic powder.
- const int SFX_MAGICDUST = 63; //Sound for the Magic Powder
- //The size of Link's sprite.
- const int WEAP_MAGIC_POWDER_LINK_TILEHEIGHT = 16;
- const int WEAP_MAGIC_POWDER_LINK_TILEWIDTH = 16;
- item script MagicPowder
- {
- void run()
- {
- c //Magic powder is a sparkle-class weapon, so we are using a flag to (later) compare for it.
- Link->Action = LA_ATTACKING;
- lweapon dust = Screen->CreateLWeapon(LW_SPARKLE);
- if ( Link->Dir == DIR_UP )
- {
- dust->HitXOffset = 0; dust->HitYOffset = 0; dust->DrawXOffset = 0; dust->DrawYOffset = 0;
- dust->X = Link->X;
- dust->Y = (Link->Y - (WEAP_MAGIC_POWDER_LINK_TILEHEIGHT/2) - WEAP_MAGIC_POWDER_DIST);
- }
- else if ( Link->Dir == DIR_DOWN )
- {
- dust->HitXOffset = 0; dust->HitYOffset = 0; dust->DrawXOffset = 0; dust->DrawYOffset = 0;
- dust->X = Link->X;
- dust->Y = (Link->Y + (WEAP_MAGIC_POWDER_LINK_TILEHEIGHT/2) + WEAP_MAGIC_POWDER_DIST);
- }
- else if ( Link->Dir == DIR_LEFT )
- {
- dust->HitXOffset = 0; dust->HitYOffset = 0; dust->DrawXOffset = 0; dust->DrawYOffset = 0;
- dust->X = (Link->X - (WEAP_MAGIC_POWDER_LINK_TILEWIDTH/2) - WEAP_MAGIC_POWDER_DIST);
- dust->Y = Link->Y;
- }
- else if ( Link->Dir == DIR_RIGHT )
- {
- dust->HitXOffset = 0; dust->HitYOffset = 0; dust->DrawXOffset = 0; dust->DrawYOffset = 0;
- dust->X = (Link->X + (WEAP_MAGIC_POWDER_LINK_TILEWIDTH/2) + WEAP_MAGIC_POWDER_DIST);
- dust->Y = Link->Y;
- }
- else //default
- {
- dust->X = Link->X; dust->Y = Link->Y;
- }
- dust->UseSprite(WEAP_MAGIC_POWDER_SPRITE);
- dust->Misc[WEAP_MAGIC_POWDER_MISC_INDEX] |= WEAP_MAGIC_POWDER_MISC_FLAG;
- Game->PlaySound(SFX_MAGICDUST);
- }
- }
- ffc script AntiFairy //Changing the script name, for this application.
- {
- void run(int enemyID)
- {
- npc ghost;
- int flags;
- int angle;
- float step;
- float xStep;
- float yStep;
- // Initialize
- ghost=Ghost_InitAutoGhost(this, enemyID, GHF_NO_FALL);
- Ghost_TileWidth=Ghost_GetAttribute(ghost, WB_ATTR_TILE_WIDTH, 1, 1, 4);
- Ghost_TileHeight=Ghost_GetAttribute(ghost, WB_ATTR_TILE_HEIGHT, 1, 1, 4);
- Ghost_SpawnAnimationPuff(this, ghost);
- // Set flags
- flags=GHF_STUN|GHF_CLOCK;
- if(ghost->Attributes[WB_ATTR_IGNORE_WATER]>0)
- flags|=GHF_IGNORE_WATER;
- if(ghost->Attributes[WB_ATTR_IGNORE_PITS]>0)
- flags|=GHF_IGNORE_PITS;
- Ghost_SetFlags(flags);
- // Get initial movement
- angle=45+90*Rand(4);
- step=ghost->Step/100;
- ghost->Step=0; // In case it's a walker
- xStep=step*Cos(angle);
- yStep=step*Sin(angle);
- int become_faerie; //Using a simple var now, because the array indices were extraneous, and this is faster in run-time.
- while(true)
- {
- // Bounce
- if(xStep<0)
- {
- if(!Ghost_CanMove(DIR_LEFT, -xStep, 3))
- xStep*=-1;
- }
- else
- {
- if(!Ghost_CanMove(DIR_RIGHT, xStep, 3))
- xStep*=-1;
- }
- if(yStep<0)
- {
- if(!Ghost_CanMove(DIR_UP, -yStep, 3))
- yStep*=-1;
- }
- else
- {
- if(!Ghost_CanMove(DIR_DOWN, yStep, 3))
- yStep*=-1;
- }
- // And move
- //Check for 'Magic Power' interaction:
- for ( int q = Screen->NumLWeapons(); q > 0; --q )
- {
- lweapon lw = Screen->LoadLWeapon(q);
- if ( lw->ID != LW_SPARKLE ) { continue; }
- if ( lw->Misc[WEAP_MAGIC_POWDER_MISC_INDEX]&WEAP_MAGIC_POWDER_MISC_FLAG ) //matches against the magic powder flag set from the item script
- {
- if ( Collision(lw, this) ) { become_faerie = 1; break; }
- if ( Collision(lw, ghost) ) { become_faerie = 1; break; }
- }
- }
- //Transformation
- if ( become_faerie )
- {
- item fairy = Screen->CreateItem(I_FAIRY);
- fairy->X = ghost->X; //These do not need to be array indices. Changing them to use the base struct members. -Z
- fairy->Y = ghost->Y;
- ___kill(this,ghost);
- }
- Ghost_MoveXY(xStep, yStep, 3);
- Ghost_Waitframe(this, ghost, true, true);
- }
- }
- //Kills a ghosted enemy.
- void ___kill(ffc a, npc b)
- {
- ___kill(a); ___kill(b);
- Quit();
- }
- //Kills any npc, with no death effect.
- void ___kill(npc n)
- {
- n->HP = HP_SILENT;
- Remove(n);
- }
- //Clears an ffc to default system params. Note that ffc->Link was broken prior to 2.53,
- //and it is not possible for a script to set *its own* script ID to 0.
- void ___kill(ffc f)
- {
- f->Data = 0;
- f->Script = 0; //This will only work if ___kill(ffc) is called from another script.
- //e.g., AntiFairy.___kill(ffc)
- f->CSet = 0;
- f->Delay = 0;
- f->X = 0;
- f->Y = 0;
- f->Vx = 0;
- f->Vy = 0;
- f->Ax = 0;
- f->Ay = 0;
- f->TileWidth = 1;
- f->TileHeight = 1;
- f->EffectWidth = 16;
- f->EffectHeight = 16;
- f->Link = 0;
- for ( int q = 0; q <= 15; q++ ) f->Misc[q] = 0;
- for ( int q = 0; q <= 10; q++ ) f->Flags[q] = false;
- }
- }
- /*
- This will work with walking enemies so you can use their touch effects. Other attributes won't work normally.
- Attribute 3 (Death Attr. 1): Tile width (1-4, default 1)
- Attribute 4 (Death Attr. 2): Tile Height (1-4, default 1)
- Attribute 5 (Death Attr. 3): Move over water (0: no, 1: yes)
- Attribute 6 (Extra Shots): Move over direct warps (0: no, 1: yes)
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement