|
You last visited: Today at 09:04
Advertisement
[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 Private Server category.
12/08/2015, 21:02
|
#1
|
elite*gold: 258
Join Date: Dec 2015
Posts: 106
Received Thanks: 127
|
[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
|
|
|
12/08/2015, 21:22
|
#2
|
elite*gold: 26
Join Date: Oct 2011
Posts: 1,262
Received Thanks: 1,062
|
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
|
|
|
12/08/2015, 21:31
|
#3
|
elite*gold: 258
Join Date: Dec 2015
Posts: 106
Received Thanks: 127
|
Quote:
Originally Posted by Socialized
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 ^.^
|
|
|
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(int* tab, int 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.
|
|
|
12/09/2015, 14:24
|
#5
|
elite*gold: 258
Join Date: Dec 2015
Posts: 106
Received Thanks: 127
|
Quote:
Originally Posted by kstmr
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(int* tab, int 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;
}
|
|
|
11/04/2017, 05:27
|
#6
|
elite*gold: 315
Join Date: Jun 2012
Posts: 5,158
Received Thanks: 4,814
|
u have this proble after paste this code?
some sf needs to implate 6/7 boni first to use
|
|
|
11/07/2017, 23:51
|
#7
|
elite*gold: 0
Join Date: Sep 2017
Posts: 117
Received Thanks: 18
|
Funktioniert.
Tested nice thanks.
|
|
|
03/10/2018, 22:12
|
#8
|
elite*gold: 0
Join Date: Nov 2013
Posts: 26
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
|
|
|
03/13/2018, 20:27
|
#9
|
elite*gold: 0
Join Date: Nov 2013
Posts: 26
Received Thanks: 1
|
Bump
There is a fix somewhere ? :x
|
|
|
03/15/2018, 13:22
|
#10
|
elite*gold: 0
Join Date: Mar 2013
Posts: 58
Received Thanks: 10
|
Quote:
Originally Posted by voldakov
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 ^^
|
|
|
03/15/2018, 21:43
|
#11
|
elite*gold: 0
Join Date: Mar 2018
Posts: 44
Received Thanks: 9
|
Quote:
Originally Posted by voldakov
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
|
|
|
03/22/2018, 20:20
|
#12
|
elite*gold: 0
Join Date: Nov 2013
Posts: 26
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
bool CItem::AddRareAttribute()
{
int count = GetRareAttrCount();
if (count >= 2)
return false;
int pos = count + 5;
TPlayerItemAttribute & attr = m_aAttr[pos];
int nAttrSet = GetAttributeSetIndex();
std::vector<int> avail;
for (int i = 0; i < MAX_APPLY_NUM; ++i)
{
const TItemAttrTable & r = g_map_itemRare[i];
if (r.dwApplyIndex != 0 && r.bMaxLevelBySet[nAttrSet] > 0 && HasRareAttr(i) != true)
{
avail.push_back(i);
}
}
const TItemAttrTable& r = g_map_itemRare[avail[number(0, avail.size() - 1)]];
int nAttrLevel = 5;
if (nAttrLevel > r.bMaxLevelBySet[nAttrSet])
nAttrLevel = r.bMaxLevelBySet[nAttrSet];
attr.bType = r.dwApplyIndex;
attr.sValue = r.lValues[nAttrLevel - 1];
UpdatePacket();
Save();
const char * pszIP = NULL;
if (GetOwner() && GetOwner()->GetDesc())
pszIP = GetOwner()->GetDesc()->GetHostName();
LogManager::instance().ItemLog(pos, attr.bType, attr.sValue, GetID(), "SET_RARE", "", pszIP ? pszIP : "", GetOriginalVnum());
return true;
}
Line 405 : const TItemAttrTable& r = g_map_itemRare[avail[number(0, avail.size() - 1)]];
|
|
|
03/23/2018, 13:36
|
#13
|
elite*gold: 285
Join Date: Sep 2016
Posts: 148
Received Thanks: 208
|
Quote:
Originally Posted by voldakov
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
bool CItem::AddRareAttribute()
{
int count = GetRareAttrCount();
if (count >= 2)
return false;
int pos = count + 5;
TPlayerItemAttribute & attr = m_aAttr[pos];
int nAttrSet = GetAttributeSetIndex();
std::vector<int> avail;
for (int i = 0; i < MAX_APPLY_NUM; ++i)
{
const TItemAttrTable & r = g_map_itemRare[i];
if (r.dwApplyIndex != 0 && r.bMaxLevelBySet[nAttrSet] > 0 && HasRareAttr(i) != true)
{
avail.push_back(i);
}
}
const TItemAttrTable& r = g_map_itemRare[avail[number(0, avail.size() - 1)]];
int nAttrLevel = 5;
if (nAttrLevel > r.bMaxLevelBySet[nAttrSet])
nAttrLevel = r.bMaxLevelBySet[nAttrSet];
attr.bType = r.dwApplyIndex;
attr.sValue = r.lValues[nAttrLevel - 1];
UpdatePacket();
Save();
const char * pszIP = NULL;
if (GetOwner() && GetOwner()->GetDesc())
pszIP = GetOwner()->GetDesc()->GetHostName();
LogManager::instance().ItemLog(pos, attr.bType, attr.sValue, GetID(), "SET_RARE", "", pszIP ? pszIP : "", GetOriginalVnum());
return true;
}
Line 405 : const TItemAttrTable& r = g_map_itemRare[avail[number(0, avail.size() - 1)]];
|
post gdb you also should use this
|
|
|
03/28/2018, 10:49
|
#14
|
elite*gold: 0
Join Date: Nov 2013
Posts: 26
Received Thanks: 1
|
Fixed, missing function in AddRareATTR
|
|
|
04/02/2018, 23:09
|
#15
|
elite*gold: 105
Join Date: Aug 2011
Posts: 1,065
Received Thanks: 494
|
Quote:
Originally Posted by voldakov
Fixed, missing function in AddRareATTR
|
Can you share the fix please?
|
|
|
 |
|
Similar Threads
|
[C++/Source] Item Bonus auf Maps
10/25/2015 - Metin2 Private Server - 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 - Conquer Online 2 - 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 09:04.
|
|