Snippet Create a field of destructables

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
This code takes the locals you input and generates a field of doodads at random points and heights within the parameters, centered on the map middle. This is so simple, but it might help someone.

Code:
function Trig_DoodadField_Actions takes nothing returns nothing
 local real dim = 800
 local real height = 200
 local real minscale = .001
 local real maxscale = .8
 local integer doodad = 'LTbs'
 local integer count = 1
    loop
        exitwhen count > 100
        call CreateDestructableZ(doodad,GetRandomReal(-dim,dim),GetRandomReal(-dim,dim),GetRandomReal(0,height),GetRandomReal(0,355),GetRandomReal(minscale,maxscale),1)
        set count = count + 1
    endloop
    call FogEnable(false)
    call FogMaskEnable(false)
endfunction

Map is attached for an example.
 

Attachments

  • pretend stars.w3x
    17.1 KB · Views: 262

Hero

─║╣ero─
Reaction score
250
Why not make it more function-able

Example:

JASS:
function DoodadField takes real nod, real dim, real height, real minscale, real maxscale, integer doodadint returns nothing
 local integer count = 1
    loop
        exitwhen count > nod
        call CreateDestructableZ(doodadint,GetRandomReal(-dim,dim),GetRandomReal(-dim,dim),GetRandomReal(0,height),GetRandomReal(0,355),GetRandomReal(minscale,maxscale),1)
        set count = count + 1
    endloop
endfunction


Might have a flaw in there...I just freehanded it...but anyways That would be more function-able

doodadint=The Rawcode of the Doodad(Integer)
nod=Number of Doodads
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Mnice. is that one way to cut out all those locals?
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Thats nice. Your way you can change the center of the field too. With my original you can't - easily.
Hmmm thinking about it... might want to make that part of it as well.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Doodads or Destructables? I don't think you can create doodads....
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
True. It is destructables. Would you mind changing the title?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Ok. Cleared up. I was getting confused. :p

> Would you mind changing the title?

Done.
 

Hero

─║╣ero─
Reaction score
250
Lol neither. It's hard to tell sometimes when your so deep in the WE.
Thanks Ghan for changing the title. Is this snippet useful?

Yes it is useful...not for me personally...but it is useful for people who can not write one for themself...(and there are tons of people like that)
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Quick question about "function-able" if its made function-able, it could be used in GUI more easily correct?
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
I need some help with some of the logic of the next level of this snippet. Programming isn't my strong point.

I have your code. It's ok being functionable. Whats not ok is the x and y. The z is fine as that will be defined in the coding. At the mo x and y are random from (-dim,dim). Trouble is dim being coordinates its being set from 0,0. So if I say dim=300 it will create the field within -300,300 from map origin (centre).

What can I type in to locate the center and move it to wherever...say for example unit location?

By the way Ghan, sorry that this has become a WIP. I honestly thought I'd finished, so i wanted to share with other people.
 

Hero

─║╣ero─
Reaction score
250
Well this is the native

JASS:
native          CreateDestructableZ         takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns destructable


So it doesn't take location meaning you need to use

JASS:

GetLocationX(locationhere)
GetLocationY(locationhere)


So basically it should look like this

JASS:
function DoodadField takes real nod, location loc, real dim, real height, real minscale, real maxscale, integer doodadint returns nothing  
    local integer count = 1 
  loop  
    exitwhen count > nod 
call CreateDestructableZ(doodadint,GetLocationX(loc),GetLocationY(loc),GetRandomReal(0,height),GetRandomReal(0,355),GetRandomReal(minscale,maxscale),1)  
set count = count + 1 
    endloop 
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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