-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Created a new 'game_item' module. - Created RookiesRing.csx in the 'game_item' module. - Moved Rookie's Ring settings from general server logic to specific RookiesRing.csx settings file. - Implemented a new 'constant' and 'dynamic' mode for the Rookie's Ring. - Added a new option to completely disable the Rookie's Ring.
- Loading branch information
1 parent
53be753
commit cd8243a
Showing
14 changed files
with
279 additions
and
64 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
21 changes: 21 additions & 0 deletions
21
Arrowgene.Ddon.GameServer/Scripting/Interfaces/IGameItem.cs
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,21 @@ | ||
using Arrowgene.Ddon.Shared.Model; | ||
using System.Collections.Generic; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Scripting.Interfaces | ||
{ | ||
public abstract class IGameItem | ||
{ | ||
public abstract ItemId ItemId { get; } | ||
|
||
/** | ||
* @brief Called when an item is used by a player. | ||
*/ | ||
public abstract void OnUse(DdonGameServer server, GameClient client); | ||
|
||
/** | ||
* Called for items which have an impact to the player or pawn when they are | ||
* equipped when completing certain actions such as killing enemies or completing quests. | ||
*/ | ||
public abstract double GetBonusMultiplier(DdonGameServer server, CharacterCommon characterCommon); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
Arrowgene.Ddon.GameServer/Scripting/Modules/GameItemModule.cs
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,78 @@ | ||
using Arrowgene.Ddon.GameServer.Scripting.Interfaces; | ||
using Arrowgene.Ddon.Shared; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Scripting; | ||
using System.Collections.Generic; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Scripting | ||
{ | ||
public class GameItemModule : ScriptModule | ||
{ | ||
public override string ModuleRoot => "game_items"; | ||
public override string Filter => "*.csx"; | ||
public override bool ScanSubdirectories => true; | ||
public override bool EnableHotLoad => true; | ||
|
||
private Dictionary<ItemId, IGameItem> Items { get; set; } | ||
|
||
public bool HasItem(ItemId itemId) | ||
{ | ||
return Items.ContainsKey(itemId); | ||
} | ||
|
||
public bool HasItem(uint itemId) | ||
{ | ||
return HasItem((ItemId)itemId); | ||
} | ||
|
||
public IGameItem? GetItemInterface(ItemId itemId) | ||
{ | ||
if (!Items.ContainsKey(itemId)) | ||
{ | ||
return null; | ||
} | ||
return Items[itemId]; | ||
} | ||
|
||
public IGameItem? GetItemInterface(uint itemId) | ||
{ | ||
return GetItemInterface((ItemId)itemId); | ||
} | ||
|
||
public GameItemModule() | ||
{ | ||
Items = new Dictionary<ItemId, IGameItem>(); | ||
} | ||
|
||
public override ScriptOptions Options() | ||
{ | ||
return ScriptOptions.Default | ||
.AddReferences(MetadataReference.CreateFromFile(typeof(DdonGameServer).Assembly.Location)) | ||
.AddReferences(MetadataReference.CreateFromFile(typeof(AssetRepository).Assembly.Location)) | ||
.AddImports("System", "System.Collections", "System.Collections.Generic") | ||
.AddImports("Arrowgene.Ddon.Shared") | ||
.AddImports("Arrowgene.Ddon.Shared.Model") | ||
.AddImports("Arrowgene.Ddon.GameServer") | ||
.AddImports("Arrowgene.Ddon.GameServer.Characters") | ||
.AddImports("Arrowgene.Ddon.GameServer.Scripting") | ||
.AddImports("Arrowgene.Ddon.GameServer.Scripting.Interfaces") | ||
.AddImports("Arrowgene.Ddon.Shared.Entity.PacketStructure") | ||
.AddImports("Arrowgene.Ddon.Shared.Entity.Structure") | ||
.AddImports("Arrowgene.Ddon.Shared.Model.Quest"); | ||
} | ||
|
||
public override bool EvaluateResult(string path, ScriptState<object> result) | ||
{ | ||
if (result == null) | ||
{ | ||
return false; | ||
} | ||
|
||
IGameItem item = (IGameItem)result.ReturnValue; | ||
Items[item.ItemId] = item; | ||
|
||
return true; | ||
} | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
Arrowgene.Ddon.Shared/Files/Assets/scripts/game_items/README.md
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,7 @@ | ||
# Game Items | ||
|
||
This module handles the implementation of items which requires the server to be involved. | ||
|
||
- When creating a new `game_item`, create a `csx` file which matches the name of the item. | ||
- If an item has many settings or complex settings, create a new settings file for the item | ||
under `settings/game_items`, named the same as the `Item.csx` |
70 changes: 70 additions & 0 deletions
70
Arrowgene.Ddon.Shared/Files/Assets/scripts/game_items/RookiesRing.csx
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,70 @@ | ||
/** | ||
* @brief Settings for this object can be found in | ||
* <assets>/scripts/settings/game_items/RookiesRing.csx | ||
*/ | ||
public class GameItem : IGameItem | ||
{ | ||
private class RingMode | ||
{ | ||
public const uint Constant = 0; | ||
public const uint Dynamic = 1; | ||
} | ||
|
||
public override ItemId ItemId => ItemId.RookiesRing; | ||
|
||
public GameItem() | ||
{ | ||
} | ||
|
||
public override void OnUse(DdonGameServer server, GameClient client) | ||
{ | ||
// The rookies ring has no OnUse behavior | ||
} | ||
|
||
private double CalculateConstantBonus(DdonGameServer server, CharacterCommon characterCommon) | ||
{ | ||
if (characterCommon.ActiveCharacterJobData.Lv > server.GameLogicSettings.Get<uint>("RookiesRing", "RookiesRingMaxLevel")) | ||
{ | ||
return 0; | ||
} | ||
|
||
return server.GameLogicSettings.Get<double>("RookiesRing", "RookiesRingBonus"); | ||
} | ||
|
||
private double CalculateDynamicBonus(DdonGameServer server, CharacterCommon characterCommon) | ||
{ | ||
var dynamicBands = server.GameLogicSettings.Get<List<(uint MinLv, uint MaxLv, double ExpMultiplier)>>("RookiesRing", "DynamicExpBands"); | ||
|
||
var characterLv = characterCommon.ActiveCharacterJobData.Lv; | ||
|
||
foreach (var band in dynamicBands) | ||
{ | ||
if (characterLv >= band.MinLv && characterLv <= band.MaxLv) | ||
{ | ||
return band.ExpMultiplier; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
public override double GetBonusMultiplier(DdonGameServer server, CharacterCommon characterCommon) | ||
{ | ||
double bonus = 0; | ||
|
||
var mode = server.GameLogicSettings.Get<uint>("RookiesRing", "RookiesRingMode"); | ||
switch (mode) | ||
{ | ||
case RingMode.Dynamic: | ||
bonus = CalculateDynamicBonus(server, characterCommon); | ||
break; | ||
default: | ||
// Mode is either 0 or an invalid value, so treat it as zero | ||
bonus = CalculateConstantBonus(server, characterCommon); | ||
break; | ||
} | ||
|
||
return bonus; | ||
} | ||
} | ||
|
||
return new GameItem(); |
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
Oops, something went wrong.