HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Very Complex Trigger

08-15-2005, 11:43 PM#1
MrApples
Ok, I'm working on a anti gang trigger.

Ganging is when 2 or more players declare war on 1 or more players when they have much more resorces than the victim.

I'm trying to build a trigger that can prevent this by handicapping the units of the "gangers".

I first tried to set it up like a checkerboard formation of regions set all over the map, but then you can't just use the handicap on units so I changed it to the whole map hoping it would work with players, than I found out the handicap only is for food.

I figure the only way to do this, is to make a trigger that can observe the game and act off of what it observes. Kind of like AI.

After 3 days I came up with a very long system of triggers.

I Have no Idea if it will work yet, or what lag it may cause.

Default Life
Events
Time - Elapsed game time is 5.00 seconds
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
Advanced - Set the custom real value for (Picked unit) to (Max life of (Picked unit))


-----------------------------------------------------------------------
Default Life2
Events
Unit - A unit Finishes training a unit
Conditions
Actions
Advanced - Set the custom real value for (Trained unit) to (Max life of (Targeted unit))

THE ABOVE TRIGGERS SETS A VALUE STORED IN THE UNIT SO THE ORIGINAL MAX LIFE IS NOT LOST
-----------------------------------------------------------------------
Set Life
Events
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
Advanced - For (Picked unit) Increase life maximum by ((Integer(((Picked unit)'s custom real value))) - (Integer((Max life of (Picked unit)))))
Set LifeMax = (((Integer((Max life of (Picked unit)))) / 1) x (Custom value of (Picked unit)))
Advanced - For (Picked unit) Decrease life maximum by ((Integer((Max life of (Picked unit)))) - LifeMax)

THIS TRIGGER APPLIES THE HANDICAPP TO UNITS
-----------------------------------------------------------------------
FOR THE MAIN 2 TRIGGERS I WILL SEPERATES INTO GROUPS OF ACTIONS
-----------------------------------------------------------------------
AntiGang
Events
Time - Elapsed game time is 60.00 seconds
Conditions
Actions
Set GangRegion = (Playable map area)
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Player Group - Add (Picked player) to GangWorkingOn
Player Group - Pick every player in GangWorkingOn and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is an ally of (Picked player)) Equal to True
Then - Actions
Player Group - Remove (Picked player) from GangAllied
Player Group - Add (Picked player) to GangAllied
Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Unit - Set the custom value of (Picked unit) to 100)
Else - Actions
Do nothing
THE ABOVE ACTION SEPERATES THE PEOPLE WHO ARE NOT INVOLVED IN ANY WAR FROM ThE GROUP ANd SETS THEIR UNITS HANDICAP TO 100%
-----------------------------------------------------------------------
Set GangTeamFinder = (Random player from GangWorkingOn)
Player Group - Pick every player in (All enemies of GangTeamFinder) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is in GangWorkingOn) Equal to True
Then - Actions
Player Group - Remove (Picked player) from GangWorkingOn
Player Group - Add (Picked player) to GangTeam1
Else - Actions
Do nothing
Player Group - Pick every player in (All allies of GangTeamFinder) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is in GangWorkingOn) Equal to True
Then - Actions
Player Group - Remove (Picked player) from GangWorkingOn
Player Group - Add (Picked player) to GangTeam2
Player Group - Remove GangTeamFinder from GangWorkingOn
Player Group - Add GangTeamFinder to GangTeam2
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of players in GangWorkingOn) Greater than 0
Then - Actions
Player Group - Pick every player in GangTeam1 and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of players in GangTeam1) Greater than 1
((Picked player) is an ally of (Picked player)) Equal to False
Then - Actions
Set GangUseTeams = 4
Set GangTeamFinder = (Random player from GangTeam1)
Player Group - Pick every player in (All enemies of GangTeamFinder) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is in GangTeam1) Equal to True
Then - Actions
Player Group - Remove (Picked player) from GangTeam1
Player Group - Add (Picked player) to GangTeam3
Player Group - Pick every player in GangTeam3 and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is an ally of (Picked player)) Equal to False
Then - Actions
Set GangTeamFinder = (Random player from GangTeam3)
Player Group - Pick every player in (All allies of GangTeamFinder) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is in GangTeam3) Equal to True
Then - Actions
Else - Actions
Player Group - Remove (Picked player) from GangTeam3
Player Group - Add (Picked player) to GangTeam4
Else - Actions
Else - Actions
Do nothing
Else - Actions
Do nothing
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is an ally of (Picked player)) Equal to False
Then - Actions
Set GangTeamFinder = (Random player from GangTeam3)
Player Group - Pick every player in (All enemies of GangTeamFinder) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) is in GangTeam3) Equal to True
Then - Actions
Else - Actions
Player Group - Remove (Picked player) from GangTeam3
Else - Actions
Do nothing


THE ABOVE PART SEPERATES THE PLAYERS INVOLVED IN WAR INTO 2-4 GROUPS
BY FIRST PICKING A RANDOM PLAYER FROM THE WORKINGON GROUP THEN SORTING THE ALLIES OF THAT PLAYER INTO A GROUP AND THE ENEMIES INTO ANOTHER. AND IF THE ENEMIES OF THE PLAYER ARE NOT ALL ALLIED THEY ARE SORTED INTO THE OTHER GROUPS OR UNUSED.
-----------------------------------------------------------------------
Trigger - Turn on Detected <gen>
Trigger - Run Detected <gen> (ignoring conditions)
Wait until (AttackDetect Equal to True), checking every 1.00 seconds
Trigger - Turn off Detected <gen>
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GangTeamTotal Greater than 2
Then - Actions

THIS RUNS THE TRIGGERS THAT FIND OUT WHO IS ATTACKING WHO OF THE 4 GROUPS.
-----------------------------------------------------------------------
Player Group- Pick every player in GangSmallest and do (Actions)
Player Group- Pick every player in GangLargest and do (Actions)
Player Group- Pick every player in GangSmallest2 and do (Actions)
Player Group- Pick every player in GangLargest2 and do (Actions)
THIS PART IS EXTREMELY LONG SO I WILL NOT POST IT FULLY.
THIS PART DETERMINES THE RESORCES OF EACH GROUP
-----------------------------------------------------------------------


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GangSmallestResorces Greater than or equal to (GangLargestResorces - 2)
Then - Actions
Do nothing
Else - Actions
Set GangHandiPercent = ((Number of players in GangLargest) / ((Number of players in GangSmallest) x 100))
Player Group - Pick every player in GangLargest and do (Actions)
Loop - Actions
Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
Loop - Actions
Unit - Set the custom value of (Picked unit) to GangHandiPercent
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GangTeamTotal Equal to 4
GangSmallest2Resorces Greater than or equal to (GangLargest2Resorces - 2)
Then - Actions
Do nothing
Else - Actions
Set GangHandiPercent = ((Number of players in GangLargest2) / ((Number of players in GangSmallest2) x 100))
Player Group - Pick every player in GangLargest2 and do (Actions)
Loop - Actions
Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
Loop - Actions
Unit - Set the custom value of (Picked unit) to GangHandiPercent
THIS PART SETS THE UNITS CUSTOM VALUES TO WHAT THEIR HANDICAP SHOULD BE.
SUCH AS IF THE GANG IS 4vs2 THE UNITS OF THE 4 TEAM SHALL BE SET TO 50.
-----------------------------------------------------------------------
Else - Actions
ELSE IS BASICALLY THE SAME THING AS ABOVE EXCEPT NOT INVLUDING LARGEST2 and SMALLEST2
-----------------------------------------------------------------------
Player Group - Remove all players from GangLargest
Player Group - Remove all players from GangLargest2
Player Group - Remove all players from GangSmallest
Player Group - Remove all players from GangSmallest2
Player Group - Remove all players from GangDisputeSort
Player Group - Remove all players from GangWorkingOn
Player Group - Remove all players from GangAllied
Player Group - Remove all players from GangTeam1
Player Group - Remove all players from GangTeam2
Player Group - Remove all players from GangTeam3
Player Group - Remove all players from GangTeam4
Set AttackDetect = False
Set GangUseTeams = 0
Set GangTeamTotal = 0
Trigger - Run Set Life <gen> (ignoring conditions)
Trigger - Run (This trigger) (ignoring conditions)

THIS PART JUST RESETS THE VARIABELS AND TEAMS SO THEY CAN BE REUSED
-----------------------------------------------------------------------
END OF MAIN TRIGGER
-----------------------------------------------------------------------

AttackDetect
Events
Unit - A unit Is attacked
Conditions
Actions
Player Group - Pick every player in GangTeam1 and do (Actions)
Loop - Actions
Player Group - Add (Picked player) to GangDisputeSort
Player Group - Pick every player in GangTeam2 and do (Actions)
Loop - Actions
Player Group - Add (Picked player) to GangDisputeSort
Player Group - Pick every player in GangTeam3 and do (Actions)
Loop - Actions
Player Group - Add (Picked player) to GangDisputeSort
Player Group - Pick every player in GangTeam4 and do (Actions)
Loop - Actions
Player Group - Add (Picked player) to GangDisputeSort
Player Group - Pick every player in GangDisputeSort and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of players in GangLargest) Greater than or equal to 0
(Number of players in GangSmallest) Greater than or equal to 0
((Attacked unit) is in (Units owned by (Picked player))) Equal to True
((Attacking unit) is in (Units owned by (Picked player))) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Owner of (Attacked unit)) is in GangTeam1) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Owner of (Attacking unit)) is in GangTeam2) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of players in GangTeam1) Less than or equal to (Number of players in GangTeam2)
Then - Actions
Player Group - Pick every player in GangTeam1 and do (Actions)
Loop - Actions
Player Group - Remove (Picked player) from GangDisputeSort
Player Group - Remove (Picked player) from GangTeam1
Player Group - Add (Picked player) to GangSmallest
Player Group - Pick every player in GangTeam2 and do (Actions)
Loop - Actions
Player Group - Remove (Picked player) from GangDisputeSort
Player Group - Remove (Picked player) from GangTeam2
Player Group - Add (Picked player) to GangLargest
Else - Actions
Player Group - Pick every player in GangTeam1 and do (Actions)
Loop - Actions
Player Group - Remove (Picked player) from GangDisputeSort
Player Group - Remove (Picked player) from GangTeam1
Player Group - Add (Picked player) to GangLargest
Player Group - Pick every player in GangTeam2 and do (Actions)
Loop - Actions
Player Group - Remove (Picked player) from GangDisputeSort
Player Group - Remove (Picked player) from GangTeam2
Player Group - Add (Picked player) to GangSmallest

THIS TRIGGER FINDS WHO IS ATTACKING WHO AND PUTS THEM INTO 1-2 SETS OF GROUPS.

THE REST OF THE TRIGGER GOES ON JUST LIKE ABOVE FOR EVERY POSSIBLE COMBINATION
1-3
1-4
2-1
ETC
And Then again for Smallest2 and Largest2
-----------------------------------------------------------------------

THE FoLLOWING LAST 2 TRIGGERS JUST PUT A LIMIT ON HOW LONG TO LOOK FOR ATTACKS
vDetected
Events
Time - Every 0.10 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GangUseTeams Equal to 4
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Number of players in GangSmallest2) Greater than 0
(Number of players in GangLargest2) Greater than 0
Then - Actions
Set AttackDetect = True
Else - Actions
Do nothing
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of players in GangSmallest) Greater than 0
(Number of players in GangLargest) Greater than 0
Then - Actions
Set AttackDetect = True
Else - Actions
Do nothing

-----------------------------------------------------------------------
TimesUp
Events
Conditions
Actions
Wait 10.00 game-time seconds
Set AttackDetect = True


08-17-2005, 02:49 AM#2
MrApples
The Trigger so far does not work.

Does picked unit work for individual units working with many units?
08-17-2005, 08:02 PM#3
MrApples
Reposted Trigger
08-18-2005, 07:59 PM#4
MrApples
How come no one posts!

I am basically trying to make a trigger that detects when a gang happens(When a team has a unfair advantage over another team) and sets the health of the units of the ganging players to a certain percent.

2vs1=50%
3vs1=33.3%
4vs1=25%
ETC

But so far it doesn't work and I've spent like 15 hours on it.
08-18-2005, 10:01 PM#5
Anitarf
I'll post this just for the sake of your thread not remaining unanswered, but I don't have a solution for you, just an explanation why not.

Figuring out what's the bug in a huge system like this that someone else wrote is not easy. The continious lack of code tags on the forums doesn't make it any easier. For me, it would be easier to make a new system from scratch... you can see by yourself how hard that is.

Futhermore, I don't see much point in what you are trying to do. I think I already mentioned this when you were doing anti tp triggers. Why try so hard to "fix" some aspects of the game which are directly inherent to it's design. If you don't like the unfairness of people teleporting and declaring war, of people ganging up, then why do you want to allow players to be able to change their alliances ingame? The only thing alliance changing in mid game is good for is precisely what you are trying to prevent, allowing the players to be treacherous bastards. So what's the point?
08-19-2005, 01:10 AM#6
MrApples
I don't know what the point is..

I do know that the actual setting life part doesn't work correctly now. Does picked unit very from action to action?

I made it so it adds all the picked units to a group and then selects one from the group and does the actions for it and loops unit the unit group is empty, but it crashes the game.