Register for your free account! | Forgot your password?

You last visited: Today at 21:04

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

 

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

Reply
 
Old   #1

 
elite*gold: 258
Join Date: Dec 2015
Posts: 104
Received Thanks: 123
[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
12 Users
Old   #2
 
elite*gold: 26
Join Date: Oct 2011
Posts: 1,262
Received Thanks: 1,056
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   #3

 
elite*gold: 258
Join Date: Dec 2015
Posts: 104
Received Thanks: 123
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   #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   #5

 
elite*gold: 258
Join Date: Dec 2015
Posts: 104
Received Thanks: 123
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   #6
 
elite*gold: 315
Join Date: Jun 2012
Posts: 5,055
Received Thanks: 4,771
u have this proble after paste this code?
some sf needs to implate 6/7 boni first to use
Lauling is offline  
Old   #7
 
elite*gold: 0
Join Date: Sep 2017
Posts: 117
Received Thanks: 18
Funktioniert.
Tested nice thanks.
Kryptonit.' is offline  
Old   #8
 
elite*gold: 0
Join Date: Nov 2013
Posts: 18
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   #9
 
elite*gold: 0
Join Date: Nov 2013
Posts: 18
Received Thanks: 1
Bump

There is a fix somewhere ? :x
voldakov is offline  
Old   #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   #11
 
elite*gold: 0
Join Date: Mar 2018
Posts: 34
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   #12
 
elite*gold: 0
Join Date: Nov 2013
Posts: 18
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   #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
https://www.elitepvpers.com/forum/me...l#post33513388
GucciMane. is offline  
Old   #14
 
elite*gold: 0
Join Date: Nov 2013
Posts: 18
Received Thanks: 1
Fixed, missing function in AddRareATTR
voldakov is offline  
Old   #15
 
elite*gold: 55
Join Date: Aug 2011
Posts: 1,000
Received Thanks: 391
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



« Previous Thread | Next Thread »

Similar Threads
[C++/Source] Item Bonus auf Maps
Guten Abend, Ich habe hier eine kleine Funktion geschrieben, und diese soll Bonuse von Item`s auf Maps ändern. Jedoch klappt meine const int...
0 Replies - Metin2 PServer - Discussions / Questions
[Source]NPC Menü texte direkt per Character.inc
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...
3 Replies - Flyff PServer Guides & Releases
Item Bonus Packs
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...
13 Replies - CO2 Main - Discussions / Questions



All times are GMT +2. The time now is 21:04.


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

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