Sure, beside changing the health status value to something that doesn't immediately kill the combatant again, you also need to set the death state (and a status recalculation afterwards doesn't hurt): combatant.Status.DeathState = CombatantDeathState.Alive; combatant.Status.MarkResetStatus();
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Using the functions below I was able to get in the player's Combatant Component IsDead = false Health = max value but once "revived", the player doesn't respond anymore to click-movement inputs can't perform any ability (the shortcut ability HUD is gone).
Might be either a control block (e.g. in the death schematic of the player), a game over (check the game over settings in Game > Game Settings, especially Auto Game Over should be disabled to not cause game over in field/real time area battles) or dead combatants being set up to leave their groups (see the death settings of the combatant/general combatant settings, found in their battle settings).
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I am getting discrepancies in editor Vs in build when the player gets killed. Everything works in editor but in the build the player does not get revived. I don't know if this is caused by obvious errors on my part or not accounting for other elements like saving times on file...
Currently the cycle at the end of a session when the player gets killed is the following. 1) player killed 2) revive player (so it's not saved dead) using the revive functions below 3) player progress saved using:
5) New game using ORK.Game.NewGame(true); 6) wait for player spawned 7) Load previous progress on new blank player using: DataObject data = new GamingIsLove.Makinom.IO.XMLParser(xml, null).Parse(); 8) check if player was saved "dead" and revive it if needed ( added on top of 2) since it was not working)
Revive functions used in 2) and 6)
if(playerCombatant.Status.DeathState == CombatantDeathState.Dead ) { ORKCombatantStatusValues.AddCombatantStatusPoints(playerObject, 1000, ORKGUIDs.statusValue_health); // 1000 is waay over the max player hp playerCombatant.Status.DeathState = CombatantDeathState.Alive; playerCombatant.Status.MarkResetStatus(); }
Is any error occuring in the built game when this happens? Might be some code stripping in the built game. Check your build/player settings in Unity - depending on the Unity version that can be named differently, but should be in the optimization settings and named something like Managed Stripping Level, which you should set to disabled.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I checked and that Managed Stripping Level was already set to disabled :(
If there are no obvious errors in my code above, would you suggest:
a) reviving the player before saving its XML data b) saving it dead and reviving it when the game starts after it's spawned and the previous XML is loaded onto the player? c) they are equivalent
If there'd be errors, it'd already break in the editor :)
Could be that something in the custom saving is not working in build (SavePlayerXML_ToFile and whatever you use to load that again). E.g. saving somewhere it's not allowed to or some other thing.
Maybe add some debug output throughout the save/load process and check what's going on that way.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
On a related note, before reviving the player, I was trying to set its HP to the max value through this function (as opposed to adding a very high value, which works) but this function doesn't seem to actually set anything:
Should work, though depends on what amount is set to.
On a different note, there's a function to regenerate (heal consumable stats) and revive a combatant available: combatant.Status.Regenerate(true);
Post edited by gamingislove on
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I did some tests and I am getting some odd behaviors.
I moved the ReplenishPlayer() and RevivePlayer() functions to the player gameobject Death event. combatant.Events.DeathStateChangedSimple += this.NotifyDeath; public virtual void NotifyDeath() { ReplenishPlayer(); RevivePlayer(); }
private void RevivePlayer() { Debug.Log("EventDeath.RevivePlayer() Player."); //(1) if(combatant.Status.DeathState == CombatantDeathState.Dead) //(2) { Debug.Log("EventDeath.RevivePlayer() Player. Player status = dead"); //(3) playerCombatant.Status.DeathState = CombatantDeathState.Alive; playerCombatant.Status.MarkResetStatus(); } }
The event is received correctly when the player dies but: - the player attributes are not changed - the player death state does not get recognized on (2) - even if (2) condition gets removed, the player still does not get revived...
gamingislove said: or dead combatants being set up to leave their groups (see the death settings of the combatant/general combatant settings, found in their battle settings).
Did you check that earlier as well? E.g. if the player leaves the player group on death, changing things on that combatant and afterwards getting player will operate on different combatants (or rather only have one combatant and no player).
Your script uses different combatants - one checks if combatant is dead and afterwards changes things on playerCombatant. Both are not really set anywhere in the code you posted, so hard to say if they are the correct combatants ...
Post edited by gamingislove on
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Just noticed, The code above only sets the death state back to alive, but doesn't regenerate health, so combatant will just die again if health is still 0.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
combatant.Status.DeathState = CombatantDeathState.Alive;
combatant.Status.MarkResetStatus();
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
IsDead = false
Health = max value
but once "revived", the player doesn't respond anymore to
click-movement inputs
can't perform any ability (the shortcut ability HUD is gone).
These are the Kill/Revive functions I used:
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I don't know if this is caused by obvious errors on my part or not accounting for other elements like saving times on file...
Currently the cycle at the end of a session when the player gets killed is the following.
1) player killed
2) revive player (so it's not saved dead) using the revive functions below
3) player progress saved using: 4) End game using: 5) New game using
ORK.Game.NewGame(true);
6) wait for player spawned
7) Load previous progress on new blank player using:
DataObject data = new GamingIsLove.Makinom.IO.XMLParser(xml, null).Parse();
8) check if player was saved "dead" and revive it if needed ( added on top of 2) since it was not working)
Revive functions used in 2) and 6)
Might be some code stripping in the built game. Check your build/player settings in Unity - depending on the Unity version that can be named differently, but should be in the optimization settings and named something like Managed Stripping Level, which you should set to disabled.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If there are no obvious errors in my code above, would you suggest:
a) reviving the player before saving its XML data
b) saving it dead and reviving it when the game starts after it's spawned and the previous XML is loaded onto the player?
c) they are equivalent
Could be that something in the custom saving is not working in build (SavePlayerXML_ToFile and whatever you use to load that again). E.g. saving somewhere it's not allowed to or some other thing.
Maybe add some debug output throughout the save/load process and check what's going on that way.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
On a different note, there's a function to regenerate (heal consumable stats) and revive a combatant available:
combatant.Status.Regenerate(true);
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I moved the ReplenishPlayer() and RevivePlayer() functions to the player gameobject Death event.
combatant.Events.DeathStateChangedSimple += this.NotifyDeath;
public virtual void NotifyDeath()
{
ReplenishPlayer();
RevivePlayer();
}
private void RevivePlayer()
{
Debug.Log("EventDeath.RevivePlayer() Player."); //(1)
if(combatant.Status.DeathState == CombatantDeathState.Dead) //(2)
{
Debug.Log("EventDeath.RevivePlayer() Player. Player status = dead"); //(3)
playerCombatant.Status.DeathState = CombatantDeathState.Alive;
playerCombatant.Status.MarkResetStatus();
}
}
The event is received correctly when the player dies but:
- the player attributes are not changed
- the player death state does not get recognized on (2)
- even if (2) condition gets removed, the player still does not get revived...
Your script uses different combatants - one checks if combatant is dead and afterwards changes things on playerCombatant. Both are not really set anywhere in the code you posted, so hard to say if they are the correct combatants ...
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Regarding the combatant and playerCombatant, they are the same, I was trying to simplify the code for the sake of brevity on the forum.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Apologies about the lack of clarity, I was trying to be concise but I realize it's actually not helping the conversation :(