|
|
|
|
# 1 |
|
Member
Join Date: Jun 2007
|
[ScAR] Automatic Territory Capture v1.15.9
Hello everybody.
I've got a useful scar code to post. What it does This code checks for squad and entity count in each territory and when there's more or equal points (squads) than set in settings for that territory, it is automatically captured by that player and team. There are tons of additional settings like what to do with sectors which have no units in them, which have both teams in them etc (Below is the full list of them) Thanks to Jarhead for the idea, helping and providing of all the useful suggestions and notes about the code, -=Firefly=- for all the reports, 1SSPzGrenLehr for all the reports, Halftrack for the reports and suggestions, Sturmhaubitze for his suggestions, UberBugz for reports and suggestions and all the other people who in any way helped and supported me in development of this code. Changelog [ v1.15.9 ] 27-12-2008 - Fixed a nil table bug for upgrades (probably a temporary fix, hard to find a reason for this) [ v1.15.8 ] 24-12-2008 Thanks to UberBugz for reporting these issues - Fixed Issue with units not capturing secured friendly sectors - 'Exclude in buildings' setting set to true due to the bugs it's causing. I'll try to do something about this shortly. Already thought of a way which could help (I'm not so sure if it actually will) but it would require lots of re-scripting. [ v1.15.7 ] 19-12-2008 - Added a readme (UberBugz suggestion) and fixed some comment typos - Added additional comments and explanations for UpgradeSystem [ v1.15.6 ] 27-07-2008 Walkaround for another issue reported by Firefly, thanks for the reports man ![]() [ v1.15.5 ] 27-07-2008 Fixed the cleanup issue [ v1.15.4 ] 26-07-2008 Performance issues reported I'm making minor improvements which may result in a complete fix and may not too... [ v1.15.3 ] 14-07-2008 - Fixed another scar error with SGroups, created specialized function to prevent any SGroup or EGroup errors like that in the future - Changed the upgradesystem a bit, upgrade is nil may stop appearing now. [ v1.15.2 ] 05-07-2008 - Fixed scar error when squads were in hold of vehicles [ v1.15.1 ] 25-06-2008 - Fixed the game start error (Yet again some luaconsts references for my mod, sorry about that, should have known) [ v1.15 hotfixed ] 23-06-2008 - Fixed bug when playing with 3 or more players (team detection) [ v1.15 ] 22-06-2008 - Fixed save games in skirmish - Fixed Campaign! (Save games are not yet fully properly working, points become visible after game load) - Added squad detection in vehicles. - 'Exclude in vehicles' setting added - Fixed UpgradeSystem bug. - Points owned by other player at the game start have automatically assigned 100% capture percentage - Points are no longer being copied unless they are hidden - Dynamic information will not be displayed when mouse is on the task bar on show setting 4 - Dynamic information position tweaked - Redone lots of things about team detection. Now will detect teams properly if there's also a neutral team (that's one of the things fixing the compaign) - Fixed bug with 'SP Copies' setting. Would probably crash if disabled from game start - Updated some things in varutil.scar [ v1.14 ] 16-06-2008 Thanks for Halftrack for the reports and ideas Added very useful new setting for squad member count detection and use with ATC, if set to true will count squad members and increase their capture rate with it. (2 members have 2x capture rate, that's why i modified lots of settings to make this go properly) - Fixed a bug with upgrade system. Allies could receive that bug for their 2nd upgrade, now won't. - Changed some code structure - Lots of settings changed - Added settings: * 'If no units present in the sector: Min points to decrement to' * 'Use squad member count' * 'Dynamic information' > * 'Percent' > * 'Show max points' > * 'Show enemy points' [ v1.13 Beta ] 11-06-2008 This is a beta release, although i'm pretty sure it will work very well. It's the 13th though plus lots of changes are done, so i guess it's reasonable ![]() But seriously - I still need to test what happens if the validate upgrades get enabled and disabled for a couple of times, since i already had so much troubles with it. If you play a long and full game with Brits and won't find any bugs, tell me ![]() Don't forget to set g_ATC_Enable to true in the beginning of the file, otherwise it will be disabled. Forgot about this by accident - Fully commented and completed the main concept of upgrade system - Added various new upgrades: * Axis capture 1.2x faster when there's an officer in the field * Commonwealth capture faster with number of lieutenants in the field. +0.1, 0.2, 0.3 to the overall capture rate. * Commonwealth capture faster if a commander is present on the field: +0.3 to overall capture rate. * Commonwealth tanks can capture territory if there's a command tank in the field, each tank gets a separate capture rate. - added a new file with the archive called varutil.scar. It contains useful scar functions that are usually required for coding. Feel free to use it - Fixed the float number display, was showing too many numbers after the dot, now rounds to two. - Changed many default settings * All strategic points (except Victory Points, still didn't touch them) are invisible now * Checks are performed more frequently - 2 times per second * 'Min points to capture' are now set to 10 * 'Capture Incremental: max points' are now 100 * 'If no units present in the sector' is now 3 - increases the points by 0.05 with each check * Commonwealth default capture rate is now 0.9 instead of 1 - New settings: * 'If no units present in the sector' setting 3 allowing increasing or decreasing the points slowly for each sector if no units are present. * 'If no units present in the sector: Increment' for the 3rd 'If no units present in the sector' setting * 'SP Copies' - creates a copy of all the strategic points this number higher (or lower if negative) then the original points. Allows leaving the strategic point icons visible on minimap and show income of each point on the tactical map (although the icons remain grey all the time, even if the sector is captured) The settings A whole code is with comments and easy to use. Here are the available settings Code:
Last edited by AGameAnx : 27th Dec 08 at 1:22 AM. |
|
|
|
# 3 |
|
Member
Join Date: Jan 2007
Location: England
|
Superb! Havent got round to downloading it yet, still at work, working hard obviously
How does the AI handle it? What about secured sectors? (in my mod sectors will be secured in another fashion, but still secured never-the-less) It would be good to exclude some squads from this? i.e. sniper etc, although you already mentioned that for future development. Ill be downloading it later for testing. Thanks once again!!! |
|
|
|
# 4 |
|
Member
Join Date: Jun 2007
|
Alright, i can confirm that ["Sector - If Enemy Is Present"] is not working fine. I've been fixing it for past 2 hours. Making a small change, playing a game in my mod, making a small change, playing another game
|
|
|
|
# 6 |
|
Member
Join Date: Jun 2007
|
I've been meaning to reply on that. I've fixed a lot of other stuff too, also added squad excludes allready. I'll post the current code now, it is working, but i believe the enemy in territory is not yet doing anything, not sure why.
Since you see me losing against AI (i did no changes since adding this code), you don't really have to make anything with this. Unless raise help_ext, then i think they walk by groups more. It worked out pretty good. |
|
|
|
# 7 |
|
Member
Join Date: Jan 2007
Location: England
|
Interesting, I'll give a test now..
Hmmmm just looking through the code, is there supposed to be 2 elseif statements "elseif ATC_Settings["Sector - If Enemy Present"] == 2", or is the second supposed to be set to 3? Code:
Just played a quick game which seemed to work pretty well. Although, the AI needs to view each sector for capture the same way it does a normal point, so sending enough capture squads to capture it. |
|
|
|
# 8 |
|
Member
Join Date: Oct 2006
|
So when you say that the "If Enemy Present" setting isn't working, what happens when an enemy enters a sector you currently control and have squads in?
I'd prefer to have it so that you can't capture a sector until every enemy in it is removed. Another possibility is that you must have the minimum amount needed to capture and outnumber the enemy by a certain ratio (2 to 1, maybe?). Maybe that could be added in once you've debugged it. For the upgrades idea, one possibility is a list of "potentially included" squads, with each entry having a table that lists the upgrades needed to qualify as a capturing squad. Code:
So in the above example, the axis sniper is included if the player has a certain upgrade, OR if the sniper has two certain squad upgrades. It basically gets parsed the way binary_expr and unary_expr requirements are in RGDs, recursively traveling through the logical statement. |
|
|
|
|
# 9 |
|
Member
Join Date: Jan 2007
Location: England
|
Also this is a setting, but I dont see it mentioned in the code?
Code:
I cant write the code but I'm quite good at understanding it.. in the []ATC_UpdateData function all players are parsed in to the ATC_TerritorySquads. In the ATC_Check, I think only players 1 and 2, maybe? Just going to run some more tests .. It has something to do with this line - Code:
As I ran a print line, and the log shows no matter what I did, it ran the else statement, not the piece of code in this IF statement. Last edited by Jarhead : 6th May 08 at 3:24 PM. |
|
|
|
# 11 |
|
Member
Join Date: Oct 2006
|
By the way, tried the following:
Code:
Territory is only captured if you have the minimum squads needed, and there's no enemies in the territory. Works like a charm, and is what I needed. Thought I'd post in case someone else wanted that functionality too. |
|
|
|
|
# 12 | ||||||
|
Member
Join Date: Jun 2007
|
Guys, i'm sorry for that last post, i was really busy and the code was not finished. As you can see i've even made rules for the same thing. I'm gonna fix it right up right now.
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
I hope i didn't forget to reply to something ![]() Thanks for your replies guys, but i repeat, that last version was released in a huge rush, just like the first one. I'm gonna spend more time on it today. |
||||||
|
|
|
# 13 |
|
Member
Join Date: Jan 2007
Location: England
|
Hi thanks for the reply.. dont worry about it. Its a great idea, as you can tell myself and Sturm are both interested in it.
So keep up the good work ![]() Can I ask, the main check code allocates points to players 0 and 1. What happens if there are multiple players? Will it still work? |
|
|
|
# 14 |
|
Member
Join Date: Jun 2007
|
I found the error and posting a new version now.
The count function wasn't counting the friendly territory squads. All should be fixed now. ![]() @Jarhead not to players, but to teams To a random player of that team to be exact. I can't do much to make territory be captured by the player which has more squads in the sector now. But it's possible to make thatLast edited by AGameAnx : 7th May 08 at 7:09 AM. |
|
|
|
# 15 |
|
Member
Join Date: Oct 2006
|
One thing I tried is editing the EBPs of the sector points so that they would disappear. After all, no need for them to be visible and physical objects if the sector is captured automatically. I did this by setting the "visible in game" value to false in their entity blueprint. This had the unfortunate side effect of making the AI lethargic, as it couldn't see the points anymore and didn't budge to cap anything. It didn't start moving until it's attack timer hit zero, then it went to attack me and only captured the sectors along the way.
So everyone will need to keep the points visible, but I think there might be ways to have it unobtrusive. |
|
|
|
|
# 19 |
|
Member
Join Date: Jun 2007
|
It works, AI captures them
Posting the updated version.It's also has a serious fix in there. You would get a scar error each time you have your territory neutraled by enemy EDIT: To answer your questions Jarhead - i'm pretty sure it is not possible to make AI walk by groups to capture, what we can do with AI is change it's choises, what will it do when he decides to buy things, what tasks to perform next etc, But not HOW to perform those tasks. And those tactics that are allowed to edit are not really very editable, yet again changing some conditions in there allowed only. So i wouldn't hope that someone will think of the way to do this. Although i made it possible to hide Strategic Points with SCAR, at least that way AI went capturing them and was doing pretty well. And when min squads to capture is set to two it's pretty easy for AI to capture anyway. At least in my mod - units come in platoons there, by 3 or 2 squads, so AI usually uses them in groups. Last edited by AGameAnx : 7th May 08 at 10:47 AM. |
|
|
|
# 20 |
|
Member
Join Date: Jan 2007
Location: England
|
Just about to try this version out
![]() Great work... work really well, and great fun too!! Although sometimes, although I had ["If Enemy Present"] = 4. The territory sector kept changing hands whilst enemies were present from both sides. Once again, very, very good work! |
|
|
|
# 21 |
|
Member
Join Date: Oct 2006
|
Gave the new code a try, and it works like a charm for me. I noticed one AI squad passing through various territories I had claimed, but since I had cut them from the supply sector all they could do was neutralize them. The territory they were in was theirs, but not in supply, then they'd leave and the sector would go to neutral.
I suppose one possibility is to not allow a capture if the territory wouldn't be in supply, and instead only neutralize it. Is it possible to check for this before doing a capture? |
|
|
|
|
# 23 |
|
Member
Join Date: Jun 2007
|
Thanks for positive replies
![]() Hmm, unless something is yet again wrong with the functions finding squads in the territory, this couldn't have happened ![]() If you are right about both teams being on that sector than that condition in there would be met, and there's no way it could change territory owner from there to another player, unless the setting was 2 or 3. I've just went through the code with my eyes yet again... I will have to play-test this tomorrow. Too late for today, just wanna take my last 15 minutes and listen to some music ![]() EDIT: OMG ninja'd by 2 posts EDIT2: Storm, good idea yet again, although I'm not very sure i can test properly if it will be in supply after capturing. I'll have to make it first go captured and then checked if it is in supply and then make it neutral if it's not. Will give this a try tomorrow and see how it'll work out Jarhead, that's going to TODO list Last edited by AGameAnx : 7th May 08 at 11:56 AM. |
|
|
|
# 24 |
|
Member
Join Date: Oct 2006
|
Weird, I just did a skirmish where sectors were never permanently captured. As soon as you left, they reverted to neutral, even if they were in supply.
I didn't change anything in the atc scar, though I did make a new win condition that checked what percentage of the map a team controlled. Don't see how that would 'cause this though. EDIT: I found the problem. You're only getting a list of players for the Allied team, so if Axis captures a sector it won't return true for the World_IsInSupply function. You'll need to check for TeamID 0 and 1 together, not just 0. Last edited by Sturmhaubitze : 7th May 08 at 1:31 PM. |
|
|
|
|
# 26 |
|
Member
Join Date: Jun 2007
|
Alright, i've decided to make big changes to the code. Adding per army settings, timers for capture (points, read below), checking squads in buildings, captured buildings, emplacements.
It will now be possible to make different squads capture with different speeds. Territory is captured by points, not squads counts (hope i'll add a setting for this too). This will take a lot of time to make... |
|
|
|
# 27 |
|
Member
Join Date: Jun 2007
|
v1.3 beta released
1.3 beta Release, Cheers!
Didn't expect it to work out so good. Spent all my free time on this today, but all those new changes won't be working so fast, so please report bugsAt least the game works fine, but i think there's something wrong with buildings still... Last edited by AGameAnx : 8th May 08 at 12:16 PM. |
|
|
|
# 28 |
|
Member
Join Date: Jan 2007
Location: England
|
Nice one.. ill give it a whirl right now!
Few suggestions reading the code: What about mobile units that secure sectors? Or other entities? My idea was to have the forward bases secure sectors for example Also when I use ["If Enemy Present"] = 4, I dont want the enemy to outnumber me by anything, just to conquer that sector. Is it not possible to have the sector allocated to the player with the most points of the winning team? Last edited by Jarhead : 8th May 08 at 3:29 PM. |
|
|
|
# 29 | |||
|
Member
Join Date: Jun 2007
|
Quote:
Quote:
![]() Quote:
Last edited by AGameAnx : 9th May 08 at 2:41 AM. |
|||
|
|
|
# 30 |
|
Member
Join Date: Jan 2007
Location: England
|
Thanks for the responses.
Also, when I played a 2v2 game with 3 AI's, the AI on my own team didnt do anything, which was Axis incidently. The other 2 Allied players were a bit difficult to say the least by myself |
|
|
|
# 31 |
|
Member
Join Date: Jun 2007
|
Hmm, interesting. Although I can't think of something with the code, there's nothing with AI in it, just that strategic point hide, which could have caused it... I wouldn't say the new code could do that...
Last edited by AGameAnx : 9th May 08 at 3:40 AM. |
|
|
|
# 32 |
|
Member
Join Date: Oct 2006
|
It might have something to do with the map. I've noticed that the AI in the bottom right corner of Lyon 4p sometimes does nothing for most of the game. Like it literally will not build anything, and just produces engineers and observation posts. Other times it builds, but doesn't attack, and just stockpiles its units around the strategic point that's near the road, forest, and the buildings close to the river. This occurs in the regular unmodded game.
|
|
|
|
|
# 33 |
|
Member
Join Date: Jan 2007
Location: England
|
Ahhhh funny I was playing on that map too... the enemy Allied forces both built up and advanced heavily, where I got creamed lol The previous game on Linden, the AI advanced on both sides for a good slug match.
Ill check it again on the Linden again.. |
|
|
|
# 35 |
|
Member
Join Date: Jan 2007
Location: England
|
I played it again, and again the AI on my team captured some sectors.. but then retreated back to his HQ.. built lots of forces which never left about 3 sectors. He did however manage to build an OP on a non-exsitent SP
Gonna play around with the setting some more, see if it is anything to do with my setup? |
|
|
|
# 37 |
|
Member
Join Date: Jun 2007
|
UpgradeSystem
I'm currently working on another useful Scar code named UpgradeSystem. This will help improve this code with upgrade support etc.
I'm looking for some ideas now. Here's the example of the code, i hope someone will make some notes about it: Code:
I'm thinking to rename the whole thing aswell, but i'm not very sure of the new name. It would look like RequirementActionSystem? What do you think? |
|
|
|
# 38 |
|
Member
Join Date: Jan 2007
Location: England
|
Great idea..
Im looking for some more help again. This code works, as in it has no errors, however doesnt do what it supposed too. Any ideas? Code:
|
|
|
|
# 42 |
|
Member
Join Date: Jan 2007
Location: England
|
Instead of storing team data, I was trying to store each players data per sector. Just renamed some of the variables to make them easier to understand for a simpleton like me
then for each sector check for the winning team and allocate this sector to the player of the winning team with the most units present. And, depending what SGroup_TotalMembersCount function does exactly, count the number of soldiers instead of squads?When I ran the code and solved all the errors that came up, the code appears to run without error. When a unit moves into a sector, nothing happens. Just the AI capturing invisible sector points. |
|
|
|
# 44 | |
|
Member
Join Date: Jun 2007
|
Jarhead, i'm starting to think i had a mistake in my own code in this line:
Quote:
Changed it to: Code:
|
|
|
|
|
# 46 |
|
Member
Join Date: Jun 2007
|
Released 1.5 Proper.
This version was mainly a fix of all kinds of bugs, no upgrades are yet supported The incremental capturing is finally playable, i've been trying to fix as many bugs as i can. Hope someone is still interested in this, there was so many bugs it was impossible to play with this, lol |
|
|
|
# 47 |
|
Member
Join Date: Jan 2007
Location: England
|
Just reading your new code, the last part of the Update has a variable Enemy, which doesnt appear to be used, should it have been?
Code:
|
|
|
|
# 49 |
|
Member
Join Date: Dec 2007
|
I am having some issues trying to get this to work at all... I followed the directions to the letter and have the atc.scar and all other things in the Mod, I am not sure what "spaces" means - is that line spaces or spaces inbetween code?
Just curious, why not instead of pasting code here, just save the file and post it so that we don't have to cut and paste with notepad and all... then the forum wouldn't put spaces in it... just a .rar file with the a working atc.scar and scarutil.scar in it? |
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|