My first time with JASS

Rommel

New Member
Reaction score
13
-Hi friends...I spent 18 hours without sleeping last night to learn Jass. I read all great tutorials of Vexorain, Daelin, Wyrmlord, DarkWolf...and i found JASS Very interesting

-Well, yes, firstly i have to convert GUI to JASS for learning, and try to research and optimize it....but later on, when my knowledge is better, i will try to write my own code. I also thank you all friends for your help.

-Here is the list of my next spells..But i should introduce they abit, right...so you can imagine how they work and see if my code is going right.

-Lay on Hands:
A holy light that can heal a friendly unit or deal half damage to a target foe.

-And the code:

JASS:
function Trig_Lay_on_Hands_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Lay_on_Hands_Actions takes nothing returns nothing
local unit Caster_LOH = GetTriggerUnit()
local integer Int_LOH = GetUnitAbilityLevel(Caster_LOH, 'A003')
local unit Target_LOH = GetSpellTargetUnit()
call TriggerSleepAction(0.50)
if IsUnitAlly(Target_LOH, GetOwningPlayer(Caster_LOH))then
 call SetUnitState(Target_LOH, UNIT_STATE_LIFE, GetUnitState(Target_LOH, UNIT_STATE_LIFE) + (Int_LOH * 80. + udg_Bonus_LOH))
else
 call UnitDamageTargetBJ(Caster_LOH, Target_LOH, (80. * Int_LOH + udg_Bonus_LOH), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL)
endif
set Caster_LOH = null
set Target_LOH = null
endfunction

//===========================================================================
function InitTrig_Lay_on_Hands takes nothing returns nothing
    set gg_trg_Lay_on_Hands = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lay_on_Hands, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddCondition( gg_trg_Lay_on_Hands, Condition( function Trig_Lay_on_Hands_Conditions ) )
    call TriggerAddAction( gg_trg_Lay_on_Hands, function Trig_Lay_on_Hands_Actions )
endfunction


-Holy Incantation:
Passive - An aura that gives friendly nearby units a damage shield, which returns a percentage of a melee attacker's damage back to it.

-And the code for Conversion (For multiple conditions, we use "and", right? So i added this line at the end of the Condition Function: and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO :

JASS:
constant function Conversion_SpellId takes nothing returns integer
return 'A007'
endfunction
constant function Conversion_BuffId takes nothing returns integer
return 'AeAh'
endfunction
constant function Conversion_Dum takes nothing returns integer
return 'A004'
endfunction

function Trig_Conversion_Conditions takes nothing returns boolean
return GetUnitTypeId(GetAttacker()) =='Hpal' and IsUnitType(GetTriggerUnit(), UNIT_TYPE_UNDEAD) and GetUnitAbilityLevel(GetAttacker(), Conversion_SpellId()) >=1 and GetUnitAbilityLevel(GetAttacker(), Conversion_BuffId()) >0 and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO )
endfunction

function Trig_Conversion_Actions takes nothing returns nothing
  local unit c = GetAttacker()
  local unit t = GetTriggerUnit()
  local integer ir = GetRandomInt(1,100)
  local integer ic = 2 * GetUnitAbilityLevel(c, Conversion_SpellId())
if ir <= ic then
  call SetUnitAnimation(c, "attack")
  call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", t, "origin"))
  call SetUnitOwner(t, GetOwningPlayer(c), true)
  call UnitAddAbility(t, Conversion_Dum())
endif
  set c = null
  set t = null
endfunction

function InitTrig_Conversion takes nothing returns nothing
call TriggerRegisterAnyUnitEventBJ(gg_trg_Conversion, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(gg_trg_Conversion, Condition(function Trig_Conversion_Conditions))
call TriggerAddAction(gg_trg_Conversion, function Trig_Conversion_Actions)
endfunction


-Judicial Chop:
The Paladin focus his holy strength to jolt a hot light stream at a target enemy unit, causing damage and ministun.

-Sacred Strength:
Passive - The Paladin channels divine power to gain bonus Strength. Also adds more points to Lay on Hands, gives extra damage VS Undead to Judicial Chop, completely immune to Disease and has a chance to convert Undead creatures to your side on attacks under the effect of Holy Incantation

-And the Code for Extra damage for Judicial Chop(I make the game wait 0.5 sec before triggering damage and creating floating text because the caster need a small time to cast his spell or i should use event "A unit finish casting a spell" ?):

JASS:
function Trig_Judicial_Chop_Conditions takes nothing returns boolean
   return GetSpellAbilityId() == 'AHtb'
endfunction

function Trig_Judicial_Chop_Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local integer i = 100 * GetUnitAbilityLevel(c, 'A007')
    call TriggerSleepAction(0.50)
    call UnitDamageTargetBJ(c, t, i, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL)
    call CreateTextTagUnitBJ( ( "+" + I2S(i) ), t, 0, 10, 100, 0.00, 0.00, 0 )
    call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 40.00, 90 )
    call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
    call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 3.00 )
    set c = null
    set t = null
    
endfunction

//===========================================================================
function InitTrig_Judicial_Chop takes nothing returns nothing
    set gg_trg_Judicial_Chop = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Judicial_Chop, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Judicial_Chop, Condition( function Trig_Judicial_Chop_Conditions ) )
    call TriggerAddAction( gg_trg_Judicial_Chop, function Trig_Judicial_Chop_Actions )
endfunction


-The Code for Extra Strength and bonus point to Lay on Hands:

JASS:
function Trig_Sacred_Strength_Conditions takes nothing returns boolean
  return GetLearnedSkillBJ() == 'A007'and GetUnitTypeId(GetTriggerUnit()) == 'Hpal'
endfunction

function Trig_Sacred_Strength_Actions takes nothing returns nothing
  local unit c = GetTriggerUnit()
  local integer i = GetUnitAbilityLevel(GetTriggerUnit(), 'A007')
  set udg_Bonus_LOH = 3 * i
  if i == 1 then
     call UnitAddAbility(c, 'A008')
   elseif i ==2 then
           call UnitRemoveAbility(c, 'A008')
           call UnitAddAbility(c, 'A009')
     elseif i == 3 then
            call UnitRemoveAbility(c, 'A009')
            call UnitAddAbility(c, 'A00A')
  endif
  set c = null
endfunction

//===========================================================================
function InitTrig_Sacred_Strength takes nothing returns nothing
    set gg_trg_Sacred_Strength = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Sacred_Strength, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Sacred_Strength, Condition( function Trig_Sacred_Strength_Conditions ) )
    call TriggerAddAction( gg_trg_Sacred_Strength, function Trig_Sacred_Strength_Actions )
endfunction



Well, i saved it, the map report no bug, but except Lay on Hands i see it clearly works...The other i am not sure, and the Conversion action still does not work, hix.

I attach the map here, so if you have time, can you take a look at it? Also, if my spells have any typo or grammar error, i hope you could help me fix :lol:

At this corner is a group of Undead for testing:
CS-Undead.jpg

And i want to bother you one more thing, how to create a game message like Blizzard's one, like this:

Text.jpg


I will play here around to waiting for answerm hix
 

Attachments

  • CASTLE SIEGE.w3x
    201.8 KB · Views: 101

Rommel

New Member
Reaction score
13
Well, i saved it, the map report no bug, but except Lay on Hands i see it clearly works...The other i am not sure, and the Conversion action still does not work, hix.

Hix the biggest problem is the code for "Conversion" does not work.
Under the effect of holy incantation and Sacred Strength, the caster must has 2/4/6% to convert an Undead creature to his side on attacks but nothing happens.

Also i hope some one could help me fix any error or unefficient things :D
 

Tukki

is Skeleton Pirate.
Reaction score
29
Oh, much code..

1) Holy Hands
JASS:
function Trig_Lay_on_Hands_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Lay_on_Hands_Actions takes nothing returns nothing
local unit Caster_LOH = GetTriggerUnit()
local integer Int_LOH = GetUnitAbilityLevel(Caster_LOH, 'A003')
local unit Target_LOH = GetSpellTargetUnit()
local real TempReal = Int_LOC * 80 + udg_Bonus_LOH // new line
call TriggerSleepAction(0.50) // <- this can be removed.
if IsUnitAlly(Target_LOH, GetOwningPlayer(Caster_LOH))then
 call SetUnitState(Target_LOH, UNIT_STATE_LIFE, GetUnitState(Target_LOH, UNIT_STATE_LIFE) + TempReal)
else
 call UnitDamageTargetBJ(Caster_LOH, Target_LOH, TempReal/2, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL) // use Attack_type_CHAOS and Damage_Type_UNIVERSAL for 'spell damage', chaos as it does not deal extra to anything and universal as it ignores armor. I added TempReal/2 as it should deal half of the hp healed.
endif
set Caster_LOH = null
set Target_LOH = null
endfunction

//===========================================================================
function InitTrig_Lay_on_Hands takes nothing returns nothing
    set gg_trg_Lay_on_Hands = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lay_on_Hands, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddCondition( gg_trg_Lay_on_Hands, Condition( function Trig_Lay_on_Hands_Conditions ) )
    call TriggerAddAction( gg_trg_Lay_on_Hands, function Trig_Lay_on_Hands_Actions )
endfunction

2) Holy Incantation
Consider using Thorns Shield (or something that way).

but this will not work;
add '== true' in this case.

3) Conversion

JASS:
function Trig_Conversion_Actions takes nothing returns nothing
  local unit c = GetAttacker()
  local unit t = GetTriggerUnit() 
  local integer ir = GetRandomInt(1,100)
  local integer ic = 2 * GetUnitAbilityLevel(c, Conversion_SpellId())
if ir <= ic then // change to "ic >= ir"
  call SetUnitAnimation(c, "attack")
  call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", t, "origin"))
  call SetUnitOwner(t, GetOwningPlayer(c), true)
  call UnitAddAbility(t, Conversion_Dum())
endif
  set c = null
  set t = null
endfunction

also this line is spooky;
JASS:
GetUnitTypeId(GetAttacker()) =='Hpal' and IsUnitType(GetTriggerUnit(), UNIT_TYPE_UNDEAD) and GetUnitAbilityLevel(GetAttacker(), Conversion_SpellId()) >= 1 and GetUnitAbilityLevel(GetAttacker(), Conversion_BuffId()) >0 and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO )
endfunction


things to change;


Hope it works.

EDIT: Are you using JassNewGenPack?
 

Rommel

New Member
Reaction score
13
Ah...yes.. my friend i think so..i checked the code thoroughly and fixed a those bugs you reported..it works now..blah ^^
Now i have a question: How to remove a buff from a unit, i trying to make the paladin immune to disease whenever a unit cast it on him. Jass define the buff as spell and the code looks like this, right:

JASS:
call RemoveUnitAbility(unit, buffcode)


But i cant know why it does not work.

Also about timer, Rising_Dusk said a way to use CS Safety of Vexorian...(The very first use he introduced is to use 2 functions where global vars are used>>this is not MUI)..but how to use it? thats the problem, sorry if the question is stupid just forget it :emote_grin:

P/S: Yes, im using JNGP
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
To display messages like bliz, I'd suggest trying this.
The 50 and the 0 are the texts position, it could actually be 0.5. I haven't used it beyond 0,0.
JASS:
call DisplayTextToPlater(GetLocalPlayer(),50,0,"MyMsg")
 

Tukki

is Skeleton Pirate.
Reaction score
29
JASS:
call RemoveUnitAbility( unit, buffcode)

Obviously the unit is whichUnit you want to remove the buff from, and the buffcode is the id of the buff you want to remove. (example: 'B000')

CS Safety is a library for timer/group recyling, so you don't need to destroy them.

To make a unit immune to a buff like 'disease' I would do something like this;
JASS:
scope Test initializer InitTrig

globals
    private constant integer AID_DISEASE = 'A000' // Your disease spell id.
    private constant integer BID_DISEASE = 'B000' // Your disease buff id.
    private constant integer AID_DISEASEPROTECTION = 'A001' // Your disease protection spell.
endglobals

private function Actions takes nothing returns nothing
 local unit Targeted = GetSpellTargetUnit()
 
    if (Targeted != null) and (GetUnitAbilityLevel(Targeted, AID_DISEASEPROTECTION) > 0) then
        if (GetUnitAbilityLevel(Targeted, BID_DISEASE) > 0) then
            call UnitRemoveAbility(Targeted, BID_DISEASE)
        endif
    endif
    
    set Targeted = null
endfunction

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == AID_DISEASE
endfunction

private function InitTrig takes nothing returns nothing
 local trigger Trg = CreateTrigger()
 
    call TriggerRegisterAnyUnitEventBJ(Trg, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(Trg, Condition( function Conditions))
    call TriggerAddAction(Trg, function Actions)
endfunction
endscope


And since you are using JNGP, you should maybe start to learn vJass?

Edit: And your other spells can be made into vJass very easily!
 

Rommel

New Member
Reaction score
13
Thanks for your great help, tukki..Yes, VJass looks promising but i cant find any documents to start my learning course :(
 

Rommel

New Member
Reaction score
13
Muahhahaha..I've been looking for this...kiss you one thousand times, tukki :D
If you have any more documents, send me please...Well, one more week without sleeping...Amen :cool:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top