No durability loss on weapons & XP gain from monster infighting

Talk about Severance Blade of Darkness modifications and maps here. No tips or tech support questions please, use the forum above. Note that the game is rated 18 so some content may be unsuitable for younger readers.

Moderators: prospero, Ade

Post Reply
User avatar
Sordid
Hatchling
Posts: 4
Joined: Wed Mar 11, 2020 8:03 pm

No durability loss on weapons & XP gain from monster infighting

Post by Sordid »

So recently I decided to relive my childhood and play BoD again, and immediately I found myself wanting to make adjustments to some of the gameplay mechanics.

Removing durability loss from two-handed weapons was very easy, just comment out this line in damage.py and boom, weapons no longer lose durability when you block attacks with them:

Code: Select all

victimsShieldData[5][4]= victimsShieldData[5][4]-damage_withstood
I'm sure there's a more complex and elegant solution that changes two-handed weapons to not even have durability, similar to one-handed weapons, but this crude tweak is enough for my purposes.

My second issue is that monsters killing each other grants no experience to the player, and I'm having some trouble addressing that. I found the line where XP is awarded in basic_funcs.py:

Code: Select all

me.PartialLevel=me.PartialLevel+CharStats.GetCharExperienceReward(KilledEntity.CharType,KilledEntity.Level)
If I understand the chunk of code that line is part of correctly, it's a function that gets called when something kills something else. The line in particular awards XP to the killer based on the type and level of the creature killed, and the obvious problem is that if the killer is a monster, the XP goes to the monster rather than to the player.

I'm having some trouble tweaking this to always award XP to the player. I tried replacing "me" with "Bladex.GetEntity("Player1")", which is how the player character is referenced elsewhere in the code, and that does award XP to the player, but also only when the player gets the killing blow. I also tried inserting a tweaked version of this line into damage.py, towards the end of the damage calculation following the check for health less or equal to 0, which I understand to mean "run this code if the creature has been killed", but with the same result - I could get the game to award XP that way, but also only if the player gets the killing blow.

Having spent all day on this (I'm a coding noob with zero Python experience), I'm at the end of my rope and forced to ask for help from the only BoD modding forum I could find. Thanks for reading this. :)

User avatar
MBK_MBK
Dragon
Posts: 413
Joined: Sun Jun 19, 2011 9:06 am
Location: Spain
Contact:

Re: No durability loss on weapons & XP gain from monster infighting

Post by MBK_MBK »

Greetings friend. :)
Well, this is how the people starts to "modding"! :D :wink:
And this is how I started 10 years ago, from "zero"; wanting to modify, correct, add and improve things... :lol:

To "removing durability loss from two-handed weapons". YOU HAVE DONE WELL.. :)

To make "the hero always gain experience". YOU HAVE ALSO DONE IT WELL, ONLY ONE THING IS MISSING. :)
In the file ../Lib/Damage.py
Approximately near to the line: 1520
Use Notepad++ to look this code. In this code, the function "OnKilledEnemy" is called from the other file "Basic.Funcs.py":

AttackerEntity=Bladex.GetEntity(AttackerName)
if AttackerEntity:
. AttackerEntity.Data.OnKilledEnemy(VictimName)


Modify that code for what you've already tried to do, like this:

Hero=Bladex.GetEntity("Player1")#
if Hero.Life>=1:#
. Hero.Data.OnKilledEnemy(VictimName)#
Delete that point from the beginning of the line, I have put it so that the web respects the spaces.

Remember that the following line after the "if" conditioner; it must be tabulated at the beginning, or with 4 spaces, so that it is well in the syntax of the code. Before the code line "Hero.Data.OnKilledEnemy(VictimName)#", there must be a tab or 4 spaces. In this web can not see well the tab or spaces; so, Delete that point from the beginning of the line, I have put it so that the web respects the spaces.

Try it, this must to work well; I hope. 8) :)
Loose your ghosts, because they chain suspiciously your freedom.
My Youtube channel, tests with Hyperborean Mod:
https://www.youtube.com/user/MBEASTKING1980
Web site of Hyperborean mod:
https://sites.google.com/view/bodhyperboreanmodbymbk

User avatar
Sordid
Hatchling
Posts: 4
Joined: Wed Mar 11, 2020 8:03 pm

Re: No durability loss on weapons & XP gain from monster infighting

Post by Sordid »

MBK_MBK wrote: Thu Mar 12, 2020 6:05 am Try it, this must to work well; I hope. 8) :)
Works great, thank you so much! :D

I don't understand why they coded it this way. They call OnKilledEnemy whenever something kills something else, but all OnKilledEnemy does is award XP and level up the player. And there's even a specific check in OnKilledEnemy to make sure the level up code doesn't run unless it's the player receiving the XP. So... they allow enemies to gain XP but not to level up? I don't get it. As far as I know, monsters gaining XP doesn't do anything. If they wanted to prevent the player from gaining XP from monster infighting, they could've simply put a check in the damage calculation to only call OnKilledEnemy if the killing blow is delivered by the player, right? Why even call OnKilledEnemy at all when a monster kills another monster?

User avatar
MBK_MBK
Dragon
Posts: 413
Joined: Sun Jun 19, 2011 9:06 am
Location: Spain
Contact:

Re: No durability loss on weapons & XP gain from monster infighting

Post by MBK_MBK »

About strange or illogical or crazy things, that is in the code of 20 years ago... :shock: :roll: I have also been thinking sometimes, "but how can this be done like this?" :? Who was the damn dude who filled all of unnecessary spaces and who does not know how to use tabs and comments well?
Answer: a hardware engineer. Hahaha... :lol: :mrgreen:

May be the original game could not be completely finished or corrected; In other words, the developer company (REBEL ACT) did not have the time or money to apply style and syntax corrections to the python code. :(

When I first became interested on improving the BoD game, I was reading and observing the game code for 8 months to understand the necessary basic mechanics... And I did it by correcting those strange crazy things that I saw in the code, while I also made more mistakes that I then had to correct. :oops: :roll:

It is possible for all characters to gain experience and level up by killing other characters.
Look in the file ../Stats/CharData.py
In the parameter "CharExperienceCost", only the 4 heroes are programmed; all other characters (or enemies) do not have programmed how many experience points they need to pass each level. So, if you put "10" for level 1 or 2, for example, the character will go up to level 1 and 2 when he gets 10 experience points. Always put higher numbers, at the highest levels.
Don't forget to modify the code from the other place again, so that the experience goes to whoever gave the last blow to the character who has died.

I have made the enemy level up, when he kills the hero; and that the hero level down as a penalty when killed by an enemy. Thus, it is not necessary to load the game every time they kill you. :idea: It was an idea, for example. :)

I like to make enemies very difficult, but I also like that the hero is skillful, strong or resistant enough to be able to defeat those difficult enemies. 8)
Another example: On the "Peasants Revolt" map (by Prospero), allies and enemies gain experience and level up, killing each other.
Well, there are many functions, entities, etc; a lot of complexity... At first it is a mess, very complex, too many variables; but then it is not so bad, if we compare it with the complexity of the code of the Great maps of master Prospero, or with the code that I am doing myself now for the Hyperborean Mod V1.6... For example, making dialogues is quite complex, but it's fun to see how it works in the game.

Greetings and good luck in your "mod-ing journey". :)
Loose your ghosts, because they chain suspiciously your freedom.
My Youtube channel, tests with Hyperborean Mod:
https://www.youtube.com/user/MBEASTKING1980
Web site of Hyperborean mod:
https://sites.google.com/view/bodhyperboreanmodbymbk

User avatar
Sordid
Hatchling
Posts: 4
Joined: Wed Mar 11, 2020 8:03 pm

Re: No durability loss on weapons & XP gain from monster infighting

Post by Sordid »

Ah, that's very cool! I don't think my modding journey is going to be much longer, weapon durability and XP from monsters killing each other are basically the only things that I really wanted to change about this game. Thanks so much for your help with that, it makes the game a lot more fun for me. Maybe someday I'll look into tweaking the combos a bit or something, but for now I'm happy.

User avatar
cieply
Dragon
Posts: 350
Joined: Wed Jun 26, 2013 3:43 pm

Post by cieply »

Sordid wrote: Wed Mar 11, 2020 9:18 pmMy second issue is that monsters killing each other grants no experience to the player
Why would they? Why would monster give experience points to player for their job? It's player job to eliminate "monsters" and he gets experience for that. In similar fashion monsters should get experience and level up. But that would require lot more work, and preparation of experience table in $BOD_DIR/Stats/CharData.py: CharExperienceReward={} (Experience points needed to move to the next level) and CharExperienceReward={} (Experience points given to the killer).


But if it's just to mod then feel free to do whatever you want, and remember to share with interesting discoveries on forum. There is whole, looooong topic relating modding: "Level Editing: Scripting". You may want to read it first, as there are many things done and many problems solved already there.
Even firstly you should read python tutorial, and concept of indentation in python as it will save you lot of time and nerves as python is not that obvious as it may seem at first glance.

Second thing is
Sordid wrote: Wed Mar 11, 2020 9:18 pmI tried replacing "me" with "Bladex.GetEntity("Player1")", which is how the player character is referenced elsewhere in the code
That's why you should know python a little bit before you start playing with code as it may be somewhat difficult without basics.
Bladex.GetEntity("Player1") is an object and me is variable. Somewhere before referencing me there had to be assignment: me = Bladex.GetEntity("Player1"). At this point me is the same what Player1 entity.
l'aria fresca,
vino puro, ...

User avatar
Sordid
Hatchling
Posts: 4
Joined: Wed Mar 11, 2020 8:03 pm

Re:

Post by Sordid »

cieply wrote: Tue Mar 31, 2020 6:34 pm
Sordid wrote: Wed Mar 11, 2020 9:18 pmMy second issue is that monsters killing each other grants no experience to the player
Why would they? Why would monster give experience points to player for their job?
Because it's really annoying to bring a monster down to 10% HP only for another monster to steal the kill. Annoyance is not a feeling I want any of the entertainment products I use to evoke, which is really the same reason I wanted to get rid of weapon durability loss as well.
feel free to do whatever you want
That's always been my plan.
Second thing is
Sordid wrote: Wed Mar 11, 2020 9:18 pmI tried replacing "me" with "Bladex.GetEntity("Player1")", which is how the player character is referenced elsewhere in the code
That's why you should know python a little bit before you start playing with code as it may be somewhat difficult without basics.
Bladex.GetEntity("Player1") is an object and me is variable. Somewhere before referencing me there had to be assignment: me = Bladex.GetEntity("Player1"). At this point me is the same what Player1 entity.
I know that. When I was playing around with it, it made no difference whether I referred to the object directly or stored it in a variable and used that. The solution MBK_MBK gave me works great, but I still don't quite get why mine doesn't. Not that it really matters.

User avatar
MBK_MBK
Dragon
Posts: 413
Joined: Sun Jun 19, 2011 9:06 am
Location: Spain
Contact:

Re: No durability loss on weapons & XP gain from monster infighting

Post by MBK_MBK »

Hello. :)
Many thanks for the Python tutorials! I appreciate it a lot! :D
Loose your ghosts, because they chain suspiciously your freedom.
My Youtube channel, tests with Hyperborean Mod:
https://www.youtube.com/user/MBEASTKING1980
Web site of Hyperborean mod:
https://sites.google.com/view/bodhyperboreanmodbymbk

User avatar
Sryml
Dragon
Posts: 206
Joined: Tue Aug 28, 2012 12:50 pm
Location: China
Contact:

Re: No durability loss on weapons & XP gain from monster infighting

Post by Sryml »

My second issue is that monsters killing each other grants no experience to the player, and I'm having some trouble addressing that.

Basic_Funcs.PlayerPerson.OnKilledEnemy is an instance function and you may not understand the concept. But you need to know who called this function and then self.Name points to whom.
So MBK's method is to make Player1 call it instead of the non-unique killer variable. The result is that no matter who killed the enemy, it is always considered to be done by Player1. I suddenly felt that Player1 was a miserable scapegoat, haha... :mrgreen:

And your method is to modify the function so that the rules are changed. The original reward was for whoever killed the enemy, but now the reward is always given to Player1.
Your method is correct, but you can be bold and directly assign the entity Player1 to the variable me. Then cancel the conditional judgment or make it always true, because if other killers call this function, then self.Name will point to the killer. In order not to reduce the indentation, I make it always true if 1:.



So the same result can have different processes.

Someday you will understand these codes, and everyone is here to help each other and make progress together. :D
Fear can hold you prisoner. Hope can set you free.
My YouTube: https://www.youtube.com/channel/UCg0SHO ... P3FdZLWzpQ

User avatar
MBK_MBK
Dragon
Posts: 413
Joined: Sun Jun 19, 2011 9:06 am
Location: Spain
Contact:

Re: No durability loss on weapons & XP gain from monster infighting

Post by MBK_MBK »

Hello, :)

Here is, the tutorials of Master Prospero: :wink:
http://prospero.bigtruck-canada.ca/

I can read the tutorials, better from there. :idea: :)
Loose your ghosts, because they chain suspiciously your freedom.
My Youtube channel, tests with Hyperborean Mod:
https://www.youtube.com/user/MBEASTKING1980
Web site of Hyperborean mod:
https://sites.google.com/view/bodhyperboreanmodbymbk

Post Reply