• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[cJASS] Holy Light (RPG style) V1.05.c8

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
The basic Holy Light spell of the Human Paladin remade.
Unlike the other one I uploaded, this is written in cJASS.
God, I love the C syntax.

Requirements:


Features:
  • Full MUI
  • Leak Free
  • Avoided as many BJ's as possible
  • Written in cJASS
  • Abillity based on Channel
  • Fast Cast
  • Very Customizable



The code:

JASS:
scope HolyLight initializer Init
{ // We have a scope se we can make things private. This helps us avoid name conflicts.

        private integer    abilityID         = 'A001'
                                                // The ID of the ability.
                                                // aka Raw Code
        
        private attacktype attackType        = ATTACK_TYPE_MAGIC
                                                // The attack type of the ability's damage.
        private damagetype damageType        = DAMAGE_TYPE_DIVINE
                                                // The damage type of the ability
        private weapontype weaponType        = WEAPON_TYPE_WHOKNOWS
                                                // The weapon type of the ability.
                                                // It's used for sound.
                                                // I recommend leaving it like this.
        
        private real       texttagSize       = 9.00
                                                // The size of the text tag, in screen pixels
                                                // Like normal fonts. Have you ever used
                                                // Microsoft Office Word? :D
        private real       texttagVelocity   = 45.00
                                                // The velocity of the text tag.
                                                // I've set it to go only up.
                                                // Set to 0 for no movement.
        private real       texttagFadePoint  = 3.00
                                                // The (time) point at which the text tag
                                                // starts fading (in seconds)
        private real       texttagDeathPoint = 5.50
                                                // The (time) point at which the text tag
                                                // will be completly invisible and gets
                                                // DESTROYED (in seconds)
        private boolean    texttagVisible    = true
                                                // Show the text tag?
                                                // Set to false for no text tag
        private real       texttagZoffset    = 30.00
                                                // The height of the text tag from the start.
                                                // It will go up by the velocity.
        

private boolean Conditions() // This is the condition of the trigger. Shouldn't be changed.
{
    
    return GetSpellAbilityId() == abilityID
    
}

private nothing Actions() // The real spell, the action of the trigger.
{

    unit caster = GetSpellAbilityUnit(), target = GetSpellTargetUnit()
                  // The caster       and         the target unit.
                  // We store them here to avoid more calls.
                  // Results in speed.
                  
    real r = GetHeroInt(caster, true) * GetUnitAbilityLevel(caster), AbilityID)
             // We calculate the damage with this formula
             
    string sign // We'll use this string later and make it "+" or "-"
    integer colorR, colorG, colorB, colorA // Our color variables. Look below for setup.
    
    texttag tt = CreateTextTag()
                 // We create a simple text tag.
    
    SetTextTagVelocity(tt, 0,texttagVelocity * 0.071 / 128 )
            // We add the velocity to the text tag. Look at the top for values.
    SetTextTagPermanent(tt, false )
            // We need the text tag to dissapear after some time, so it will not be permanent.
    SetTextTagFadepoint(tt,texttagFadePoint )
            // We add the fadepoint to the text tag. Look at the top for values.
    SetTextTagLifespan(tt,texttagDeathPoint )
            // We add the death point to the text tag. Look at the top for values.
    SetTextTagVisibility(tt,texttagVisible )
            // We make the text tag visible. Look at the top for the setup.
    SetTextTagPosUnit(tt, target,texttagZoffset)
            // We position the text tag above our target.
    
    if ( IsPlayerAlly(GetOwningPlayer(target), GetOwningPlayer(caster)) == true )
    { // The below code will run if the target is an ALLY of the caster!
    
        SetWidgetLife( target, ( GetUnitState( target, UNIT_STATE_LIFE ) + r ) )
                // We "heal" the ALLY
                
        colorR = 230 // The RED value of the text tag's color.
        colorG = 230 // The GREEN value of the text tag's color.
        colorB = 150 // The BLUE value of the text tag's color.
        colorA = 255 // The ALPHA value of the text tag's color.
        sign = "+" // The sign which shows the health was given to the target.
        // Colors have 4 values, Red, Green, Blue and Alpha.
        // Play with these values to find your color.
    }
    else
    { // The below code will run if the target is an ENEMY of the caster!
    
        UnitDamageTarget( caster, target, r, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS )
                // We damage the ENEMY. We use this native so we don't have to take care of
                // experience and bounty.
        colorR = 230 // The RED value of the text tag's color.
        colorG = 100 // The GREEN value of the text tag's color.
        colorB = 150 // The BLUE value of the text tag's color.
        colorA = 255 // The ALPHA value of the text tag's color.
        sign = "-" // The sign which shows the damage was dealt to the enemy.
        // Colors have 4 values, Red, Green, Blue and Alpha.
        // Play with these values to find your color.
    }
    
        SetTextTagText(tt, ( sign + ( I2S ( R2I (r) ) + " HP" ) ), texttagSize * 0.023 / 10 ) //Avoided using a BJ.
                // Now we make the text tag show "-" or "+" and the damage/heal
                // If the target is ALLY, it will show "+damage"
                // If the target is ENEMY, it will show "-damage"
        SetTextTagColor(tt, colorR, colorG, colorB, colorA )
                // Now we give the text the color we want.
                // The colors are chosen above, depending if the target is ALLY or ENEMY.
    
}

private boolean AntiLeak() // A basic anti-leak function
{

    return true

}

private nothing Init() // The initialization trigger of our spell.
{

    trigger t = CreateTrigger() // We make the trigger local.
    filterfunc f = Filter( function AntiLeak ) // The AntiLeak filter function.
                                               // We make a variable to avoid 16 calls
    integer i = 0 // An integer to keep track of the loop.
    
    loop // The event(s) that will trigger the action.
    {    // In this case, an unit casts an ability.
    
        TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, f)
        
        i += 1
        exitwhen i >= 16
    
    } // We're done for all 16 players (0 to 15)
    
    TriggerAddCondition(t, Condition( function Conditions ) ) // Now we have a condition.
                                                              // The actions will run only if the condition returns true.
                                                              // In out case, if the ability being cast is the one we need.
    TriggerAddAction(t, function Actions ) // The actions of the trigger.
                                           // They will run when the event happends and the condition returns true.
    
    DestroyFilter(f) // To avoid leaks, we need to destroy out filterfunc,
    f = null // And null the variable.
    
}

}

Keywords:
vercas, holy, light, holy light, ray, heal, healing, undead, divine, rpg, paladin, knight.
Contents

Holy Light cJass V1.05.c6 (Map)

Reviews
17:13, 30th Nov 2009 TriggerHappy: No cJass.
Level 13
Joined
May 10, 2009
Messages
868
JASS:
if ( IsPlayerAlly(GetOwningPlayer(GetSpellTargetUnit()), GetOwningPlayer(GetSpellAbilityUnit())) == true ) {
        SetWidgetLife( GetSpellTargetUnit(), ( GetUnitState( GetSpellTargetUnit(), UNIT_STATE_LIFE ) + r ) )
        SetTextTagText(tt, ( "+" + ( I2S ( R2I (r) ) + " HP" ) ), TextTagSize * 0.023 / 10 ) //Avoided using a BJ.
        SetTextTagColor(tt, 230, 230, 150, 255 )
    } else {
        UnitDamageTarget( GetSpellAbilityUnit(), GetSpellTargetUnit(), r, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS )
        SetTextTagText(tt, ( "-" + ( I2S ( R2I (r) ) + " HP" ) ), TextTagSize * 0.023 / 10 ) //Avoided using a BJ.
        SetTextTagColor(tt, 230, 100, 150, 255 )
    }
--
Nice Spell! (Y) [irony xD]
 
Level 9
Joined
Aug 2, 2008
Messages
219
krisserz said:
cJASS wins. YEah, nice spell , but is cJASS already legal in spell section?
The last cJass resources i´ve seen in the spells section were rejected right away and until now there was no real official announcement that allowed cJass, but yeah cJass wins !

@vercas
The code can still be a bit more optimized, for instance:

I´d say you could make the values at the beginning of the script constant, but since you are yousing cJass you could use the private define feature to inline them directly. I´m really missing some some comments, you could have put at least some explanation to the config block. Oh and the script is not scoped !

real r = ( I2R(GetHeroInt(GetSpellAbilityUnit(), true)) * I2R(GetUnitAbilityLevel(GetSpellAbilityUnit(), AbilityID)) ) can be optimized to
real r = GetHeroInt(GetSpellAbilityUnit(), true) * GetUnitAbilityLevel(GetSpellAbilityUnit(), AbilityID) The I2R cast is not necessary.

And the thing BloodSoul said could be changed to:
JASS:
    if ( IsPlayerAlly(GetOwningPlayer(GetSpellTargetUnit()), GetOwningPlayer(GetSpellAbilityUnit())) == true ) {
        SetWidgetLife( GetSpellTargetUnit(), ( GetUnitState( GetSpellTargetUnit(), UNIT_STATE_LIFE ) + r ) )
    } else {
        UnitDamageTarget( GetSpellAbilityUnit(), GetSpellTargetUnit(), r, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS )
    }
    SetTextTagText(tt, ( "-" + ( I2S ( R2I (r) ) + " HP" ) ), TextTagSize * 0.023 / 10 ) //Avoided using a BJ.
    SetTextTagColor(tt, 230, 100, 150, 255 )

~TNT
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
Really, a lot easier!

I've updated it:
- Increased speed by using more variables; avoids function calls.
- Now color's R, G, B and Alpha are defined in the if/then/else, so they can be applied later.
- Added MASSIVE documentation. Every little thing is explained, so even a 5 years old can understand it now.
- Re-arranged blocks, now the code is more readable.
- Added a scope, made everything private so... now you won't have name conflicts.
 
Level 25
Joined
Jun 5, 2008
Messages
2,572
I still dunno why is it illegal, i mean if you can make a spell with it without crashing the Warcraft game it is good if you ask me.

I think it is because it would be harder for moderators to review spells in cJass, because i really can't figure out a better reason.
 
Level 9
Joined
Aug 2, 2008
Messages
219
At the moment we don´t have a development director and there is no one (besides Ralle) who could make cJASS an accepted scripting language in the hive. Anyway i guess we´re getting a bit to offtopic with our discussion about cJass in this thread. Someone should start a poll like 'should cJASS be accepted' in the Site discussion. I would do it myself but i dont have time now.
 
Top