Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
This system is not fully GUI (I think) because almost half of the code is custom script.
I been searching a system that will make units wandering around with
simple implementation and I can't find any. Most of it is JASS and takes lot of work.
Since I can't find it, I made this system and I made the implementation simple as I could.
This system will make registered unit move around certain area or everywhere
based on user configuration. The system will stop forcing unit from wandering when the unit is unit combat
until the unit is out of combat.
For me, this kind of system would be useful for RPG mapping.
Making the forest and village looks lively.
This is just the base of the system, I'll update it with various kind of feature
if I see any support. Maybe I'll make the registered unit emotional likes
angry, panic, etc.
If you have any idea for the update, please tell me. TQ
How to import:
1. Copy all trigger in System and Requirements category. Don't the system inside
Requirement if you already have it.
2. For Damage Engine system, copy Cheat Death Ability in Object Editor > Ability
3. Paste the trigger and the custom ability into your map.
4. Check and enable disabled actions in systems trigger.
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WanderDelayCount[WanderIndex] Greater than or equal to WanderDelay[WanderIndex]
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WanderIsAroundLoc[WanderIndex] Equal to True
Then - Actions
Custom script: set udg_WanderPoint[1] = Location(udg_WanderLocX[udg_WanderIndex], udg_WanderLocY[udg_WanderIndex])
Else - Actions
Set WanderPoint[1] = (Position of WanderUnit)
Custom script: loop
Set WanderPoint[2] = (WanderPoint[1] offset by (Random real number between WanderMinDist[WanderIndex] and WanderMaxDist[WanderIndex]) towards (Random angle) degrees)
Custom script: set x[1] = GetLocationX(udg_WanderPoint[2])
Custom script: set y[1] = GetLocationY(udg_WanderPoint[2])
Unit - A unit Is issued an order targeting an object
Unit - A unit Is attacked
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Attacked unit) is in WanderRegisteredGroup) Equal to True
Then - Actions
Set WanderCoUnit = (Attacked unit)
Trigger - Run Wander <gen> (ignoring conditions)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Attacking unit) is in WanderRegisteredGroup) Equal to True
Then - Actions
Set WanderCoUnit = (Attacking unit)
Trigger - Run Wander <gen> (ignoring conditions)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Ordered unit) is in WanderRegisteredGroup) Equal to True
Then - Actions
Set WanderCoUnit = (Ordered unit)
Trigger - Run Wander <gen> (ignoring conditions)
Else - Actions
Demo
Events
Player - Player 1 (Red) types a chat message containing <Empty String> as An exact match
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Entered chat string) Equal to -add
Then - Actions
-------- I'm registering unit in playable map area. --------
Set TmpGroup[2] = (Units in (Playable map area))
Unit Group - Pick every unit in TmpGroup[2] and do (Actions)
Loop - Actions
-------- Set this to the unit you want to register --------
Set WanderRegUnit = (Picked unit)
Set WanderIndex = (Custom value of WanderRegUnit)
-------- You want the unit move around point (true) or anywhere (false) --------
Set WanderIsAroundLoc[WanderIndex] = True
-------- If the answer is true, then set the point. --------
Set WanderWPoint = (Position of WanderRegUnit)
-------- Order id --------
Set WanderOrder[WanderIndex] = attack
-------- How long the combat last --------
Set WanderCoDelay[WanderIndex] = 4.00
-------- How often the unit wander around. --------
Set WanderDelay[WanderIndex] = (Random real number between 4.00 and 8.00)
-------- Maximum wander distance. --------
Set WanderMaxDist[WanderIndex] = (Random real number between 400.00 and 500.00)
-------- Minimum wander distance. --------
Set WanderMinDist[WanderIndex] = (Random real number between 100.00 and 200.00)
-------- Now, run the system. --------
Trigger - Run Wander <gen> (ignoring conditions)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Entered chat string) Equal to -remove
Then - Actions
-------- I'm removing unit in playable map area. --------
Set TmpGroup[2] = (Units in (Playable map area))
Unit Group - Pick every unit in TmpGroup[2] and do (Actions)
Loop - Actions
-------- Set this to the unit you want to remove --------
Set WanderRemoveUnit = (Picked unit)
-------- Now, run the system. --------
Trigger - Run Wander <gen> (ignoring conditions)
Else - Actions
Custom script: call DestroyGroup(udg_TmpGroup[2])
Updated!
--added feature to detect un-pathable location
v0.01
--first release v0.2
--added feature to remove unit from the system
--removed periodic configuration v0.3
--removed hashtable, used UnitIndexer
--changed variables name
--added feature to modify unit order id
--added feature to modify the combat delay v0.4
--registered unit will only move to pathable location
Credit:
Unit Indexer by Bribe
Keywords:
wandering, moving around, live creep, live villager, GUI wander, rpg, rpg system, unit brain, patrol, village scene
For me its kinda great to have two version of a system.
Both version has its own features.
EDIT : Can someone tell me how to make the countdown work precisely. I mean, if the Wander_Delay is 0.50 scale and i set Wander_Periodic to any number that not 0.50 scale, how to calculate the countdown to make Wander_DelayCount == Wander_Delay and not Wander_DelayCount >= Wander_Delay
or should i make the timer periodic unconfigurable.
Improvements:
- Only start the timers if they weren't already started
- Instead of a hashtable, use arrays and the custom value of the unit as the array index.
Arrays names:
WanderLocX/Y
WanderMin/MaxDist
WanderDelay
WanderDelayCount
etc.
Maybe an option to make the NPCs attack-move instead of just move.
Instead of doing a perfect "Equal to" when you check if the wander duration has expired, do an equal to or greater than. This way you also don't have to do weird stuff like converting real to integer.
Move this out of the if-block to shorten the code: Unit - Order Wander_Unit to Move To Wander_Point[2]
This looks conceptually good. The other systems seem to want to add 6,000 features in addition to wandering. I like just strictly wandering as a standalone system.
What is this? I never see you using it anywhere else on the triggers, only once...
Correct me If I'm wrong, but you will leak if the udg_WanderPathCheck is false
Custom script: loop
Set WanderPoint[2] = (WanderPoint[1] offset by (Random real number between WanderMinDist[WanderIndex] and WanderMaxDist[WanderIndex]) towards (Random angle) degrees)
Custom script: set x[1] = GetLocationX(udg_WanderPoint[2])
Custom script: set y[1] = GetLocationY(udg_WanderPoint[2])
yes it is long because of its features. if you can see in the description, this system will make unit wander if the unit is out of combat and if the terrain is pathable. btw i will try to make it short later and thanks for telling, i forgot to change that
What is this? I never see you using it anywhere else on the triggers, only once...
Correct me If I'm wrong, but you will leak if the udg_WanderPathCheck is false
Custom script: loop
Set WanderPoint[2] = (WanderPoint[1] offset by (Random real number between WanderMinDist[WanderIndex] and WanderMaxDist[WanderIndex]) towards (Random angle) degrees)
Custom script: set x[1] = GetLocationX(udg_WanderPoint[2])
Custom script: set y[1] = GetLocationY(udg_WanderPoint[2])
The debug keyword can only be compiled with JPNG. In public GUI only code it shouldn't be used.
Here and there you check if a specific goup is empty. Even if that is true you perform
a ForGroup operation. Move that to the else part of the is group empty condition.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.