• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Making Cannibalism gain Mana instead of HP when eating a corpse? Any ideas?

Level 5
Joined
Nov 17, 2022
Messages
84
Hello 👋 I am making a map about survival and I'm using mana to represent hunger. I got a system working for mana to deplete but now I got a new situation in my quest to make this game. Is there any method to make an ability like Cannibalism but instead of restoring HP it restores it's mana when devouring a corspe? If anyone has insight, it'd mean the world to me, thank you in advance!
 
Level 27
Joined
Aug 29, 2012
Messages
1,209
The problem is that Cannibalize can't be used when units are at full health so using it as base ability it probably not a good idea sadly.

I think your best bet would be to use something like Raise Dead to simulate the consumption of a corpse while spawning an invisible dummy unit instead of skeletons
 
Level 28
Joined
Sep 26, 2009
Messages
2,517
As Chaosium mentioned, Raise Dead will probably be the best candidate for what you want.
Set following data of the spell like this:
  • 'Data - Units Summoned (Type xyz)' fields to 0 to not summon anything
  • 'Stats - Cast Time' to however long the spell should last
  • 'Stats - Cast Range' to some low number like 20.0

This setup will cause the unit to run towards a corpse until it is within 20.0 range, then just stand nearby doing nothing and after X seconds of 'Cast Time', it will start the actual spell, summoning exactly 0 unit, so the corpse just disappears.

When testing this, the only downside was that the caster had to be within ~400.0 range of the corpse, otherwise the spell just wrote that there are no corpses nearby.

The rest will need to be triggered. You can use trigger like this to detect when unit starts the cast time:
  • Eat Corpse Start
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Eat Corpse
    • Actions
      • Animation - Add the channel animation tag to (Triggering unit)
In my test map, I had a ghoul, so this trigger just starts playing ghoul's eating animation. In your case, you should start some kind of timer that will periodically increase triggering unit's mana.

You can use this event to determine if unit successfully finished the spell (in other words, if it waited the entire duration set by 'Cast time'):
  • Unit - A unit Begins casting an ability
and also use this to determine when the spell stopped:
  • Unit - A unit Stops casting an ability
However note that the 'stop' event will fire when unit successfully finished the spell (but it will fire always after the 'Begins casting' event) AND if unit has been interrupted (i.e. stunned).
 
Level 5
Joined
Nov 17, 2022
Messages
84
As Chaosium mentioned, Raise Dead will probably be the best candidate for what you want.
Set following data of the spell like this:
  • 'Data - Units Summoned (Type xyz)' fields to 0 to not summon anything
  • 'Stats - Cast Time' to however long the spell should last
  • 'Stats - Cast Range' to some low number like 20.0

This setup will cause the unit to run towards a corpse until it is within 20.0 range, then just stand nearby doing nothing and after X seconds of 'Cast Time', it will start the actual spell, summoning exactly 0 unit, so the corpse just disappears.

When testing this, the only downside was that the caster had to be within ~400.0 range of the corpse, otherwise the spell just wrote that there are no corpses nearby.

The rest will need to be triggered. You can use trigger like this to detect when unit starts the cast time:
  • Eat Corpse Start
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Eat Corpse
    • Actions
      • Animation - Add the channel animation tag to (Triggering unit)
In my test map, I had a ghoul, so this trigger just starts playing ghoul's eating animation. In your case, you should start some kind of timer that will periodically increase triggering unit's mana.

You can use this event to determine if unit successfully finished the spell (in other words, if it waited the entire duration set by 'Cast time'):
  • Unit - A unit Begins casting an ability
and also use this to determine when the spell stopped:
  • Unit - A unit Stops casting an ability
However note that the 'stop' event will fire when unit successfully finished the spell (but it will fire always after the 'Begins casting' event) AND if unit has been interrupted (i.e. stunned).
Thank you for such a detailed response and providing a trigger sheet example too. I'll try this today when I get back to editing my game and report back my results. This is a very clever work around from both of you guys.
 
Level 5
Joined
Nov 17, 2022
Messages
84
The problem is that Cannibalize can't be used when units are at full health so using it as base ability it probably not a good idea sadly.

I think your best bet would be to use something like Raise Dead to simulate the consumption of a corpse while spawning an invisible dummy unit instead of skeletons
Thanks for the idea, I hadn't thought of that angle to try getting the effect.
 
Top