|
Post by John on Aug 29, 2021 4:35:37 GMT
Hi all, I want to create some new skill which will make target slience (hex is the one of them, but it will also make target change to a animal model and deal less damage). I tried FlipToggle but it does not work what i expected...
|
|
|
Post by cerulea on Aug 29, 2021 8:45:55 GMT
A toggle should work actually, what was the code you set up? A toggle set on the unit, a sub mesh to display when frogged, and an override when attacking that checks for frogged toggle status when filtering damage.
|
|
|
Post by John on Aug 29, 2021 9:34:41 GMT
Thanks for the reply, I am new to coding and this is my first project that I want to complete, some of the code that in tutorial I don't understand, and now I'm reviewing the notification center part.
|
|
|
Post by John on Aug 30, 2021 2:17:50 GMT
And I got another problem, I add a skill called Death, this skill will knock out the target immediately, but in next turn the target's knock out status removed itself... photos.app.goo.gl/MjKvXoSFGdYvmCmu6
|
|
|
Post by Admin on Aug 30, 2021 13:31:23 GMT
If you want to post some code, along with what happens vs what you expected to happen, we may be able to help.
|
|
|
Post by cerulea on Aug 31, 2021 2:21:04 GMT
Perhaps death should check the unit’s hp and simply set the go to 0 directly instead of inflicting a status. Then the knocked out effect will function as expected.
|
|
|
Post by John on Sept 1, 2021 8:26:57 GMT
Perhaps death should check the unit’s hp and simply set the go to 0 directly instead of inflicting a status. Then the knocked out effect will function as expected. I find the problem, it was because the observer add to a wrong nitification in stat comparison condition class, and thank you for the advice, it works now.
|
|
|
Post by John on Sept 1, 2021 8:42:04 GMT
Sry not stat comparison condition but duration status condition
|
|
|
Post by John on Jan 14, 2023 8:47:17 GMT
Hi again,
I finally got time to finish this effect, and here's the implementation
public class SlienceStatusEffect : StatusEffect { private Unit owner;
private void OnEnable() { owner = GetComponentInParent<Unit>(); if (owner) this.AddObserver(OnCanPerformCheck, Ability.CanPerformCheck); }
private void OnDisable() { this.RemoveObserver(OnCanPerformCheck, Ability.CanPerformCheck); }
private void OnCanPerformCheck(object sender, object args) { var unit = (sender as Ability).GetComponentInParent<Unit>(); if (owner == unit) { var exc = args as BaseException; if (exc.defaultToggle) exc.FlipToggle(); } } }
Let me know if there's anything that I could imporve, thanks!
|
|
|
Post by Admin on Jan 15, 2023 1:39:14 GMT
I think you've got a good start here. One thing to consider though is that this prevents the owner unit from performing ANY ability, whereas I normally consider silence only to block casting spells. So it might make sense to add a component to an ability that indicates whether or not the ability can be silenced and only flip the toggle in that case. For example create a component called "Silenceable" (feel free to use whatever name makes sense) and add it to an Ability game object.
|
|
|
Post by John on Jan 16, 2023 11:10:23 GMT
Thanks for the advice! Much appreciated
|
|