Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Mana Shield Script (https://forums.graalonline.com/forums/showthread.php?t=62919)

Raeiphon 12-22-2005 05:29 PM

Mana Shield Script
 
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 :D

Lance 12-22-2005 09:56 PM

You can't set clientr.strings clientside (and have them stored on the server).

That is the point of clientr.strings.

Yen 12-22-2005 10:00 PM

You didn't close some lines with a ;
You can use if (isweapon) to check if it's the currently selected NPC.
It helps if you ever change the name.
Take out the toweapons part.
What's the point of dontblock?

Lance 12-22-2005 10:25 PM

Quote:

Originally Posted by Yen
You can use if (isweapon) to check if it's the currently selected NPC.

Uh, no, you can't? isweapon is true if the script is a weapon script. Please don't give bad advice.


All times are GMT +2. The time now is 06:57 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.