• 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] unit problem in JNGP

Status
Not open for further replies.
Level 11
Joined
Apr 6, 2008
Messages
760
Vjass Problem

i fixed the problem with the unit...

its a more advanced way of creating a SFX at the caster(just to try things out) but i dont see any SFX :<

any comments for first vjass "spell" or something^^ (if any moderate could change the name of my post to "Vjass" coz i dont wanna do more posts :p)

JASS:
scope Spell

private struct Data
unit caster
real x
real y
endstruct

globals
private constant integer abil_id = 'A000'
private constant string SFX = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
endglobals

private function PreLoad takes nothing returns nothing
    call Preload(SFX)
endfunction

private function conds takes nothing returns boolean
    return GetSpellAbilityId() == abil_id
endfunction

private function Spell_Cast takes nothing returns nothing
    local Data data = Data.create()
    set data.caster = GetTriggerUnit()
    set data.x = GetUnitX(data.caster)
    set data.y = GetUnitY(data.caster)
    call DestroyEffect(AddSpecialEffect(SFX,data.x,data.y))
    call data.destroy()
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local integer index = 0
        loop
            call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == 16
        endloop
    call TriggerAddAction( trig, function Spell_Cast)
    call TriggerAddCondition( trig, Filter(function conds) )
    call PreLoad()
endfunction

endscope

EDIT!:eek:mg i forget too add a event ^^ yep it's working :)
 
Last edited:
Level 11
Joined
Apr 6, 2008
Messages
760
this is what im working on now there is somestupid bugg when i try to move back the caster to he's start position he will just stand at the last position but everything else works (destroying the timer ect ect)

EDIT: ok i did fix it quite happy for being my first Vjass spell :D

JASS:
scope Spell

globals
private constant integer abil_id = 'A000'
private constant string SFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
endglobals

private struct Data
unit caster
unit target
real sx
real sy
integer loops
timer t = CreateTimer()
endstruct

private function PreLoad takes nothing returns nothing
    call Preload(SFX)
endfunction

private function Slash takes nothing returns nothing
    local Data data = GetTimerStructA(GetExpiredTimer())
    local real angle = GetUnitFacing(data.target)-180
    local real x = (GetUnitX(data.target)+75*Cos(angle*bj_DEGTORAD))
    local real y = (GetUnitY(data.target)+75*Sin(angle*bj_DEGTORAD))
    set data.loops = data.loops - 1
    call SetUnitFacingTimed(data.caster,angle+180,0.)
    if data.loops <= 0 or GetUnitState(data.target,UNIT_STATE_LIFE) <= .405 then
        call SetUnitX(data.caster,data.sx)
        call SetUnitY(data.caster,data.sy)
        call SetUnitInvulnerable(data.caster,false)
        call PauseUnit(data.caster,false)
        call SetUnitVertexColor(data.caster,255,255,255,255)
        call PauseTimer(data.t)
        call DestroyTimer(data.t)
        call ClearTimerStructA(data.t)
        call data.destroy()
    else
        call SetUnitX(data.caster,x)
        call SetUnitY(data.caster,y)
        call SetUnitAnimation(data.caster,"attack slam")
        call DestroyEffect(AddSpecialEffect(SFX,x,y))
        call UnitDamageTarget(data.caster,data.target,GetRandomReal(10,20),true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,null)
    endif
endfunction
    
private function Spell_Cast takes nothing returns nothing
    local Data data = Data.create()
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    set data.caster = caster
    set data.target = target
    set data.sx = GetUnitX(caster)
    set data.sy = GetUnitY(caster)
    set data.loops = GetUnitAbilityLevel(caster,abil_id)*3
    call SetUnitInvulnerable(caster,true)
    call PauseUnit(caster,true)
    call SetUnitVertexColor(caster,50,50,50,50)
    call SetTimerStructA(data.t, data)
    call TimerStart(data.t,.3,true,function Slash)
    set caster = null
    set target = null
endfunction

private function conds takes nothing returns boolean
    return GetSpellAbilityId() == abil_id
endfunction

public function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local integer index = 0
        loop
            call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == 16
        endloop
    call TriggerAddAction( trig, function Spell_Cast)
    call TriggerAddCondition( trig, Filter(function conds) )
    call PreLoad()
endfunction

endscope
 
Last edited:
Status
Not open for further replies.
Top