• 🏆 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] PUI, DD and others

Status
Not open for further replies.
Level 19
Joined
Aug 24, 2007
Messages
2,888
Hi all

It seems like that thing called PUI attaches variables like UserData to units
I didnt checked it all. Doesnt the Local Handle Variables by KaTTaNa do the same
DD seems nice too
I use a AnyUnitTakesDamage system that works with CSCache but DD seems better I dont really need CSCache in other things (I dont know what does Caster System at all)

I dont know anything about those libraries, scopes and other things that JassCraft doesnt know
can someone explain them
I tried to read the help things inside jassnewgenpack but didnt get anything
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
1- PUI is basically useless, it's "faster" than GC, but there are even faster ways than it that are easier to do.

2- DD is just a vJassed AnyUnitTakesDamage - more efficient than the latter, but still less efficient than it should be. It shouldn't really make much of a difference which you use, though, since the calls aren't very frequent.

As for the vJass features;

Libraries: basically, their contents are moved to the top of the script. This allows for cleaner code sorting than the "Custom script section"

Scopes: are allowed to have members which only other things within the scope can see

What else do you need to know about?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
JASS:
function DamageArea takes unit attacker, location point, real area, real damage returns nothing
    local unit u
    local group g = CreateGroup()
    local player p = GetOwningPlayer(attacker)
    call GroupEnumUnitsInRange(g,GetLocationX(point),GetLocationY(point),area,Filter(null))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if IsUnitEnemy(u,p) and GetWidgetLife(u) > 0 and not (IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE) or IsUnitType(u,UNIT_TYPE_STRUCTURE)) then
            call SetUnitExploded(u,true)
            call UnitDamageTarget(attacker,u,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
            call SetUnitExploded(u,false)
        endif
        call GroupRemoveUnit(g,u)
    endloop
    call DestroyGroup(g)
    set g = null
    set p = null
    set attacker = null
    set point = null
endfunction

function thunder takes location pos returns nothing
local effect spec
local lightning light
local real x = GetLocationX(pos)
local real y = GetLocationY(pos)
set light = AddLightningEx("CLPB",true,GetRandomReal(x-400,x+400),GetRandomReal(y-400,y+400),1000,x,y,0)
set spec = AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl",x,y)
call DestroyEffect(spec)
call TriggerSleepAction(0.1)
call DestroyLightning(light)
set light = null
set spec = null
endfunction
function redthunder takes location pos returns nothing
local effect spec
local lightning light
local real x = GetLocationX(pos)
local real y = GetLocationY(pos)
set light = AddLightningEx("AFOD",true,x,y,1000,x,y,0)
set spec = AddSpecialEffect("buildings\\other\\MageTower\\MageTower.mdl",x,y)
call DestroyEffect(spec)
call TriggerSleepAction(0.5)
call DestroyLightning(light)
set light = null
set spec = null
endfunction
function strikeac takes nothing returns nothing
local group g = CreateGroup()
local unit u
local location tar
local rect reg
local integer a
call GroupAddGroup(udg_locusts,g)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetUnitTypeId(u) == 'h001' then
set a = GetUnitUserData(u)
set reg = RectFromCenterSizeBJ(GetUnitLoc(u), 420.00, 420.00)
set tar = GetRandomLocInRect(reg)
call DamageArea(u,tar,100,20+a*12)
call thunder(tar)
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g = null
call RemoveLocation(tar)
set tar = null
call RemoveRect(reg)
set reg = null
endfunction

function dummyac takes nothing returns nothing
local unit dummyu
local unit caster = GetTriggerUnit()
local location pos = GetSpellTargetLoc()
local integer a = GetUnitAbilityLevel(caster,'A000')
if  ( GetSpellAbilityId() == 'A000' )  then
set dummyu = CreateUnitAtLoc(GetOwningPlayer(caster),'h001',pos,bj_UNIT_FACING)
call SetUnitUserData(dummyu,GetUnitAbilityLevel(caster,'A000'))
call DamageArea(caster,pos,300,0)
call SetUnitAnimation(dummyu,"birth")
call GroupAddUnit(udg_locusts,dummyu)
call TriggerSleepAction(3)
call GroupRemoveUnit(udg_locusts,dummyu)
call TriggerSleepAction(0.5)
call DamageArea(dummyu,pos,300,a*100)
call redthunder(pos)
call KillUnit(dummyu)
set dummyu = null
call RemoveLocation(pos)
set caster = null
endif
endfunction

//===========================================================================
function InitTrig_Thunder_Strike takes nothing returns nothing
    local trigger strike
    local trigger dummy
    set  dummy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( dummy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( dummy, function dummyac )
    set  strike = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( strike, 0.05 )
    call TriggerAddAction( strike, function strikeac )
endfunction

So as you see that "locusts" global must be gone
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
... this works well only I asked this becuase
you said there is a global variable and globals are no good in a spell

So there is nothing to change in this to make it better then ?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Does GroupEnumUnitsOfPlayer detect locusts (optional question)
so I can remove the global there
I also need this on that "BIG spell" I posted in another thread
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
It does ???
I cant use words for what it does mean to me
I'd like to give you 999999999999 +rep for this
JASS:
loop
exitwhen 1==2
udg_ReputationPoints[GetUserId(PurplePoot)] = udg_ReputationPoints[GetUserId(PurplePoot)]+1
endloop
 
Status
Not open for further replies.
Top