Spy Hunt

I need help making a map!

Information and discussion for custom maps and mods.
Post Reply
MirageTD
Posts: 6
Joined: Mon Jul 18, 2016 8:18 am

Spy Hunt

Post by MirageTD »

Greetings! I’ve been making maps for Red Alert 2 for a while now and I thought I’d try my hand at making something for OpenRA. So I starting poking and prodding at some of the originals that had scripting I could use as an example. The lua stuff does not make much sense to me. I’m sure I’ll be able to figure it out eventually, but I need somewhere to start.

The first thing I want to do is make a map for OpenRA that works about the same as This RA2 map. The basic idea is that one side gets a spy and has to blend in with the neutral infantry patrols while making their way to the target to infiltrate it, and the other side has to find and kill the spy before that happens.

These should be all the things I need to do to make this work:

- set up patrols of infantry and tanks
- keep the hunting side's unit(s) from automatically targeting anything
- set up a win condition for the spy's side when the target buildings have been infiltrated
- set up a win condition for the hunter's side if the spy is killed
- set up a lose condition for the hunter's side if a number of patrolling infantry units that are not the spy are killed
- implement the spy's disguise sound effect from RA2 (this isn't as important, but if it's possible that would be great)

If anyone could provide some advice as to how to go about this I could really use the help.
Last edited by MirageTD on Wed Aug 24, 2016 8:48 am, edited 1 time in total.

User avatar
r34ch
Posts: 137
Joined: Sun Mar 01, 2015 2:02 pm

Post by r34ch »

Allies mision 05 (Tanya tale) ships with the game and has many of the things you list. It would be a good place to start to pick apart the yaml.

MirageTD
Posts: 6
Joined: Mon Jul 18, 2016 8:18 am

Post by MirageTD »

Thanks for the tip. I've been using that and Fort Lonestar to try to figure out how the lua works. So far I haven't been able to do much, my patrols don't seem to be working and setting win conditions is miles off. The patrol tutorial on GitHub didn't really help much either. I did learn how to add units though...

Image
Iowa model was made by Lin Kuei Ominae

The yaml files are infinitely easier to master. Beyond patrolling I can pretty much get the units to do exactly what I want them to, so as soon as I can accomplish the simplest of lua tasks I'll be set to start making the map.

Also, I couldn't find a way to get the disguise sound working. I imagine it's possible since it was in RA2, which should mean that it is or will be a feature in OpenRA as well, but there doesn't seem to be any info pertaining to that.

User avatar
Graion Dilach
Posts: 277
Joined: Fri May 15, 2015 5:57 pm

Post by Graion Dilach »

MirageTD wrote: Also, I couldn't find a way to get the disguise sound working. I imagine it's possible since it was in RA2, which should mean that it is or will be a feature in OpenRA as well, but there doesn't seem to be any info pertaining to that.
Will be. Thank you for the reminder.
Image
Image
Image
AS Discord server: https://discord.gg/7aM7Hm2

MirageTD
Posts: 6
Joined: Mon Jul 18, 2016 8:18 am

Post by MirageTD »

I finished the map I'll be setting this up on. Couldn't figure out how to use the map renderer so I had to hack this together from screenshots...

Image

I also got pretty much all the lua stuff I need to know figured out. All I need is something that can detect when a certain number of units belonging to the AI owning the patrolling units have been lost and something to keep the AI from floating. That and the motivation to set up the gargantuan amount of patrols this'll need.
Graion Dilach wrote: Will be. Thank you for the reminder.
Not a thing yet, eh? Oh well, I'll be sure to implement it when it is.

User avatar
Murto the Ray
Posts: 487
Joined: Mon Nov 10, 2014 4:34 pm

Post by Murto the Ray »

MirageTD wrote: I also got pretty much all the lua stuff I need to know figured out. All I need is something that can detect when a certain number of units belonging to the AI owning the patrolling units have been lost and something to keep the AI from floating. That and the motivation to set up the gargantuan amount of patrols this'll need.
For tracking losses you could add an OnKIlled Trigger to each patrol unit.

For preventing floating you could just set their cash to zero (Or some other number) every X ticks.

MirageTD
Posts: 6
Joined: Mon Jul 18, 2016 8:18 am

Post by MirageTD »

Murto the Ray wrote: For tracking losses you could add an OnKIlled Trigger to each patrol unit.
Is there a way to add a trigger to a spawned unit or would they have to be pre-existing actors on the map?

abcdefg30
Posts: 641
Joined: Mon Aug 18, 2014 6:00 pm

Post by abcdefg30 »

MirageTD wrote: Is there a way to add a trigger to a spawned unit or would they have to be pre-existing actors on the map?
Sure, "Actor.Create" returns the actor created, so you can just store it in a variable. E.g.

Code: Select all

myActor = Actor.Create(...)
Trigger.OnKilled(myActor, function()
    -- Do something here
end)
Similiar with reinforcements

Code: Select all

-- myReinforcements is a table (array) containing actors
myReinforcements = Reinforcements.Reinforce(...)
Trigger.OnAllKilled(myReinforcements, function()
    -- Do something here
end)

User avatar
Murto the Ray
Posts: 487
Joined: Mon Nov 10, 2014 4:34 pm

Post by Murto the Ray »

To add to what abcdefg30 said,

if the actor is already placed on the map you can reference it by it's name in the map.yaml. This is usually something like Actor42 but you can rename it. You simply use this name in the script to reference it.

MirageTD
Posts: 6
Joined: Mon Jul 18, 2016 8:18 am

Post by MirageTD »

Murto the Ray wrote: For preventing floating you could just set their cash to zero (Or some other number) every X ticks.
I got that to work on a real player, but it doesn't seem to apply to bots.
Murto the Ray wrote: To add to what abcdefg30 said, if the actor is already placed on the map you can reference it by it's name in the map.yaml. This is usually something like Actor42 but you can rename it. You simply use this name in the script to reference it.
Yep, I've been using that to detect the infiltration of the forward command.
abcdefg30 wrote: Similiar with reinforcements

Code: Select all

-- myReinforcements is a table (array) containing actors
myReinforcements = Reinforcements.Reinforce(...)
Trigger.OnAllKilled(myReinforcements, function()
    -- Do something here
end)
Havn't had any success with this yet, I'm not sure what I'm doing wrong. But I think I found some kind of kill counter in the fourth GDI mission in Tiberian Dawn.

Code: Select all

KillsUntilReinforcements = 12

kills = 0
KillCounter = function() kills = kills + 1 end

ReinforcementsSent = false
Tick = function()
	enemy.Cash = 1000

	if not ReinforcementsSent and kills >= KillsUntilReinforcements then
		ReinforcementsSent = true
		player.MarkCompletedObjective(reinforcementsObjective)
		SendGDIReinforcements()
	end

	if player.HasNoRequiredUnits() then
		Trigger.AfterDelay(DateTime.Seconds(1), function() player.MarkFailedObjective(gdiObjective) end)
	end
end
Does this do exactly what it says on the tin or am I missing something?

abcdefg30
Posts: 641
Joined: Mon Aug 18, 2014 6:00 pm

Post by abcdefg30 »

MirageTD wrote:
Murto the Ray wrote: For preventing floating you could just set their cash to zero (Or some other number) every X ticks.
I got that to work on a real player, but it doesn't seem to apply to bots.
You probably need to set the players "Resources" to zero. There is a difference between cash and resources. Resources is the stuff inside your silos, while cash includes resources and all other income you can spend (starting money, money from bounties/oil derricks...).

In the campaign missions, however, we don't set the cash/resources to zero, so that the AI has something to spend. We just cap the resource count before the silos are full.
Here is an examples from survival01 (from inside the Tick function):

Code: Select all

if soviets.Resources > soviets.ResourceCapacity / 2 then
	soviets.Resources = soviets.ResourceCapacity / 2
end
This will prevent the silos from being filled more than 50%.
MirageTD wrote: Does this do exactly what it says on the tin or am I missing something?
Unfortunately you are, I think. The script contains many times "Trigger.OnKilled(actor, KillCounter)" (or "Trigger.OnKilled(unit, KillCounter)"). You can/should look at those lines (and the code around which creates the actor). They mean that the script calls the KillCounter function every time an actor is killed.

But yeah, looking at the existing scripts is certainly a good idea!

MirageTD
Posts: 6
Joined: Mon Jul 18, 2016 8:18 am

Post by MirageTD »

abcdefg30 wrote: Here is an examples from survival01 (from inside the Tick function):

Code: Select all

if soviets.Resources > soviets.ResourceCapacity / 2 then
	soviets.Resources = soviets.ResourceCapacity / 2
end
This will prevent the silos from being filled more than 50%.
Voila! Floating prevention achieved. Thanks, I didn't catch that map. I ought to be able to use it as a reference for some other things as well.
abcdefg30 wrote: Unfortunately you are, I think. The script contains many times "Trigger.OnKilled(actor, KillCounter)" (or "Trigger.OnKilled(unit, KillCounter)"). You can/should look at those lines (and the code around which creates the actor). They mean that the script calls the KillCounter function every time an actor is killed.
I should be able to use that kind of kill counter system to make it so, say, if the AI loses 1 patrolling unit all you get is a warning, then if it loses another one you lose the match. As soon as I get the OnKilled triggers working properly I'll be able to set that up.

Now that most of the technical stuff is out of the way this thing should be a piece of cake. I'll be sure to upload the map to the resource center when it's done.

Post Reply