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

KB3D - Knock back 3D

Status
Not open for further replies.
Level 16
Joined
Jul 31, 2012
Messages
2,217
Hello Helpers!

Go check out our KB3D System:

KNOCK-BACK 3D

Some Noticed things in the System:
DPWrDKB.png

The System has 180+ comments! within just 12 days!!
the system has 4 5/5 votes by users
and a 5/5 Moderation vote
dtix.png
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
The System MUST be in JASS, i want to hit the most users possible with this, making it in vJASS makes too much users unable to use it
Chobibo, what do you mean by wrong calculations?
Z isn't yet here because i have that problem i said in the first post
No problem IcemanBo
and hell, i subscribed to this thread why didn't i have an email notif?!!?
Attached the triggers in first post
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
I told chobibo the reason: i want the system to be affecting the most users possible
yes a 3D Knockback system :p
and :( so bored i hate school

BTW: I found the bug that makes the instances go wrong, but still wondering why the hell the system kncockbacks one unit at a time!
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Leaks:
JASS:
    call RemoveLocation(L)
    call RemoveLocation(L1)
    call RemoveLocation(L2)
fix:
JASS:
    call RemoveLocation(L)
    call RemoveLocation(L1)
    call RemoveLocation(L2)
    set L=null
    set L1=null
    set L2=null
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
I'm used to gui (i mean when i create fxs in gui i directly scroll a little and add destroy last fx... So i forgot to destroy it here :/

Edit: here it is now:
JASS:
if ( z > 0 ) then
        call DestroyEffect(AddSpecialEffectTarget(Fx, U, Attach))
    else
        call DestroyEffect(AddSpecialEffect(Fx, x, y))
    endif
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
I'll fix what you just told me,
The problem, yh, i just figured almost out the exact source of it, if like 2-5 units are knockbacked at the same time, no problem, but if more (when i order some of my units to attack the blue ones, = many instances, the problem starts and it starts to knockback 1 at a time)

second possible source: if the same unit has 2 or more instances running on him
like he was attacked 2 times at once
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
Wow, this system is cursed, within the last 3 tests, the instancing was correct even with lots of units, but lagged with more than 300 instances xD
anw, for the radians, i think you missed one thing:
JASS:
if ( Target == null ) then
        set Angle = LoadReal(udg_KB3D_HA, 5, Loop)
shouldn't it be changed?
and secondly, if i added a unit target, so we will use this one:
JASS:
set Angle = Atan2(Y - GetUnitY(Target), X - GetUnitX(Target))
this makes the unit move like 180 degrees wrong, meaning that he should move toward the attacking unit, he moves backward..... if you got my idea
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
JASS:
function KB3D_Registration_Actions takes nothing returns nothing
    set udg_KB3D_Counter = udg_KB3D_Counter + 1
    set udg_KB3D_Instances = udg_KB3D_Instances + 1
    set udg_KB3D_Zoffset = 2 * udg_KB3D_Zoffset
    call SaveUnitHandle( udg_KB3D_HA, 0, udg_KB3D_Counter, udg_KB3D_Unit )
    call SaveReal( udg_KB3D_HA, 1, udg_KB3D_Counter, udg_KB3D_Range )
    call SaveReal( udg_KB3D_HA, 2, udg_KB3D_Counter, udg_KB3D_Speed )
    call SaveReal( udg_KB3D_HA, 3, udg_KB3D_Counter, udg_KB3D_Zoffset )
    call SaveReal( udg_KB3D_HA, 4, udg_KB3D_Counter, udg_KB3D_Accel )
    if ( udg_KB3D_Targeted_Unit == null ) then
        call SaveReal( udg_KB3D_HA, 5, udg_KB3D_Counter, udg_KB3D_Angle*bj_DEGTORAD )
    else
        call SaveUnitHandle( udg_KB3D_HA, 5, udg_KB3D_Counter, udg_KB3D_Targeted_Unit )
    endif
    call SaveBoolean( udg_KB3D_HA, 6, udg_KB3D_Counter, udg_KB3D_DisableUnit )
    call SaveBoolean( udg_KB3D_HA, 7, udg_KB3D_Counter, udg_KB3D_UnpathableStop )
    call SaveBoolean( udg_KB3D_HA, 8, udg_KB3D_Counter, udg_KB3D_DestroyTree )
    call SaveStr( udg_KB3D_HA, 9, udg_KB3D_Counter, udg_KB3D_Fx )
    call SaveStr( udg_KB3D_HA, 10, udg_KB3D_Counter, udg_KB3D_Fx_Attach )
    call SaveReal( udg_KB3D_HA, 11, udg_KB3D_Counter, -1 * udg_KB3D_Speed / udg_KB3D_Accel )
    call SaveReal( udg_KB3D_HA, 12, udg_KB3D_Counter, udg_KB3D_Zoffset / (-1 * udg_KB3D_Speed / udg_KB3D_Accel / 2) )
    call SaveReal( udg_KB3D_HA, 13, udg_KB3D_Counter, ( -1 * udg_KB3D_Zoffset / (-1 * udg_KB3D_Speed / udg_KB3D_Accel / 2) ) / (-1 * udg_KB3D_Speed / udg_KB3D_Accel / 2) )
    call SaveBoolean( udg_KB3D_HA, 15, udg_KB3D_Counter, true )
    if UnitAddAbility(udg_KB3D_Unit, 'Amrf') then
        call UnitRemoveAbility(udg_KB3D_Unit, 'Amrf')
    endif
    if ( udg_KB3D_Counter == 1 ) then
        call EnableTrigger(udg_KB3D_Loop)
    endif
    //Nulling
    set udg_KB3D_Accel = 0.00
    set udg_KB3D_Angle = 0.00
    set udg_KB3D_DestroyTree = false
    set udg_KB3D_DisableUnit = false
    set udg_KB3D_Fx = ""
    set udg_KB3D_Fx_Attach = ""
    set udg_KB3D_Range = 0.00
    set udg_KB3D_Speed = 0.00
    set udg_KB3D_Targeted_Unit = null
    set udg_KB3D_Unit = null
    set udg_KB3D_UnpathableStop = false
    set udg_KB3D_Zoffset = 0.00
endfunction
EDIT: wouldn't be sensible to make it hog processing time, it shouldn't be in the periodic function, it should be on the registration function.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I'm having a hard time figuring out what your saving on the hashtables Jad, could you help me by making a detailed list of what the saved data are?

i.e.:
udg_KB3D_Unit - this one is the unit knocked back if there is no target.
udg_KB3D_Targeted_Unit - this one is the omg I dunno?

like that lol, I'm confused.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
So what is the relationship between the target_unit and the unit? I don't get it. I also don't know what 11 to 15 are. I'll skip them temporarily then.
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
unit is the knockbacked unit
targeted_unit is (if not null) the direction where the Kbed unit goes, meaning it is like he follows the unit, try setting this to attacking unit for example, the kbed unit will then go to the attacking unit's location
11>13 are basically not fixed yet, they work, but i will enhance them afterwards, but just to tell you what they are:
11>>time taken to finish the knockback
12>>speed of Z changing (AKA 'rate')
13>>Acceleration of Z changing speed >> you can see them in the loop where they are named
14>>empty space if required
15>> if the specific instance is finished = false, if not = true
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
set udg_KB3D_HA = InitHashtableBJ()
Use
set udg_KB3D_HA = InitHastable()

Why don't use triggeraddcondition for the reg trigger ? It is still better than using triggeraddaction.

call TriggerRegisterTimerEvent( udg_KB3D_Loop, 0.03125, TRUE )
TRUE refers to true so just write this :
call TriggerRegisterTimerEvent( udg_KB3D_Loop, 0.03125, true )

There is also a non-indented loop but that's only verbose x)
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
Ahah ^^
I'll try to help :p
So the problem is when there is a (large ?) number of instances it starts to lag ?

if ( LoadBoolean(udg_KB3D_HA, 15, x) == true ) then
->
if ( LoadBoolean(udg_KB3D_HA, 15, x) ) then

call EnumItemsInRectBJ( udg_CP_Rect, function KB3D_CW_Loop )
->
call EnumItemsInRect(udg_CP_Rect, null, function KB3D_CW_Loop )

There is a trick to get the z offset of a unit.
You can add a location at the position of the unit and then use the formula : GetUnitFLyHeight(u) + GetLocationZ(L)

if ( (UnpathableStop == false) or ( KB3D_CW(x, y) == true ) ) then
->
if ( not(UnpathableStop) or KB3D_CW(x, y) ) then

if ( DisableUnit == true ) then
-> Oh by the way this condition got nothing if it is true so just do the complementary version and delete the else.
if DisableUnit then

( GetUnitState(U, UNIT_STATE_LIFE) <= 0 )
->
( GetWidgetLife(U) <= 0 )
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
Sorry for the late reply...
Any way malhorne, thanks for poiting all those out
Chobibo, what did you come up with ?
Btw, in the version i am working on, i merged the 2 triggers into 1 and added credits to you 2 for helping in the triggers
 
Status
Not open for further replies.
Top