wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > vJass Spells
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 09-13-2008, 06:19 PM   #1
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default Sun Ray

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.

Click image for larger version

Name:	Sun Ray.jpg
Views:	761
Size:	232.0 KB
ID:	37223

Requirements:
- Jass NewGen Pack (uses vJASS)
- TimerUtils

History:
Hidden information:

Version 1.0
- Fixed a Math problem
- Spell was ready, initial release to the forums, for improvements

Version 1.1
- Now you can have waves of lights! If you don't like, just set the interval to zero!

Version 1.2
- Optimization in the code's speed, now it is even faster, and the code is more simple than ever !

Version 1.3
- Added a JESP manifest document
- Added a nice effect on the hero

Version 1.4
- Removed some members from the structure that weren't needed, now x, y and angle are just local variables
- Added Anitarf to the credits section

Version 1.4a
- Removed member "i" it was not needed. Now it is also a local variable
- Made some improvements to the comments

Version 1.5
- Added a boolean variable. Now the rays can depend on the casters angle if the user wants to

Version 1.5.1
- Updated for patch 1.24


Collapse 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
Attached Files
File Type: w3x SunRay 1.5.1.w3x (30.8 KB, 194 views)
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 08-06-2009 at 10:02 AM.
Flame_Phoenix is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 09-14-2008, 02:26 AM   #2
TKF
User
 
TKF's Avatar
 
Join Date: Dec 2006
Posts: 384

TKF is on a distinguished road (10)

Default

Hmmm this might be the killing blow to my best spell design idea (which is light). Maybe you are getting the gold on light spell category with this one...


Here is how mine looks like. I'll be glad if I even get a medal with such fierce and good contestants. This is my first contest and I had to learn triggers in this contest (Yeah, atm GUI)

I'll be more than happy to even get a bronse against 20-30 contestants.

Zoom (requires log in)
(That hammer is griffin hammer enlarged)
__________________
Retired
TKF is offline   Reply With Quote
Old 09-14-2008, 10:36 AM   #3
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

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 =)
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 09-14-2008 at 12:21 PM.
Flame_Phoenix is offline   Reply With Quote
Old 09-14-2008, 01:26 PM   #4
TKF
User
 
TKF's Avatar
 
Join Date: Dec 2006
Posts: 384

TKF is on a distinguished road (10)

Default

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...
__________________
Retired
TKF is offline   Reply With Quote
Old 09-14-2008, 05:38 PM   #5
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
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...
Well I am entering with 5 spells, some are good, others very simple, and some took days to debug, others took weeks.
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
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 09-14-2008 at 05:39 PM.
Flame_Phoenix is offline   Reply With Quote
Old 09-17-2008, 03:13 PM   #6
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

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.
__________________
Anitarf is offline   Reply With Quote
Old 09-17-2008, 04:01 PM   #7
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

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 !?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 09-17-2008, 05:00 PM   #8
TKF
User
 
TKF's Avatar
 
Join Date: Dec 2006
Posts: 384

TKF is on a distinguished road (10)

Default

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.
__________________
Retired
TKF is offline   Reply With Quote
Old 09-17-2008, 05:12 PM   #9
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Flame_Phoenix
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.
Yeah. So?

Quote:
A cone ?! How would I do that ?
I would have to make drastic changes in the spell code.
Not really, no.
__________________
Anitarf is offline   Reply With Quote
Old 09-17-2008, 07:40 PM   #10
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
Not really, no.
What do I have to change ?

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:
I don't see why x, y and angle are struct members instead of local variables in the CreateLights function.
Mm, happens that I was not seeing that part of the code, thx for poiting that out.
Code is now updated according to your comment and you were added to Credits.

Version 1.4 released
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 09-17-2008 at 07:41 PM.
Flame_Phoenix is offline   Reply With Quote
Old 09-17-2008, 07:58 PM   #11
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

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.
__________________
Anitarf is offline   Reply With Quote
Old 09-17-2008, 08:18 PM   #12
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
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.
It is truth for the member "i", however it is NOT for distInc. Just try turning it into a local and you'll see what happens xD

Ok guys, new version released 1.4a, please read History for more information.
Hope you all like new small optimization again =D
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 09-17-2008, 08:38 PM   #13
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

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.
__________________
Anitarf is offline   Reply With Quote
Old 09-17-2008, 08:45 PM   #14
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
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.
Sorry but I DO think my approach is far easier to understand ... I mean it's not like it's going to cause massive super lag on a map it's just one single member ...
I believe I'll keep it this way for now.
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 09-27-2008, 04:17 AM   #15
chobibo
100% Genuine Retard!
 
chobibo's Avatar
 
Join Date: Jan 2007
Posts: 797

chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)chobibo has a spectacular aura about (101)

Send a message via Yahoo to chobibo
Default

wrong test map...
__________________
Where's mah sig?
chobibo is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 07:07 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services