Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-22-2005, 05:29 PM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
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
__________________

I hope for nothing. I fear nothing. I am free.
Reply With Quote
  #2  
Old 12-22-2005, 09:56 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
You can't set clientr.strings clientside (and have them stored on the server).

That is the point of clientr.strings.
Reply With Quote
  #3  
Old 12-22-2005, 10:00 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
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?
Reply With Quote
  #4  
Old 12-22-2005, 10:25 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:36 AM.


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