#1Subject: Questions about modifying source (various) 7/10/2020, 2:13 am
Hey guys,
I've been fiddling around with the config files and source code a bit and some questions have come up.
1. To start, I'm not sure exactly how the drop rates interact. It seems that they are connected to each other, but it seems (to me) to be complex. Any clarity on the drop rate numbers in setting.cfg will help. I do understand that primary drop rate affects how often items/gold/etc drops. I'm not too sure on the secondary/rare one though. I haven't been able to tell much difference on these even when I change them.
2. I've added some new items (just re-colored skins of old ones) and have them dropping from mobs, but I can't figure out how to get them to drop with the enchants (stats) on them. I'm hoping it's as easy as adding their item id's to a list somewhere, but I have a feeling it isn't.
3. I added a new spell, but I'm not sure how to give it graphics. I was unable to locate the portion of code that tells the game what spell has what graphic. I have one I'd like to use, but not sure how to hook it up! Any help would be appreciated
4. I want to change some things in the shop/blacksmith, but I can't seem to locate their code. I'd like to be able to add new items or change existing ones for sale. If anyone could point me in the right direction, I'd be very grateful!
I'm sure I'll have more questions come up as time goes on, and I'll refer back to this thread when they do. I also asked these questions in the official discord server - if someone helps me there or I figure it out, I'll try to add my answer here so that it might help someone else as well.
Thanks for all of your help guys!
Last edited by david909 on 7/11/2020, 1:27 am; edited 1 time in total
SabbaT[GM]
Silver 2
Earned by having 36 posts & comments.
Likes : 3
#2Subject: Re: Questions about modifying source (various) 7/10/2020, 8:05 am
1) for items drop, the main variables in hg src are: m_iPrimaryDropRate, m_iSecondaryDropRate
in NpcDeadItemGenerator, hg src.
the line: if (iDice(1, 10000) >= m_iPrimaryDropRate)
this line tells you that as bigger is m_iPrimaryDropRate, worst will be the probabilities of drop.
iDice returns a number(aleatory) between 1 an 10000. if m_iPrimaryDropRate = 1, 100% of drops probabilities if m_iPrimaryDropRate = 10000, 0% of drops probabilities a bigger number means worst probabilities.
m_iSecondaryDropRate is used for specials items, like sharp, ancient, etc. it use the rating of character, and some other opcions in a formula. a bigger number means better probabilities. the oposite than the m_iPrimaryDropRate
in olders hg src versions. this variables does not exist. they are 2 defaults numbers.
2) again. as i told before. in NpcDeadItemGenerator is your answer the variable dwType is used for special items values like sharp, ancient, etc. go several lines down and watch this.
again, iResult use iDice. is by default a number. pure luck. character rating or other factors does not matter here. you has to modified that. there you have the items: DEF_ITEMEFFECTTYPE_ATTACK DEF_ITEMEFFECTTYPE_ATTACK_DEFENSE DEF_ITEMEFFECTTYPE_ATTACK_MAXHPDOWN
go down, and you will found DEF_ITEMEFFECTTYPE_ATTACK_MANASAVE
and DEF_ITEMEFFECTTYPE_DEFENSE
each one has differents configurations.
3) let supose that ID "91" is Blizzard by default. in client src search "case "100+91":" then, search "case 191:" bAddNewEffect bEffectFrameCounter and an other fuction. but i dont remember the name.
not all the magics calls only that 2 functions. sometimes 3 diferents functions. i dont remembers the 3rd one.
take blisar, copy and paste. change the id, for an avaible one, like 99 in client. copy and paste case 191, modificate the frames of images, time, etc. go to magic.cfg add it for magic tower for buying. explorate the magic type in hg src, is the first number after magic's name.
david909
Silver 4
Earned by having 12 posts & comments.
Likes : 0
#3Subject: Re: Questions about modifying source (various) 7/10/2020, 4:55 pm
1. Sabba, thanks for your input! Your explanation helped the drop rates make a bit more sense. I'm still not sure what the rare drop rate does, but I have a better understanding of the other two now
2. With some help from Sleeq in the discord chat, I was able to get my new items (bows) to drop with stats! I was missing part of a line in npc.cpp - for me, it was line 2185 -
Code:
if (pItem->m_sItemEffectType == DEF_ITEMEFFECTTYPE_ATTACK || pItem->m_sItemEffectType == DEF_ITEMEFFECTTYPE_ATTACK_ARROW) {
I didn't have the or (||) in there before. To have bows drop I had to add it and the code after it so that bows would drop with stats. Sleeq provided me the code
3. I was able to find some of the code thanks to you! I haven't gotten it to have a spell effect yet, but I was able to make my custom spell display the magic circle when casting now. Progress! I'm hoping to figure out how to give it an effect later today - I found the code in game.cpp in the client source folder. It was under the bAddNewEffect function like you said. I think I need to add some code under the Draw function that follows to get the effect to display.
Thank you for your help!
david909
Silver 4
Earned by having 12 posts & comments.
Likes : 0
#4Subject: Re: Questions about modifying source (various) 7/10/2020, 9:23 pm
Hey guys, I have another question about the drop rates - I'm trying to figure out how the second drops / rares work, and I ran across this code in npc.cpp
Code:
if (iDice(1, 45) == 13) { switch (sNpcType) { case 11: if (iDice(1, 550) != 11) return FALSE; // Skeleton 2 * 100 case 12: if (iDice(1, 400) != 11) return FALSE; // Stone-Golem 2 * 100 case 13: if (iDice(1, 100) != 11) return FALSE; // Cyclops 6 * 100 case 14: if (iDice(1, 700) != 11) return FALSE; // Orc 4 * 100 case 17: if (iDice(1, 600) != 11) return FALSE; // Scorpoin 5 * 100 case 18: if (iDice(1, 850) != 11) return FALSE; // Zombie 1 * 100 case 22: if (iDice(1, 600) != 11) return FALSE; // Amphis 5 * 100 case 23: if (iDice(1, 400) != 11) return FALSE; // Clay-Golem 2 * 100 case 27: if (iDice(1, 100) != 11) return FALSE; // Hellhound 7 * 100 case 28: if (iDice(1, 100) != 11) return FALSE; // Troll 5 * 100 case 29: if (iDice(1, 150) != 11) return FALSE; // Orge 7 * 100 case 30: if (iDice(1, 120) != 11) return FALSE; // Liche 1 * 100 // Demon 5 * 100 case 32: if (iDice(1, 200) != 11) return FALSE; // Unicorn 5 * 100 case 33: if (iDice(1, 300) != 11) return FALSE; // WereWolf 7 * 100 case 48: if (iDice(1, 100) != 11) return FALSE; // Stalker case 52: if (iDice(1, 300) != 11) return FALSE; // Gagoyle case 53: if (iDice(1, 500) != 11) return FALSE; // Beholder case 54: if (iDice(1, 200) != 11) return FALSE; // Dark-Elf case 57: if (iDice(1, 400) != 11) return FALSE; // Giant-Frog case 63: if (iDice(1, 300) != 11) return FALSE; // Frost case 79: if (iDice(1, 200) != 11) return FALSE; // Nizie case 70: if (iDice(1, 200) != 11) return FALSE; // Barlog case 71: if (iDice(1, 200) != 11) return FALSE; // Centaurus default: break; } } else return FALSE;
switch (sNpcType) { case 11: // Skeleton case 17: // Scorpoin case 14: // Orc case 28: // Troll case 57: // Giant-Frog switch (iDice(1, 7)) { case 1: iItemID = 334; break; // LuckyGoldRing case 2: iItemID = 336; break; // SapphireRing case 3: if (iDice(1, 15) == 3) iItemID = 335; break; // EmeraldRing case 4: iItemID = 337; break; // RubyRing case 5: iItemID = 333; break; // PlatinumRing case 6: if (iDice(1, 15) == 3) iItemID = 634; break; // RingofWizard case 7: if (iDice(1, 25) == 3) iItemID = 635; break; // RingofMage } break;
case 13: // Cyclops case 27: // Hellhound case 29: // Orge switch (iDice(1, 7)) { case 1: iItemID = 311; break; // MagicNecklace(DF+10) case 2: if (iDice(1, 20) == 13) iItemID = 308; break; // MagicNecklace(MS10) case 3: if (iDice(1, 10) == 13) iItemID = 305; break; // MagicNecklace(DM+1) case 4: iItemID = 300; break; // MagicNecklace(RM10) case 5: if (iDice(1, 30) == 13) iItemID = 632; break; // RingofOgrepower case 6: if (iDice(1, 30) == 13) iItemID = 637; break; // KnecklaceOfLightPro case 7: if (iDice(1, 30) == 13) iItemID = 638; break; // KnecklaceOfFirePro } break;
I thought that this was what controlled the rare drops and their drop rates, but even when I changed the rates I was not able to tell any difference. I also tried changing the rare drop rate in the config file, but that also did not seem to make any change. Am I looking in the wrong place? Any insight would be appreciated!
SabbaT[GM]
Silver 2
Earned by having 36 posts & comments.
Likes : 3
#5Subject: Re: Questions about modifying source (various) 7/11/2020, 4:28 am
as i said before.
m_iSecondaryDropRate is used with m_cRepDropModifier and m_pClientList[]->m_iRating
let's use hg 2.24c version to explain.
Code:
dTmp1 = m_pClientList[sAttackerH]->m_iRating*m_cRepDropModifier; if (dTmp1 > 3000) dTmp1 = 3000; if (dTmp1 < -3000) dTmp1 = -3000; dTmp2 = (m_iSecondaryDropRate - (dTmp1)); if (iDice(1,10000) <= dTmp2) { .....................
dTmp1 is a number, given by m_iRating and m_cRepDropModifier the result can not be bigger than 3000, or smaller than -3000 dTemp2 is a number, the diference of m_iSecondaryDropRate and dTmp1
then... here comes de if statement... if the result of iDice is equal or lower than dtemp2, you can access to a second drop chances.
as i said, m_iPrimaryDropRate is used for only one item drop: GOLD if m_iPrimaryDropRate is too big, the chances of getting gold are to low. if m_iPrimaryDropRate is very small, there are big chances to get GOLD droped.
if you dont get gold, then the code says "else", here comes the m_iSecondaryDropRate if this statement is true,"if (iDice(1,10000) <= dTmp2)"
you have chances to get potions, candys, armor dyes, stone merien/xelime, etc and all that crap. if you wan to change "iResult = iDice(1,12000);", do it. you will be changing the probabilities of getting thouse items.
that is all you need to know about primary and secondary drops rate.
lets supose that the hg could not make any "true" in the first and second if statement. it could not give you gold, or potions/etc.
the "else" statement of the second if comes to save you. the next steep is selecting the npc type. using this. switch (m_pNpcList[iNpcH]->m_sType)
for each npc type, there is a "iGenLevel" after getting the "iGenLevel" you has to get 2 true condition in this:
Code:
if (iDice(1,10000) <= 6000) { if (iDice(1,10000) <= 8000) {
if you made it, you will get a weapond, depending on the iGenLevel if you dont, here comes the "else" statement of that if. here, you can get an armor, or shield. AGAIN. depending on iGenLevel
after all thouse "if"s and "else"s is time to create de item.
Code:
pItem = new class CItem; if (_bInitItemAttr(pItem, iItemID) == FALSE) {delete pItem; return; }
if _bInitItemAttr is FALSE, it means that the pItem with "iItemID" does not exist. here ends if it is true. if it doesnt, if item exist, code continues with a checking of m_sItemEffectType. if is a weapond, DEF_ITEMEFFECTTYPE_ATTACK magic staff, DEF_ITEMEFFECTTYPE_ATTACK_MANASAVE shield, DEF_ITEMEFFECTTYPE_DEFENSE
in thouse configuration you have the item type values for ancient, ritius, sharp, and other.
THATS ALL YOU NEED TO KNOW
Sponsored content
#6Subject: Re: Questions about modifying source (various)