| 12-08-2006, 09:02 PM | #1 |
Ok the topic name sounds retarded. Allow me to explain. I am making a map in which the units (wolves) slowly lose their mana (which represents food). In order to get this food back you must eat. But the only spell which is anything like this is cannabalize, but that can only heal HP (I've checked). I devised this very shitty script which probably doesn't work, which detects a corpse, then allows the activating spell to continue (the spell is channel), and gives the wolf the mana regen (which is over time). The mana regen spell is Clarity Potion. But I think I can find something better. There is also a trigger that tries to stop the mana regen, but I know it doesn't work. JASS:function Eat_Conditions takes nothing returns boolean return (GetSpellAbilityId() == 'A003') endfunction function If_Conditions takes nothing returns boolean return ( udg_i < 1 ) return ( GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE) < .405 ) endfunction function Group_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local unit u2 if ( If_Conditions() ) then set u2 = CreateUnit( GetOwningPlayer(u), 'e000', GetUnitX(u), GetUnitY(u), 270.0 ) call IssueTargetOrder( u2, "firebolt", u)//firebolt is the order ID I had call RemoveUnit(u2) //to give the Mana Regen ability set udg_i = 1 else call PauseUnit(u, true ) call IssueImmediateOrder(u, "stop" ) call PauseUnit(u, false ) call ErrorMsg( GetOwningPlayer(GetEnumUnit()), "There are no corpses nearby." ) endif set u = null set u2 = null endfunction function Eat_Actions takes nothing returns nothing local group g = CreateGroup() local unit u = GetTriggerUnit() local location l = GetUnitLoc(u) local real x = GetLocationX(l) local real y = GetLocationY(l) local rect r = RectFromCenterSizeBJ(l, 20.0, 20.0) set g = GetUnitsInRectAll(r) call ForGroup( g, function Group_Actions ) endfunction //=========================================================================== function InitTrig_Eat takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST) call TriggerAddAction( t, function Eat_Actions) call TriggerAddCondition(t, Condition(function Eat_Conditions)) set t = null endfunction What I'm asking for, is either a fixed version of this, or a completely new trigger which might actually work. I'd open the map this one is based off of, but of course, it's protected. Of course, credits will be given, and rep. Thanks in advance to anyone who decides to help. ~Darkwulfv |
| 12-08-2006, 09:10 PM | #2 |
Give em a raise dead based ability that summons a dummy unit with no model (or an SFX model) for 0.01 seconds, then trigger each time the raise dead abilty is cast to add mana. You can also use animate dead, but that won't cause the woof to run to the nearest corpse when cast. |
| 12-08-2006, 09:30 PM | #3 |
I like your idea, but I'm a bit confused on it. I see how raise dead would work, but wouldn't that remove the corpse? Or maybe I'm really confused (I think I am) It's been a while since I've worked with the WE, I need some more info and maybe a quick walkthrough (just small stuff, no need to do the whole thing). Sorry if it's a burden =/ |
| 12-08-2006, 09:45 PM | #4 |
You can use cannablize as the dummy ability, and every 0.3 seconds or so add 0.3% to mana. Make cannabalize add 0 hit points of course. I'll try to give you a basic trigger that will do this, and you can modify it of course since it's just an example. This requires Local Handle Vars to work, I wasn't sure what you were using so I used that. Usually I use Vexorian's Caster System. JASS:// Conditions function Mana_Cannibalize_Conditions takes nothing returns boolean // Check to see that the channeling ability is cannabalize return GetSpellAbilityId()=='Acan' endfunction // Timer Callback function Mana_Cannabalize_Timer_Callback_Core takes timer t returns nothing local unit wolf = GetHandleUnit(GetExpiredTimer(), "Wolf") local real mana // Check to see the wolf is channeling cannabalize if GetUnitCurrentOrder(wolf) == "cannibalize" then // Store the wolf's current mana set mana = ( GetUnitState(wolf, UNIT_STATE_MANA) ) if mana == GetUnitState(wolf, UNIT_STATE_MAX_MANA) then // Stop channeling cannabalize, because the wolf has full mana call IssueImmediateOrder(wolf,"stop") else // Add 0.3% to the wolf's current mana set mana = mana + ( GetUnitState(wolf, UNIT_STATE_MAX_MANA) * 0.003 ) call SetUnitState(wolf, UNIT_STATE_MANA, mana ) endif else // Flush stored value and destroy timer so we don't leak call SetHandleHandle(t, "Wolf", 0) call PauseTimer(t) call DestroyTimer(t) endif // More clean up set wolf = null endfunction function Mana_Cannabalize_Callback takes nothing returns nothing call Mana_Cannabalize_Callback_Core(GetExpiredTimer()) endfunction function Mana_Cannabalize_Init_Timer takes timer t, unit wolf returns nothing call SetHandleHandle(t,"Wolf",wolf) call TimerStart(t, 0.3, true, function Mana_Cannabalize_Callback) endfunction // Actions function Mana_Cannabalize_Actions takes nothing returns nothing local unit wolf = GetTriggerUnit() call Mana_Cannabalize_Init_Timer(CreateTimer(), wolf) set wolf = null endfunction //=========================================================================== function InitTrig_Mana_Cannibalize takes nothing returns nothing local integer i set gg_trg_Mana_Cannibalize = CreateTrigger( ) loop exitwhen i > bj_MAX_PLAYERS call TriggerRegisterPlayerUnitEventSimple(gg_trg_Mana_Cannibalize,Player(i),EVENT_PLAYER_UNIT_SPELL_CHANNEL) set i = i + 1 endloop call TriggerAddCondition(gg_trg_Mana_Cannibalize,Condition(function Mana_Cannabalize_Conditions)) call TriggerAddAction( gg_trg_Mana_Cannibalize, function Mana_Cannabalize_Actions ) endfunction I kind of wrote it in a hurry so there may be errors. |
| 12-08-2006, 09:58 PM | #5 |
Hmm... Looks pretty good, I'll wait for someone's feedback on your trigger before I use it and confuse myself =/. Thanks tho! |
| 12-08-2006, 09:59 PM | #6 |
The reason why I did that is because, I'd rather have the corpse finding and such done automatically by the cannabalize ability. It's much less work to simply add mana than it is to find corpses, automatically run to it and set channeling animation. |
| 12-08-2006, 10:02 PM | #7 |
yeah I thought of that but one issue. If the wolf has full health, cannabalize won't work. And it will stop working once the wolf has full health. (so if it eats with 2 HP missing and regenerates it cannabilize will stop)... Right? I know it won't cast due to full health but maybe it will continue despite full health. |
| 12-08-2006, 10:03 PM | #8 | |
Quote:
True, but I thought cannabalize had a flag that made it eat even when full. Perhaps you can find a different ability that channels and targets a corpse? |
| 12-08-2006, 10:05 PM | #9 |
hmm, I didn't look for that. I'll have to do that when I get a minute. |
| 12-09-2006, 01:16 AM | #10 |
It doesn't, go with the raise dead ability. Yes, it will remove the corpse, but so will Cannibalise (the corpse vanishes when the unit stops channelling) it just means you'll need to adjust the numbers a bit. As for a different channeled ability that targets a corpse, i can't think of any apart from cannibalise, you can't actually physically target a corpse, so you need an ability that auto-channels when you press the button, so unless you want to do a bunch of detection options and not have it seek out the nearest corpse when you press it, i don't think you can do it with a channeled spell. |
| 12-09-2006, 01:45 AM | #11 |
The corpse is supposed to go away when the unit stops channeling the eating spell. That's perfectly normal and is 100% intended. Raise dead however will remove the corpse at the first cast, and the wolf will stand there eating dirt. But what I'm not understanding about your way is, raise dead needs a corpse. So you said to make it cast over and over, but wouldn't that mean I would need a massive number of corpses? EDIT: I beleive I've found a possible solution. It requires 2 triggers. One to start the cycle, one to end it. The unti starts channeling Cannabalism, which will kick off a "Unit starts channeling an ability" event trigger. This trigger will contain the timer callback actions which will periodically heal mana. Then, when this unit stops channeling Cannabalism, a trigger with "A unit stops channeling an ability" event will turn off trigger A, thus ending the cycle. The corpse will dissapear because cannabalism does that, and it is supposed to happen. Also, it will stop others from eating from the same corpse (as realistic as it would be for more than one to eat, it's a pain in the ass to do without redoing the entire spell in JASS.) I beleive this should work. Correct me if I'm wrong anyone. EDIT EDIT: Shit, just realised something. That's not MUI. I'm pretty sure you can attach timers to units or something, so that you can stop a specific timer for a specific unit. However, I have no idea how. I could probably do something like this with arrays of course. But if there is an easier way, I'd be happy to learn. |
| 12-09-2006, 02:14 AM | #12 | |
Quote:
This is just wrong it will only consider the first condition, use the and operator |
| 12-09-2006, 03:15 AM | #13 |
Yeah I'm aware of how many errors were laced in this, and even then I forgot about the and operator. Whenever I used it, it called for Boolexprs. |
