Spy Hunt
I need help making a map!
Spy Hunt
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.
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.
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...
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.
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.
- Graion Dilach
- Posts: 277
- Joined: Fri May 15, 2015 5:57 pm
Will be. Thank you for the reminder.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.
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...
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.
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.
Not a thing yet, eh? Oh well, I'll be sure to implement it when it is.Graion Dilach wrote: ↑Will be. Thank you for the reminder.
- Murto the Ray
- Posts: 487
- Joined: Mon Nov 10, 2014 4:34 pm
For tracking losses you could add an OnKIlled Trigger to each patrol unit.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 preventing floating you could just set their cash to zero (Or some other number) every X ticks.
Sure, "Actor.Create" returns the actor created, so you can just store it in a variable. E.g.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?
Code: Select all
myActor = Actor.Create(...)
Trigger.OnKilled(myActor, function()
-- Do something here
end)
Code: Select all
-- myReinforcements is a table (array) containing actors
myReinforcements = Reinforcements.Reinforce(...)
Trigger.OnAllKilled(myReinforcements, function()
-- Do something here
end)
- Murto the Ray
- Posts: 487
- Joined: Mon Nov 10, 2014 4:34 pm
I got that to work on a real player, but it doesn't seem to apply to bots.Murto the Ray wrote: ↑For preventing floating you could just set their cash to zero (Or some other number) every X ticks.
Yep, I've been using that to detect the infiltration of the forward command.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.
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.abcdefg30 wrote: ↑Similiar with reinforcementsCode: Select all
-- myReinforcements is a table (array) containing actors myReinforcements = Reinforcements.Reinforce(...) Trigger.OnAllKilled(myReinforcements, function() -- Do something here end)
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
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
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.MirageTD wrote: ↑ Does this do exactly what it says on the tin or am I missing something?
But yeah, looking at the existing scripts is certainly a good idea!
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: ↑Here is an examples from survival01 (from inside the Tick function):This will prevent the silos from being filled more than 50%.Code: Select all
if soviets.Resources > soviets.ResourceCapacity / 2 then soviets.Resources = soviets.ResourceCapacity / 2 end
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.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.
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.