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: 102

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
590
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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top