Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   giveweapon help? (https://forums.graalonline.com/forums/showthread.php?t=134263858)

littlekinky 07-14-2011 11:04 AM

giveweapon help?
 
Alright so i got this script NPC i want it to give the player that killed the NPC a weapon, but have no idea how i'd start this, or even make it any suggestions?

Will be appreciated.

iBeatz 07-14-2011 12:15 PM

I suggest that when the NPC is slashed by way of the onWa****() event, it will add the weapon to the player like so:

PHP Code:

function onWa****(){
 
player.addweapon("your weapon name");
} 


callimuc 07-14-2011 03:58 PM

Quote:

Originally Posted by iBeatz (Post 1658722)
PHP Code:

function onWa****(){
 
player.addweapon("your weapon name");
} 


the onWa**** = onWas.hit
remove the .

fowlplay4 07-14-2011 04:41 PM

Your baddy should have an event that is called when it dies.

If you're using a classic system track the last person who hit the baddy using was hit (no space).

PHP Code:

function onWasH1t() {
  
this.last_attacker = player.account;
} 

When the baddie dies use findplayer and add the weapon. I.e:

findplayer(this.last_attacker).addweapon("SomeWeap onName");

BboyEatsbacon 07-16-2011 12:21 AM

PHP Code:

function onCreated() {
setTimer(0.05);
}
function 
onWasH1t() {
  
this.last_attacker = player.account;
}
function 
onTimeOut() {
if (
this.hearts == "0" || this.hearts == NULL) {
findplayer(this.last_attacker).addweapon("SomeWeaponName");
}
setTimer(0.05);
} 

(Remember to change "WasH1T" and change the "1" to an "i")
I believe that should be the final script, or something around there. =)

Also, remember rule one of posting in the scripting section of the Graal Forums.
Quote:

1. Be clear on your ability level. In other words, do not post asking for scripts, or asking people to fix scripts that are above your ability level. If you are writing a script to aid learning, then try writing a simpler script. If you are looking for a script for a server, then the best solution is probably to hire a scripter.

fowlplay4 07-16-2011 12:36 AM

Quote:

Originally Posted by BboyEatsbacon (Post 1658989)
(Remember to change "WasH1T" and change the "1" to an "i")
I believe that should be the final script, or something around there. =)

Also, remember rule one of posting in the scripting section of the Graal Forums.

No.

1. You can only loop at the speed of 0.1 seconds on the server-side.
2. Your "solution" would constantly add the weapon to the player while it's dead.
3. A properly scripted baddy would have a onBaddyDies event or similar making your timeout pointless.
4. See Quote.

Quote:

Originally Posted by Scripting Subforum Rules
If you aren't sure what you are doing, please don't post a solution. By posting bad advice, you are causing confusion


callimuc 07-16-2011 01:41 AM

[QUOTE=BboyEatsbacon;1658989]
PHP Code:

function onCreated() {
setTimer(0.05);
}
function 
onWasH1t() {
  
this.last_attacker = player.account;
}
function 
onTimeOut() {
if (
this.hearts == "0" || this.hearts == NULL) {
findplayer(this.last_attacker).addweapon("SomeWeaponName");
}
setTimer(0.05);
} 

Quote:

Originally Posted by fowlplay4 (Post 1658994)
2. Your "solution" would constantly add the weapon to the player while it's dead.

What fowlplay wants to say is:

PHP Code:

function onWasH1t() {
  
this.last_attacker = player.account;
  if (
this.hearts == "0" || this.hearts == NULL) { //If you use costume health system for baddies or whatever than replace it with this part
    
findplayer(this.last_attacker).addweapon("SomeWeaponName");
  }
} 

and again 1 = i at the WasH1t

fowlplay4 07-16-2011 01:46 AM

Quote:

Originally Posted by callimuc (Post 1659002)
What fowlplay wants to say is:

...

No that's not what I want to say at all. My posts indicate that the weapon should be added when the baddy dies not when it's hit and it's health is 0.

ffcmike 07-16-2011 01:49 AM

I'm curious as to whether this is supposed to be something happening with every baddy of that type, or just one specific baddy.

If it's a one-off baddy then within the class script it might be a good idea to do something like:

PHP Code:

function onWasH1t(){
  
this.hearts -= player.swordpower; //or whatever would be relevant damage/function name for the attack, I personally approach this in a much more sophisticated way
  
if(this.hearts <= 0){
    
this.trigger("BaddyKilled", player);
  }
} 

And then within the level NPC script which is joining the class:

PHP Code:

function onBaddyKilled(temp.killer){
  
temp.killer.addweapon("nameofweapon");
} 



All times are GMT +2. The time now is 11:19 PM.

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