forked from gdquest-demos/godot-open-rpg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Monsters can now be configured to drop items based on a resource (MonsterDrops.gd). The usability is not the greatest, but that's due to not being able to export custom types. There were two possible approaches that I saw: 1. An `Array` holding dictionaries for each item that can be dropped along with the data needed for the drop behavior. 2. Create a custom resource that would encapsulate all the data for the items that can be dropped from a monster: The item itself, min and max quantities, and the chance. I decided to go with the first one. ps: The items are _NOT_ being added to the player's inventory . This is just the functionality needed for the monsters to start dropping items. Closes gdquest-demos#59
- Loading branch information
1 parent
f3e19d8
commit d5b2211
Showing
9 changed files
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
extends Resource | ||
class_name MonsterDrops | ||
|
||
""" | ||
While we still can't export custom types, we'll have to use an Array of dictionaries | ||
Example: | ||
{ | ||
'item': Sword.tres, | ||
'min_quantity': 1, | ||
'max_quantity': 1, | ||
'chance': 0.5 | ||
}, { | ||
'item': Potion.tres, | ||
'min_quantity': 3, | ||
'max_quantity': 20, | ||
'chance': 0.25 | ||
}, | ||
""" | ||
|
||
export var items : Array |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[gd_resource type="Resource" load_steps=5 format=2] | ||
|
||
[ext_resource path="res://animation/PorcupineAnim.tscn" type="PackedScene" id=1] | ||
[ext_resource path="res://combat/battlers/enemies/porcupine/PorcupineDrops.tres" type="Resource" id=2] | ||
[ext_resource path="res://combat/battlers/BattlerTemplate.gd" type="Script" id=3] | ||
[ext_resource path="res://combat/battlers/jobs/Porcupine.tres" type="Resource" id=4] | ||
|
||
[resource] | ||
|
||
script = ExtResource( 3 ) | ||
anim = ExtResource( 1 ) | ||
stats = ExtResource( 4 ) | ||
skills = [ ] | ||
drops = ExtResource( 2 ) | ||
|
15 changes: 15 additions & 0 deletions
15
godot/combat/battlers/enemies/porcupine/PorcupineDrops.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[gd_resource type="Resource" load_steps=3 format=2] | ||
|
||
[ext_resource path="res://items/Potion.tres" type="Resource" id=1] | ||
[ext_resource path="res://combat/battlers/enemies/MonsterDrops.gd" type="Script" id=2] | ||
|
||
[resource] | ||
|
||
script = ExtResource( 2 ) | ||
items = [ { | ||
"chance": 0.75, | ||
"item": ExtResource( 1 ), | ||
"max_quantity": 4, | ||
"min_quantity": 2 | ||
} ] | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters