Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
83c46cb9
Commit
83c46cb9
authored
May 11, 2022
by
AnimeGitB
Committed by
Melledy
May 13, 2022
Browse files
Custom costs for different gacha pulls
parent
f83f1320
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/gacha/GachaBanner.java
View file @
83c46cb9
...
...
@@ -6,13 +6,18 @@ import emu.grasscutter.utils.Utils;
import
static
emu
.
grasscutter
.
Configuration
.*;
import
emu.grasscutter.data.common.ItemParamData
;
public
class
GachaBanner
{
private
int
gachaType
;
private
int
scheduleId
;
private
String
prefabPath
;
private
String
previewPrefabPath
;
private
String
titlePath
;
private
int
costItem
;
private
int
costItemId
=
0
;
private
int
costItemAmount
=
1
;
private
int
costItemId10
=
0
;
private
int
costItemAmount10
=
10
;
private
int
beginTime
;
private
int
endTime
;
private
int
sortId
;
...
...
@@ -36,11 +41,8 @@ public class GachaBanner {
// Kinda wanna deprecate these but they're in people's configs
private
int
[]
rateUpItems1
=
{};
private
int
[]
rateUpItems2
=
{};
private
int
softPity
=
-
1
;
private
int
hardPity
=
-
1
;
private
int
eventChance
=
-
1
;
private
int
baseYellowWeight
=
-
1
;
private
int
basePurpleWeight
=
-
1
;
private
int
costItem
=
0
;
public
int
getGachaType
()
{
return
gachaType
;
...
...
@@ -66,8 +68,15 @@ public class GachaBanner {
return
titlePath
;
}
public
ItemParamData
getCost
(
int
numRolls
)
{
return
switch
(
numRolls
)
{
case
10
->
new
ItemParamData
((
costItemId10
>
0
)
?
costItemId10
:
getCostItem
(),
costItemAmount10
);
default
->
new
ItemParamData
(
getCostItem
(),
costItemAmount
*
numRolls
);
};
}
public
int
getCostItem
()
{
return
costItem
;
return
(
costItem
>
0
)
?
costItem
:
costItemId
;
}
public
int
getBeginTime
()
{
...
...
@@ -82,14 +91,6 @@ public class GachaBanner {
return
sortId
;
}
public
int
getBaseYellowWeight
()
{
return
baseYellowWeight
;
}
public
int
getBasePurpleWeight
()
{
return
basePurpleWeight
;
}
public
int
[]
getRateUpItems4
()
{
return
(
rateUpItems2
.
length
>
0
)
?
rateUpItems2
:
rateUpItems4
;
}
...
...
src/main/java/emu/grasscutter/game/gacha/GachaManager.java
View file @
83c46cb9
...
...
@@ -19,6 +19,7 @@ import emu.grasscutter.database.DatabaseHelper;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.gacha.GachaBanner.BannerType
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.Inventory
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.inventory.MaterialType
;
import
emu.grasscutter.game.player.Player
;
...
...
@@ -233,7 +234,8 @@ public class GachaManager {
if
(
times
!=
10
&&
times
!=
1
)
{
return
;
}
if
(
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_WEAPON
).
getSize
()
+
times
>
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_WEAPON
).
getMaxCapacity
())
{
Inventory
inventory
=
player
.
getInventory
();
if
(
inventory
.
getInventoryTab
(
ItemType
.
ITEM_WEAPON
).
getSize
()
+
times
>
inventory
.
getInventoryTab
(
ItemType
.
ITEM_WEAPON
).
getMaxCapacity
())
{
player
.
sendPacket
(
new
PacketDoGachaRsp
());
return
;
}
...
...
@@ -246,7 +248,8 @@ public class GachaManager {
}
// Spend currency
if
(
banner
.
getCostItem
()
>
0
&&
!
player
.
getInventory
().
payItem
(
banner
.
getCostItem
(),
times
))
{
ItemParamData
cost
=
banner
.
getCost
(
times
);
if
(
cost
.
getCount
()
>
0
&&
!
inventory
.
payItem
(
cost
))
{
return
;
}
...
...
@@ -304,9 +307,9 @@ public class GachaManager {
}
addStarglitter
=
(
itemData
.
getRankLevel
()==
5
)?
10
:
2
;
int
constItemId
=
itemId
+
100
;
GameItem
constItem
=
player
.
getI
nventory
()
.
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
constItemId
);
GameItem
constItem
=
i
nventory
.
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
constItemId
);
gachaItem
.
addTransferItems
(
GachaTransferItem
.
newBuilder
().
setItem
(
ItemParam
.
newBuilder
().
setItemId
(
constItemId
).
setCount
(
1
)).
setIsTransferItemNew
(
constItem
==
null
));
player
.
getI
nventory
()
.
addItem
(
constItemId
,
1
);
i
nventory
.
addItem
(
constItemId
,
1
);
}
isTransferItem
=
true
;
break
;
...
...
@@ -315,7 +318,7 @@ public class GachaManager {
// Create item
GameItem
item
=
new
GameItem
(
itemData
);
gachaItem
.
setGachaItem
(
item
.
toItemParam
());
player
.
getI
nventory
()
.
addItem
(
item
);
i
nventory
.
addItem
(
item
);
stardust
+=
addStardust
;
starglitter
+=
addStarglitter
;
...
...
@@ -336,10 +339,10 @@ public class GachaManager {
// Add stardust/starglitter
if
(
stardust
>
0
)
{
player
.
getI
nventory
()
.
addItem
(
stardustId
,
stardust
);
i
nventory
.
addItem
(
stardustId
,
stardust
);
}
if
(
starglitter
>
0
)
{
player
.
getI
nventory
()
.
addItem
(
starglitterId
,
starglitter
);
i
nventory
.
addItem
(
starglitterId
,
starglitter
);
}
// Packets
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment