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: 122

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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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