• 🏆 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!

[JASS] JassNewGenPack glitch.

Status
Not open for further replies.
Level 12
Joined
Sep 24, 2007
Messages
283
I dont really understand why this happens.

Well who did i recognize it?
When you save a map - after all normal WE save - JASSHepler checks vJASS syntax and etc.

Here's version that worked perfect:
JASS:
library Dash initializer InitDash uses IsTerrainWalkable
globals
private constant real               speed = 12
private constant integer            distance = 400
private constant integer            dpl = 120
private constant integer            ID = 'A001'
private constant integer            BID = 'B000'
private constant string             SFX = "Abilities\\Spells\\Other\\StrongDrink\\BrewmasterMissile.mdl"


timer T = CreateTimer()
real x
real y
real x2
real y2
rect r


endglobals

struct Movement

unit u
real angle
real dis
real sp

static Movement array Index
static integer Total = 0



static method Move takes nothing returns nothing
local Movement dat

local integer i = 0
    loop
        exitwhen i >= dat.Total
        set dat = dat.Index[i]
        
        set x = GetUnitX(dat.u)
        set y = GetUnitY(dat.u)
        
        set x2 = x + (Cos(dat.angle * bj_DEGTORAD)*(dat.sp+40))
        set y2 = y + (Sin(dat.angle * bj_DEGTORAD)*(dat.sp+40))
        
        
        if IsTerrainWalkable(x2,y2) then
            call SetUnitX(dat.u, x + (Cos(dat.angle * bj_DEGTORAD)*dat.sp))
            call SetUnitY(dat.u, y + (Sin(dat.angle * bj_DEGTORAD)*dat.sp))
            call IssueImmediateOrder(dat.u, "stop")
            call DestroyEffect(AddSpecialEffect(SFX,x,y))
            
            
        else
            set dat.dis = -150
        endif
    
        
        set dat.dis = dat.dis - dat.sp
        set dat.sp = dat.sp + 1
        
        if dat.dis <= 0 then
        call SetUnitPathing(dat.u, true)
        call UnitRemoveAbility(dat.u,BID)
        
        call dat.destroy()
        set dat.Total = dat.Total - 1
        set dat.Index[i] = dat.Index[dat.Total]
        set i = i - 1
        
        endif
        
    set i = i  + 1
    if dat.Total == 0 then
      call PauseTimer(T)
    endif
    endloop
    
    
endmethod


static method Start takes nothing returns nothing
    local Movement dat = Movement.allocate()
    
    if dat.Total == 0 then
    call TimerStart(T,0.02,true,function Movement.Move)
    endif
    
    set dat.u = GetTriggerUnit()
    set dat.angle = GetUnitFacing(dat.u)
    set dat.sp = speed
    set dat.dis = distance+(120*GetUnitAbilityLevel(dat.u,ID))
    call SetUnitPathing(dat.u, false)
    set dat.Index[dat.Total] = dat
    set dat.Total = dat.Total + 1
endmethod

endstruct

private function Check takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction 



private function InitDash takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
            exitwhen i == bj_MAX_PLAYER_SLOTS
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set i =i+1
    endloop
    
    call TriggerAddAction(t, function Movement.Start)
    call TriggerAddCondition(t, Filter( function Check))
    
endfunction



endlibrary

Now after i edited a bit to destroy trees around caster and i got this:
JASS:
library Dash initializer InitDash uses IsTerrainWalkable
globals
private constant real               speed = 12
private constant integer            distance = 400
private constant integer            dpl = 120
private constant integer            ID = 'A001'
private constant integer            BID = 'B000'
private constant string             SFX = "Abilities\\Spells\\Other\\StrongDrink\\BrewmasterMissile.mdl"


timer T = CreateTimer()
real x
real y
real x2
real y2
rect r


endglobals

struct Movement

unit u
real angle
real dis
real sp

static Movement array Index
static integer Total = 0



static method Move takes nothing returns nothing
local Movement dat

local integer i = 0
    loop
        exitwhen i >= dat.Total
        set dat = dat.Index[i]
        
        set x = GetUnitX(dat.u)
        set y = GetUnitY(dat.u)
        
        set x2 = x + (Cos(dat.angle * bj_DEGTORAD)*(dat.sp+40))
        set y2 = y + (Sin(dat.angle * bj_DEGTORAD)*(dat.sp+40))
        
        
        if IsTerrainWalkable(x2,y2) then
            call SetUnitX(dat.u, x + (Cos(dat.angle * bj_DEGTORAD)*dat.sp))
            call SetUnitY(dat.u, y + (Sin(dat.angle * bj_DEGTORAD)*dat.sp))
            call IssueImmediateOrder(dat.u, "stop")
            call DestroyEffect(AddSpecialEffect(SFX,x,y))
            
            
            set r = Rect( x2 - 200*0.5, y2 - 200*0.5, x2 + 200*0.5, y2 + 200*0.5 )
            call EnumDestructablesInRect(r, null, function Movement.KillDestruct)
            
            
        else
            set dat.dis = -150
        endif
    
        
        set dat.dis = dat.dis - dat.sp
        set dat.sp = dat.sp + 1
        
        if dat.dis <= 0 then
        call SetUnitPathing(dat.u, true)
        call UnitRemoveAbility(dat.u,BID)
        
        call dat.destroy()
        set dat.Total = dat.Total - 1
        set dat.Index[i] = dat.Index[dat.Total]
        set i = i - 1
        
        endif
        
    set i = i  + 1
    if dat.Total == 0 then
      call PauseTimer(T)
    endif
    endloop
    
    
endmethod


static method Start takes nothing returns nothing
    local Movement dat = Movement.allocate()
    
    if dat.Total == 0 then
    call TimerStart(T,0.02,true,function Movement.Move)
    endif
    
    set dat.u = GetTriggerUnit()
    set dat.angle = GetUnitFacing(dat.u)
    set dat.sp = speed
    set dat.dis = distance+(120*GetUnitAbilityLevel(dat.u,ID))
    call SetUnitPathing(dat.u, false)
    set dat.Index[dat.Total] = dat
    set dat.Total = dat.Total + 1
endmethod


static method KillDestruct takes nothing returns nothing
    call KillDestructable( GetEnumDestructable() )
endmethod

endstruct

private function Check takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction 



private function InitDash takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
            exitwhen i == bj_MAX_PLAYER_SLOTS
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set i =i+1
    endloop
    
    call TriggerAddAction(t, function Movement.Start)
    call TriggerAddCondition(t, Filter( function Check))
    
endfunction



endlibrary

or this:
JASS:
scope Dash initializer InitDash
globals
private constant real               speed = 12
private constant integer            distance = 400
private constant integer            dpl = 120
private constant integer            ID = 'A001'
private constant integer            BID = 'B000'
private constant string             SFX = "Abilities\\Spells\\Other\\StrongDrink\\BrewmasterMissile.mdl"


timer T = CreateTimer()
real x
real y
real x2
real y2


endglobals

struct Movement

unit u
real angle
real dis
real sp

static Movement array Index
static integer Total = 0



static method Move takes nothing returns nothing
local Movement dat

local integer i = 0
    loop
        exitwhen i >= dat.Total
        set dat = dat.Index[i]
        
        set x = GetUnitX(dat.u)
        set y = GetUnitY(dat.u)
        
        set x2 = x + (Cos(dat.angle * bj_DEGTORAD)*(dat.sp+40))
        set y2 = y + (Sin(dat.angle * bj_DEGTORAD)*(dat.sp+40))
        
        
        if IsTerrainWalkable(x2,y2) then
            call SetUnitX(dat.u, x + (Cos(dat.angle * bj_DEGTORAD)*dat.sp))
            call SetUnitY(dat.u, y + (Sin(dat.angle * bj_DEGTORAD)*dat.sp))
            call IssueImmediateOrder(dat.u, "stop")
            call DestroyEffect(AddSpecialEffect(SFX,x,y))
        else
            set dat.dis = -150
        endif
    
        
        set dat.dis = dat.dis - dat.sp
        set dat.sp = dat.sp + 1
        
        if dat.dis <= 0 then
        call SetUnitPathing(dat.u, true)
        call UnitRemoveAbility(dat.u,BID)
        
        call dat.destroy()
        set dat.Total = dat.Total - 1
        set dat.Index[i] = dat.Index[dat.Total]
        set i = i - 1
        
        endif
        
    set i = i  + 1
    if dat.Total == 0 then
      call PauseTimer(T)
    endif
    endloop
    
    
endmethod


static method Start takes nothing returns nothing
    local Movement dat = Movement.allocate()
    
    if dat.Total == 0 then
    call TimerStart(T,0.02,true,function Movement.Move)
    endif
    
    set dat.u = GetTriggerUnit()
    set dat.angle = GetUnitFacing(dat.u)
    set dat.sp = speed
    set dat.dis = distance+(120*GetUnitAbilityLevel(dat.u,ID))
    call SetUnitPathing(dat.u, false)
    set dat.Index[dat.Total] = dat
    set dat.Total = dat.Total + 1
endmethod

endstruct




private function Check takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction 



private function InitDash takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
            exitwhen i == bj_MAX_PLAYER_SLOTS
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set i =i+1
    endloop
    
    call TriggerAddAction(t, function Movement.Start)
    call TriggerAddCondition(t, Filter( function Check))
    
endfunction



endscope


JASSHelper doesnt do it's actions. It is just like normal WE saving.



I really nead your help.


EDIT:
after any changes to the spell - it doesnt work o_O
 
Level 12
Joined
Sep 24, 2007
Messages
283
First example:
I added Tree Destroying while dashing.
JASS:
            set r = Rect( x2 - 200*0.5, y2 - 200*0.5, x2 + 200*0.5, y2 + 200*0.5 )
            call EnumDestructablesInRect(r, null, function Movement.KillDestruct)

also another method
JASS:
static method KillDestruct takes nothing returns nothing
    call KillDestructable( GetEnumDestructable() )
endmethod

Second example:
My friend told me that scopes are better for spells.
So insteed of Library i used Scope.



as i said - After any edit to the code - JASSHelper stops working
 
I fixed up your code a bit

JASS:
scope Dash initializer InitDash
	globals
		private constant real		SPEED 	= 12
		private constant integer	DISTANCE 	= 400
		private constant integer	DPL 		= 120
		private constant integer	ID 		= 'A001'
		private constant integer	BID 		= 'B000'
		private constant string		SFX 		= "Abilities\\Spells\\Other\\StrongDrink\\BrewmasterMissile.mdl"
		
		
		private			timer		T			= CreateTimer()
		private			real 		x			= 0.
		private			real 		y			= 0.
		private			real 		x2			= 0.
		private			real 		y2			= 0.
	endglobals
	
	private struct Movement
		
		unit u
		real angle
		real dis
		real sp
		
		static thistype array Index
		static integer Total = 0
		
		static method Move takes nothing returns nothing
			local Movement dat
			local integer i = 0
			
			loop
			exitwhen i >= dat.Total
			set dat = dat.Index[i]
			
			set x = GetUnitX(dat.u)
			set y = GetUnitY(dat.u)
			
			set x2 = x + (Cos(dat.angle * bj_DEGTORAD)*(dat.sp+40))
			set y2 = y + (Sin(dat.angle * bj_DEGTORAD)*(dat.sp+40))
			
			
			if IsTerrainWalkable(x2,y2) then
				call SetUnitX(dat.u, x + (Cos(dat.angle * bj_DEGTORAD)*dat.sp))
				call SetUnitY(dat.u, y + (Sin(dat.angle * bj_DEGTORAD)*dat.sp))
				call IssueImmediateOrder(dat.u, "stop")
				call DestroyEffect(AddSpecialEffect(SFX,x,y))
			else
				set dat.dis = -150
			endif
			
			
			set dat.dis = dat.dis - dat.sp
			set dat.sp = dat.sp + 1
			
			if dat.dis <= 0 then
			call SetUnitPathing(dat.u, true)
			call UnitRemoveAbility(dat.u,BID)
			
			call dat.destroy()
			set dat.Total = dat.Total - 1
			set dat.Index[i] = dat.Index[dat.Total]
			set i = i - 1
			
			endif
			
			set i = i  + 1
			if dat.Total == 0 then
			  call PauseTimer(T)
			endif
			endloop
		endmethod
		
		static method Start takes nothing returns nothing
			local Movement dat = Movement.allocate()
			
			if dat.Total == 0 then
			call TimerStart(T,0.02,true,function Movement.Move)
			endif
			
			set dat.u = GetTriggerUnit()
			set dat.angle = GetUnitFacing(dat.u)
			set dat.sp = SPEED
			set dat.dis = distance+(120*GetUnitAbilityLevel(dat.u,ID))
			call SetUnitPathing(dat.u, false)
			set dat.Index[dat.Total] = dat
			set dat.Total = dat.Total + 1
		endmethod
	endstruct
	
	private function Check takes nothing returns boolean
	    return GetSpellAbilityId() == ID
	endfunction 
	
	private function InitDash takes nothing returns nothing
	    local trigger t = CreateTrigger()
	    local integer i = 0
	    loop
		    exitwhen i == bj_MAX_PLAYER_SLOTS
		    call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
		    set i =i+1
	    endloop
	    
	    call TriggerAddAction(t, function Movement.Start)
	    call TriggerAddCondition(t, Filter( function Check))
	endfunction

endscope

Haven't checked the bug yet though. I am not at home.
 
Status
Not open for further replies.
Top