| 09-13-2008, 06:19 PM | #1 | |
Ok guys, this is one of the spells for my map, for the light knight. It is a simple spell, but I like the effects and lights so I decided to use it on spell Olympics and to submit it here, because I think people can really make use of it. This is one of those spells with which I am proud, mainly because this time I made the maths alone (or mostly xD). The spell is of course JESP, and I hope you all like it. This spell belongs to my project Castle vs Castle Flame Edition and I hope you all enjoy it. Description: - The light paladin uses the forces of the light to send several Sun Rays which will heal allied units and damage Undead units. Requirements: - Jass NewGen Pack (uses vJASS) - TimerUtils History:
JASS://=========================================================================== //The caster uses his light powers to summon waves of Light Rays around him, //damaging enemy Undead units nearby, and healing allied units // //Requires TimerUtils // //@author Flame_Phoenix // //@credits //- Blackroot (aka Modeler), the first creator, gave me the basic idea and concept //- the-thingy, by telling me where to use bj_DEGTORAD and why //- Alexander244, for helping me fixing a bug with parenthesis ... lol //- Anitarf, for suggesting a slight improvement for the code //- My first teacher of vJASS: Blue_Jeans //- All other people I forgot or ignored // //@version 1.5 //=========================================================================== scope SunRay initializer Init //needed for spell's core, don't change private keyword tmpPlayer //=========================================================================== //=============================SETUP START=================================== //=========================================================================== globals private constant integer AID = 'A000' //raecode of ability private constant real LIGHT_RADIUS = 100 //radius of each single light private constant string LIGHT_EFFECT = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" //the effect of the light private constant real LIGHT_INTERVAL = 0.2 //the interval that separates each light private constant boolean CASTER_ANG = true //if true we consider the caster's facing angle, else we don't endglobals private constant function Damage takes integer level returns real return level * 5. //the damage the enemy undead units will take endfunction private constant function Heal takes integer level returns real return level * 10. //the heal your allied units will receive endfunction private constant function LightNumber takes integer level returns integer //each Sun Ray of (4 + level) lights return 4 + level endfunction private constant function RayNumber takes integer level returns integer //the number of Sun Rays of the spell return 5 + level endfunction private function AllyTargets takes nothing returns boolean //what allied units will be affected by the spell return IsUnitAlly(GetFilterUnit(), tmpPlayer) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false) and (GetWidgetLife(GetFilterUnit()) > 0.405) endfunction private function EnemyTargets takes nothing returns boolean //what enemy units will be affected by the spell return IsUnitEnemy(GetFilterUnit(), tmpPlayer) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false) and (GetUnitRace(GetFilterUnit()) == RACE_UNDEAD) and (GetWidgetLife(GetFilterUnit()) > 0.405) endfunction //=========================================================================== //=============================SETUP END===================================== //=========================================================================== globals private player tmpPlayer private group g private boolexpr enemies private boolexpr allies endglobals private struct MyStruct unit caster real casterX real casterY integer level timer t real distInc integer lightsCreated static method create takes unit caster returns MyStruct local MyStruct data = MyStruct.allocate() //setting variables set data.caster = caster set data.casterX = GetUnitX(caster) set data.casterY = GetUnitY(caster) set data.level = GetUnitAbilityLevel(caster, AID) set data.t = NewTimer() //this will create the lights =) set data.distInc = LIGHT_RADIUS set data.lightsCreated = 0 return data endmethod method onDestroy takes nothing returns nothing call ReleaseTimer(.t) endmethod endstruct //=========================================================================== private function CreateLights takes nothing returns nothing local MyStruct data = MyStruct(GetTimerData(GetExpiredTimer())) local unit f local real x //the X position of the effect local real y //the Y position of the effect local real angle local integer i //a counter for the loop //we set this variable depending if we want to consider the //caster's angle or not if CASTER_ANG then set angle = GetUnitFacing(data.caster) else set angle = 0 endif //if we didn't pass the number of lights, than we create lights //again, however, if we did, we end everything if data.lightsCreated < LightNumber(data.level) then //in this outer loop we create the Sun Rays set i = 0 loop exitwhen(i == RayNumber(data.level)) set x = data.casterX + data.distInc * Cos(angle) set y = data.casterY + data.distInc * Sin(angle) call DestroyEffect(AddSpecialEffect(LIGHT_EFFECT, x, y)) //in this first double inner loop we select the enemy units and damage them set tmpPlayer = GetOwningPlayer(data.caster) call GroupEnumUnitsInRange(g, x, y, LIGHT_RADIUS, enemies) loop set f = FirstOfGroup(g) exitwhen(f == null) call GroupRemoveUnit(g, f) call UnitDamageTarget(data.caster, f, Damage(data.level), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null) endloop //in this second double inner loop we select the allied units and heal them set tmpPlayer = GetOwningPlayer(data.caster) call GroupEnumUnitsInRange(g, x, y, LIGHT_RADIUS, allies) loop set f = FirstOfGroup(g) exitwhen(f == null) call GroupRemoveUnit(g, f) call SetWidgetLife(f, GetWidgetLife(f) + Heal(data.level)) endloop set angle = angle + (360 / RayNumber(data.level)) * bj_DEGTORAD set i = i + 1 endloop set data.distInc = data.distInc + LIGHT_RADIUS set data.lightsCreated = data.lightsCreated + 1 else call data.destroy() endif endfunction //=========================================================================== private function Conditions takes nothing returns boolean local MyStruct data if GetSpellAbilityId() == AID then set data = MyStruct.create(GetTriggerUnit()) //now we start the timer ! call SetTimerData(data.t, integer(data)) call TimerStart(data.t, LIGHT_INTERVAL, true, function CreateLights) endif return false endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger SunRayTrg = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( SunRayTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( SunRayTrg, Condition( function Conditions ) ) set SunRayTrg = null //setting globals set g = CreateGroup() set enemies = Condition(function EnemyTargets) set allies = Condition(function AllyTargets) //preloading effect call Preload(LIGHT_EFFECT) endfunction endscope |
| 09-14-2008, 10:36 AM | #3 |
I don't think I am going to win, specially with participants like Anitarf (real pro guys, trust me). I don't think I am meant to gold, but if I get silver or bronze I'll be happy. Your spell looks real good, you should submit it too. You see, by submitting your spell people will help you improve your code, and it is more likely for you to get more points =) |
| 09-14-2008, 01:26 PM | #4 |
Well, it has no code and it's in raw GUI. And with just 1 day until judging begins, it's way to late now. I've been told that those who use GUI, will never be able to get a medal, but I'll prove that could be possible, even I cannot surpass 70 points (cuz i lose 15 effort points cuz I use no effort into the spells), I must hope there is only 2 good submission in some category... I've made 7 spells in only 2-3 days... While some uses longer time for fewer spells... |
| 09-14-2008, 05:38 PM | #5 | |
Quote:
I am entering the dark section too, with my spell Confusion (which I will now submit here too). I hope I at least have a chance =) I would like, at least, to win 1 single medal, to represent my country, but I don't know if it will be possible. Wish me luck =) GUI is limited, but people can do spells with them. I find your spells quite nice =) Good luck for you too ! xD |
| 09-17-2008, 03:13 PM | #6 |
I don't see why x, y and angle are struct members instead of local variables in the CreateLights function. I don't have much else to say, except that the spell is kinda simple, it would be nice if you could upgrade it a bit: for example, instead of evenly distributing the rays in a circle, you could distribute them in a cone (which, if the user specifies 360 degrees as it's width, could still be a circle) in the direction of the facing of the caster or a target point. |
| 09-17-2008, 04:01 PM | #7 |
x y and angle are members because I need to update them constantly in the function. If they are locals, they will die when I the first cycle ends, and their values will be lost. I know the spell is kinda simple, but I like it =) That's why I am submitting it, I like the effect of the sun (if the caster is the center he can be seen as the start, and the rays, well, as the rays of light xD). A cone ?! How would I do that ? I would have to make drastic changes in the spell code. That is not an option for now,I am more concerned with the Confusion spell in which I still need help and more concerned about your ADamage system I still have to learn how to use decently because I don't have any examples. This spell is complete and it is not a priority so far. Thx for your post though =) A cone !? |
| 09-17-2008, 05:00 PM | #8 |
Well you can submit your spells as resources. You have coded it well in JASS and are decent spells. Also it looks nice. But my spells are just for the olympic contest and nothing else. Even winning a single bronze medal is extremely unlikely, I'll still going to participate even if it's futile. I didn't know that competitions here are so fierce, compared to the hives competitions. |
| 09-17-2008, 05:12 PM | #9 | ||
Quote:
Quote:
|
| 09-17-2008, 07:40 PM | #10 | ||
Quote:
EDIT EDIT EDIT Ok guys I made an update to the code, now the structure is smaller, hope you all like the update, although it is just a small one. Quote:
Code is now updated according to your comment and you were added to Credits. Version 1.4 released |
| 09-17-2008, 07:58 PM | #11 |
The same thing that was true for x, y and angle is true for distInc and i, I kinda missed those in my first review, sorry. |
| 09-17-2008, 08:18 PM | #12 | |
Quote:
Ok guys, new version released 1.4a, please read History for more information. Hope you all like new small optimization again =D |
| 09-17-2008, 08:38 PM | #13 |
distInc can be expressed as a function of lightsCreated, so only one of them needs to be maintained between updates, the other one can be calculated from it every time. |
| 09-17-2008, 08:45 PM | #14 | |
Quote:
I believe I'll keep it this way for now. |
| 09-27-2008, 04:17 AM | #15 |
wrong test map... |
