Register for your free account! | Forgot your password?

You last visited: Today at 21:38

  • Please register to post and access all features, it's quick, easy and FREE!


[C++/SOURCE]6/7 Bonus direkt im Item

Discussion on [C++/SOURCE]6/7 Bonus direkt im Item within the Metin2 PServer Guides & Strategies forum part of the Metin2 PServer - Discussions / Questions category.

Reply
 
Old   #1
 
elite*gold: 258
Join Date: Dec 2015
Posts: 106
Received Thanks: 126
[C++/SOURCE]6/7 Bonus direkt im Item

Hallo,
Ich habe auf manchen Servern gesehen, dass gedropte Items mit einer geringen Wahrscheinlichkeit schon einen 6/7 Bonus drauf hatten.
Aus diesem Grund hab ich mich mal hingesetzt und das in C++ für euch geschrieben^^

Ihr öffnet item_manager.cpp und such nach:
Code:
LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagic, int iRarePct, bool bSkipSave)
Fügt darüber folgendes:
Code:
bool inArr(int* tab, int line) {
        for(int i = 0; i < sizeof(tab); i++){
                if(tab[i] == line)
                        return true;           
        }
        return false;
}
Nun sucht ihr in der Datei noch nach:
Code:
                        if (number(1, 100) <= iRarePct)
                                item->AlterToMagicItem();
Und fügt darunter folgendes ein:
Code:
                        int RareArray[2] = {1,2}; //Hier alle Typ angeben welche 6/7 Boni droppen sollen.
                        if(inArr(RareArray,item->GetType())){
                                if (number(1, 100) <= 20){ //20% Chance
                                        item->AddRareAttribute();
                                        if (number(1, 100) <= 10) // 10% Chance
                                                item->AddRareAttribute();
                                }                              
                        }
Kleine Erklärung zur Anpassung:
Code:
        int RareArray[2] = {1,2};
       
       
        //Wenn ihr hier in dem Array z.B. noch Gürtel haben wollt dann ändert es zu:
        int RareArray[3] = {1,2,34};
Ich hoffe ihr könnt etwas mit dem Release anfangen^^

Sollte soweit alles verständlich sein
Falls ihr fragen habt schreibt mich einfach in Skype an, ich beiße nicht



Creek' is offline  
Thanks
13 Users
Old 12/08/2015, 21:22   #2
 
elite*gold: 26
Join Date: Oct 2011
Posts: 1,262
Received Thanks: 1,057
Danke für dein Release!

Verbesserungsvorschlag:
C-style arrays zu verwenden ist seit C++11 nicht mehr nötig.
Gibt noch vereinzelt Dinge bei denen uns C-style arrays noch was bringen, sind aber nicht für M2 relevant. (Außer evtl. string literals... char[] ist in machen Situationen schon was tolles..)
Du kannst std::array verwenden. Ist ein besseres Interface für die gleiche "Containerart".
Wenn du std::array verwendest kannste auch nen Range-based loop verwenden, da std::array über .begin und .end Methoden verfügt.

- Socialized


He3o Crysis is offline  
Thanks
2 Users
Old 12/08/2015, 21:31   #3
 
elite*gold: 258
Join Date: Dec 2015
Posts: 106
Received Thanks: 126
Quote:
Originally Posted by Socialized View Post
Danke für dein Release!

Verbesserungsvorschlag:
C-style arrays zu verwenden ist seit C++11 nicht mehr nötig.
Gibt noch vereinzelt Dinge bei denen uns C-style arrays noch was bringen, sind aber nicht für M2 relevant. (Außer evtl. string literals... char[] ist in machen Situationen schon was tolles..)
Du kannst std::array verwenden. Ist ein besseres Interface für die gleiche "Containerart".
Wenn du std::array verwendest kannste auch nen Range-based loop verwenden, da std::array über .begin und .end Methoden verfügt.

- Socialized
Danke für deinen Tipp. Bin noch nicht so erfahren in C++, aber werde mal versuchen deinen Vorschlag umzusetzen

Grüße ^.^
Creek' is offline  
Old 12/09/2015, 13:00   #4
 
elite*gold: 0
Join Date: Feb 2012
Posts: 95
Received Thanks: 29
for(int i = 0; i < sizeof(tab); i++)i pretty much do not get it.
since sizeof tab is going to be bigger (unless you are under a system that has int set to 16bit only) then the length of your array. (here 4 btw)
there sizeof cannot detect the size of arrays passed from function to another one.
here is a sample of the bug:
PHP Code:
// sizeof-problem.cpp
// illustrates a bug of getting the size of an array using sizeof
#include <iostream>

void inArr(int*,int[]);

int main()
{
    
int ar_x[2] = {1,2};
    
// showing the sizeif ar_x where it was declared
    
std::cout << sizeof(ar_x) << std::endl// 8
    // passing ar_x to another function
    
inArr(ar_x,ar_x);
}

void inArr(inttabint line[]) // tab and line are both pointers to int there is no difference
{
    
std::cout << sizeof(tab) << " " << sizeof(line) << std::endl// 4

thus the size of a passed array of int is always 4 (under a system that set it to be 32bit (aka 4 byte))
consider using the array class next time.
btw im not german so sorry if someone already told you the same thing.

good luck.


kstmr is offline  
Thanks
1 User
Old 12/09/2015, 14:24   #5
 
elite*gold: 258
Join Date: Dec 2015
Posts: 106
Received Thanks: 126
Quote:
Originally Posted by kstmr View Post
for(int i = 0; i < sizeof(tab); i++)i pretty much do not get it.
since sizeof tab is going to be bigger (unless you are under a system that has int set to 16bit only) then the length of your array. (here 4 btw)
there sizeof cannot detect the size of arrays passed from function to another one.
here is a sample of the bug:
PHP Code:
// sizeof-problem.cpp
// illustrates a bug of getting the size of an array using sizeof
#include <iostream>

void inArr(int*,int[]);

int main()
{
    
int ar_x[2] = {1,2};
    
// showing the sizeif ar_x where it was declared
    
std::cout << sizeof(ar_x) << std::endl// 8
    // passing ar_x to another function
    
inArr(ar_x,ar_x);
}

void inArr(inttabint line[]) // tab and line are both pointers to int there is no difference
{
    
std::cout << sizeof(tab) << " " << sizeof(line) << std::endl// 4

thus the size of a passed array of int is always 4 (under a system that set it to be 32bit (aka 4 byte))
consider using the array class next time.
btw im not german so sorry if someone already told you the same thing.

good luck.
I have to thank you.
Now i tested it with the "_countof" and it seems to work.

_countof will always print the right size.

Code:
                        int RareArray[2] = {1,2}; //Hier alle Typ angeben welche 6/7 Boni droppen sollen.
                        if(inArr(RareArray,item->GetType(),_countof(RareArray))){
                                if (number(1, 100) <= 20){ //20% Chance
                                        item->AddRareAttribute();
                                        if (number(1, 100) <= 10) // 10% Chance
                                                item->AddRareAttribute();
                                }                              
                        }
Code:
bool inArr(int* tab, int line,int size) {
        for(int i = 0; i < size; i++){
                if(tab[i] == line)
                        return true;           
        }
        return false;
}
Creek' is offline  
Old 11/04/2017, 05:27   #6
 
elite*gold: 315
Join Date: Jun 2012
Posts: 5,055
Received Thanks: 4,775
u have this proble after paste this code?
some sf needs to implate 6/7 boni first to use
Lauling is offline  
Old 11/07/2017, 23:51   #7
 
elite*gold: 0
Join Date: Sep 2017
Posts: 117
Received Thanks: 18
Funktioniert.
Tested nice thanks.
Kryptonit.' is offline  
Old 03/10/2018, 22:12   #8
 
elite*gold: 0
Join Date: Nov 2013
Posts: 25
Received Thanks: 1
Do not work, try to connect with a ninja

syserr: number_ex: number(): first argument is bigger than second argument 0 -> -1, item_attribute.cpp 405
voldakov is offline  
Old 03/13/2018, 20:27   #9
 
elite*gold: 0
Join Date: Nov 2013
Posts: 25
Received Thanks: 1
Bump

There is a fix somewhere ? :x
voldakov is offline  
Old 03/15/2018, 13:22   #10
 
elite*gold: 0
Join Date: Mar 2013
Posts: 57
Received Thanks: 10
Quote:
Originally Posted by voldakov View Post
Do not work, try to connect with a ninja

syserr: number_ex: number(): first argument is bigger than second argument 0 -> -1, item_attribute.cpp 405

same problem ^^
synthou1234 is offline  
Old 03/15/2018, 21:43   #11
 
elite*gold: 0
Join Date: Mar 2018
Posts: 44
Received Thanks: 8
Quote:
Originally Posted by voldakov View Post
Do not work, try to connect with a ninja

syserr: number_ex: number(): first argument is bigger than second argument 0 -> -1, item_attribute.cpp 405
It doesn't matter what race your character has.
Can u maybe post your code so we can help you?

Kind regards
Ex0dia
Ex0dia is offline  
Old 03/22/2018, 20:20   #12
 
elite*gold: 0
Join Date: Nov 2013
Posts: 25
Received Thanks: 1
I use exactly same code here, compile fine, but when i want to log in my serveur, core dumped with this error :

syserr: number_ex: number(): first argument is bigger than second argument 0 -> -1, item_attribute.cpp 405

I never touch item_attribute.cpp file

my function in item_attribute.cpp


Line 405 : const TItemAttrTable& r = g_map_itemRare[avail[number(0, avail.size() - 1)]];
voldakov is offline  
Old 03/23/2018, 13:36   #13
 
elite*gold: 544
Join Date: Sep 2016
Posts: 148
Received Thanks: 206
Quote:
Originally Posted by voldakov View Post
I use exactly same code here, compile fine, but when i want to log in my serveur, core dumped with this error :

syserr: number_ex: number(): first argument is bigger than second argument 0 -> -1, item_attribute.cpp 405

I never touch item_attribute.cpp file

my function in item_attribute.cpp


Line 405 : const TItemAttrTable& r = g_map_itemRare[avail[number(0, avail.size() - 1)]];
post gdb you also should use this
GucciMane. is offline  
Old 03/28/2018, 10:49   #14
 
elite*gold: 0
Join Date: Nov 2013
Posts: 25
Received Thanks: 1
Fixed, missing function in AddRareATTR
voldakov is offline  
Old 04/02/2018, 23:09   #15
 
elite*gold: 55
Join Date: Aug 2011
Posts: 1,015
Received Thanks: 409
Quote:
Originally Posted by voldakov View Post
Fixed, missing function in AddRareATTR
Can you share the fix please?


x'Radon is offline  
Reply

Tags
bonus im item source



« [Bugfix]Mount riding bugs | [Release] Weapon Set by Maltasack »

Similar Threads
[C++/Source] Item Bonus auf Maps
10/25/2015 - Metin2 PServer - Discussions / Questions - 0 Replies
Guten Abend, Ich habe hier eine kleine Funktion geschrieben, und diese soll Bonuse von Item`s auf Maps ändern. Jedoch klappt meine const int Funktion nicht. Eingefügt im Code -> bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell) /* Item Bonus Check */ const int item_table = { 271, 274, 275 }; const int index_warp = { 1, 21, 41, 81, 62, 110, 111, 113, 63, 58, 143, 243 };
[Source]NPC Menü texte direkt per Character.inc
09/23/2012 - Flyff PServer Guides & Releases - 3 Replies
Mit diesem edit könnt ihr die texte für NPC menüs direkt via character.inc vergeben Beispiel: AddMenu2(MMI_TRADE , "Handel Mich an!"); dann hat dieser NPC anstatt Handel , handel mich an oder bei menüs wo ihr garnichts eingetragen habt in textclient.inc und somit ????? oder error ingame erscheint gleich das passende dazu(deswegen hab ich es bei mir gemacht) so könnt ihr euhc das lästige eintragen der define textclient.inc und .txt.txt sparen und das raussuche nder passenden id
Item Bonus Packs
01/07/2009 - CO2 Main - Discussions / Questions - 13 Replies
O.K, i have wanted to know for a while... ever since these came out... what items do u get, how many of them do u get, and at wat lvl do u get them... i know up to lvl 95, and there was onnly a 3 day heaven blessing thing... an exp ball, and a whole heap of exp potions, and at lvl 95 u get a super +1 helmet, suited for ur lvl... but wat do u get at lvl 100+??? ty in advance:handsdown:



All times are GMT +1. The time now is 21:38.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2019 elitepvpers All Rights Reserved.