home *** CD-ROM | disk | FTP | other *** search
- function startShake(shakePower)
- {
- _global.s1.gotoAndPlay("shake_" + myRand(1,4));
- if(!lowRes)
- {
- if(idShake == 0)
- {
- _parent.moveZone.overlay_5.debris.gotoAndPlay("play");
- _parent.moveZone._y += shakePower;
- idShake = setInterval(shakeIt,30);
- }
- }
- }
- function shakeIt()
- {
- var curY = _parent.moveZone._y;
- if(curY < -0.4)
- {
- curY += myRand(0.1,0.8);
- }
- else if(curY > 0.4)
- {
- curY -= myRand(0.1,0.8);
- }
- else
- {
- curY = 0;
- clearInterval(idShake);
- idShake = 0;
- }
- curY = - curY;
- _parent.moveZone._y = curY;
- }
- function secretIn()
- {
- secretDiscovered = true;
- _parent.moveZone["BG_" + BGCur].gotoAndStop(2);
- persoXSpeed = 0;
- persoYSpeed = 0;
- }
- function secretOut()
- {
- _parent.moveZone["BG_" + BGCur].gotoAndStop(1);
- perso._x = secretInX;
- perso._y = secretInY;
- }
- function setDamage(instanceName, damageAmount)
- {
- instTemp = -1;
- j = 0;
- while(j < tabEnemy.length)
- {
- if(String(tabEnemy[j][0]) eq String(instanceName))
- {
- tabEnemy[j][1] += damageAmount;
- instTemp = j;
- break;
- }
- j++;
- }
- if(instTemp == -1)
- {
- tabEnemy.push([String(instanceName),damageAmount]);
- }
- }
- function getDamage(instanceName)
- {
- j = 0;
- while(j < tabEnemy.length)
- {
- if(String(tabEnemy[j][0]) eq String(instanceName))
- {
- return tabEnemy[j][1];
- }
- j++;
- }
- return -1;
- }
- function death()
- {
- persoIsDying = true;
- _parent.life["life_" + _root.persoLife].gotoAndPlay("close");
- _root.persoLife--;
- persoAnim("death");
- }
- function damage(damageAmount)
- {
- _root.persoHealth -= damageAmount;
- frameLife = Math.round(100 / _root.persoFullHealth * (_root.persoFullHealth - _root.persoHealth));
- if(idLife != 0)
- {
- clearInterval(idLife);
- }
- idLife = setInterval(animDamage,33);
- }
- function animDamage()
- {
- if(_parent.lifeBar._currentframe >= 100 and frameLife >= 100)
- {
- clearInterval(idLife);
- idLife = 0;
- _parent.lifeBar.gotoAndStop(100);
- death();
- }
- else if(_parent.lifeBar._currentframe < frameLife)
- {
- var lifeSpeed = Math.floor((_parent.lifeBar._currentframe - frameLife) / lifeBarSpeed);
- _parent.lifeBar.gotoAndStop(_parent.lifeBar._currentframe - lifeSpeed);
- }
- else if(_parent.lifeBar._currentframe > frameLife)
- {
- var lifeSpeed = Math.ceil((_parent.lifeBar._currentframe - frameLife) / lifeBarSpeed);
- _parent.lifeBar.gotoAndStop(_parent.lifeBar._currentframe - lifeSpeed);
- }
- else
- {
- clearInterval(idLife);
- idLife = 0;
- }
- }
- function persoAnim(action)
- {
- if(persoIsDying)
- {
- action = "death";
- }
- else if(persoIsInPain)
- {
- action = "hit";
- }
- else if(persoIsInvisible)
- {
- action = "invisible";
- }
- switch(action)
- {
- case "idle":
- if(persoIsActivating)
- {
- action = "activate";
- }
- else if(persoIsAttacking)
- {
- action = "attack";
- }
- else if(persoIsLanding)
- {
- action = "land";
- }
- break;
- case "run":
- if(persoIsLanding)
- {
- action = "land";
- }
- else if(persoIsAttacking)
- {
- action = "attack";
- }
- break;
- case "land":
- persoIsLanding = true;
- break;
- case "crouch":
- if(persoIsAttacking)
- {
- action = "attack";
- }
- break;
- case "attack":
- break;
- case "death":
- persoXSpeed = 0;
- }
- if(persoCurAction ne action)
- {
- perso.gotoAndStop(action);
- persoCurAction = action;
- }
- }
- function transitTo(direction)
- {
- _quality = "MEDIUM";
- inTransit = direction;
- transitNewX = (- BGWidth) * (BGCur + direction - 1);
- BGLast = BGCur;
- BGCur += direction;
- if(_root.level == 2 and BGCur + BGLast == 5)
- {
- transitAccel = 1;
- }
- else if(_root.level == 1 and BGCur == 9)
- {
- transitAccel = 1;
- }
- else
- {
- transitAccel = 3.5;
- }
- _parent.moveZone.attachMovie("BGHit_l" + _root.level + "_" + BGCur,"BG_" + BGCur,BGCur);
- _parent.moveZone.attachMovie("overlay_l" + _root.level + "_" + BGCur,"overlay_" + BGCur,101 + BGCur);
- with(eval("_parent.moveZone.BG_" + BGCur))
- {
- _x = BGWidth * (BGCur - 1);
- _y = 0;
- }
- with(eval("_parent.moveZone.overlay_" + BGCur))
- {
- _x = BGWidth * (BGCur - 1);
- _y = 0;
- }
- }
- function myRand(valMin, valMax)
- {
- x = Math.round(Math.random() * (valMax - valMin)) + valMin;
- return x;
- }
- function myRandDec(valMin, valMax)
- {
- return Math.random() * (valMax - valMin) + valMin;
- }
- enemyTab = new Array();
- damagedEnemyTab = new Array();
- damagedEnemyNum = 0;
- inTransit = 0;
- transitNewX = 0;
- transitXSpeed = 0;
- accroche = 8;
- keyUpListener = new Object();
- Key.addListener(keyUpListener);
- stillPressingKeyUp = false;
- keyAttListener = new Object();
- Key.addListener(keyAttListener);
- stillPressingKeyAtt = false;
-