Jump to content
  • 0

Quick question regarding || (or) in item scripts.


Mumbles

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

I'd like to know if such a result is possible:

if(Class == Job_Assassin || Class == Job_Assassin_Cross) { bonus2 bAddMonsterDropItem,908,200; || bonus2 bAddMonsterDropItem,909,200; }

 

The objective is:

[Assassin, Assassin Cross]

Add a 20% chance of gaining 'Jellopy' or 'Spawn' when a monster is killed.

 

Please note this is simply an example. The key word here is "or", with the goal of adding a chance to gain either a Jellopy or Spawn; not a chance to gain both.

Edited by Via
Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

if( rand(1) ) bonus2 bAddMonsterDropItem,908,200; else bonus2 bAddMonsterDropItem,909,200;

?

 

forget it won't work

Edited by Capuche
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

Can we use variables in item scripts? o3o

if(Class == Job_Assassin || Class == Job_Assassin_Cross) { for(set @var,rand(908,909); countitem(@var) > 0; set @var,rand(908,909) do(bonus2 bAddMonsterDropItem,@var,200;) }

 

I'm at school so I can't exactly test this til later today. Halp ;~;

Edited by Via
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  161
  • Reputation:   31
  • Joined:  12/06/11
  • Last Seen:  

bonus2 bAddMonsterDropItem,(rand(1)? 908:909),200;

 

Nevermind, what Capuche said I'll look into it later, bed first ~_~.

Edited by Jeroen
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

if( rand(1) ) bonus2 bAddMonsterDropItem,908,200; else bonus2 bAddMonsterDropItem,909,200;
?

 

forget it won't work

 
bonus2 bAddMonsterDropItem,(rand(1)? 908:909),200;
 

Nevermind, what Capuche said I'll look into it later, bed first ~_~.

rand(1) always returns 0. :P

It should be rand(2) if you want it to return 0 or 1.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

XD! Where are you my beloved brain ?!

 

 

 

btw none of us find an answer

Add a 20% chance of gaining 'Jellopy' or 'Spawn' when a monster is killed.

bonus2 bAddMonsterDropItem,(rand(2)? 908:909),200; just add 1 bonus when player equip the item

 

I think you need source modification

Edited by Capuche
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

Sigh. I mean, the logic seems right in either case; why *Athena doesn't already support variables in item scripts by now is beyond me. ;~;

 

Brian, halp!

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  410
  • Reputation:   29
  • Joined:  04/04/12
  • Last Seen:  

There's a backwards way around this.

 

Have the item call a function when equipped. 

 

if(Class == Job_Assassin || Class == Job_Assassin_Cross) { callfunc "awesomefunc"; }

 

In that function, have an 'OnNPCKillEvent' label with code like this in it:

OnNPCKillEvent:
set .@number,rand(0,1);
if (.@number == 0) {
     set .@drop,rand(0,9);
     if (.@drop < 2) 
          getitem 908,1;
}

else if (.@number == 1) {
     set .@drop,rand(0,9);
     if (.@drop < 2) 
          getitem 909,1;
}
break;
Edited by michaelsoftman
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  161
  • Reputation:   31
  • Joined:  12/06/11
  • Last Seen:  

How do item effects work anyway? I mean they have to be refreshed by re-equiping everytime. Anyway here's a little work around

 

-    script    IDrop    -1,{

OnNPCKillEvent:
    If(isequiped(.id))
        if(!rand(.chance))
            getitem (rand(2)? 908:909),1;
    end;

//Config
OnInit:
 set .id,1002; //Item ID of the item needed for the drop chance
 set .chance,5; //Chance of drop rate (2 = 1 in 2 (50%) 3 = 1 in 3 (33%), 4 = 1 in 4 (25%) etc.
 end;
 
}
Edited by Jeroen
  • Upvote 1
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...