Jump to content

Success in implementing simulated surrender.


Recommended Posts

I've built a mission which uses a trigger scheme to implement a simulated ability for AI units to surrender. I'm happy to report I've had some success.

I've made the scheme general enough that it can be used in any mission with only minor tweaks. Also, several of the triggers can be used in other contexts (retrieving all of the UnitIDs in an entire army one at a time and converting strings to numbers).

The player will even be able to select guards that the prisoners will follow where ever the player likes. Currently there is no chance that the prisoners will try to escape, but I'm working on that.

Before I upload this, if anyone is interested, I'm looking for someone familier with the mission builder to look at this and give me some feedback.

Sneaksie, if you're reading this, if the team doesn't have time to implement a surrender in the add-on, could they at least include a command in the mission builder to make a unit drop all of its weapons? I think that's the main thing that's still missing with this.

Link to comment
Share on other sites

  • 2 months later...

Well chaps unless we see the code we'll never know.... :rolleyes:

I'd also be fascinated to know how Boog did this but I bet it involves a shed load of code monitoring numbers on every group which is going to be a significant overhead on what is an already a resource hungry game because I think the checks would need to be quite granular (<=5secs) so it might not be a simple as it seems at face value.

I could also find alot of uses for a piece of code that did this, I've been meaning to have a play aorund with this myself but haven't as yet found the time... :mad: So please post some code....

What really surprises me is that Slap found this thread when it had been dead for nearly 3 months, well bumped that man!

Link to comment
Share on other sites

Well code is one thing needed for sure smile.gif

My approach is actually pretty simple. There is a trigger command called ChangeArmy. It's syntax looks something like this:

</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> SET @groupName = “Group_01”

SET @newArmyIndex = 2

ChangeArmy ( "GROUP” , @groupName , @newArmyIndex )

// Changing the army of the group with the identifier Group_01 to army 2

Halt </pre>

Link to comment
Share on other sites

Obviously, working group by group, or unit by unit would be more complex than one global routine per army. It would also probably add more checks to the game as mentioned above.

It would probably be more realistic, however.

Conditions could run a wide gamut of possibilities. You could simply do random probabilities based on squad losses (or entire army, again depending on your approach) or tie the whole thing into the morale status or both.

You could also have different probabilities based on army nationality if you really want to be biased about it smile.gif . You would have to use different scripts or do additional checks for that, however.

Link to comment
Share on other sites

Ive been playing with this & managed to get some code that works ok. Need to work on getting this prettier, maybe they should retreat in column..?

The surrender conditions for germans are < 4 soldiers or less than 40% of British troops in the target rect.

</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> label 99

delay ( 5000 )

SetWorkArmy ( Army , 1 )

Set @uk_inf_In_rect = GetnunitsInArea ( Army , 1 , HUMAN , "Wood" , "NO_PANIC" )

if ( @uk_inf_In_rect > 1 ) Then

label 100

delay ( 5000 )

SetWorkArmy ( Army , 1 )

Set @uk_inf_In_wood = GetnunitsInArea ( Army , 1 , HUMAN , "Wood" , "NO_PANIC" )

SetWorkArmy ( Army , 2 )

Set @German_In_wood = GetnunitsInArea ( GROUP , "Group_wood snipers" , HUMAN , "Wood" , "NO_PANIC" )

if ( @German_In_wood <= 4 ) Then

goto 101

endif

Set @snum = @German_In_wood

div ( @snum , @uk_inf_In_wood )

mul ( @snum , 100 )

if ( @snum <= 40 ) Then

goto 101

halt

endif

goto 100

halt

endif

goto 99

label 101

SetWorkArmy ( Army , 2 )

ChangeArmy ( GROUP , "Group_wood snipers" , "4" )

delay ( 500 )

RunCommand ( ARMY , "4" , RETREAT , rect , "surrender" )

delay ( 500 )

QuestWin ( "Woods" , 10000 )

destroytrigger ( "snipers" )

delay ( 500 )

Halt

goto 101 </pre>

Link to comment
Share on other sites

Wow, there was interest.

There was some weirdness I hadn't thought of if say, they guard was killed. I had to reprogram part of it. That's fixed. Also as of now you can only have one guard, and I had wanted to plan multi-guard support. I shelved till the patch came out because I thought there was no interest. I have the files, should I post them somewhere?

There is a lot of code, but it doesn't always monitor every group. It monitors an area, then later if you do get your POWs it monitors them to make sure they are behaving themselves.

Link to comment
Share on other sites

I havent really looked at this yet but how about using this to mod a dynamic campaign?

Looking at campaign.xml files you can specify different follow-up missions depending on mission success/failure...

Why not just add some smaller, easier missions in between the main ones that only get called if the player fails.

One would then just implement and adapt surrender events/triggers to every mission for both the player and the KI.

The Player could use these easier missions to regain strength (experience) and could still be able to successfully continue his main campaign.

Using the existing campaigns, the new map-editor and surrender events this could be a pretty simple task?!

Link to comment
Share on other sites

hi,

im absolutly newbie in modding any escenario, and my knowledge about scripting is limited. But will be very interesting use this script in custom scenarios, for tourney and ladder purposes.

Is there any easy way to use "surrender script" into custom scenarios? a tutorial will be very appreciated.

Link to comment
Share on other sites

Boog

I'm having trouble with the mission. When the game starts, it is in pause mode. When I hit the space bar to take it out of pause mode, almost instantly, it goes back into pause mode?

I'm going to try loading it again. I'm not aware of any scripting issues that could cause this...I suppose you're not having this problem?

Link to comment
Share on other sites

×
×
  • Create New...