Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-19-2011, 11:52 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Problems with onwall

The following script is part of a weapon, that when fired pushes any player in front of the player who fired the weapon a certain distance depending on how far away they are. Everything is working fine except for detecting a wall and stopping the player from going through it when they are hit. In this script I made it so my chat would say "onwall" if its detecting that the player is onwall and "good" if they are not, but regardless of where I fire the weapon wall present or not my chat always shows as "onwall", which leads me to believe I had no idea how to use onwall, but I haven't been able to find anything to help me with it. So yeah, as always, any help/advice would be greatly appreciated.

PHP Code:
function onActionServerSide(this.face, this.firex, this.firey){
  for (
temp.pl: players){
    if (
player.communityname != pl.communityname){
      
// Attack came from the bottom
      
if (face == 0){
        if(
pl.y in | firey - 2, firey -.1 |) {
          if(
pl.x in | firex - 1, firex + 1 |) {
            
pl.hearts = 0;
          }
        }
        if(
pl.y in | firey - 3, firey - 2.1 |) {
          if(
pl.x in | firex - 1.5, firex + 1.5 |) {
            
temp.strength = 12;
            for (
strength = 12; strength > 0; strength --){
              
sleep (.05);
              
pl.y = pl.y - .5;
              if (
onwall(pl.x,pl.y-1.5)){
                
player.chat = "onwall";
              }
              else{
                
player.chat = "good";
              }
            }
          }
        }
      }
      if(
pl.y in | firey - 4, firey - 3.1 |) {
        if(
pl.x in | firex - 2, firex + 2 |) {
          
temp.strength = 8;
          for (
strength = 8; strength > 0; strength --){
            
sleep (.05);
            
pl.y = pl.y - .5;
            if (
onwall(pl.x,pl.y-1.5)){
              
player.chat = "onwall";
            }
            else{
              
player.chat = "good";
            }
          }
        }
      }
      if(
pl.y in | firey - 5, firey - 4.1 |) {
        if(
pl.x in | firex - 2.5, firex + 2.5 |) {
          
temp.strength = 4;
          for (
strength = 4; strength > 0; strength --){
            
sleep (.05);
            
pl.y = pl.y - .5;
            if (
onwall(pl.x,pl.y-1.5)){
              
player.chat = "onwall";
            }
            else{
              
player.chat = "good";
            }
          }
        }
      }
    }
  }
} 
Reply With Quote
  #2  
Old 02-19-2011, 02:52 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Ahhh- you're doing this on the serverside.

What you should do is trigger to the clientside and move the player clientside with a similar function- it will be lassy laggy on your server.

HTML Code:
function onActionServerSide(this.face, this.firex, this.firey){ 
  for (temp.pl: findnearestplayers(this.firex, this.firey)){ 
    if (temp.pl == player) continue;

    //Do your HP checks here [to kill the player]
    temp.pl.triggerclient("weaponname for the function", "moveplayer", {this.face, this.firex, this.firey});
  }
}
in the weapon you trigger:
HTML Code:
//#CLIENTSIDE
function onActionClientside(option) {
  if (temp.option == "moveplayer") this.onmovePlayer(params[1]);
}

function onMovePlayer(data) {
  temp.face = temp.data[0];
  temp.firex = temp.data[1];
  temp.firey = temp.data[2];
  //Do your movement stuff
}
__________________

Last edited by xAndrewx; 02-19-2011 at 09:16 PM..
Reply With Quote
  #3  
Old 02-19-2011, 07:46 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
This line is incorrect:
Quote:
Originally Posted by xAndrewx View Post
PHP Code:
    if (temp.pl == player.account) continue; 
You're comparing the player object to the player's account. It might work through some quirk in GScript, but the proper way to do it is

PHP Code:
     if (temp.pl == player) continue; 
__________________
Reply With Quote
  #4  
Old 02-19-2011, 09:16 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
oh yeah- returns object hehe

(fixed) rep++ @ chris
__________________
Reply With Quote
  #5  
Old 02-20-2011, 03:47 PM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Thanks to you both, this fixed problem for me.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:24 AM.


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