Comments (5)
Note the project's generally outdated. It could use a complete rewrite, pretty much from scratch. Which I did, in part, by creating a new demo here: https://github.com/GDQuest/godot-2d-jrpg-combat
If you want to report and fix bugs that's fine, just note I'm personally focusing on newer, better-written projects.
from godot-open-rpg.
I picked an old repository because I worry I'll interfere with somebody else work.
I'll fix this. Except I went down a rabbit hole. The function randf
is documented to be inclusive. I have confirmed experimentally that randf
can output exactly 1 and exactly 0 (it took a while),
One would expect chance = 0 to mean never, and chance = 1 to be always. If I write:
if drop.chance < randf():
continue;
Then when chance is 0 and randf is 0, that is false, and you would get the drop (it is not skipped). Which is wrong because chance of 0 is never.
If I write:
if drop.chance <= randf():
continue;
Then when chance is 1 and randf is 1, that is true, and you would not get the drop (it is skipped). Which is wrong because chance of 1 is always.
So, I should write something like
if drop.chance < 1 and drop.chance <= randf():
continue;
or
if drop.chance <= 0 or drop.chance < randf():
continue;
And my brain wants to simplify that so badly… And it is so error prone! If I confuse <
and <=
, or and
and or
, or 1
and 0
, it is wrong. I keep double guessing myself. I want a better way to write it, one where it is easier to notice if it is wrong.
With Microsoft (pseudo)random number generator (which I could use in C#), this is more intuitive, because it does not include the upper bound.
from godot-open-rpg.
Basically, you could get away with randf() <= drop.chance
.
For the rest, if an item has a drop chance of 0, it shouldn't be in the list of items an enemy can drop, that's an error from the designer, and you could use an assert to prevent that.
If you want to be extra sure for the "should always drop" case, you can add a condition.
if is_equal_approx(drop.chance, 1.0) or randf() < drop.chance:
# Add the items
That solves both problems.
from godot-open-rpg.
I picked an old repository because I worry I'll interfere with somebody else work.
When translating code to C#, you won't. If you have a doubt, open an issue or super WIP PR to say you'll be translating the code. As long as the repository isn't a work-in-progress, you're good to work on any.
from godot-open-rpg.
This is what I decided on: if drop.chance < 1 and randf() >= drop.chance:
, I have the pull request ready (Edit: I mean, for this fix), I was testing.
from godot-open-rpg.
Related Issues (20)
- Attacking one monster attacks them all HOT 4
- Error when trying to get rewards from a quest
- CompleteQuestAction: error if trying to complete an already-completed quest
- Remove the Localmap's Grid YSort HOT 1
- OpenRPG code rewrite HOT 11
- Duplicating Visual Script node loses custom script reference HOT 3
- Resources broken when project is exported to an .exe HOT 3
- One gray pixel line appear on tiles, when the camara moves HOT 2
- Auto battle HOT 1
- I want an example that only includes the turn combat system, but there is too much in this example. HOT 1
- Dialogue path is wrong
- rpg
- DialogueCombatPawn loops dialogue if Enter key is pressed HOT 1
- OpenRPG rewrite: Godot 4.X HOT 14
- Contributors guide link in readme leads to 404 HOT 1
- Add event sequences (dialogue, map changes, cutscenes, etc.) HOT 1
- Feature implementation: v 0.3.0 - Player Progression HOT 7
- QUERY: is there any accompanying dev documents or vedios available? HOT 1
- Combat Milestone HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godot-open-rpg.