PHP Code:
// NPC made by Sephir Scarrend
//Mana Absorpotion Shield
//#CLIENTSIDE
if (created) {
this.state=0;
}
if (playertouchsme) {
toweapons Mana Shield;
}
if (weaponfired) {
if (strtofloat(#s(clientr.player_mp))>0) {
this.on=1;
} else {
setplayerprop #c, Not enough MP!;
}
timeout=.05;
setimg light2.png;
this.hearts=playerhearts;
this.state=0;
}
if (timeout) {
if (this.on==1) {
timeout=.05;
if(playerhearts!=this.hearts){
playerhearts=this.hearts;
freezeplayer 0;
}
showimg 1,light2.png,playerx-2.5,playery-2.5;
changeimgcolors 1,1,1,1,0.9;
this.state=(this.state+1)%12;
changeimgzoom 1,1-.08*this.state;
drawaslight;
this.mp = strtofloat(#s(clientr.player_mp))-.01; //MP drain while shield is active
setstring clientr.player_mp,#v(this.mp);
if (strtofloat(#s(clientr.player_mp))<0) {
this.on=0;
hideimg 1;
setimg door.gif;
dontblock;
this.mp = 0;
setstring clientr.player_mp,this.mp;
}
}
}
if (playerhurt) {
if (this.on==1) {
this.mp = strtofloat(#s(clientr.player_mp))-.35; //MP lost when hurt normally (damage absorption)
setstring clientr.player_mp,#v(this.mp)
}
}
//below lines allow for disabling the shield
if(keypressed){
if(keydown(6)){
if(strequals(Mana Shield,#w)){
if(this.on==1){
this.on=0;
setimg door.gif;
hideimg 1;
dontblock;
}
}
}
}
I have that, it works, perfectly, it's my first light script ever and my first try of doing any script without help.
I'm asking for criticism and what I can improve with this (nothing too complex please, or actually explain it to me..). If you want to use this on your server or anything, please let me know
