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 12-18-2011, 03:58 AM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 818
PrinceOfKenshin has a spectacular aura about
Running Attack

Hey, I ran into a problem where I have weapon that's supposed to be allowing the player to use a sword gani while walking, basically pressing two keys at once (walking dir key, s key for attacking). Here's part of the script, which is triggered from a timeout:
PHP Code:
function onWalkCheck() {
  if (
player.ani == "e_weapon-1h-attack") {
    if(
keydown(5)) {
      
setani("e_weapon-1h-attackwalk"params[3]);
    }
  }

__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.

Last edited by PrinceOfKenshin; 12-18-2011 at 04:09 AM..
Reply With Quote
  #2  
Old 12-18-2011, 04:04 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
1. You have to use == to check for equality, one = is for assigning a value.
2. Your code is impossible to debug without the 'bigger' picture (the code that's responsible for calling onWalkCheck()).
3. Please use PHP tags instead, and style your code properly when you post it. You can use my beautifier to do that for you: http://fp4.ca/gs2beautifier
__________________
Quote:
Reply With Quote
  #3  
Old 12-18-2011, 04:15 AM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 818
PrinceOfKenshin has a spectacular aura about
fixed the style and syntax errors. Here is the timeout

PHP Code:
function onTimeout() {
  
this.oldplx player.x;
  
this.oldply player.y;
  
onWalkCheck();
  if (
player.account == "DrakilorP2P") {
    
showtext(20016100"""""Classes: " player.joinedclasses);
    
changeimgvis(2004);
  }
  if (!
player.isinclass("player_combat") || !player.isinclass("methods_health")) {
    if (
player.account == "DrakilorP2P") {
      
changeimgcolors(2001001);
    }
    
setTimer(0.05);
    return;
  }
  if (
player.account == "DrakilorP2P") {
    
changeimgcolors(2000101);
  }
  if (
canAttack()) {
    if (
keydown(5)) { //S
      //if (keydown(6)) { //A
      
attack();
    }
  }
  if (
this.dashFramesLeft 0) {
    if (!
onwall2(player.vecx(player.dir) * 0.5player.vecy(player.dir) * 0.533)) {
      
player.+= vecx(player.dir) * 0.5;
      
player.+= vecy(player.dir) * 0.5;
    }
    
this.dashFramesLeft--;
  }
  if (
this.shakeFramesLeft 0) {
    
this.shakeFramesLeft--;
    if (
this.shakeFramesLeft 0) {
      
temp.random(0pi 2);
      
temp.random(00.25);
      
setfocus(player.cos(temp.a) * temp.rplayer.sin(temp.a) * temp.r);
    } else {
      
resetfocus();
    }
  }
  
setTimer(0.05);

__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
Reply With Quote
  #4  
Old 12-18-2011, 04:54 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
I think your best bet is to replace the walking gani while the player is attacking, and then set it back to the walking gani when the player is done their attack.

I.e:

PHP Code:
function attack() {
  
replaceani("walk""new_walking_ani");
  
this.scheduleevent(0.5"FixWalkingAni""");
}

function 
onFixWalkingAni() {
  
replaceani("walk""proper_walking_ani");

Your walk check seems unnecessary.
__________________
Quote:
Reply With Quote
  #5  
Old 12-20-2011, 09:34 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
We replaced the gani under the Attack function, which supprisingly resulted in the gani being replaced at all times.. That's kinda an issue, but here's what we have:

PHP Code:
function attack() {
    
this.onehands = {
      
"katana""rubyblade""blueaxe""grayblade"
    
};
    if (
player.clientr.weaponClass "blueaxe"player.attr[3] = "e_weapon-blueaxe.png";
    if (
player.clientr.weaponClass "grayblade"player.attr[3] = "e_weapon-grayblade.gif";
    if (
player.clientr.weaponClass "rubyblade"player.attr[3] = "spawn_ruby-blade.gif";
    if (
player.clientr.weaponClass ""player.attr[3] = "";
    if (
player.clientr.weaponClass in this.onehands) {
      
setani("e_weapon-1h-attack"player.attr[3]);
      
sleep(1);
    }
    elseif(
player.clientr.weaponClass == "mallet"setani("dusty_hammer""whammer1.png""lift.wav");
    elseif(
player.clientr.weaponClass == "staff"setani("esteria_weapon-trainstaff-attack1"null);
    elseif(
player.clientr.weaponClass == "destructoaxe"setani("e_destructoaxe-attack"null);
    elseif(
player.clientr.weaponClass == "goldensword"setani("e_goldensword-attack"null);
    else 
setani("e_punch"null);
 
    
//this.nextAttack = .1;
    
if (player.clientr.weaponClass == "katana"this.dashFramesLeft 5;
    if (
player.clientr.weaponClass == "mallet"this.shakeFramesLeft 5;
    
triggerServer("weapon"this.name"attack");
    
// The Gani replacement.
    
if (player.clientr.weaponClass in this.onehands) {
      
replaceani("walk""e_weapon-1h-attackwalk");
      
player.chat "replace";
      
sleep(.5);
      
replaceani("e_weapon-1h-attackwalk""walk");
    }

Reply With Quote
  #6  
Old 12-20-2011, 09:42 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Alpho View Post
We replaced the gani under the Attack function, which supprisingly resulted in the gani being replaced at all times.. That's kinda an issue, but here's what we have:

PHP Code:
    if (player.clientr.weaponClass in this.onehands) {
      
replaceani("walk""e_weapon-1h-attackwalk");
      
player.chat "replace";
      
sleep(.5);
      
replaceani("e_weapon-1h-attackwalk""walk");
    } 
Because itīs in a timeout?
In case yes, you shouldnīt use sleep() in a timeout
__________________
MEEP!
Reply With Quote
  #7  
Old 12-20-2011, 09:53 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
If you press the key 'S', then the Attack function is triggered. There is no timeout used here. I am just using replaceani, then a sleep which would generally be as long as the attack gani is, then replace the gani back to normal. The player chat is there so I could see that it works.
Reply With Quote
  #8  
Old 12-20-2011, 10:09 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by Alpho View Post
We replaced the gani under the Attack function, which supprisingly resulted in the gani being replaced at all times.. That's kinda an issue, but here's what we have:

PHP Code:
      // blah blah ...
      
replaceani("e_weapon-1h-attackwalk""walk"); 
try
PHP Code:
replaceani("walk","walk"); 
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
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 10:23 PM.


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