HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why does this spell only work once?

06-22-2006, 03:39 AM#1
darkwulfv
Trigger:
Untitled Trigger 001
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Commander Rage
Collapse Actions
Unit - Create 1 Dummy Unit for Neutral Hostile at (Position of (Triggering unit)) facing (Position of (Triggering unit))
Set DummyUnit = (Last created unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Commander Rage for (Triggering unit)) Equal to 1
Collapse Then - Actions
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Remove DummyUnit from the game
Collapse Else - Actions
Unit - Set level of Commander Rage BL 1 for DummyUnit to 2
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Commander Rage for (Triggering unit)) Equal to 2
Collapse Then - Actions
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Remove DummyUnit from the game
Collapse Else - Actions
Unit - Set level of Commander Rage BL 1 for DummyUnit to 3
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Commander Rage for (Triggering unit)) Equal to 3
Collapse Then - Actions
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Remove DummyUnit from the game
Collapse Else - Actions
Unit - Set level of Commander Rage BL 1 for DummyUnit to 4
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Commander Rage for (Triggering unit)) Equal to 4
Collapse Then - Actions
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Remove DummyUnit from the game
Collapse Else - Actions
Unit - Set level of Commander Rage BL 1 for DummyUnit to 5
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Commander Rage for (Triggering unit)) Equal to 5
Collapse Then - Actions
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Remove DummyUnit from the game
Collapse Else - Actions
Unit - Set level of Commander Rage BL 1 for DummyUnit to 6
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Commander Rage for (Triggering unit)) Equal to 6
Collapse Then - Actions
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Remove DummyUnit from the game
Collapse Else - Actions
Do nothing
Custom script: set udg_DummyUnit = null

It's supposed to make the casting unit do a roar (that's the spell, it works) and make a dummy unit cast Bloolust on the triggering unit. This works the first time it is cast, but any other time it just roars. Was it the null I put in at the end, since I'm using a global variable?
06-22-2006, 04:48 AM#2
Rising_Dusk
Just to let you know, you don't have to null global variables.
So that custom script line at the end really doesn't do anything useful.
Also, use "Starts the effects of an ability" for the event, not "begins casting".

However, that isn't something that would stop it from working more than once.
Make sure the ability based on Bloodlust is able to level past 1.
Also make sure that its able to be cast on ANYONE (Allies and enemies), since you spawn the dummy for Neutral Hostile and most (If not all) players are enemies of Neutral Hostile.
06-22-2006, 04:53 AM#3
darkwulfv
I've done everything you pointed to check for, so maybe I just need to re-check everything and make sure I didn't do anything wrong. Why would I use "Starts the effect of an ability"? Where is the difference inbetween the two? Also, I don't think my spell actually has an effect, but I may be mixing things up here. The Bloodlust ability I made has 6 levels in it, but does the Dummy unit have to have levels or something? I'm actually not even sure if the spell casts once. I have to watch my tests closer. I'll let you know what happens.
06-22-2006, 05:05 AM#4
aquilla
A common issue when using something like
Trigger:
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Remove DummyUnit from the game
is that the unit will be removed before the order is executed, try adding a short Wait before it is removed, or use an expiration timer instead:
Trigger:
Unit - Add a 1.00 second Generic expiration timer to DummyUnit
Also, you might wanna use this line, instead of all the if statements, to shorten the code ;P
Trigger:
Unit - Set level of Commander Rage BL 1 for DummyUnit to (Level of (Ability being cast) for (Triggering unit))
06-22-2006, 05:11 AM#5
darkwulfv
Ok, 6 quick waits coming up. I'd rather use waits to be postive that the spell is cast. I'll pop them in and test.

Edited it, nothing happened. In fact, bloodlust is never even cast, ever! Here's my map, if that helps anything. Feel free to poke around the heroes and things. The units on the map were for testing the 2 heroes I've gotten done (which aren't done anymore becasue of new-found spell triggering skills) The Arthas hero is the one who is giving me trouble. Just test the map and learn "Commander Rage" to any level and try it out.

EDIT: gotta re-edit, hold on. I'll re-upload in a minute.
EDIT EDIT: Done, it can be uploaded now, maybe you can find the mistake. I suggest looking at my dummy unit (it's a wisp, thusly named dummy unit in the object editor) and then the spells (commander rage and commander rage BL 1) Thx in advance, + rep and creidts if you can find the problem. :D
Attached Files
File type: w3xFriends Tribute.w3x (29.9 KB)
06-22-2006, 05:42 AM#6
PipeDream
There are some nice dummy unit systems for taking care of the handling. Give this a shot. I would imagine there is also one built into vex's caster system.

Actually I'd add a little something like
Collapse JASS:
function TACleaner takes nothing returns nothing
    call TriggerRemoveAction(GetTriggeringTrigger(),ItoTA(GetStoredInteger(GC(),I2S(HtoI(GetTriggeringTrigger())),"ta")))
endfunction

function SpellFinish_cb takes nothing returns nothing
    local trigger t = GetTriggeringTrigger()
    local string key = I2S(HtoI(t))
    if(GetStoredInteger(GC(),key,"spellid") == GetSpellAbilityId()) then
        call ExecuteFunc(GetStoredString(GC(),key,"action"))
        call ExecuteFunc("TACleaner")
        call FlushStoredMission(GC(),key)
        call DestroyTrigger(t)
    endif
    set t = null
endfunction
//When unit u finishes casting spell spellid, action is called with some data on GetTriggeringTrigger()
//"spellid" holds spellid and "unit" holds unit
function OnSpellFinish takes unit u, integer spellid, string action returns nothing
    local trigger t = CreateTrigger()
    local triggeraction ta = TriggerAddAction(t,action)    //Jass gives T&A a really bad name
    local string key = I2S(HtoI(t))
    call StoreInteger(GC(),key,"ta",HtoI(TriggerAddAction(t,function SpellFinish_cb)))
    call StoreInteger(GC(),key,"spellid",spellid)
    call StoreInteger(GC(),key,"unit",HtoI(u))
    call StoreString(GC(),key,"action",action)
    call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_SPELL_FINISH)
    set t = null
    set ta = null
endfunction

function DummyCleanup takes nothing returns nothing
    local string key = I2S(HtoI(GetTriggeringTrigger()))
    local unit dummy = ItoU(GetStoredInteger(GC(),key,"unit"))
    call ReleaseDummy(dummy,0.)
    set dummy = null     //Not actually necessary since we don't deallocate dummies
endfunction

function CleanDummyAfterSpell takes unit u,integer spellid returns nothing
    call OnSpellFinish(u,spellid,"DummyCleanup")
endfunction
to catch the precise moment when the dummy finishes casting, rather than relying on bogus waits. Functional programming for the win.
06-22-2006, 05:51 AM#7
aquilla
Right, well, before finding out that your wisp had 0 max mana and blood lust costed 1 mana I played around a bit:

changed targets allowed to default and the dummy is now created for the owner of the unit casting the spell
Edited the Dummy unit (I set pretty much everything to 0) so there would be a minimal delay between the roar and the bloodlust
Shortened the code

hope it's what you wanted :)
Attached Files
File type: w3xFriends Tribute.w3x (29.3 KB)
06-22-2006, 06:02 AM#8
Undead_Lives
What I would do is create 6 different units rather than relying on making them level their abilities...but that's just me.
06-22-2006, 09:21 AM#9
Captain Griffen
Just to clarify, this is what it should be:

Trigger:
Collapse Untitled Trigger 001
Events
Unit - A unit Starts the effect of an ability
Collapse
Conditions
(Ability being cast) Equal to Commander Rage
Collapse
Actions
Set TempPoint = Position of (Triggering unit)
Unit - Create 1 Dummy Unit for Neutral Hostile at TempPoint facing 0
Custom Script: call RemoveLocation(udg_TempPoint)
Unit - Set level of Commander Rage BL 1 for (Last created unit) to (Level of Commander Rage for (Triggering unit))
Unit - Order DummyUnit to Orc Shaman - Bloodlust (Triggering unit)
Unit - Add a 1 second generic timer to (Last created unit)

Just as an aside, you can nullify global variables in GUI, by setting them to No unit (preset). Not got much use in GUI, though, other than for conditions.
06-22-2006, 11:30 AM#10
Rising_Dusk
Quote:
What I would do is create 6 different units rather than relying on making them level their abilities...but that's just me.

Trust me when I say making one unit and leveling the ability is better.
06-22-2006, 11:31 AM#11
darkwulfv
@aquilla: I originally had bloodlust set to 0 mana, I thought that I had also set the dummy unit to having mana before that. Hmm. Anything that helps the map, I don't really care what is changed, as long as it's for the better. I'm gonna try and solve some of my problems with spells and then come here so you don't have to hear my complaining. :D

@CaptainGriffen: Thx for the code, if it's not alreayd in my map after Aquilla fixed it, I'll compare them and maybe insert yours depending.

Thank you all so much for the help, especially Aquilla. +rep, and I'll put you in somewhere in the loading screen as a speical thanks. If you liked what you may have seen, if somehow I get into a beta stage, you can test if you'd like (it's gonna need it). I expect theres gonna be alot more posts with my problems in them, but that'll slow down some once I grasp the full capabilities of the WEU! I used the If/Then/else fuctions becuase I had basically just gotteb hold of what they could do. I'm gonna test my map out now and work on some more spells, hopefully these ones will work. Wish me luck, you'll be hearing from me soon (trust me) :D