Special effect problem

Kazuga

Let the game begin...
Reaction score
110
Hm ok, I have the HAIL system now. For what I have seen earlier, the system is to be in it's own trigger right? Question now is what to do next to make it mui... I don't really have any idea at all how HAIL works either (did read through it at wc3 campaigns but I didn't really understand what they ment really...)

I'm sorry but I don't quite get your post either that explains how to use HAIL, for what I can see I need a library function and then somehow call upon the HAIL system in the main function?
 

Flare

Stops copies me!
Reaction score
662
1) Copy the HAIL trigger into your map.

2) There's a number of ways you can initialize HAIL. You can make a generic, global initializer OR you can make specific initializers for each trigger that is needed.

For a global initializer just do
JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")
endlibrary


That will generate 3 functios
  • SetData (yourhandle, yourinteger)
  • GetData (yourhandle)
  • ResetData (yourhandle)

For specific initializers, just put your textmacro line into a scope/library, and make the third argument "private" i.e.
JASS:
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")

//Structs are integers, so second argument will be "integer" unless you are attaching something else
//Beware of name conflicts if you made a more generally named initializing textmacro, like the first example


4) Now you make a struct
JASS:
struct MyStruct
unit caster
unit target
unit dummy
real damage
//Any other stuff that needs to be moved between functions can be added here.
//Also, if you assign any struct member an array it must be done like so
real array numbers[numberofarrays]
//Using arrays can severely limit MUI potential of your stuff though, since you can only declare 8192/(highest array limit) instances of the struct
//e.g. if numberofarrays was 100, you can only have 81 instances of MyStruct at any one time (.destroy will free up space for new structs though)
endstruct


5) Declare your struct
JASS:
function PrimaryFunc takes nothing returns nothing
local MyStruct data = MyStruct.create ()
//Declare your other locals
set data.caster = GetTriggerUnit () //To use struct members, you must use the identifier you gave them (in this case, data) followed by . and finally the name of your struct member
endfunction


6) Assign your struct to a handle (e.g. timer)
JASS:
function PrimaryFunc takes nothing returns nothing
local MyStruct data = MyStruct.create ()
local timer t = CreateTimer ()
//First argument = Handle to which you are attaching
//Second argument = Data which you are attaching to first argument
call SetData (t, data)
call TimerStart (t, mytimerduration, false, function TimerCallback)
set t = null
endfunction


7) In your timer callback, retrieve your struct data
JASS:
function TimerCallback takes nothing returns nothing
local timer t = GetExpiredTimer ()
local MyStruct data = GetData (t)
//Do something with your struct, e.g.
call BJDebugMsg (GetUnitName (data.caster))
//Now, we can destroy this timer since it isn't periodic.
//First, destroy the struct instance
call data.destroy ()
//Next, clear the attachment
call ResetData (t)
//Finally, destroy our timer and null the handle
call DestroyTimer (t)
set t = null


Hopefully I explained it well enough :p
If there is any part you are unsure of, let me know exactly which part :D Makes it so much easier to solve any problems
 

Kazuga

Let the game begin...
Reaction score
110
At the third point, should I put the library at the top of the code? Also what should be inside of it? Don't quite get what you mean with set data, get data, reset data.. It's here the global should be?
 

Flare

Stops copies me!
Reaction score
662
At the third point, should I put the library at the top of the code?

It can be anywhere, as long as its in a library (assuming you want a general, global set of functions that every trigger can use), and has the 'requires HAIL' part after library name (if you put it into the HAIL library itself, you wont need the 'requires HAIL' bit)

Also what should be inside of it?

What's 'it'? The textmacro?

Don't quite get what you mean with set data, get data, reset data

SetData attaches the given data to a given handle (which you can recall from another function)
GetData retrieves the attached data from a given handle
ResetData clears the attachment from the handle (this part is necessary to keep the system working effectively)

It's here the global should be?

What global? Did I say anything about a global?
 

Kazuga

Let the game begin...
Reaction score
110
Still a little confused, the set-get and resetdata should be spread around at the places you need them or should they be in that order within the library? What I ment with the globals was that the dummy variable is global, wich makes it un mui, wich is why I need this system, wich is why I wonder if I need the globals inside the system/library?

JASS:
scope Lightnings initializer Lightning
globals
private constant integer raw = 'AHtb'
unit dummy
unit caster
unit target
real tx
real ty
endglobals
library HAILInit requires HAIL
//What do I write here?
endlibrary
 

Flare

Stops copies me!
Reaction score
662
You won't be needing globals. You just make a struct (like I showed you in earlier post) and give it a few members. Then, you can pass that struct between functions, and refer to that unit. No globals needed (unless you are using a ForGroup).

You should look up a struct tutorial, there's one made by AndrewGosu and DuckieKing IIRC. They will probably be able to inform you of what structs are and how to use them better than I can

JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "")
endlibrary

scope Lightnings initializer Lightning
globals
private constant integer raw = 'AHtb'
unit dummy
unit caster
unit target
real tx
real ty
endglobals

//More stuff
endscope
 

Kazuga

Let the game begin...
Reaction score
110
Something like this...?
JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty ("Data", "integer", "private")

endlibrary
struct MyStruct
unit dummy
unit caster
unit target
real tx
real ty

endstruct
function PrimaryFunc takes nothing returns nothing
local MyStruct data = MyStruct.create ()
set data.caster = GetTriggerUnit ()
endfunction
function PrimaryFunc takes nothing returns nothing
local MyStruct data = MyStruct.create ()
local timer t = CreateTimer ()
call SetData (t,data)
call TimerStart (t, mytimerduration, false, function TimerCallback)
set t = null
endfunction
function TimerCallback takes nothing returns nothing
local timer t = GetExpiredTimer ()
local MyStruct data = GetData (t)
call BJDebugMsg (GetUnitName (data.caster))
call data.destroy ()
call DestroyTimer (t)
set t = null
endfunction 

scope Lightnings initializer Lightning

globals
private constant integer raw = 'AHtb'
endglobals

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

private function Slide takes nothing returns nothing
local real x = GetUnitX(dummy)
local real y = GetUnitY(dummy)
local real newX
local real newY
local real angle

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


call SetUnitPosition(dummy,newX,newY)
endfunction
private function Actions takes nothing returns nothing
local timer SlideTimer = CreateTimer()
local unit Unit                    = GetTriggerUnit()
local real real1                   = GetUnitFacing(Unit)

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

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

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

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


call TriggerSleepAction(1)
set target = (GetSpellTargetUnit())
call BJDebugMsg ("This part works")
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 PauseUnit (Unit, true)
call AddLightning ("CLPB",true, x,y,x2,y2)
call AddLightning ("CLPB",true, x,y,x3,y3)
call AddLightning ("CLPB",true, x,y,x4,y4)
call TriggerSleepAction (1)
set dummy = CreateUnit (GetOwningPlayer(Unit),'h000',x,y,0)
//call PauseUnit (Unit, false)
call TimerStart (SlideTimer,0.1,true, function Slide)

//set t    = null
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
 

Flare

Stops copies me!
Reaction score
662
put everything except the HAILInit library in the scope. and change the "private" in third argument of HAIL textmacro to ""

If you are still having trouble with it tommorow, I can make out a few samples for you. (don't have time now unfortunately). I'll do a very simple one (basically, passing a single unit to another function using a struct) and something a little more complicated (such as a slide)
 

Kazuga

Let the game begin...
Reaction score
110
Would be great, these structs etc are real hard to understand... I read through Andregosus tutorial about structs but I must say I did not understand alot of it...
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Since you can use public/private values inside libraries, you would put "private" if you want the function for that independent library.

Since you need to use it outside of the library, you would simply use "" as it is null. I think, that is how HSAS works. :p
 

Flare

Stops copies me!
Reaction score
662
Since you need to use it outside of the library, you would simply use "" as it is null. I think, that is how HSAS works.

Ye :D

Or, make it public, and call <libraryname>_<functionname> but what Purge said will work fine


EDIT: Here's the first sample anyway. Basically, it'll create a unit, and 5 seconds later, it will display the name of that unit.

JASS:
scope Test initializer TestInit
//Our HAIL initializer function
//! runtextmacro HAIL_CreateProperty (&quot;TestData&quot;, &quot;integer&quot;, &quot;private&quot;)

//Our three functions are:
// call SetTestData (whichHandle, whichInteger)
// call GetTestData (whichHandle)
// call ResetTestData (whichHandle)

//We can only use SetTestData, GetTestData and ResetTestData -WITHIN- this particular scope since the third argument is private

private struct TestStruct
unit testunit
//I&#039;ll use a struct timer instead of a local timer.
timer testtimer
endstruct

private function TimerCallback takes nothing returns nothing
    local timer t = GetExpiredTimer () //Assign a variable to expiring timer
    local TestStruct data = GetTestData (t) //Retrieving the data from the timer
    call BJDebugMsg (GetUnitName (data.testunit)) //Let&#039;s display the name of our struct unit
    call PauseTimer (t) //Pause the timer before destroying it
    call data.destroy () //Destroy our struct instance
    call ResetTestData (t) //Clear the data from the timer
    call DestroyTimer (t) //Destroy the timer
    set t = null //Null the local timer
endfunction

private function TestFunc takes nothing returns nothing
    local TestStruct data = TestStruct.create () //Declaring our struct as &quot;local (struct name) (identifier)&quot;
    set data.testunit = CreateUnit (GetTriggerPlayer (), &#039;hpea&#039;, 0, 0, 270) //Creating a unit and assigning it to testunit
    set data.testtimer = CreateTimer () //Creating the timer
    call SetTestData (data.testtimer, data) //Assigning the struct to testtimer
    call TimerStart (data.testtimer, 5, false, function TimerCallback)
endfunction

//===========================================================================
private function TestInit takes nothing returns nothing
    local trigger t = CreateTrigger ()
    call TriggerRegisterPlayerEvent (t, Player (0), EVENT_PLAYER_END_CINEMATIC)
    call TriggerAddAction( t, function TestFunc )
endfunction

endscope


EDIT: Wait, that's not working, lemme fix it :p
EDIT: Fixed
 

Attachments

  • test2.w3m
    31.6 KB · Views: 190

Kazuga

Let the game begin...
Reaction score
110
Hm making Jass into mui is even harder then making gui into mui^^ (Atleast now the first time:p)
So eh, I think I got the most part right but the programm says otherwise^^ It can't find the declarations of the structed variables...
JASS:
library HAILInit requires HAIL
//! runtextmacro HAIL_CreateProperty (&quot;Data&quot;, &quot;integer&quot;, &quot;&quot;)
endlibrary
scope Lightnings initializer Lightning
globals
private constant integer raw = &#039;AHtb&#039;
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 Slide takes nothing returns nothing
local real x = GetUnitX(dummy)               //Error
local real y = GetUnitY(dummy)               //Error
local real newX
local real newY
local real angle
local real distance

set tx    = GetUnitX(target)                    //Error
set ty    = GetUnitY(target)                    //Error
set angle = Atan2(ty-y,tx-x)
set newX  = x + 50 *Cos(angle)
set newY  = y + 50 *Sin(angle)

call SetUnitPosition(dummy,newX,newY)


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

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

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

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

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

set data.SlideTimer = CreateTimer()
call TriggerSleepAction(1)
set data.target = (GetSpellTargetUnit())
call BJDebugMsg (&quot;This part works&quot;)
call TriggerSleepAction (0.1)
call AddSpecialEffect(&quot;Abilities\\Weapons\\Bolt\\BoltImpact.mdl&quot;,x2,y2)
call AddSpecialEffect(&quot;Abilities\\Weapons\\Bolt\\BoltImpact.mdl&quot;,x3,y3)
call AddSpecialEffect(&quot;Abilities\\Weapons\\Bolt\\BoltImpact.mdl&quot;,x4,y4)
//call PauseUnit (Unit, true)
call AddLightning (&quot;CLPB&quot;,true, x,y,x2,y2)
call AddLightning (&quot;CLPB&quot;,true, x,y,x3,y3)
call AddLightning (&quot;CLPB&quot;,true, x,y,x4,y4)
call TriggerSleepAction (1)
set data.dummy = CreateUnit (GetOwningPlayer(Unit),&#039;h000&#039;,x,y,0)
//call PauseUnit (Unit, false)
call TimerStart (SlideTimer,0.1,true, function Slide)             //Error

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 &gt; 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
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
Don't you have to end the library at the end of the script?
(Never used it before mind.)
 

Flare

Stops copies me!
Reaction score
662
Look at my example. Struct members must be refered to using <identifier>.<structmember>, you are referring to them as if they were normal variables.

JASS:
call TimerStart (SlideTimer,0.1,true, function Slide)


Should be
JASS:
call TimerStart (data.SlideTimer,0.1,true, function Slide)


You never attached the struct data. At some point in that trigger (after you create the timer) add this line
JASS:
call SetData (data.SlideTimer, data)


You never retrieved the struct in Slide
JASS:
local TestStruct data = GetData (GetExpiredTimer ())
//then refer to your struct members like i said above i.e.
local real x = GetUnitX(data.dummy)               
local real y = GetUnitY(data.dummy)


Also, you aren't destroying your lightning effects. You can use this to deal with the lightning effects easily (since the system does all the work of movement etc), all you need to do is call the appropriate function

Don't you have to end the library at the end of the script?
Nope. Everything within a library is sent to map header anyway, so it doesn't make alot of difference where you place it :)
 

Kazuga

Let the game begin...
Reaction score
110
Ah nice! Thanks:thup:
About your lightning system, it says that I need TT?
 

Kazuga

Let the game begin...
Reaction score
110
Ok triggers added. Shall I replace
JASS:
call AddLightning (&quot;CLPB&quot;,true, x,y,x2,y2)
call AddLightning (&quot;CLPB&quot;,true, x,y,x3,y3)
call AddLightning (&quot;CLPB&quot;,true, x,y,x4,y4)

with

JASS:
call TimedLightningUnit (lightid_string, source_unit, target_unit, duration, fade_on, init_fade, end_fade)
call TimedLighningLoc (lightid_string, loc1, loc2, duration, fade_on, init_fade, end_fade)
call TimedLightning (lightid_string, x1, y1, z1, x2, y2, z2, duration, fade_on, init_fade, end_fade)

and edit the locations?
 

Flare

Stops copies me!
Reaction score
662
Ok triggers added. Shall I replace
JASS:
call AddLightning (&quot;CLPB&quot;,true, x,y,x2,y2)
call AddLightning (&quot;CLPB&quot;,true, x,y,x3,y3)
call AddLightning (&quot;CLPB&quot;,true, x,y,x4,y4)

with

JASS:
call TimedLightningUnit (lightid_string, source_unit, target_unit, duration, fade_on, init_fade, end_fade)
call TimedLighningLoc (lightid_string, loc1, loc2, duration, fade_on, init_fade, end_fade)
call TimedLightning (lightid_string, x1, y1, z1, x2, y2, z2, duration, fade_on, init_fade, end_fade)

and edit the locations?

In that case, you will be using this one
JASS:
call TimedLightning (lightid_string, x1, y1, z1, x2, y2, z2, duration, fade_on, init_fade, end_fade)


And this is what it should look like in your script
JASS:
call TimedLightning (&quot;CLPB&quot;, x, y, 0, x2, y2, 0, duration, fade_on, init_fade, end_fade)
//Change those 0&#039;s to something else if you want the lightning to float above/below default ground height


And repeat with the other 2 lightnings
(since I don't know the values you want for duration, fade enabled, initial fade, and end fade, I can't substitute them in :p)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top