Jump to content

Photo

Shields are hard.


  • Please log in to reply
1 reply to this topic

#1 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 26 February 2017 - 07:17 AM

As I went about on my scripting ventures, I was scripting a boss that is meant to equip a shield; which blocks attacks from the front much like how Link's shield does.

Well, as it turns out, scripting shields is not an easy affair and I am honestly stuck on how to do it. Can people give me pointers on how to make a scripted shield. While I am only working on a boss right now, I need it to also be compatible with regular enemies too as I will be needing shielded scripted enemies down the track.



#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 March 2017 - 04:39 AM

 
//Check if a weapon that exists can be blocked.
if ( BossBlockFlags(weap_id) ){ //Short circuit nesting.
    //Check if it is in proximity just ere collision.
    if ( DistXY(weap, boss, dist) ){ //More short-circuit nesting
        //Check if the weapon and boss are facing one-another.
        if ( Facing(weap, boss) && Facing(boss, weap) &&  ) { 
            weap->HitYOffset = -1000;  //Move the weapon collision box
            Game->PlaySound(SFX_PLINK);  //Play a shield block sound.
            CreateSprite(SPRITE_WEAPON_PLINK, weap->X, weap->Y);  //Make a deflection sprite.
            Remove(weap); //Kill the weapon.
        }
    } 
}
 
 
That is how I would do it.

If the enemy had a mirror shield, you could substitute Remove(weap) with:

Reflect(weap).

All of these functions, other than BossBlockFlags() are in that expanded std.zh pack for 2.54.

Edited by ZoriaRPG, 02 March 2017 - 04:50 AM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users