• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] 2 Spells that wont work

Status
Not open for further replies.
Level 10
Joined
Apr 13, 2005
Messages
630
I only have 1 spell right now that doesnt wanna work


Troll Blood - this passive spell is suppose to allow an attacked unit to regenerate hp over combat but 6 seconds after leaving combat the regen shuts off til he enters combat. It doesnt seem to be firing at all


JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Troll_Blood_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetAttacker()) == 'U00G' ) ) then
        return false
    endif
    if ( not ( GetHeroLevel(GetAttacker()) >= 5 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Troll_Blood_Func005C takes nothing returns boolean
    return udg_BloodBool[GetPlayerId(GetOwningPlayer(GetAttacker())) + 1] == true
endfunction

function Trig_Troll_Blood_Actions takes nothing returns nothing
    set udg_BerserkerBloodInt[GetPlayerId(GetOwningPlayer(GetAttacker())) + 1] = 0
    if ( Trig_Troll_Blood_Func005C() ) then
        set udg_BloodBool[GetPlayerId(GetOwningPlayer(GetAttacker())) + 1] = false
        call UnitAddAbility( GetAttacker(), 'A0W5' )
    else
        call TriggerExecute(gg_trg_Troll_Blood_Check)
    endif
endfunction

//===========================================================================
function InitTrig_Troll_Blood takes nothing returns nothing
    set gg_trg_Troll_Blood = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(0), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(1), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(2), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(3), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(4), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(5), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(6), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(7), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(8), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Troll_Blood, Player(9), EVENT_PLAYER_UNIT_ATTACKED, null)
    call TriggerAddCondition( gg_trg_Troll_Blood, Condition( function Trig_Troll_Blood_Conditions ) )
    call TriggerAddAction( gg_trg_Troll_Blood, function Trig_Troll_Blood_Actions )
endfunction

Troll Blood Check

JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Troll_Blood_Check_Func003C takes nothing returns boolean
    return udg_BerserkerBloodInt[GetPlayerId(GetOwningPlayer(GetAttacker())) + 1] >= 11
endfunction

function Trig_Troll_Blood_Check_Actions takes nothing returns nothing
    call TriggerSleepAction( 1.00 )
    set udg_BerserkerBloodInt[GetPlayerId(GetOwningPlayer(GetAttacker())) + 1] = ( udg_BerserkerBloodInt[GetPlayerId(GetOwningPlayer(GetAttacker())) + 1] + 1 )
    if ( Trig_Troll_Blood_Check_Func003C() ) then
        set udg_BloodBool[GetPlayerId(GetOwningPlayer(GetAttacker())) + 1] = true
        call UnitRemoveAbility( GetAttacker(), 'A0W5' )
        call UnitRemoveAbility(GetAttacker(), 'B02F')
    endif
endfunction

//===========================================================================
function InitTrig_Troll_Blood_Check takes nothing returns nothing
    set gg_trg_Troll_Blood_Check = CreateTrigger(  )
    call DisableTrigger( gg_trg_Troll_Blood_Check )
    call TriggerAddAction( gg_trg_Troll_Blood_Check, function Trig_Troll_Blood_Check_Actions )
endfunction
 
Last edited:
Level 10
Joined
Apr 13, 2005
Messages
630
I know nothing of Jass, this spell came from a map i took up from Kebab_taxi Eclipse and they must thought it was cool to convert all GUI triggers into jass. I'm trying my best to understand jass to atleast repair the coding but i dont understand the works. When you say Optimize the conditions you are meaning????
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I assume you have no previous programming experience with any typed language (python, java, ruby, C, C++ etc). This will make it extreemly difficult to maintain the above triggers.

What is most likly the case of your problem are the object types (they look like 'A0MR' which are 4 ASCII characters between ' and '). You probably have not updated them to match the types they are given in your map so it is referencing the wrong or incorrect object types. You can see object type identifiers by viewing raw data in the object editor (they look like A000 for custom abilities as an example).

I would start by updating these to reference the appropiate abilities and dummy objects inside your own map. They are easy to change as you just need to change the 4 characters of each to the 4 characters of the appropiate object in your map. You can use the source map to find which objects are being referenced where (so you can choose the correct objects).

As for learning JASS, that can be easy or difficult depending on your programming experience. I advise looking at some tutorials for the basics.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Well I created a spell nearby the same like your TrollBlood ability. I modified it a little and hope this matches your idea:



!! Name of the trigger is: TrollBlood

JASS:
library TrollBlood initializer init

    globals
        private constant integer SPELL_ID = 'A000'  // the rawcode of the passive ability
        
        private constant real DUR_AFTER_FIGHT = 6.
        
        private constant string SFX = "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodFootman.mdl"
        
        private constant real L = 0.04
        private constant hashtable H = InitHashtable()
    endglobals
    
    private function heal takes integer level returns real
        return 10. + 5. * level
    endfunction
    
    // Configuration ends here \\
    
    private struct TrollBlood
        unit    caster      = null
        real    h           = 0.
        real    d           = 0.
        real    t           = 0.
        
        private static method Loop takes nothing returns nothing
            local timer t = GetExpiredTimer()
            local thistype this = LoadInteger(H,GetHandleId(t),0)
            
            if GetUnitCurrentOrder(.caster) == S2I("attack") then
                set .t = .t + L
                if .t > 1. then
                    set .t = 0.
                    call SetWidgetLife(.caster,GetWidgetLife(.caster) + .h)
                    call DestroyEffect(AddSpecialEffectTarget(SFX,.caster,"origin"))
                endif
            endif
            
            if GetUnitCurrentOrder(.caster) != S2I("attack") then
                set .t = .t + L
                set .d = .d + L
                
                if .t > 1. then
                    set .t = 0.
                    call SetWidgetLife(.caster,GetWidgetLife(.caster) + .h)
                    call DestroyEffect(AddSpecialEffectTarget(SFX,.caster,"origin"))
                endif
                if .d > DUR_AFTER_FIGHT then
                    call PauseTimer(t)
                    call DestroyTimer(t)
                    call .destroy()
                endif
            endif
            set t = null
        endmethod
        
        static method create takes unit caster returns thistype
            local thistype this = .allocate()
            local timer t = CreateTimer()
            
            set .caster = caster
            set .h = heal(GetUnitAbilityLevel(.caster,SPELL_ID))
            call SaveInteger(H,GetHandleId(t),0,this)
            call TimerStart(t,L,true,function TrollBlood.Loop)
            set t = null
            return this
        endmethod
    endstruct
    
    private function cast takes nothing returns boolean
        if GetUnitAbilityLevel(GetAttacker(),SPELL_ID) > 0 then
            call TrollBlood.create(GetAttacker())
        endif
        return false
    endfunction
    
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
                
        loop
            exitwhen i == 15
            call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_ATTACKED,null)
            set i = i + 1
        endloop
        call TriggerAddCondition(t,Condition(function cast))
        
        call Preload(SFX)
        
        set t = null
    endfunction
endlibrary

Well and about the other ability, well if you want heal the attacked by a percent value of his damage you will need a damage detect system. If you are glad with just restoring a value not depends on the damage of the attacked, then this would be easy.


100% NO! This tutorial doesn't really show how to make bad GUI into good jass .. the creator even say GUI > vJass (which is wrong). Also this tut is already to old to be used.

Greetings and Peace
Dr. Boom
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
deathdoorway did not make the spells if you read his posts.
He has got them from some other map which for some reason did not support their GUI version (he says the makers of that map just liked to mess with people by converting all GUI to JASS and then prety much leaving the JASS alone.

I say the most likly cause of any problems is that he has forgot to change the object type references to match his map.
 
Level 10
Joined
Apr 13, 2005
Messages
630
@super I do understand the 'A021" inside as it refers to units, spells, or other stuff. I'm not total jass literate. the units do match up and spells to the units and spells in the current map. so that shouldn't exactly be the prob. About learning jass I'm not really joy happy about this as GUI is the world to me and i could just throw in Egui to spice things up a bit

@dr.boom I will see about your spell once i get outta work but the map does have a damage detection system as it shows damage done by every spells and what units have lost etc...

I'll repeat what i said in first and super tried clearing up, This map isnt made by me I'm editing for a favor of the map maker. His method to madness was to Convert stuff to jass without any care to fixing up the codes. I'm sure the leak like hell and I'm just asking to point out the prob not get lectured on cleaning up GUI to jass. Thank you all
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You could drop the map by me with the problimatic triggers highlighted and I may be able to fix it up (I would prefer using vJASS but if JNGP is not an option I might be able to use normal JASS).

If it is not object type related, it may be that some of the event response getters (like the AttackedUnit) may not work inside triggers run that way.
 
Level 10
Joined
Apr 13, 2005
Messages
630
Whatcha mean Drop the map by you?

I dont know how to use vJASS nor do i know how to open maps encoded with it so it maybe a prob but there prob is already some in there already. There is some libraries installed in the maps for bosses but like i said my knowledge is very limited :(
 
Level 10
Joined
Apr 13, 2005
Messages
630
mck i love the spell but there was 2 prob. It doesnt heal the whole battle, Only heals on attacks so the whole 6 sec after battle is pointless or during battle. Your text spam idk why you truely do have it???? its just a waste of show and dam healing effect that spam that much would annoy even the simplest person. I do freaken love the spell and your effort though. Is there anyway i could edit this? or where to.

Also Super Good I'll send you the map but where do i post it?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Upload it to the pastbin that this site hosts (at far top of page). Then you can hand out the temporary link it generates to people (via private message if you are concerned about others downloading it or just post it publically if not).

Remember to highlight the spells that do not work and also try ang give some problem specification (what the spells are meant to do) so that I do not fix them incorrectly.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Since this just looks like GUI converted Jass, you would probably be better off getting more help if you posted the code in GUI.

Anyway, Troll Blood Check doesn't work since GetAttacker doesn't apply to anything in that trigger event. You have to store that unit somehow; if you want the spell to be MUI, you should look into GUI indexing.

Blood Mark is coded wrong. You should store the duration in a real variable that decreases periodically (with timers or triggers in GUI), then remove the ability after the duration reaches 0.
 
Status
Not open for further replies.
Top