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 09-16-2010, 04:50 AM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
Adding exp once baddy killed

Well no matter how much I try I can't seem to get this script working! First the baddies join monster_base with their attributes set, then
PHP Code:
public function onNPCHit(itemIDdamagerangeattackereffectstypepos) {
  if(!
this.hit) {
    
this.hit true;

    
x// Stop movement

    
this.hp += damage;

    if(
this.hp <= 0) {
      
hide();
      
sleep(6);
      
show();
      
Respawn();
    }

    
this.hit false;
  }

  
ShowHP();

I've tried everything in this thread but have had no luck, can someone just post a simple script, not 3 or 4 scripts which will make my baddy work!
__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #2  
Old 09-16-2010, 04:52 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
Unless your damage is negative:

this.hp += damage;

should be

this.hp -= damage;
__________________
Quote:
Reply With Quote
  #3  
Old 09-16-2010, 04:57 AM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
Ah yes well my damage wasn't being set through the triggers or something and dealing -1 so i used +=
__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #4  
Old 09-16-2010, 05:09 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
Well judging by your code you still let them hit the NPC for whatever reason so just do something like...

PHP Code:
public function onNPCHit(itemIDdamagerangeattackereffectstypepos) { 
  if (
this.dead) return;
  
this.hp += damage;
  
showHP();
  if (
this.hp <= 0) {
    
this.dead true;
    
hide();
    
sleep(6);
    
show();
    
respawn();
  }
}

function 
respawn() {
  
// your other code
  
this.dead false;

__________________
Quote:
Reply With Quote
  #5  
Old 09-16-2010, 06:20 AM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
But how do I send the attacker param in the trigger? Talking about the sword and how do I get the baddy to add the exp to attacker

Edit: The damage system receives player.DoAttack and then triggers onNPCHit to the baddy
__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #6  
Old 09-16-2010, 06:30 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
pass player.account as a parameter then.

Here's a little example that might help you understand parameters a bit better.

PHP Code:
function onPlayerEnters() {
  
this.trigger("Example""random"12player.account36);
}

function 
onExample(abaccc) {
  echo(
a); // same as echo(params[0]);
  
echo(b); // same as echo(params[1]);
  
echo(acc); // same as echo(params[2]);
  
echo(c); // same as echo(params[3]);

When you get to the point where you have a working 'attacker' parameter you can then just do (assuming you have an EXP like the one I posted here)..

findplayer(attacker).addEXP(amount);
__________________
Quote:
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 03:23 AM.


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