• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Mystic Wolf 1.5

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: deepstrasz
Created by Barathrum

Summons a Wolf, which will live aslong as you have mana to feed it. You lose a set amount of mana each set amount seconds. Also, if enabled in the triggers, you have a set chance to summon a even stronger wolf. Which drains extra mana if set.

Spell Name: Mystic Wolf
Levels: 3
MUI: Yes
Leakless: Should be

JASS:
native UnitAlive takes unit u returns boolean

scope Mystic initializer InitTrig_Mystic_Wolf

private constant function Conditions takes nothing returns boolean
   return GetSpellAbilityId() == 'A000'   // ID of your spell
endfunction

private function Actions takes nothing returns nothing
// Don't change these
local unit x = GetTriggerUnit()
local location l = GetSpellTargetLoc()
local player xo = GetOwningPlayer(x)
local unit y
local integer lvl = GetUnitAbilityLevel(x, 'A000')
local real rnd = GetRandomReal(1 , 100)
local integer array d
// End

// Config variables bellow.
local boolean txt = true  //displays debug messeges if set to true.
local boolean order = true // if the caster should get Ordered to stop after cast.
local boolean special = true  // if set to true, you will have a chance (set bellow) to summon a special wolf.
local real mps = 4. - lvl  // mana per second drained.
local real mps_rnd = 4. - lvl
local real t = 1.  // the delay in which the caster looses mana.
local real chance = 25.  // The chance to summon a special wolf.

// Dummy Units
set d[1]='n001'        // This one will be created if level==1 (as you see in [])
set d[2]='n000'        // This one will be created if level==2 (as you see in [])
set d[3]='n002'        // This one will be created if level==3 (as you see in [])
set d[4]='n003'        // This is the RawCode of special
// End of Dummy Units
// End of Config variables.

if GetUnitState(x , UNIT_STATE_MANA) < 1 then
call Error(GetOwningPlayer(x), "Not enough mana")
call RemoveLocation(l)
set x = null
set y = null
return
else
if rnd <= chance and special == true then
set mps = mps + mps_rnd
set y = CreateUnitAtLoc (xo, d[4], l, 0.)  // We have a chance of 25% to summon a special Wolf.
else
set y = CreateUnitAtLoc (xo, d[lvl], l, 0.)
endif
endif

if order == true then
call IssueImmediateOrder(x , "stop")  // if order is set to true, it will order the caster to stop.
endif

loop
exitwhen UnitAlive(y) == false or GetUnitState(x , UNIT_STATE_MANA) < 1 or UnitAlive(x) == false
call SetUnitState(x , UNIT_STATE_MANA , GetUnitState(x, UNIT_STATE_MANA) - mps)   // we set the mana of the caster to his mana - variable mps.
call TriggerSleepAction(t)   // delay action, deafult 1.
endloop

if txt == true then
if UnitAlive(y) == false then
call DisplayTimedTextToPlayer(Player(0), 0, 0, 2.5 , "Wolf has died.")
elseif UnitAlive(x) == false then
call DisplayTimedTextToPlayer(Player(0), 0, 0, 2.5 ,"The caster has died, therefore the wolf dies.")
elseif GetUnitState(x , UNIT_STATE_MANA) < 1 then
call DisplayTimedTextToPlayer(Player(0), 0, 0, 2.5 ,"The caster's mana has reached 0, the wolf dies.")
endif
endif
call KillUnit(y)  // we kill our unit.

// we remove leaks
call RemoveLocation(l)
set x = null
set y = null
endfunction

//===========================================================================
private function InitTrig_Mystic_Wolf takes nothing returns nothing
   local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction
endscope


Keywords:
Wolf, summon, options, chance
Contents

Mystic Wolf 1.5 (Map)

Reviews
12th Dec 2015 IcemanBo: Too long time as NeedsFix. Rejected. 13:56, 21st Mar 2010 TriggerHappy: Don't use locations. Indent! Waits..? Basically all the same problems as your other spell(s). I highly suggest getting code help before...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long time as NeedsFix. Rejected.

13:56, 21st Mar 2010
TriggerHappy:

Don't use locations.
Indent!
Waits..?

Basically all the same problems as your other spell(s). I highly suggest getting code help before submitting any spells (or updating them).
 
Level 18
Joined
Feb 28, 2009
Messages
1,970
JASS:
function Mana_Timer_Conditions takes nothing returns boolean
Can be constant

JASS:
exitwhen GetUnitState(x , UNIT_STATE_MANA) <= 0   // if his mana is 0 or less, the unit dies.
exitwhen GetUnitState(y, UNIT_STATE_LIFE) <= 0  // if the unit dies, the spell ends.
Can be split to
JASS:
exitwhen GetUnitState(y, UNIT_STATE_LIFE) <= 0 or GetUnitState(x , UNIT_STATE_MANA) <= 0
And should be at the beginning of if.

JASS:
if rnd <= chance and special == true then
set mps = mps + mps_rnd
set y = CreateUnitAtLoc(xo , d4 , l , 0.00)  // We have a chance of 25% to summon a special Wolf.
else
if lvl == 1 then
set y = CreateUnitAtLoc(xo , d1 , l , 0.00)  // we create our unit.
endif
if lvl == 2 then
set y = CreateUnitAtLoc(xo , d2 , l , 0.00)  // we create our unit.
endif
if lvl == 3 then
set y = CreateUnitAtLoc(xo , d3 , l , 0.00)  // we create our unit.
endif
endif
You can put it in other func, which will check the taking integer lvl and return the right RawCode which you will use to create unit.

And don`t use TSA.

Sorry but didn`t have time to write/check more.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Note that I have only checked the code.

The spell is rather simple and would have been done better if it was coded in vJass. (It's easier to make it MUI)

Avoid using locations like GetSpellTargetLoc(), use coordinates like GetSpellTargetX() and GetSpellTargetY()

Follow krisserz's suggestion except use GetWidgetLife(y) < 0.405[icode=jass] Name the variables better. (Using x for the caster unit and y for the summoned unit is too confusing.) It would have been much easier and better to make the dummy units' id an array. I also think they should be called Summoned Unit instead of Dummy Unit. You should indent your coding. (It makes it easier to read.) Shouldn't the wolf get killed when the caster dies since it's living off the caster's mana?
 
Level 22
Joined
Feb 3, 2009
Messages
3,292
Well thanks for the comments:

1st I can't use X and Y because it's to confusing for me, same goes for vJASS MUI making (hashtables and scopes and that stuff)

And how do I make the dummies in a Array? Can locals be arrays?

Well now that I'm home, I'll do my homework, then update this.

EDIT: Fixed/Added all of the suggestions that I knew how to make, the rest I coulden't, since I don't know how...
 
Last edited:
Level 18
Joined
Feb 28, 2009
Messages
1,970
And how do I make the dummies in a Array? Can locals be arrays?
What he meant is
JASS:
local integer array d   // We create integer variable with an array
set d[1]='n001'                                      // This one will be created if level==1 (as you see in [])
set d[2]='n000'                                      // This one will be created if level==2 (as you see in [])
set d[3]='n002'                                      // This one will be created if level==3 (as you see in [])
set d[4]='n003'                                      // This is the RawCode of special
// As you see it`s not looking good so far, but later instead of making long if/then/else you can create one simple which will check if the created unit is special then you will do such an action:
set y = CreateUnitAtLoc (xo, d[4], l, 0.)
// If not then you can do just one simple call:
set y = CreateUnitAtLoc (xo, d[lvl], l, 0.)
// This will work for each lvl

And one more thing:
Why lvl is real? Change it to integer.
 
Level 7
Joined
Dec 19, 2009
Messages
249
I don't know if this bug was mentionned before but i found a bug , i tried to cast it realy fast in a row and after certain time , wolves was dying right when they are summoned...I was like , why the hell i summoned a dead wolf...
 
Level 22
Joined
Feb 3, 2009
Messages
3,292
Because you had 0 mana. The more you have, the more mana it drains, so I guess you summoned so much wolves that in the time you summoned them you drained all mana.

If you want to test if it's really a bug, then set the variable mps and mps_rnd to 0.

EDIT: I have a question on which I hope someone can answer:

I'm using this: GetUnitState(y, UNIT_STATE_LIFE) < 0.405
But, I'd like to use IsUnitAlive, but I only have IsUnitAliveBJ? Wasn't there 1 without the BJ?
 
Last edited:
Level 7
Joined
Dec 19, 2009
Messages
249
Because you had 0 mana. The more you have, the more mana it drains, so I guess you summoned so much wolves that in the time you summoned them you drained all mana.

If you want to test if it's really a bug, then set the variable mps and mps_rnd to 0.

EDIT: I have a question on which I hope someone can answer:

I'm using this: GetUnitState(y, UNIT_STATE_LIFE) < 0.405
But, I'd like to use IsUnitAlive, but I only have IsUnitAliveBJ? Wasn't there 1 without the BJ?

well , my bad then...
 
Level 22
Joined
Feb 3, 2009
Messages
3,292
I think I have...

EDIT: Well I got it to work now somehow...

Now I released new version (1.4), now the spell is vJASS, it also uses SimError Library. Now when you cast with 0 mana you get a error saying "Not enough mana" , also added a boolean txt which if true it will debug messeges on how the spell ended (dummy death, caster death or no mana)
Also I put the code in a Scope so all functions are private.
 
Last edited:
Top