| 07-11-2008, 07:53 AM | #1 |
HI! I submited my spell pack here, its in GUI and it contains lot of variables. Could someone show/tell me how to set "global(or what is it, i don't know JASS) " variables, like i want them to be "TempLoc01=Position of unit()" "TempLoc02=Targeted point of ability being cast" "TempLoc03=Targeted unit of ability being cast" etc. So lets say that i have 5 different variables for points, now how should i do that i don't need new Variables, but i only use those 5 for all spells? Here is the Spell Pack:Forbidden SpellPack1.06Final.w3x Thanks! HF -BZR- |
| 07-11-2008, 08:15 AM | #2 |
Using all those globals will make your spells non MUI. |
| 07-11-2008, 09:27 AM | #3 |
Bersek, the only way to improve that spell pack, is making it JASS. I suggest you start reading some tutorials. |
| 07-11-2008, 10:12 AM | #4 |
This will be hard :S I have red many of them, but i never program before... |
| 07-11-2008, 10:32 AM | #5 |
It is very easy, once you understand the logic, it will be even easier. I remade your Fatal Strike ability into vJASS. This is just one possible code, i tried to follow yours and make this one simple, surely many people will find a way better to do this. JASS://scopes are very good, inside this scope everything will be //called FatalStrike_funcName, the "initialozer Init " tells the //scope that the function that initializes this trigger is Init scope FatalStrike initializer Init //this is global free declaration //"private" means it can only be used by this spell //"constant" means its value never changes //private constants like this integer are excelent to make spells easy to configuure globals //rawcode of the ability private constant integer AID = 'A00B' //string model of teh effect. This way is easier to change ! private constant string EFFSTRING = "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl" //the amount of damage the caster will take private constant integer DAMAGE = 200 //the rawcode of the dummy purple unit private constant integer DUMMYID = 'h001' //the rawcode of FatalStrike the dummy will receive private constant integer FATALSTRIKE = 'A009' endglobals //=========================================================================== private function Actions takes nothing returns nothing //locals are used inside functions, they make your spells MUI //I save the catser in this variable local unit caster = GetTriggerUnit() //this stores the X and Y of the caster. //with an X and an Y, you have the location of the caster //and because you use 2 reals, this won't leak local real casterX = GetUnitX(caster) local real casterY = GetUnitY(caster) //this is a varuable for the dummy unit //it has no value yet local unit dum //instead of pausing the caster, making him invulnerable and adding him //fly height for him to disappear, we just hide the caster call ShowUnit(caster, false) //we play the caster's death animation call SetUnitAnimation( caster, "death" ) //We create and destroy an effect at the casters position call DestroyEffect(AddSpecialEffect(EFFSTRING, casterX, casterY)) //here we wait one second. Waits are evil and inacurate, i suggest you use //timers as soon as you can call TriggerSleepAction(1.0) //here we make caster appear call ShowUnit(caster, true) //here we remove 200 life from caster //SetWidgetLife and GetWidgetLife set and get the life of the unit call SetWidgetLife(caster, GetWidgetLife(caster) - DAMAGE) //we play attack animation call SetUnitAnimation( caster, "attack" ) //here we set a value for teh dummy unit //we say that variable dum is a the unit we are creating at caster's position set dum = CreateUnit(GetOwningPlayer(caster), DUMMYID, casterX, casterY, 0) //here we add 3 seconds of life to dummy //the 'BTLF' is just "buff" it has. Not important in dummies //you can always use that one. call UnitApplyTimedLife(dum, 'BTLF', 3.0) //here we add fatal strike to the dummy uniy call UnitAddAbility(dum, FATALSTRIKE) //here we order the dummy unit to cast fan of knifes immediatly call IssueImmediateOrder(dum, "fanofknives") //now that the spell has ended, we have to clean all mess to prevent leaks //we take care of the variables of type "unit" //varuables of type real and integer, per example, don't leak set caster = null set dum = null endfunction //=========================================================================== //functions can also be provate, meaning they can only be used by this spell private function Conditions takes nothing returns boolean return GetSpellAbilityId() == AID endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger FatalStrike = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( FatalStrike, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( FatalStrike, Condition( function Conditions ) ) call TriggerAddAction( FatalStrike, function Actions ) set FatalStrike = null endfunction endscope One tip - have a look on the globals I created (at top) only. After that start reading the code starting from bottom (end) in function Init, to the top. Try follow the logic, almost everything is explained. 0 - Have a look on globals 1- Init 2 - Conditions 3 - Actions Now compare this code, to the code your GUI code. 1 - go to GUI code 2 - Edit -> convert to custom text 3 - compare, everything that appears in red is everything you should change, because it is not efficient and evil. This code is vJASS like. much easier to sue and understand. Oh, and by the way, did I mention that this code is also leak free and MUI ?? =P |
| 07-11-2008, 09:05 PM | #6 |
Best way to learn is to convert your GUI into text, start replacing BJ functions, and changing as many globals as possible into locals. |
| 07-11-2008, 09:47 PM | #7 | |
Quote:
For one variable per function, you can do this in the beginning of the trigger: (your global variable is named ORC) Trigger: Custom Script: local unit udg_ORCThis won't work inside Conditions / Pick All Units / Pick all Destructables |
| 07-11-2008, 10:25 PM | #8 |
Best solution is always to use vJASS and download JNGP, however know you will need patch 1.21b to do so. |
| 07-12-2008, 08:22 AM | #9 |
Don't throw him into vJASS just yet, flame. He needs to at learn basic JASS before he starts going into vJASS. Free global declaring is fine (it's hardly vJASS), but if he's never done JASS before trying to get him to learn all of JASS PLUS all of vJASS features could be a bit much. But I digress. The only way to cure this is to make it JASS. |
| 07-12-2008, 08:30 AM | #10 |
I know what should each line deal, i just cant put all together. And in vJass why are some text blue some bold black? Its just... i cant start, i don't know any basics(well a few) i know what is global(i don't know how to set it) i know what is local(i know how to set it, but not totally), i know why the "call" have some spaces in front of it, i know what function does... and this is like 1% of Jass. So i reather stick with GUI than learn the rest of 99%, waste half year of my life, because after wc3 won't be popular anymore, i will probably newer program again. And as i told, i just tried to submit it here (spellpack), and i knew it wouldn't get aproved 1st its in GUI 2nd its not MUI(i just wonder why it should be) 3rd i'm new here(ppl think, o whata n00b) 4th i just make spells for fun(if they work for me, its ok, and if someone finds it useful its ok too) |
| 07-12-2008, 09:08 AM | #11 | |
Quote:
2: MUI is required because MUI spells are a standard, and people will probably need it. 3: Again, nothing to do with it. 4: And last, yet again, nothing to do with it. It's really NOT that hard to learn a little basic JASS so you can at least make the spells MUI. Hell, I'LL do it for you, optimization and all. Then you can submit it and we'll all be happy. |
| 07-12-2008, 09:15 AM | #12 | |
Quote:
Well, it's there to make it more readable. You actually don't need the spaces in front of the "call ...". |
