home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Aventura
/
pendekar.swf
/
scripts
/
DefineSprite_426_mPendekar
/
frame_1
/
DoAction.as
Wrap
Text File
|
2006-05-08
|
6KB
|
316 lines
function init()
{
if(runOnce)
{
return undefined;
}
this.runOnce = true;
this.weapon = 1;
this.hp = 100;
if(_root.cheats_imp)
{
this.mp = 100;
}
else
{
this.mp = 0;
}
this.dir = 1;
this.power = 5;
this.hitable = true;
this.level = _Y;
this.nLevel = _Y;
this.charName = "Sangkala";
this.lives = _root.player1Lives;
if(_name.substr(0,6) == "player")
{
setKey(_root.player1Left,_root.player1Right,_root.player1Jump,_root.player1Duck,_root.player1Attack,_root.player1Special);
}
this.left = false;
this.right = false;
this.jump = false;
this.duck = false;
this.attack = false;
this.special = false;
this.intro = false;
gotoAndStop(getIdleState());
}
function setKey(keyLeft, keyRight, keyJump, keyDuck, keyAttack, keySpecial)
{
if(keyLeft == undefined)
{
keyLeft = 37;
}
if(keyRight == undefined)
{
keyRight = 39;
}
if(keyJump == undefined)
{
keyJump = 83;
}
if(keyDuck == undefined)
{
keyDuck = 40;
}
if(keyAttack == undefined)
{
keyAttack = 65;
}
if(keySpecial == undefined)
{
keySpecial = 68;
}
control = new Object();
control.onKeyDown = function()
{
if(Key.isDown(keyLeft) && !Key.isDown(keyRight))
{
left = true;
right = false;
}
else if(Key.isDown(keyRight) && !Key.isDown(keyLeft))
{
right = true;
left = false;
}
else if(Key.isDown(keyLeft) && Key.isDown(keyRight))
{
left = false;
right = false;
}
if(Key.isDown(keyJump) && !Key.isDown(keyDuck))
{
jump = true;
duck = false;
}
else if(Key.isDown(keyDuck) && !Key.isDown(keyJump))
{
duck = true;
jump = false;
}
else if(Key.isDown(keyJump) && Key.isDown(keyDuck))
{
jump = false;
duck = false;
}
if(Key.isDown(keyAttack))
{
attack = true;
}
if(Key.isDown(keySpecial))
{
special = true;
}
};
control.onKeyUp = function()
{
if(!Key.isDown(keyLeft))
{
if(Key.isDown(keyRight))
{
right = true;
}
left = false;
}
if(!Key.isDown(keyRight))
{
if(Key.isDown(keyLeft))
{
left = true;
}
right = false;
}
if(!Key.isDown(keyJump))
{
jump = false;
}
if(!Key.isDown(keyDuck))
{
duck = false;
}
if(!Key.isDown(keyAttack))
{
attack = false;
}
if(!Key.isDown(keySpecial))
{
special = false;
}
};
Key.addListener(control);
}
function moveRight()
{
speed = !duck ? 16 : 6;
if(dir < 0)
{
_X = !duck ? _X - 59 : _X - 30;
_xscale = _xscale * -1;
}
dir = 1;
gotoAndStop(!duck ? "mRun" : "mDuckWalk");
}
function moveLeft()
{
speed = !duck ? 16 : 6;
if(dir > 0)
{
_X = !duck ? _X + 59 : _X + 30;
_xscale = _xscale * -1;
}
dir = -1;
gotoAndStop(!duck ? "mRun" : "mDuckWalk");
}
function jumpRight()
{
speed = 16;
if(dir < 0)
{
_X = _X - 59;
_xscale = _xscale * -1;
}
dir = 1;
gotoAndStop(32);
}
function jumpLeft()
{
speed = 16;
if(dir > 0)
{
_X = _X + 59;
_xscale = _xscale * -1;
}
dir = -1;
gotoAndStop(32);
}
function jumpUp()
{
speed = 0;
gotoAndStop(32);
}
function attCombo(number)
{
if(number == undefined)
{
trace("err: Combo number undefined!");
return undefined;
}
gotoAndStop("mAttack0" + number);
}
function attWeapon()
{
gotoAndStop(23);
}
function attJump()
{
gotoAndStop(22);
}
function attDuck()
{
gotoAndStop(21);
}
function attSpecial()
{
if(mp < 40)
{
return undefined;
}
if(!_root.cheats_imp)
{
mp -= 40;
}
gotoAndStop(24);
}
function inStage()
{
if(_parent.isScroll)
{
if(dir == 1 && _X + 50 < Stage.width / 2)
{
return true;
}
if(dir == -1 && _X - 50 > 0)
{
return true;
}
return false;
}
if(dir == 1 && _X + 50 < Stage.width)
{
return true;
}
if(dir == -1 && _X - 50 > 0)
{
return true;
}
return false;
}
function dirValue(number)
{
return dir * number;
}
function sqrValue(g, x, h)
{
if(x == undefined || g == undefined || h == undefined)
{
trace("err: sqrValue(g,x,h) undefined!");
return undefined;
}
g = Math.ceil(g / 2);
return level -= h * (g - x);
}
function duckDown()
{
gotoAndStop(2);
}
function getHit(power, hard, object)
{
this.hitter = object;
if(power == undefined)
{
trace("err: Hit power undefined!");
power = 0;
}
tempHp = hp;
if(!_root.cheats_inv)
{
hp -= power;
}
if(hp > 0)
{
if(_Y >= nLevel)
{
gotoAndStop(!hard ? "mHit01" : "mHit02");
}
else
{
gotoAndStop(_Y >= nLevel ? "mHit01" : "mHit02");
}
}
else
{
gotoAndStop(36);
}
}
function pickup()
{
gotoAndStop(37);
}
function releaseWeapon(hitObject)
{
temp = _parent.spawnObject("oWeapon" + _parent.getWeaponName(weapon),_X + dirValue(50));
if(hitObject)
{
temp.tempGetHit = true;
}
weapon = 0;
special = false;
}
function getIdleState()
{
return weapon <= 0 ? "mIdle" : "mIdleWeapon";
}
this.onLoad = init();
stop();