Jump to content
  • 0

Get player level & monster level OnNpcKill


gekigengar

Question


  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   2
  • Joined:  08/30/13
  • Last Seen:  

This is my script draft.

OnInit:
@score = 0;
@bonus = 0;

Onnpckill:
@bonus = (moblevel - playerlevel);
if (@bonus < 1) {
@bonus = 1;
}
@score += (1 + (Moblevel/2) + @bonus);

OnLogOut:
@score = 0

 

How do I obtain moblevel and playerlevel?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Player's Level

BaseLevel   - Character's base level.

Monster's Level

*getmonsterinfo(<mob ID>,<type>)

This function will look up the monster with the specified ID number in the
mob database and return the info set by TYPE argument.
It will return -1 if there is no such monster (or the type value is invalid),
or "null" if you requested the monster's name.

Valid types are listed in 'db/const.txt':
MOB_NAME 0
MOB_LV 1
MOB_MAXHP 2
MOB_BASEEXP 3
MOB_JOBEXP 4
MOB_ATK1 5
MOB_ATK2 6
MOB_DEF 7
MOB_MDEF 8
MOB_STR 9
MOB_AGI 10
MOB_VIT 11
MOB_INT 12
MOB_DEX 13
MOB_LUK 14
MOB_RANGE 15
MOB_RANGE2 16
MOB_RANGE3 17
MOB_SIZE 18
MOB_RACE 19
MOB_ELEMENT 20
MOB_MODE 21
MOB_MVPEXP 22

For more details, see the sample in 'doc/sample/getmonsterinfo.txt'.

So for you it would be something like this:

OnNPCKillEvent:
@bonus = ( getmonsterinfo(killedrid,1) - BaseLevel ); // killedrid is the ID of the monster killed.
if( !@bonus ){ @bonus = 1; }
@score += (1 + ( getmonsterinfo(killedrid,1) / 2 ) + @bonus);
end;
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   2
  • Joined:  08/30/13
  • Last Seen:  

Player's Level

BaseLevel   - Character's base level.

Monster's Level

*getmonsterinfo(<mob ID>,<type>)

This function will look up the monster with the specified ID number in the
mob database and return the info set by TYPE argument.
It will return -1 if there is no such monster (or the type value is invalid),
or "null" if you requested the monster's name.

Valid types are listed in 'db/const.txt':
MOB_NAME 0
MOB_LV 1
MOB_MAXHP 2
MOB_BASEEXP 3
MOB_JOBEXP 4
MOB_ATK1 5
MOB_ATK2 6
MOB_DEF 7
MOB_MDEF 8
MOB_STR 9
MOB_AGI 10
MOB_VIT 11
MOB_INT 12
MOB_DEX 13
MOB_LUK 14
MOB_RANGE 15
MOB_RANGE2 16
MOB_RANGE3 17
MOB_SIZE 18
MOB_RACE 19
MOB_ELEMENT 20
MOB_MODE 21
MOB_MVPEXP 22

For more details, see the sample in 'doc/sample/getmonsterinfo.txt'.

So for you it would be something like this:

OnNPCKillEvent:
@bonus = ( getmonsterinfo(killedrid,1) - BaseLevel ); // killedrid is the ID of the monster killed.
if( !@bonus ){ @bonus = 1; }
@score += (1 + ( getmonsterinfo(killedrid,1) / 2 ) + @bonus);
end;

Thanks again, you really helped up!

 

may I ask why did you use !@bonus?

 

What does that mean in this line?

 

if( !@bonus )

 

I apologize as I am far too green in matters of programming.

 

But I do learn fast from mistakes and curiosity, which makes up for experience.

Edited by gekigengar
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

That's no problem. Everyone who starts scripting for rAthena, is in the same boat in one way or the other.

! - Logical Not.
Reverses the boolean result of an expression. True will become false and
false will become true.

Example:
if(!callfunc("F_dosomething"))
{
mes "Doing something failed.";
close;
}

In the case I used it can be seen as that 1 = True and Anything Lower is False.
General Rule of thumb is the following:

True = +/- Numbers

Fase =  0

Example:

set @bonus,1;
if( !@bonus ) { this won't be shown, because @bonus is TRUE not false. }
else { this will be shown because the above didn't }

Additionally, it can be seen as this to check if the statement is TRUE instead of false.

set @bonus,1;
if( @bonus ){ this will be seen, because I'm checking to see if @bonus is "true" instead of false }
else { this will not be shown because the above was true }

I may not have given the best explination/example for this, but if you were to read / briefly skim through: https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

You'll learn all you need to know and more. And ofcourse, you can always come back to the script_support section for further help.

Edited by GmOcean
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

In the case I used it can be seen as that 1 = True and Anything Lower is False.

General Rule of thumb is the following:

True = + Numbers

Fase =  - Numbers & 0

negative number count as "true" ...

 

JCxkFHH.jpg

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Really? Hmm, it's been counting as negative in a few of my scripts O.o; Well, time to change them around to prevent future errors lmao. Oh wellz, Edited my post.

Edited by GmOcean
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
Answer this question...

×   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...