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 07-14-2011, 11:04 AM
littlekinky littlekinky is offline
Registered User
littlekinky's Avatar
Join Date: Sep 2007
Posts: 185
littlekinky has a little shameless behaviour in the past
Post 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.
__________________
Reply With Quote
  #2  
Old 07-14-2011, 12:15 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
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");

__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #3  
Old 07-14-2011, 03:58 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 iBeatz View Post
PHP Code:
function onWa****(){
 
player.addweapon("your weapon name");

the onWa**** = onWas.hit
remove the .
__________________
MEEP!
Reply With Quote
  #4  
Old 07-14-2011, 04:41 PM
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
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");
__________________
Quote:
Reply With Quote
  #5  
Old 07-16-2011, 12:21 AM
BboyEatsbacon BboyEatsbacon is offline
The Bacon Man
BboyEatsbacon's Avatar
Join Date: Feb 2011
Location: United States
Posts: 60
BboyEatsbacon will become famous soon enough
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.
__________________
Reply With Quote
  #6  
Old 07-16-2011, 12:36 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
Quote:
Originally Posted by BboyEatsbacon View Post
(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
__________________
Quote:
Reply With Quote
  #7  
Old 07-16-2011, 01:41 AM
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=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 View Post
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
__________________
MEEP!
Reply With Quote
  #8  
Old 07-16-2011, 01:46 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
Quote:
Originally Posted by callimuc View Post
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.
__________________
Quote:
Reply With Quote
  #9  
Old 07-16-2011, 01:49 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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");

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 11:34 AM.


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