| 02-01-2008, 05:42 AM | #1 | |
First off sorry for posting my spells too much, but iamm trying to learn jass fast so i am making spells i need with it fast. This spell creates fire balls around the caster and rotates them around him for a given time. When the fire balls crash into an enemy the deal damage to that unit. This part works fine. The part i am having a problem with is that when they finally hit something the effect never goes away it stays there where it hits them forever. In other words it never gets destroyed. Also if anyone can give me tips on how to optimize my code plz do so. It will be greatly appreciated. Also i need a question answered. I have just found out if you try to destroy a local that does not point to anything the code will stop there. Is this true?
The Trig_CopyGroup() function works fine so thats not the issue. Added some comments in first part since it jsut repeats that should say what im doing. @PipeDream sorry for not commenting but im use to looking at long lists of code with out them >.< |
| 02-01-2008, 06:02 AM | #2 | |
Quote:
Attempting to read a variable (including trying to destroy it) which has not been written stops execution. I wrote a couple tools for detecting when this can happen / does happen, the most usable is in the Jass NewGen pack over in the tools section. Your code is too complicated for me to go through it line by line. I suggest splitting it into functions or at least commenting it. Otherwise after 6 months you will look at this code and go "Wha?". |
| 02-01-2008, 08:43 AM | #3 |
Okay im a dumbdonkey i figured out my problem after i read PipeDreams post 4 times over lol. When units got hit the effect got destroyed twice. This caused the problem but now its fixed =). JASS:if (tar==null) then call DoNothing( ) else call UnitDamageTargetBJ( cas, tar, d, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC ) set a3=1 call DestroyEffectBJ(e3)//This part needed to be taken out endif However can anyone help me optimize code? that is point to tuts or other threads. Also im a nub so is there anyway i could get a native list of like all the gui things? |
| 02-01-2008, 03:01 PM | #4 |
Get Jass NewGen pack, it's packed with a complete function lists which can be accessed through TESH. |
| 02-01-2008, 05:31 PM | #5 |
I will also advise you to get JASS NewGen pack. Additionally, I can help you recode your JASS, although I can't point you to tutorials. I've gathered what I know from bits and pieces everywhere. If you do get JASS NewGen, then I think Cohadar wrote something on optimization somewhere here. I'll be waiting for your reply if you want my help. Edit: Just briefly looking at your code, I'm not entirely why you are looping 1000 times. Also, like PipeDream said, you really ought to make some separate functions to do specific things. The one that really comes to mind is one to filter your units in the groupl. You can make a simple, yet moderate improvement on execution if you change your if(a2 == 0 )then and if(a3 == 0 )then into elseif's. This way, when a condition is met, the rest of the if's are not even tested. As your code is this huge mess, I'm not sure that changing them to elseif will not affect functionality. At a glance it appeared it would not. Lastly, from the a1,a2,a3 statements, all that appears to change are a few numbers. If this is the case, we can entirely redo you trigger and make it vastly more efficient. Again, get back to me. Edit2: Oh, the effects aren't destroyed because of the TriggerSleepAction(.01), I am pretty sure. |
| 02-01-2008, 06:15 PM | #6 |
The spell is fixedin functionality.Ty i will try the Genpack but i changed the loop to 100 times to make it last the 23 seconds i desired. and the a1,a2,a3 are unts that i change to 1 if the fireball has exploded so it no longer calculates or makes the effect again. sort of like a check to where 0=true,1=false, but i think it should be other way around in real code. Oh a quick question if i make my own functions can they take and return things because ive tried making them but i always get a scripting error. |
| 02-01-2008, 06:43 PM | #7 |
Ooh... sorry to be the one to tell you this, mate, but looping 100 times doesn't equal 23 seconds... it will last longer on laggy computers, which can cause desyncs depending on what happens afterward, or what you do with the unit. You need to have a timer that executes every .05 seconds or so for 23 seconds. You would decrease the repetition time for a smoother feel, increasing it for a rougher feel, but it's less resource intensive. JASS:function DamageMultiplier takes integer level returns real return level * 1.8 endfunction Do you want my in-depth help or not? I need to know so I can organize my time. |
| 02-01-2008, 07:24 PM | #8 |
just some addon to make things run faster =\ JASS:constant function DamageMultiplier takes integer level returns real return level * 1.8 endfunction |
| 02-01-2008, 07:26 PM | #9 | |
Quote:
|
| 02-01-2008, 09:17 PM | #10 | |
Quote:
I purposely left off constant... lol. This was just an example, I didn't want him to think you had to write constant every time. Actually, there are far better techniques than this example to do a damage multiplier, but it was the only function I'd ever written that I had where I took and returned things... it seems the more I use structs/handle systems the less I use these sort of functions. |
| 02-02-2008, 12:05 AM | #11 |
Adding "constant" doesn't make it any faster or slower. All it does is place a few restrictions on the function and allows it to be inlined by Vexorian's Map Optimizer. |
| 02-02-2008, 12:35 AM | #12 |
It gets inlined without the need of Map Optimizer :P So something like this: Before Compiling:constant function DamagePerLevel takes integer i returns real return 40+(i*50) endfunction function Pwn takes nothing returns nothing local unit u = GetTriggerUnit() local unit t = GetSpellTargetUnit() local integer level = GetUnitAbilityLevel(u,'XXXX') call UnitDamageTarget(u,t,DamagePerLevel(level),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) set u = null set t = null endfunction Compiled Code:function Pwn takes nothing returns nothing local unit u = GetTriggerUnit() local unit t = GetSpellTargetUnit() local integer level = GetUnitAbilityLevel(u,'XXXX') call UnitDamageTarget(u,t,40+(level*50),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) set u = null set t = null endfunction |
| 02-02-2008, 01:25 AM | #13 |
Only with NewGen. |
