| 10-01-2003, 12:33 AM | #1 |
How would I do this? I am making a trgger based spell, and i want to have a condition to see if the unit has enough mana. How would I do this? |
| 10-01-2003, 12:39 AM | #2 |
Set the mana to an interger variable and then use If (Variable) = Equal to or Greater then 15 then do Cast Spell That should work |
| 10-01-2003, 12:45 AM | #3 |
This is much easier in jass, but with triggers... If it is not targeted, it would go something like this Event: unit begins casting an ability Condition: ability is "ability" Actions: if then else if(integer/real comparison (casting unit has 15 mana)) { spell actions } else { issue casting unit an order to target position of casting unit display message to owner of casting unit( "not enough mana") } (the thing about the order casting unit to move to position of casting unit stops the unit from finishing the spell) For a targeted spell, it is a a little more complicated Event: unit is isssued an order targeting and object (or unit) Condition: order comparison(order == the name of the order like 'firebolt') ordered unit == unit who has the spell Actions: if(ordered unit is within (range of spell) of target){ if(ordered unit has 15 or more mana) { spell actions } else { display to owner of ordered unit("No enough mana") issue order to ordered unit to move to position of ordered unit } } else { display message to owner of ordered unit("That target is too far away") issue order to ordered unit to move to position of ordered unit } The only problem with this way is you have to make a different trigger for each type of unit that has the spell and if the target is too far away, the unit will stop instead of walking until it is close enough to cast. |
| 10-01-2003, 12:51 AM | #4 |
Heh, both of u helped me answer. Mr. Obli, the spell is not a spell, just a passive one. The spell is all in the triggers. Found the answer. Thnx! |
| 10-01-2003, 01:17 AM | #5 |
I'm glad I could help. |
| 10-01-2003, 08:49 AM | #6 |
So what's the answer? I have a similar problem with my multiarrow ability, and that has got no answers yet :( |
| 10-01-2003, 02:16 PM | #7 |
What is a multiarrow ability? Tell me about it and I will help you figure it out. |
| 10-01-2003, 03:14 PM | #8 |
I based it off of barrage to shoot more arrows per level. The mana cost field in barrage dont work though. Neither does unit cast abilitiy, ability = to barrage, im guessing its because its basicly a passive skill. So how do I get it to cost mana? |
| 10-02-2003, 01:39 AM | #9 |
Alright, this is a bit complicated for levels. To do different levels you need a jass trigger. Where it says SPELLCODE put the 4 letter code of the spell you make. You can find this code by pressing ctrl+d in the spell editor and looking at your spell. It is the first 4 letter code that shows up. Also you will need to make a real variable named multiarrowLevel. Fist make a trigger named Multiarrow Level Convert it to custom text by going to edit -> Convert to custom text put this code in, replacing SPELLCODE with the spell's four letter code function Trig_Multiarrow_Level_Conditions takes nothing returns boolean if ( not ( GetLearnedSkillBJ() == 'SPELLCODE' ) ) then return false endif return true endfunction function Trig_Multiarrow_Level_Actions takes nothing returns nothing set udg_multiarrowLevel = ( udg_multiarrowLevel + 1 ) endfunction //=========================================================================== function InitTrig_Multiarrow_Level takes nothing returns nothing set gg_trg_Multiarrow_Level = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Multiarrow_Level, EVENT_PLAYER_HERO_SKILL ) call TriggerAddCondition( gg_trg_Multiarrow_Level, Condition( function Trig_Multiarrow_Level_Conditions ) ) call TriggerAddAction( gg_trg_Multiarrow_Level, function Trig_Multiarrow_Level_Actions ) endfunction Once you have done that, whenever a unit learns the skill a variable gets one larger. This trigger will only work if only one unit has the skill. Also, if the unit ever loses the ability, you will need to set the variable back to 0. You can use the variable multiarrowLevel to change the mana cost per level. If you need it for multiple heroes, you need an array, i will tell you how if you need it. I am not quite sure what barrage is, so tell me and i will tell you how to do the mana cost. |
| 10-02-2003, 02:20 AM | #10 |
barrage is what the steam tank has, it lets it shoot multiple air enemies, all at the same time. Only 1hero does have the spell however will it matter if 2people pick the same hero? |
| 10-02-2003, 03:08 AM | #11 |
well you will need to make the trigger i gave you for multiple players. Also, the variable should be changed to an array. Like this: function Trig_Multiarrow_Level_Conditions takes nothing returns boolean if ( not ( GetLearnedSkillBJ() == 'SPELLCODE' ) ) then return false endif return true endfunction function Trig_Multiarrow_Level_Actions takes nothing returns nothing set udg_multiarrowLevel[GetConvertedPlayerId(GetOwningPlayer(GetLearningUnit()))] = ( udg_multiarrowLevel[GetConvertedPlayerId(GetOwningPlayer(GetLearningUnit()))] + 1 ) endfunction function InitTrig_Multiarrow_Level takes nothing returns nothing set gg_trg_Multiarrow_Level = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Multiarrow_Level, EVENT_PLAYER_HERO_SKILL ) call TriggerAddCondition( gg_trg_Multiarrow_Level, Condition( function Trig_Multiarrow_Level_Conditions ) ) call TriggerAddAction( gg_trg_Multiarrow_Level, function Trig_Multiarrow_Level_Actions ) endfunction This trigger will make the array refer to the player who own the hero. For example, use multiarrowLevel[playernmberof(owner fo unit)] to refer to the hero. To do the mana, do you want it to take mana when the unit attacks, and not to barrage if the unit doesn't have enough mana? |
| 10-02-2003, 03:30 AM | #12 |
ya I just want a normal attck if I dont have enough mana. also when you convert to custom text, what im I converting to custom text? Dont I need somthing in there 1st? whats the thing im converting? lol sorry if thats a dumb question, I know absolutly nothing about jazz or custom text and stuff like that, I leave that to the gosu map makers here, such as yourself |
| 10-02-2003, 04:48 AM | #13 |
When you convert it, you would have to have other text there but if you paste in the code i gave you, you will need nothing else. That is the entire trigger. The only possible way i can think of to make him have a normal attack is to remove the spell when the hero doesn't have mana to use it. Becuase it is a passive spell, you can't order the unit not to use it. Sadly, you cannot add and remove hero spells at the correct level. You might have to find another way to do the spell. You could get a better effect if you did the entire spell with triggers anyhow. |
| 10-02-2003, 05:45 AM | #14 |
lol, care to help me do it entirly with triggers then? I understand if not, but I gota ask :). I really want this skill in my game, but as it stands now its just so unbalanced that unless I find a way to fix it im going to have to get rid of the Amazon. :(. THANKS 4 all the help btw, hope it is possible |
| 10-02-2003, 01:06 PM | #15 |
I'll give you the easy way to do it with triggers, but not until this afternoon (school) |
