Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////
- //// THE DALEKS /////
- ///////////////////////
- //Type: Walking Enemy
- //Weapon: NONE
- //Death Attrib 1: Angle of vision
- //Death Attrib 2: Shot step speed
- //Death Attrib 3: Cooldown between shots
- //Extra Shots: Type of weapon to use; determines if it gets blocked by walls or different shields (see the EW_ section of std_constants.zh)
- //Touch Effects: NONE
- //Effect Strength: Shot SFX
- //Misc Attrib 11: First of 4 walking combos (up, down, left, right), or -1 to use enemy editor sprite
- //Misc Attrib 12: Number of FFC script slot with this script
- //"Shielded in ___" flags will work
- ffc script walkingLaserShooter{
- void run ( int enemyID ){
- npc ghost = Ghost_InitAutoGhost(this, enemyID);
- Ghost_SetFlag(GHF_NORMAL);
- Ghost_SetFlag(GHF_4WAY);
- //Get attributes
- int angleOfVision = ghost->Attributes[2];
- int shotStep = ghost->Attributes[3];
- int shotCooldownTime = ghost->Attributes[4];
- int weaponType = ghost->Attributes[5];
- //Attributes[4] is a drop-down box
- int shotSFX = ghost->Attributes[7];
- int shotCooldown = shotCooldownTime;
- int turnTimer = ghost->Rate * 10;
- int laserStartX;
- int laserStartY;
- eweapon beam;
- while(Ghost_HP > 0){
- //Shooting
- if ( shotCooldown > 0 )
- shotCooldown--;
- //Only one beam at a time
- else if ( !beam->isValid() ){
- //Check angle to Link against angle of vision
- int angleToLink = Angle(CenterX(ghost), CenterY(ghost), CenterLinkX(), CenterLinkY());
- int facingAngle = Dir4ToDeg(Ghost_Dir);
- int difference = Abs(angleToLink - facingAngle);
- //If Link is within this angle
- if ( difference <= angleOfVision/2 ){
- shotCooldown = shotCooldownTime;
- laserStartX = CenterX(ghost);
- laserStartY = CenterY(ghost);
- beam = FireAimedEWeapon(weaponType, laserStartX, laserStartY, 0, shotStep, ghost->WeaponDamage, 0, shotSFX, 0);
- beam->DrawXOffset = 999; //Draw off-screen
- }
- }
- //Draw laser beam
- if ( beam->isValid() ){
- Screen->Line(3, laserStartX, laserStartY, CenterX(beam), CenterY(beam), WLS_LASERCOLOR, 1, 0, 0, 0, WLS_LASEROPACITY);
- }
- //Change direction
- turnTimer--;
- if ( ghost->Step > 0 && turnTimer <= 0 ){
- //Home in on Link
- if ( ghost->Homing > Rand(256) ){
- int angle = RadianAngle(ghost->X, ghost->Y, Link->X, Link->Y);
- Ghost_Dir = RadianAngleDir4(angle);
- turnTimer = ghost->Rate * 10; //Reset turn timer
- }
- //Otherwise pick random direction
- else{
- Ghost_Dir = Rand(4); //Pick a random direction
- if ( CanWalk(Ghost_X, Ghost_Y, Ghost_Dir, 10, false) ) //If it can move there,
- turnTimer = Rand(ghost->Rate * 10); //Reset turn timer (otherwise try it next frame)
- }
- }
- Ghost_Move(Ghost_Dir, ghost->Step/100, ghost->Rate);
- Ghost_Waitframe(this, ghost, true, true);
- }
- }
- }
- int Dir4ToDeg(int dir){
- if ( dir == DIR_RIGHT )
- return 0;
- if ( dir == DIR_DOWN )
- return 90;
- if ( dir == DIR_LEFT )
- return 180;
- if ( dir == DIR_UP )
- return -90;
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement