HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

My "Random Encounter System + Random Drop + Respawn"

06-18-2008, 02:38 AM#1
deathdrivex
I wanted to make a map where things spawn according to your stats and contracts that would fit perfectly for my "Hunter's" game. And so, this is "it".

Hope you find this useful...

====================
Respawn Enemies that Have Died within the Unit Group
Trigger:
Respawn
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Owner of (Dying unit)) Equal to Neutral Hostile
((Dying unit) is in HostileFight[(Player number of (Owner of (Killing unit)))]) Equal to True
Collapse Actions
Wait 30.00 game-time seconds
Unit - Create 1 (Unit-type of (Dying unit)) for Neutral Hostile at (Position of (Dying unit)) facing (Position of (Killing unit))
Wait 0.01 game-time seconds
Unit Group - Add (Last created unit) to HostileFight[(Player number of (Owner of (Killing unit)))]
Wait 0.01 game-time seconds
Unit Group - Order HostileFight[(Player number of (Owner of (Entering unit)))] to Attack (Entering unit)


This is encountering random enemies according to stats, contract, and etc. This is only for one region.

Trigger:
Entering Bandit Main
Collapse Events
Unit - A unit enters Bandit Main <gen>
Collapse Conditions
((Entering unit) is A Hero) Equal to True
Contract[(Player number of (Owner of (Entering unit)))] Equal to 0
Collapse Actions
Set CreepSpawn = (Hero level of (Entering unit))
Set RandomizedFight = (Random integer number between 0 and 3)
Wait 0.01 game-time seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CreepSpawn Equal to 1
Collapse Then - Actions
Unit - Create RandomizedFight Bandit for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Set HostileFight[(Player number of (Owner of (Entering unit)))] = (Last created unit group)
Wait 0.01 game-time seconds
Unit Group - Order HostileFight[(Player number of (Owner of (Entering unit)))] to Attack (Entering unit)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CreepSpawn Equal to 2
Collapse Then - Actions
Unit - Create RandomizedFight Bandit for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Set HostileFight[(Player number of (Owner of (Entering unit)))] = (Last created unit group)
Wait 0.01 game-time seconds
Unit Group - Order HostileFight[(Player number of (Owner of (Entering unit)))] to Attack (Entering unit)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CreepSpawn Equal to 3
Collapse Then - Actions
Unit - Create RandomizedFight Bandit for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Set HostileFight[(Player number of (Owner of (Entering unit)))] = (Last created unit group)
Wait 0.01 game-time seconds
Unit Group - Order HostileFight[(Player number of (Owner of (Entering unit)))] to Attack (Entering unit)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CreepSpawn Equal to 4
Collapse Then - Actions
Unit - Create RandomizedFight Brigand for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Set HostileFight[(Player number of (Owner of (Entering unit)))] = (Last created unit group)
Wait 0.01 game-time seconds
Unit Group - Order HostileFight[(Player number of (Owner of (Entering unit)))] to Attack (Entering unit)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CreepSpawn Equal to 5
Collapse Then - Actions
Unit - Create RandomizedFight Brigand for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Unit - Create RandomizedFight Bandit for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Set HostileFight[(Player number of (Owner of (Entering unit)))] = (Last created unit group)
Wait 0.01 game-time seconds
Unit Group - Order HostileFight[(Player number of (Owner of (Entering unit)))] to Attack (Entering unit)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CreepSpawn Greater than or equal to 6
Collapse Then - Actions
Unit - Create RandomizedFight Brigand for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Unit - Create RandomizedFight Assassin for Neutral Hostile at ((Random point in Bandit Main <gen>) offset by (10.00, 10.00)) facing (Position of (Entering unit))
Set HostileFight[(Player number of (Owner of (Entering unit)))] = (Last created unit group)
Wait 0.01 game-time seconds
Unit Group - Order HostileFight[(Player number of (Owner of (Entering unit)))] to Attack (Entering unit)
Collapse Else - Actions
Do nothing

Removing Units when leaving
Trigger:
Leaving Bandit Main
Collapse Events
Unit - A unit leaves Bandit Main <gen>
Collapse Conditions
((Leaving unit) is A Hero) Equal to True
Collapse Actions
Unit Group - Pick every unit in HostileFight[(Player number of (Owner of (Leaving unit)))] and do (Unit - Remove (Picked unit) from the game)

Heres the first part of drop system for the unit type.
Trigger:
Bandits Settings
Collapse Events
Unit - A unit owned by Neutral Hostile Dies
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Dying unit)) Equal to Bandit
Collapse Then - Actions
Set BanditDrop = (Random integer number between 1 and 5)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Dying unit)) Equal to Brigand
Collapse Then - Actions
Set BanditDrop = (Random integer number between 6 and 10)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Dying unit)) Equal to Rogue
Collapse Then - Actions
Set BanditDrop = (Random integer number between 11 and 15)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Dying unit)) Equal to Assassin
Collapse Then - Actions
Set BanditDrop = (Random integer number between 16 and 20)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Dying unit)) Equal to Enforcer
Collapse Then - Actions
Set BanditDrop = (Random integer number between 21 and 25)
Collapse Else - Actions
Do nothing
Trigger - Run Bandit Drop <gen> (ignoring conditions)

The actual drop

Trigger:
Bandit Drop
Events
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BanditDrop Equal to 3
Collapse Then - Actions
Item - Create Gold Coins at (Position of (Dying unit))
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BanditDrop Equal to 8
Collapse Then - Actions
Item - Create Gold Coins at (Position of (Dying unit))
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BanditDrop Equal to 12
Collapse Then - Actions
Item - Create Gold Coins at (Position of (Dying unit))
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BanditDrop Equal to 17
Collapse Then - Actions
Item - Create Gold Coins at (Position of (Dying unit))
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BanditDrop Equal to 23
Collapse Then - Actions
Item - Create Gold Coins at (Position of (Dying unit))
Collapse Else - Actions
Do nothing
Set BanditDrop = 0

EDIT: Just a sidenote, the "Set BanditDrop = 0" is important, or else you would have a very bad glitch later on which only one item will drop and nothing else. You will have 100% drop of same item if you dont reset the banditdrop to 0.
06-18-2008, 11:16 AM#2
Anitarf
That's no system, that's just a bunch of static GUI triggers prone to bugging out. It's really not useful at all.
06-18-2008, 11:20 AM#3
The Elite
noone will use this unless you post a map with the triggers in it. Recreateing GUI triggers is boring
06-18-2008, 03:03 PM#4
deathdrivex
http://www.epicwar.com/maps/download...27sTestMap.w3x

Ill have that there temporarily. It contains the 3 stuff altogether. I removed ALOT of stuff from the original, so all you have to do is move your unit towards one of the heroes in the town and change into a profession. Then go to left side of map and test the stuff.
06-18-2008, 04:33 PM#5
Squally425
Your system contains an enormous amount of leaks.
You create unit groups and points constantly, without removing them.

Also your spawning is a huge load of unneeded code.
You can shorten it immensely by initializing an array of unittypes, and then accessing them afterwards. That way when you use "CreepSpawn"... you could just "Create Unit of Type UnitTypes[CreepSpawn]".
All the other actions are the same anyways.

Take out the 0.01 waits. They serve no purpose.