Jump to content

Release: OnPCAttackEvent


Mastagoon

Recommended Posts


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  63
  • Reputation:   35
  • Joined:  07/04/19
  • Last Seen:  

OnPCAttackEvent


This event triggers when a player character attacks another entity. And it registers the damage and other information about the attack.

Example usage:

// @damage holds the amount of damage dealt.
// @damagegid holds the GID of the target (account ID if the target is a player).
// @damagerid holds the rid of the mob
OnPCAttackEvent:
	dispbottom "You've dealt "+@damage+" to target with GID "+@damagegid+" and RID "+@damagerid;

 


 

  • Upvote 1
Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  173
  • Reputation:   9
  • Joined:  11/14/12
  • Last Seen:  

Hi! Good day! I tried manually adding your code, but I am getting this error:

 

Spoiler

CXX    battle.cpp
battle.cpp: In function ‘void battle_calc_attack_gvg_bg(Damage*, block_list*, block_list*, uint16, uint16)’:
battle.cpp:5060:4: error: ‘do_battle_events’ was not declared in this scope
    do_battle_events(src, target, wd->damage); // OnPcAttackEvent [Mastagoon]
    ^~~~~~~~~~~~~~~~
battle.cpp:5060:4: note: suggested alternative: ‘mobskill_event’
    do_battle_events(src, target, wd->damage); // OnPcAttackEvent [Mastagoon]
    ^~~~~~~~~~~~~~~~
    mobskill_event
battle.cpp:5068:4: error: ‘do_battle_events’ was not declared in this scope
    do_battle_events(src, target, wd->damage2); // OnPcAttackEvent [Mastagoon]
    ^~~~~~~~~~~~~~~~
battle.cpp:5068:4: note: suggested alternative: ‘mobskill_event’
    do_battle_events(src, target, wd->damage2); // OnPcAttackEvent [Mastagoon]
    ^~~~~~~~~~~~~~~~
    mobskill_event
battle.cpp:5080:4: error: ‘do_battle_events’ was not declared in this scope
    do_battle_events(src, target, wd->damage); // OnPcAttackEvent [Mastagoon]
    ^~~~~~~~~~~~~~~~
battle.cpp:5080:4: note: suggested alternative: ‘mobskill_event’
    do_battle_events(src, target, wd->damage); // OnPcAttackEvent [Mastagoon]
    ^~~~~~~~~~~~~~~~
    mobskill_event
battle.cpp: In function ‘Damage battle_calc_magic_attack(block_list*, block_list*, uint16, uint16, int)’:
battle.cpp:6424:2: error: ‘do_battle_events’ was not declared in this scope
  do_battle_events(src, target, ad.damage);
  ^~~~~~~~~~~~~~~~
battle.cpp:6424:2: note: suggested alternative: ‘mobskill_event’
  do_battle_events(src, target, ad.damage);
  ^~~~~~~~~~~~~~~~
  mobskill_event
battle.cpp: In function ‘Damage battle_calc_misc_attack(block_list*, block_list*, uint16, uint16, int)’:
battle.cpp:6822:2: error: ‘do_battle_events’ was not declared in this scope
  do_battle_events(src, target, md.damage);
  ^~~~~~~~~~~~~~~~
battle.cpp:6822:2: note: suggested alternative: ‘mobskill_event’
  do_battle_events(src, target, md.damage);
  ^~~~~~~~~~~~~~~~
  mobskill_event
make[1]: *** [Makefile:84: obj/battle.o] Error 1

 

Edited by sotf
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.01
  • Content Count:  16
  • Reputation:   0
  • Joined:  10/07/20
  • Last Seen:  

Can i use this to make a damage ranking? For example world boss damage ranking that will store the damage in my database

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  795
  • Reputation:   101
  • Joined:  05/23/12
  • Last Seen:  

Yes it's not really complicated. U can check if the killed mob is a boss monster or a monster of a list/an array. Save the mob ID of the latest monster u've attacked and the dealt damage in an array. Than OnPCKillEvent check if this monster u've killed is the monster u've attacked before. Than u can save ur dealt damage in a database. Later u can sort the damage by "highest first" and u have ur ranking. U can update a database entry which structure is like: "Char ID, Latest Mob ID, Latest Dealt Dmg, Total Dealt Dmg, Create Date, Latest Update Date" or u can use the account ID to combine the Dmg of all characters of an account. 

 

Rynbef~

Edited by Rynbef
Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   1
  • Joined:  10/30/13
  • Last Seen:  

Hi Im having error on your script

 

image.png.178584eb5e0e8df2f50387b85a892b19.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...