HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What The Crap

09-13-2006, 11:47 AM#1
Pheonix-IV
First person to find the stupid mistake i've made in these lines of code and tell me how to fix them gets a cookie. For some reason, it damages the caster, not the target.

Trigger:
Mind Crush
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Mind Crush
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
ManaCost[(Player number of (Owner of (Casting unit)))] Less than or equal to (Integer((Mana of (Casting unit))))
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
ManaCost[(Player number of (Owner of (Casting unit)))] Less than or equal to (((Hero level of (Casting unit)) x 20) + 10)
Collapse Then - Actions
Set spellcasterglob = (Casting unit)
Set spelltargetglob = (Target unit of ability being cast)
Trigger - Run Mind Crush FX <gen> (ignoring conditions)
Collapse Else - Actions
Unit - Pause (Casting unit)
Unit - Order (Casting unit) to Stop
Unit - Unpause (Casting unit)
Floating Text - Create floating text that reads Too weak above (Casting unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 20.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 3.00 seconds
Floating Text - Change (Last created floating text): Disable permanence
Collapse Else - Actions
Unit - Pause (Casting unit)
Unit - Order (Casting unit) to Stop
Unit - Unpause (Casting unit)
Floating Text - Create floating text that reads Not enough mana above (Casting unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 20.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 3.00 seconds
Floating Text - Change (Last created floating text): Disable permanence

Trigger:
Mind Crush FX
Events
Conditions
Collapse Actions
Custom script: local unit udg_spelltarget = udg_spelltargetglob
Custom script: local unit udg_spellcaster = udg_spellcasterglob
Set temppoint = (Position of spellcaster)
Set temppoint2 = (Position of spelltarget)
Wait ((Distance between temppoint and temppoint2) / 600.00) seconds
Custom script: call RemoveLocation (udg_temppoint)
Custom script: call RemoveLocation (udg_temppoint2)
Set Interger = (ManaCost[(Player number of (Owner of spellcaster))] x 2)
Set Real = ((Real(A1DamageMind[(Level of spelltarget)])) x 0.01)
Set Real2 = ((Real(Interger)) x Real)
Unit - Cause spellcaster to damage spelltarget, dealing Real2 damage of attack type Spells and damage type Universal
Unit - Set mana of spellcaster to ((Mana of spellcaster) - (Real(ManaCost[(Player number of (Owner of spellcaster))])))
Set spellcaster = No unit
Set spelltarget = No unit
09-13-2006, 12:09 PM#2
zeroXD
Im not sure, but i think the problem is that you are using (Casting Unit) in the triggers. I reccommend using (Triggerimg Unit). Its easier, and faster, and aint lost after a wait. Also, wait commands is inaccurate, maybye you should run a timer and deal the damage when it expires.

Ill try make the spell just as you have your triggers, and then i try figure it out.
EDIT: Sry im a bit lazy right now, may you just give me a map with the spell, and ill see what i can do?
09-13-2006, 12:12 PM#3
Rising_Dusk
Trigger:
Mind Crush FX
Collapse Actions -
Custom script: local unit udg_spelltarget = udg_spelltargetglob
Custom script: local unit udg_spellcaster = udg_spellcasterglob
That trick can only be done once in GUI per trigger.
Therefore it's likely causing issues.
09-13-2006, 03:40 PM#4
UnMi
Ultra Ninja Edit:
I did some tests, and found out some really weird behaviours while using "fake local-global variables":
Test Map:
- Cast Banish on Mountain King
This means, you must not use a global variable and turn it into a local, like that:
Collapse JASS:
local unit udg_spelltarget = udg_spelltargetglob
Instead, you just
Collapse JASS:
local unit spelltarget
And turn every function that uses this unit into custom text.
zeroXD is correct too. In order to prevent funny problems with Waits, use as much "Triggering Unit" as you can.
Attached Files
File type: w3xglobal_ref.w3x (12.8 KB)
09-14-2006, 09:46 AM#5
Pheonix-IV
How do you use timers for waits anyway? I've been hunting around the JASS tuts but it all looks like gibberish to me.
09-14-2006, 10:44 AM#6
UnMi
I think it should work the same way you used the
Trigger:
Trigger - Run Mind Crush FX <gen> (ignoring conditions)
Instead, you start a timer with a Expiration-Time of
Trigger:
Countdown Timer - Start Timer mind_crush_timer with an Exiration Time of ((Distance between temppoint and temppoint2) / 600.00) seconds
(or something)
and give the Mind Crush FX Trigger and event
Trigger:
Time - mind_crush_timer Expires
(or something)
If you want to use JASS, make a new Trigger, put in the GUI-Function you want to JASS and turn that trigger into custom scripts. There you will see something like
Collapse JASS:
call blabla(udg_spellcaster,blabla,blabla)
The udg_spellcaster is the variable you used. Just replace that with a local variable, meaning, something without "udg_" at begin. Then paste it as a Custom Script.
Trigger:
Custom script: call blabla(spellcaster,blabla,blabla)
This means, the
Trigger:
Custom script: local unit udg_spellcaster
must be without "udg_" too.

Trigger:
Custom script: local unit spellcaster = udg_spellcasterglob
...
...
Custom script: call blabla(spellcaster,blabla,blabla)
So in your case it would look like.
Trigger:
Custom script: local unit spellcaster = udg_spellcasterglob
Custom script: local unit spelltarget = udg_spelltargetglob
...
...
Custom script: call UnitDamageTargetBJ(spellcaster,spelltarget,udg_Real2,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_UNKNOWN)
09-14-2006, 06:04 PM#7
Anitarf
The problem with the global->local trick is that it can only be done with one variable, do it with multiple and they will all somehow share the same memory adress.
09-15-2006, 01:27 AM#8
Pheonix-IV
The problem with doing it that way UnMi is that i want this spell to be multi-instancable. So i need it to use a local timer, also as far as i'm aware local variables can only be used inside a trigger, not transferred from trigger to trigger, so i can't have the pause or whatever outside the trigger, as that leaves a possibility for the two global variables i use to transfer the target and caster from trigger to trigger will be overwritten mid-cast and cause all kinds of havoc.
09-15-2006, 02:36 AM#9
Alevice
Quote:
Originally Posted by Pheonix-IV
as far as i'm aware local variables can only be used inside a trigger, not transferred from trigger to trigger

Not with the local handle vars thing you were asking that other day.
09-15-2006, 07:45 AM#10
Pheonix-IV
Wha?
09-15-2006, 09:44 AM#11
UnMi
...
If you want to make a multi-instancable timer, you will have to use 100% JASS. It's not hard to implement though, all you would do is copy paste.
The problem, as zeroXD mentioned, is that Wait actually eats some delay, thus delaying the damaging point too.
09-15-2006, 10:37 AM#12
Pheonix-IV
I'm already using 100% JASS, i figured it'd be easier to just make the trigger in GUI, convert to JASS and then switch the bits i needed to be locals and so on into what they should be.
09-15-2006, 11:03 AM#13
UnMi
Uh, so where was your problem again? >>;
09-15-2006, 11:20 AM#14
Pheonix-IV
I don't know how to use a local timer to activate the actual damage function.

Ideally i'd prefer if it did a 'wait until target has buff Mind Crush' as that assures that the damage will only occur when the bolt actually hits as opposed to when it should hit.
09-15-2006, 08:49 PM#15
UnMi
Oh, now I see what you meant by
Quote:
I'm already using 100% JASS
Would you please copy paste the whole trigger code of both triggers in JASS with [jass] tags? (Yes, because I am lazy.)