Some jass questions

Kazuga

Let the game begin...
Reaction score
110
Ok so I ran into some strange problems (to me anyway) when coding the last part of my spell.

First of all, I get the strange error that says "data is not of a type that allows .syntax" and the normal "syntax error"
JASS:
private function Effect takes nothing returns nothing
local real x
local real y
local real real1
set real x = data.x + 300 * Cos((real1+45)*bj_DEGTORAD) //Syntax error
set real y = data.y + 300 * Sin((real1+45)*bj_DEGTORAD) //Syntax error

    call TriggerSleepAction (1.00)
    call BJDebugMsg("works")
    call PauseUnit (data.target,false)      //data is not of a type that allows .syntax
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)  //data is not of a type that allows .syntax
endfunction

Also don't you call a function like this?
JASS:
    call Effect


Whole code
JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")
endlibrary
scope Lightnings initializer Lightning
globals
private constant integer raw = 'AHtb'
endglobals
private struct TestStruct
unit dummy
unit caster
unit target
real tx
real ty
timer SlideTimer
endstruct

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

private function Effect takes nothing returns nothing
local real x
local real y
set real x = data.x + 300 * Cos((real1+45)*bj_DEGTORAD)
set real y = data.y + 300 * Sin((real1+45)*bj_DEGTORAD)

call TriggerSleepAction (1.00)
call BJDebugMsg("works")
//call PauseUnit (data.target,false)
//call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)
endfunction

private function Slide takes nothing returns nothing
local TestStruct data = GetData (GetExpiredTimer ())
local real x = GetUnitX(data.dummy)
local real y = GetUnitY(data.dummy)
local real newX
local real newY
local real angle
local real distance
local real real1=45
local real x2 
local real y2 



set data.tx    = GetUnitX(data.target)
set data.ty    = GetUnitY(data.target)
set angle = Atan2(data.ty-y,data.tx-x)
set newX  = x + 30 *Cos(angle)
set newY  = y + 30 *Sin(angle)

call SetUnitPosition(data.dummy,newX,newY)
set distance=SquareRoot( (data.tx-x)*(data.tx-x) + (data.ty-y)*(data.ty-y) )
if distance < 50 then
    call BJDebugMsg ("If works")
    call PauseTimer (data.SlideTimer)
    call data.destroy ()
    call ResetData (data.SlideTimer)
    call DestroyTimer (data.SlideTimer)
    call PauseUnit (data.target,true)
    call Effect
endif
endfunction


private function Actions takes nothing returns nothing
local TestStruct data = TestStruct.create ()
local unit Unit                    = GetTriggerUnit()
local real real1                   = GetUnitFacing(GetTriggerUnit())

local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())

local real x2 = x + 300 * Cos((real1+145)*bj_DEGTORAD)
local real y2 = y + 300 * Sin((real1+145)*bj_DEGTORAD)

local real x3 = x + 300 * Cos((real1+180)*bj_DEGTORAD)
local real y3 = y + 300 * Sin((real1+180)*bj_DEGTORAD)

local real x4 = x + 300 * Cos((real1+215)*bj_DEGTORAD)
local real y4 = y + 300 * Sin((real1+215)*bj_DEGTORAD)

set data.SlideTimer = CreateTimer()
set data.target = (GetSpellTargetUnit())

call TriggerSleepAction (0.1)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)
call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",x,y)
call PauseUnit (Unit, true)

call TimedLightning ("CLPB", x, y, 0, x2, y2, 0, 2., true, 1, 0)
call TimedLightning ("CLPB", x, y, 0, x3, y3, 0, 2., true, 1, 0)
call TimedLightning ("CLPB", x, y, 0, x4, y4, 0, 2., true, 1, 0)



call TriggerSleepAction (1)
set data.dummy = CreateUnit (GetOwningPlayer(Unit),'h000',x,y,0)
call SetUnitPathing(data.dummy, false )
call PauseUnit (Unit, false)
call TimerStart (data.SlideTimer,0.1,true, function Slide)
call SetData (data.SlideTimer, data)
set Unit = null

endfunction


//===========================================================================

private function SafeFilt takes nothing returns boolean
return true
endfunction
private function Lightning takes nothing returns nothing
 local trigger trig = CreateTrigger()
local integer i = 0
loop
    exitwhen i > 15
    call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
    set i = i + 1
endloop
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
 set trig = null
 endfunction

endscope
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
591
Elaborating on 2.
JASS:
call Effect()

if the function of effect goes like....
JASS:
function Effect takes string a returns nothing

then you would do
JASS:
call Effect(MyString)
 

Kazuga

Let the game begin...
Reaction score
110
1: How exactly do I declare it?
JASS:
local TestStruct data = TestStruct.create ()

Is used in the Actions function but it didn't work in this one, also
JASS:
local TestStruct data = GetData (GetExpiredTimer ())

is for a timer..

2: Ok thanks both of you^^^^
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
How about changing the function so that it takes x and y as arguments?

JASS:
private function Effect takes real myX, real myY, unit Target returns nothing
    local real x
    local real y
    local real real1 //You never declared this one
    set x = myX + 300 * Cos((real1+45)*bj_DEGTORAD)    //myX is one of the arguments taken
    set y = myY + 300 * Sin((real1+45)*bj_DEGTORAD)    //myY is one of the arguments taken

    call TriggerSleepAction (1.00)
    call BJDebugMsg("works")
    call PauseUnit (Target,false)    //Target is one of the arguments taken
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)  
endfunction


Then you call it like this:

JASS:
call Effect(data.x, data.y, data.target)
 

Kazuga

Let the game begin...
Reaction score
110
Hm still some strange errors and buggs,
JASS:
private function Effect takes real myX, real myY, unit Target returns nothing
    local real x
    local real y
    local real real1 = 0
    set x = myX + 300 * Cos((real1+45)*bj_DEGTORAD) 
    set y = myY + 300 * Sin((real1+45)*bj_DEGTORAD)  

    call TriggerSleepAction (1.00) //None of these actions is executed =/
    call BJDebugMsg("works")
    call PauseUnit (Target,false)    
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)  
    //error "data is not of type that allows .syntax"
endfunction
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
You ALWAYS have to declare the struct in the function UNLESS it is a regular method. ;)

If it is a regular function, just use "local structname Name = structname.create()".

If it is a static method, you would use "local structname Name = structname.allocate()".

If it is a callback or trigger callback etc., you would use "local structname Name = RetrievingFunction(ObjectAttachedTo)" or however the attachment system works.

If it is a regular method, you don't have to declare it, you can just use a single "." such as ".u" or ".i" or you can use a different thing such as "this.u" or "this.i".
 

Kazuga

Let the game begin...
Reaction score
110
Darn this is complicated just to call a simple function :eek:
Shoudn't this work?.. Or is it some other type of function?
JASS:
private function Effect takes real myX, real myY, unit Target returns nothing
    local TestStruct data = TestStruct.create ()
    local real x
    local real y
    local real real1 = 0
    set x = myX + 300 * Cos((real1+45)*bj_DEGTORAD)
    set y = myY + 300 * Sin((real1+45)*bj_DEGTORAD)

    call TriggerSleepAction (1.00)
    call BJDebugMsg("works")
    call PauseUnit (Target,false)
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)  
endfunction
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)


There are two struct members in that line, data.tx and data.ty. Include these in the arguments and you should be good to go.
 

Kazuga

Let the game begin...
Reaction score
110
JASS:
private function Effect takes real myX, real myY, unit Target returns nothing
    local TestStruct data = TestStruct.create ()
    local real x
    local real y
    local real real1 = 0
    set x = myX + 300 * Cos((real1+45)*bj_DEGTORAD)
    set y = myY + 300 * Sin((real1+45)*bj_DEGTORAD)

    call TriggerSleepAction (1.00)
    call BJDebugMsg("works")
    call PauseUnit (Target,false)
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)  
endfunction

JASS:
call Effect(data.tx, data.ty, data.target,data.tx,data.ty)

JASS:
private function Slide takes nothing returns nothing
local TestStruct data = GetData (GetExpiredTimer ())
local real x = GetUnitX(data.dummy)
local real y = GetUnitY(data.dummy)
local real newX
local real newY
local real angle
local real distance
local real real1=45
local real x2 
local real y2 



set data.tx    = GetUnitX(data.target)
set data.ty    = GetUnitY(data.target)
set angle = Atan2(data.ty-y,data.tx-x)
set newX  = x + 30 *Cos(angle)
set newY  = y + 30 *Sin(angle)

call SetUnitPosition(data.dummy,newX,newY)
//call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",newX,newY)
set distance=SquareRoot( (data.tx-x)*(data.tx-x) + (data.ty-y)*(data.ty-y) )
if distance < 50 then
    call BJDebugMsg ("If works")
    call PauseTimer (data.SlideTimer)
    call data.destroy ()
    call ResetData (data.SlideTimer)
    call DestroyTimer (data.SlideTimer)
    call PauseUnit (data.target,true)
call Effect(data.tx, data.ty, data.target,data.tx,data.ty)

endif
endfunction
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Why do you put data.tx and ty twice?

JASS:
call Effect(data.tx, data.ty, data.target)


There you go. :D
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Change this:

JASS:
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",data.tx,data.ty)


To this:
JASS:

    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",myX,myY)
 

Kazuga

Let the game begin...
Reaction score
110
1: Wops dunno why I did that^^
2: Hm the function still isn't executed... Still I get no errors :S I can test the map but the function isn't called...
 

Kazuga

Let the game begin...
Reaction score
110
JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")
endlibrary
scope Lightnings initializer Lightning
globals
private constant integer raw = 'AHtb'
endglobals
private struct TestStruct
unit dummy
unit caster
unit target
real tx
real ty
timer SlideTimer
endstruct

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

private function Effect takes real myX, real myY, unit Target returns nothing
    local TestStruct data = TestStruct.create ()
    local real x
    local real y
    local real real1 = 0
    set x = myX + 300 * Cos((real1+45)*bj_DEGTORAD)
    set y = myY + 300 * Sin((real1+45)*bj_DEGTORAD)

    call TriggerSleepAction (1.00)
    call BJDebugMsg("works")
    call PauseUnit (Target,false)
    call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",myX,myY)  
endfunction



private function Slide takes nothing returns nothing
local TestStruct data = GetData (GetExpiredTimer ())
local real x = GetUnitX(data.dummy)
local real y = GetUnitY(data.dummy)
local real newX
local real newY
local real angle
local real distance
local real real1=45
local real x2 
local real y2 



set data.tx    = GetUnitX(data.target)
set data.ty    = GetUnitY(data.target)
set angle = Atan2(data.ty-y,data.tx-x)
set newX  = x + 30 *Cos(angle)
set newY  = y + 30 *Sin(angle)

call SetUnitPosition(data.dummy,newX,newY)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",newX,newY)
set distance=SquareRoot( (data.tx-x)*(data.tx-x) + (data.ty-y)*(data.ty-y) )
if distance < 50 then
    call BJDebugMsg ("If works")
    call PauseTimer (data.SlideTimer)
    call data.destroy ()
    call ResetData (data.SlideTimer)
    call DestroyTimer (data.SlideTimer)
    call PauseUnit (data.target,true)
    call Effect(data.tx, data.ty, data.target)

endif
endfunction


private function Actions takes nothing returns nothing
local TestStruct data = TestStruct.create ()
local unit Unit                    = GetTriggerUnit()
local real real1                   = GetUnitFacing(GetTriggerUnit())

local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())

local real x2 = x + 300 * Cos((real1+145)*bj_DEGTORAD)
local real y2 = y + 300 * Sin((real1+145)*bj_DEGTORAD)

local real x3 = x + 300 * Cos((real1+180)*bj_DEGTORAD)
local real y3 = y + 300 * Sin((real1+180)*bj_DEGTORAD)

local real x4 = x + 300 * Cos((real1+215)*bj_DEGTORAD)
local real y4 = y + 300 * Sin((real1+215)*bj_DEGTORAD)

set data.SlideTimer = CreateTimer()
set data.target = (GetSpellTargetUnit())

call TriggerSleepAction (0.1)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x2,y2)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x3,y3)
call AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x4,y4)
call AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",x,y)
call PauseUnit (Unit, true)

call TimedLightning ("CLPB", x, y, 0, x2, y2, 0, 2., true, 1, 0)
call TimedLightning ("CLPB", x, y, 0, x3, y3, 0, 2., true, 1, 0)
call TimedLightning ("CLPB", x, y, 0, x4, y4, 0, 2., true, 1, 0)


call TriggerSleepAction (1)
set data.dummy = CreateUnit (GetOwningPlayer(Unit),'h000',x,y,0)
call SetUnitPathing(data.dummy, false )
call PauseUnit (Unit, false)
call TimerStart (data.SlideTimer,0.05,true, function Slide)
call SetData (data.SlideTimer, data)
set Unit = null

endfunction


//===========================================================================

private function SafeFilt takes nothing returns boolean
return true
endfunction
private function Lightning takes nothing returns nothing
 local trigger trig = CreateTrigger()
local integer i = 0
loop
    exitwhen i > 15
    call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function SafeFilt))
    set i = i + 1
endloop
 call TriggerAddCondition (trig, Condition (function Conditions ) )
 call TriggerAddAction (trig, function Actions )
 set trig = null
 endfunction

endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top