New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing Vitals while HUDVitals is not Active #2593
Comments
Action example: public class ReducePlayerHealth : ActionTemplate
{
private int _percent;
private int _amount;
public ReducePlayerHealth(Quest parentQuest) : base(parentQuest)
{
}
public override string Pattern => @"reduce player health by (?<percent>\d+)|reduce player health on (?<amount>\d+)";
public override IQuestAction CreateNew(string source, Quest parentQuest)
{
Match match = Test(source);
if (!match.Success) return null;
var percentGroup = match.Groups["percent"];
var amountGroup = match.Groups["amount"];
return new ReducePlayerHealth(parentQuest)
{
_percent = percentGroup.Success ? Parser.ParseInt(match.Groups["percent"].Value) : 0,
_amount = amountGroup.Success ? Parser.ParseInt(match.Groups["amount"].Value) : 0,
};
}
public override void Update(Task _)
{
PlayerEntity player = GameManager.Instance.PlayerEntity;
var health = 0;
if (_percent > 0)
health = (int)(player.CurrentHealth - player.MaxHealth / 100f * _percent);
if (_amount > 0)
health = player.CurrentHealth - _amount;
if (health < 1) health = 1;
player.CurrentHealth = health;
SetComplete();
}
public override object GetSaveData()
{
return new SaveData_v1
{
percent = _percent,
amount = _amount,
};
}
public override void RestoreSaveData(object dataIn)
{
if (dataIn == null) return;
var data = (SaveData_v1)dataIn;
_percent = data.percent;
_amount = data.amount;
}
[FullSerializer.fsObject("v1")]
private struct SaveData_v1
{
public int percent;
public int amount;
}
} Quest example:
|
Entirely new to unity so forgive any mistakes. Based on my assessment, here's what seems to be occurring: Between the question completion and the reward, the game is unpaused for a tick. If nobody is averse to the idea, I could contribute a patch for this in the next day or two. It may take a couple rounds of CR as I'm still ramping up on unity and this project. |
Calling
When the UI is not in the main HUD status, it does not change the HUD vitals indicator.
Steps to reproduce:
The text was updated successfully, but these errors were encountered: