Let creeps walk randomly

volgera

New Member
Reaction score
0
Hey guys,
I'm in need of some help with making random creeps walk through a region. the creeps that I'm trying to get walking will be randomly spawned, so I can't pick a specific unit... What do I have to do??
 

johnnymra

New Member
Reaction score
14
As far as i know... give them the ability 'Wonder (neutral)' ...
Or make a trigger that picks every X seconds all units in that region and makes them move to random point in the same region.
 

Magthridon96

Member
Reaction score
2
Here you go :)
It could've been faster, but I didn't feel like using a linked list. If it ever causes lag, just PM me and I'll write a version that could be up to 20x faster :]

JASS:
library Wander requires TimerUtils
    globals
        private constant real MAX_DISTANCE = 700.0
        private constant real INTERVAL = 5.0
    endglobals
    
    private module Init
        private static method onInit takes nothing returns nothing
            local region reg = CreateRegion()
            local rect rec = Rect(-32256,-32256,32256,32256) // Credits to Nestharus for these values
            call RegionAddRect(reg,rec)
            call TriggerRegisterEnterRegion(CreateTrigger(),reg,Condition(function thistype.run))
            set reg = null
            set rec = null
        endmethod
    endmodule
    
    private struct wander
        unit u
        static method move takes nothing returns nothing
            local thistype this = GetTimerData(GetExpiredTimer())
            local real dis = GetRandomReal(1,MAX_DISTANCE)
            local real ang = GetRandomReal(0,6.28318530)
            call IssuePointOrder(this.u,"move",GetUnitX(this.u)+dis*Cos(ang),GetUnitY(this.u)+dis*Sin(ang))
        endmethod
        static method create takes unit un returns thistype
            local thistype this = thistype.allocate()
            local timer t = NewTimer()
            set this.u = un
            call TimerStart(t,INTERVAL,true,function thistype.move)
            call SetTimerData(t,this)
            return this
        endmethod
        static method run takes nothing returns boolean
            call thistype.create(GetTriggerUnit())
            return false
        endmethod
        method destroy takes nothing returns nothing
            set this.u = null
            call this.deallocate()
        endmethod
        implement Init
    endstruct
endlibrary
 

volgera

New Member
Reaction score
0
wow, awesome thanks ^^ so, what things do I have to change in it?... XD I'm not that familiar with JASS, and so far I triggered 80% of my new map with GUI.
 

johnnymra

New Member
Reaction score
14
>Magthridon96

Does it necessarily need a GUI Trigger or JASS system to make creeps walk randomly? why not just use the 'Wander' Ability?

I am only curious why is the system you made better? What does it do exactly?
 

Machop Fan

Active Member
Reaction score
0
>Magthridon96

Does it necessarily need a GUI Trigger or JASS system to make creeps walk randomly? why not just use the 'Wander' Ability?

I am only curious why is the system you made better? What does it do exactly?

Wander will cause the unit to wander in any direction, not restricted by a region. This could cause the creep to accidentally wander into your base!

The region trigger, on the other hand, restricts the creep to a certain region, and ensures it never leaves that region unless attacked.
 
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