Can someone help me convert this to MUI?

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
Hi, I have created a spell that creates blocks around him. But this spell is not yet finished, I discontinued finishing it since I have noticed it's not MUI xD.
Can someone help me convert it to MUI and let me study it? The part with the damage is not yet added, cuz as what I said, not yet finished. I just need to convert it to MUI and let me be the one to add the damage part

Requires TimerUtils
JASS:
scope SpiritShield
    globals
        private constant integer RAWCODE   = 'A001'  //The rawcode of spell
        private constant integer DUMMY     = 'h001'  //Rawcode of the dummy
        private constant integer NUMBER    = 5       //The number of spawning dummy per side

        private constant real    INCREMENT = 250.    //Speed of every stuff
        private constant real    DISTANCE  = 250.    //Distance away from the caster
        private constant real    AWAY      = 10.     //Distance between the stuffs
    endglobals

    globals
        private real MAX_X
        private real MAX_Y
        private real MIN_X
        private real MIN_Y
    endglobals

    private function Outside takes real x,real y returns boolean
        if x < MAX_X and y < MAX_Y and x > MIN_X and y > MIN_Y then
            return false
        else
            return true
        endif
    endfunction

    private struct Struct
        private static group MOVER   = CreateGroup()//I know
        private static unit  CASTER  = null//This part is the one
        private static timer TIMER   = null//That makes
        private static real r       = -180//This spell
        private static integer i    = 0// Un-MUI
        private static method M5 takes nothing returns nothing
            set .i = .i + 1
        endmethod

        private static method M4 takes nothing returns nothing
            call KillUnit(GetEnumUnit())
        endmethod

        private static method M3 takes nothing returns nothing
            local unit u  = GetEnumUnit()
            local real x
            local real y

            if GetUnitState(u,UNIT_STATE_LIFE) != 1 then
                set x = GetUnitX(CASTER)+DISTANCE*Cos(((GetUnitFacing(CASTER)+.r)-(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
                set y = GetUnitY(CASTER)+DISTANCE*Sin(((GetUnitFacing(CASTER)+.r)-(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
            else
                set x = GetUnitX(CASTER)+DISTANCE*Cos(((GetUnitFacing(CASTER)-.r)+(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
                set y = GetUnitY(CASTER)+DISTANCE*Sin(((GetUnitFacing(CASTER)-.r)+(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
            endif

            if not Outside(x,y) then
                call SetUnitX(u,x)
                call SetUnitY(u,y)
                call SetUnitFacing(u,bj_RADTODEG*Atan2(y-GetUnitY(CASTER),x-GetUnitX(CASTER))-180)
            else
                call GroupRemoveUnit(MOVER,u)
                call KillUnit(u)
            endif
            set u = null
        endmethod

        private static method M2 takes nothing returns nothing
            local Struct this = GetTimerData(GetExpiredTimer())
            set .r = .r + (INCREMENT/32)
            call ForGroup(MOVER,function Struct.M3)
            set .i = 0
            call ForGroup(MOVER,function Struct.M5)
                if .i == 0 then
                    call IssueImmediateOrder(CASTER,"unimmolation")
                endif
        endmethod

        private static method M1 takes nothing returns boolean
            local Struct this = Struct.allocate()
            local unit u      = null
            local integer i   = 0

            if GetIssuedOrderId() == OrderId("immolation") then
                set CASTER = GetTriggerUnit()
                set TIMER = NewTimer()

                loop
                    set i = i + 1

                    set u = CreateUnit(GetOwningPlayer(CASTER),DUMMY,GetUnitX(CASTER),GetUnitY(CASTER),GetUnitFacing(CASTER))
                    call GroupAddUnit(MOVER,u)
                    call SetUnitUserData(u,i-1)
                    set u = null
                    set u = CreateUnit(GetOwningPlayer(CASTER),DUMMY,GetUnitX(CASTER),GetUnitY(CASTER),GetUnitFacing(CASTER))
                    call GroupAddUnit(MOVER,u)
                    call SetUnitUserData(u,i-1)
                    call SetUnitState(u,UNIT_STATE_LIFE,1)
                    exitwhen i == NUMBER
                endloop

                call SetTimerData(TIMER,this)
                call TimerStart(TIMER,.03125,true,function Struct.M2)
            else
                if GetIssuedOrderId() == OrderId("unimmolation") then
                    call ReleaseTimer(TIMER)
                    set .r = -180
                    set .i = 0
                    call ForGroup(MOVER,function Struct.M4)
                endif
            endif
            set u = null
            return false
        endmethod

        private static method onInit takes nothing returns nothing
            local trigger g = CreateTrigger()
            local integer i = 0
            loop
                call TriggerRegisterPlayerUnitEvent(g,Player(i),EVENT_PLAYER_UNIT_ISSUED_ORDER,null)
                set i = i + 1
                exitwhen i == bj_MAX_PLAYER_SLOTS
            endloop
            call TriggerAddCondition(g,Condition(function Struct.M1))

            set g = null
            set MOVER   = CreateGroup()
            set MAX_X   = GetRectMaxX(bj_mapInitialPlayableArea) - 64
            set MAX_Y   = GetRectMaxY(bj_mapInitialPlayableArea) - 64
            set MIN_X   = GetRectMinX(bj_mapInitialPlayableArea) + 64
            set MIN_Y   = GetRectMinY(bj_mapInitialPlayableArea) + 64
        endmethod
    endstruct
endscope


Demo maps will be here
 

Attachments

  • Spirit Shield.w3x
    20.4 KB · Views: 116

Dinowc

don't expect anything, prepare for everything
Reaction score
223
private static group MOVER = CreateGroup()
private static unit CASTER = null
private static timer TIMER = null
private static real r = -180
private static integer i = 0


try removing the static part

also, you should create the groups dynamically instead using 1 global group
 

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
private static group mover = creategroup()
private static unit caster = null
private static timer timer = null
private static real r = -180
private static integer i = 0


try removing the static part

also, you should create the groups dynamically instead using 1 global group for this one

error
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223

because those variables are private only to the current struct's instance

so instead of:

JASS:
set CASTER = GetTriggerUnit()
set TIMER = NewTimer()

call TimerStart(TIMER,.03125,true,function Struct.M2)

//etc.


do this:

JASS:
set this.CASTER = GetTriggerUnit()
set this.TIMER = NewTimer()
call TimerStart(this.TIMER,.03125,true,function Struct.M2)

//etc.


EDIT:

try using this code (probably wont work, but hope you'll get the idea):

JASS:
scope SpiritShield
    globals
        private constant integer RAWCODE   = 'A001'  //The rawcode of spell
        private constant integer DUMMY     = 'h001'  //Rawcode of the dummy
        private constant integer NUMBER    = 5       //The number of spawning dummy per side

        private constant real    INCREMENT = 250.    //Speed of every stuff
        private constant real    DISTANCE  = 250.    //Distance away from the caster
        private constant real    AWAY      = 10.     //Distance between the stuffs
    endglobals

    globals
        private real MAX_X
        private real MAX_Y
        private real MIN_X
        private real MIN_Y
    endglobals

    private function Outside takes real x,real y returns boolean
        if x < MAX_X and y < MAX_Y and x > MIN_X and y > MIN_Y then
            return false
        else
            return true
        endif
    endfunction

    private struct Struct
        private group MOVER
        private unit  CASTER
        private timer TIMER
        private real r
        private integer i
        private static Struct D

        private static method M5 takes nothing returns nothing
            set D.i = D.i + 1
        endmethod

        private static method M4 takes nothing returns nothing
            call KillUnit(GetEnumUnit())
        endmethod

        private static method M3 takes nothing returns nothing
            local unit u  = GetEnumUnit()
            local real x
            local real y

            if GetUnitState(u,UNIT_STATE_LIFE) != 1 then
                set x = GetUnitX(D.CASTER)+DISTANCE*Cos(((GetUnitFacing(D.CASTER)+D.r)-(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
                set y = GetUnitY(D.CASTER)+DISTANCE*Sin(((GetUnitFacing(D.CASTER)+D.r)-(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
            else
                set x = GetUnitX(D.CASTER)+DISTANCE*Cos(((GetUnitFacing(D.CASTER)-D.r)+(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
                set y = GetUnitY(D.CASTER)+DISTANCE*Sin(((GetUnitFacing(D.CASTER)-D.r)+(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
            endif

            if not Outside(x,y) then
                call SetUnitX(u,x)
                call SetUnitY(u,y)
                call SetUnitFacing(u,bj_RADTODEG*Atan2(y-GetUnitY(D.CASTER),x-GetUnitX(D.CASTER))-180)
            else
                call GroupRemoveUnit(D.MOVER,u)
                call KillUnit(u)
            endif
            set u = null
        endmethod

        private static method M2 takes nothing returns nothing
            local Struct this = GetTimerData(GetExpiredTimer())
            set this.r = this.r + (INCREMENT/32)
            set D = this
            call ForGroup(this.MOVER,function Struct.M3)
            set this.i = 0
            call ForGroup(this.MOVER,function Struct.M5)
                if this.i == 0 then
                    call IssueImmediateOrder(this.CASTER,"unimmolation")
                endif
        endmethod

        private static method M1 takes nothing returns boolean
            local Struct this = Struct.allocate()
            local unit u      = null
            local integer i   = 0

            if GetIssuedOrderId() == OrderId("immolation") then
                set this.CASTER = GetTriggerUnit()
                set this.TIMER = NewTimer()
                set this.MOVER = CreateGroup()
                set this.r = -180
                set this.i = 0

                loop
                    set i = i + 1

                    set u = CreateUnit(GetOwningPlayer(this.CASTER),DUMMY,GetUnitX(this.CASTER),GetUnitY(this.CASTER),GetUnitFacing(this.CASTER))
                    call GroupAddUnit(this.MOVER,u)
                    call SetUnitUserData(u,i-1)
                    set u = null
                    set u = CreateUnit(GetOwningPlayer(this.CASTER),DUMMY,GetUnitX(this.CASTER),GetUnitY(this.CASTER),GetUnitFacing(this.CASTER))
                    call GroupAddUnit(this.MOVER,u)
                    call SetUnitUserData(u,i-1)
                    call SetUnitState(u,UNIT_STATE_LIFE,1)
                    exitwhen i == NUMBER
                endloop

                call SetTimerData(this.TIMER,this)
                call TimerStart(this.TIMER,.03125,true,function Struct.M2)
            else
                if GetIssuedOrderId() == OrderId("unimmolation") then
                    call ReleaseTimer(this.TIMER)
                    set this.r = -180
                    set this.i = 0
                    call ForGroup(this.MOVER,function Struct.M4)
                endif
            endif
            set u = null
            return false
        endmethod

        private static method onInit takes nothing returns nothing
            local trigger g = CreateTrigger()
            local integer i = 0
            loop
                call TriggerRegisterPlayerUnitEvent(g,Player(i),EVENT_PLAYER_UNIT_ISSUED_ORDER,null)
                set i = i + 1
                exitwhen i == bj_MAX_PLAYER_SLOTS
            endloop
            call TriggerAddCondition(g,Condition(function Struct.M1))

            set g = null

            set MAX_X   = GetRectMaxX(bj_mapInitialPlayableArea) - 64
            set MAX_Y   = GetRectMaxY(bj_mapInitialPlayableArea) - 64
            set MIN_X   = GetRectMinX(bj_mapInitialPlayableArea) + 64
            set MIN_Y   = GetRectMinY(bj_mapInitialPlayableArea) + 64
        endmethod
    endstruct
endscope


your coding is kinda weird... why putting everything in a single struct? :confused:

also all those calculations:

JASS:
GetUnitY(D.CASTER)+DISTANCE*Sin(((GetUnitFacing(D.CASTER)-.r)+(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)
SetUnitFacing(u,bj_RADTODEG*Atan2(y-GetUnitY(CASTER),x-GetUnitX(CASTER))-180)


makes it slow as hell
 

Laiev

Hey Listen!!
Reaction score
188
undeclared variable: d

JASS:
.
        private static method M2 takes nothing returns nothing
            local Struct this = GetTimerData(GetExpiredTimer())
            set .r = .r + (INCREMENT/32)
            set D = d
            call ForGroup(this.MOVER,function Struct.M3)
            set .i = 0
            call ForGroup(this.MOVER,function Struct.M5)
                if .i == 0 then
                    call IssueImmediateOrder(this.CASTER,"unimmolation")
                endif
        endmethod


undeclared variable this
JASS:
set x = GetUnitX(D.CASTER)+DISTANCE*Cos(((GetUnitFacing(D.CASTER)+.r)-(AWAY*GetUnitUserData(u)))*bj_DEGTORAD)


undeclared variable this
JASS:
.
        private static method M5 takes nothing returns nothing
            set .i = .i + 1
        endmethod


and what is this: (of course "Cannot convert null to integer")
JASS:
        private static method M2 takes nothing returns nothing
            local Struct this = GetTimerData(GetExpiredTimer())

in jasshelper it is:
JASS:
        function s__SpiritShield__Struct_M2 takes nothing returns nothing
            local integer this= GetTimerData(GetExpiredTimer())
 

Laiev

Hey Listen!!
Reaction score
188
the only thing which i don't understand, is why the name of the struct start with Struck.. why just don't use any normal name, like data?

also you don't need to make everything inside the struct private, the struct is already private.

some private things cannot be accessed outside struct
 
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