How-to: Abandoned vehicles in a custom map [OLD]
Posts: 3421 | Subs: 11
Posts: 10
How-To: Abandoned vehicles in a custom map
Basics
In this tutorial you will learn how to add vehicle of your choice as abandoned to your map. To do this, you will need a basic text editor. Microsoft Notepad is suitable for this job and you already have it. In case you'd like to consider getting a bit better tool for this, I would recommend using notepad++, which you can download from notepad-plus-plus.org
Important Note
One thing you should notice and understand before going any further:
Every time you save your map in WorldBuilder, <yourmapname>_ID.scar will be re-generated by the WorldBuilder. This means you have to add the code every time after saving the map if you wish to export the package. If you haven't saved your map yet, do it now!
Map Files
Have you ever looked into your map folder? Perhaps you have and you know there are bunch of files laying around related to your map. For example the <yourmapname>.sgb file, which is the main file containing all the data of your map. There are also other files, such as <yourmapname>.tga, <yourmapname>.info, <yourmapname>.options, and <yourmapname>_ID.scar.
The one we are interested in this tutorial is <yourmapname>_ID.scar.
<yourmapname>_ID.scar file
Well, what is this file in particular and why are we so interested about it?
<yourmapname>_ID.scar contains the list of Scar markers, entity groups aka. egroups, and squad groups aka. sgroups from your map. This file is sort of a directory of items listed above. This file also gives us the ability to include custom SCAR script to the map. In this tutorial we will use it for a very basic implementation.
Creating a Squad group
To begin with, place a vehicle of your choice to your map. For example, you could use panther, which is located in
Codesbps/races/german/vehicles/panther_squad/
Select it and Press Control + U to create a new squad group. Alternatively you can goto "Groups" and select "Create Squad Group".
Give the new squad group a name. I would recommend using "sg_" prefix for squad groups. In this case you could name the panther squad group as "sg_panther". Click OK and save the map.
Adding code to apply vehicle abandon actions
Open <yourmapname>_ID.scar in notepad / notepad++. It should look something like this (notice the "sg_panther" squad group appearing in the list):
Code
function OnInitID()
-- [[ Markers ]]
-- [[ Squad Groups ]]
sg_panther = SGroup_CreateIfNotFound("sg_panther")
-- [[ Entity Groups ]]
end
Normally, when no Scar markers are placed nor squad/entity groups assigned (sgroups and egroups) <yourmapname>_ID.scar will look exactly like this.
However, you should be able to see the panther squad group definition below "-- [[ Squad Groups ]]"
Let's get into adding code which applies the abandon action to the panther squad:
Add the following code above last occurring "end"-word in the file:
Code
local t_AbandondedVehicles = {sg_panther}
local player = World_GetPlayerAt(1)
for key, sgroup in ipairs(t_AbandondedVehicles) do
Command_PlayerSquadCriticalHit(player, sgroup, PCMD_CriticalHit, BP_GetCriticalBlueprint("vehicle_abandon"), 1, false)
end
The result should look something like this:
Code
function OnInitID()
-- [[ Markers ]]
-- [[ Squad Groups ]]
sg_panther = SGroup_CreateIfNotFound("sg_panther")
-- [[ Entity Groups ]]
-- List all vehicles to abandon in this table. Use comma as separator.
local t_AbandondedVehicles = {sg_panther}
local player = World_GetPlayerAt(1)
for key, sgroup in ipairs(t_AbandondedVehicles) do
Command_PlayerSquadCriticalHit(player, sgroup, PCMD_CriticalHit, BP_GetCriticalBlueprint("vehicle_abandon"), 1, false)
end
end
Double-check
Codeso it matches your squad group name(s).t_AbandondedVehicles = {sg_panther}
In case of multiple squad groups, use comma (",") as a separator.
e.g.
Code
t_AbandondedVehicles = {sg_panther, sg_stug, sg_halftrack}
Testing the results
Save the <yourmapname>_ID.scar and close the file. Goto WorldBuilder and DO NOT SAVE the map! You should have done that earlier. Just do File -> Export Package, run the game, start a match with your map. You should now be able to enjoy your freshly abandoned vehicle!
Configuring the code to match your needs
Adding and removing squad groups from the list should be easy. You can always take a look at the list in WorldBuilder by selecting "Groups" -> "Squad Group List".
Conclusions
In this tutorial you learned how to add abandoned vehicles to your map. I tried to spend some time to explain stuff a bit more briefly instead of making this tutorial as humanly short as possible. Hopefully this will give you a better understanding of what you did instead of just adding the code to a file and getting results without knowing why. If you have any additional questions, feed back, or suggestions for future tutorials, please let me know in this thread!
tnx all work! respect autor
Posts: 2
How-To: Abandoned vehicles in a custom map
Thanks for this great tutorial! Any way to get this to work for German 105mm artillery? The game loads fine right up to the point where I "Press Any Key" to begin and then it crashes to the desktop (Bugsplat).
I'm using:
sbps/races/german/vehicles/howitzer_105mm_le_fh18_artillery/howitzer_105mm_le_fh18_artillery
The howitzer_105mm_le_fh18_artillery_mp version doesn't work either.
If I place ebps/races/german/team_weapons/german_field_artillery/howitzer_105mm_le_fh18 (or the mp version) without using an entity group, the artillery piece shows as abandoned but nobody can crew it.
Any ideas?
Posts: 3421 | Subs: 11
I'll keep doing some testing later on.
Posts: 2454 | Subs: 2
Util_CreateEntities(nil, eg_howy, EBP.GERMAN.HOWITZER_105MM_LE_FH18_MP, <MARKER ALLY SPAWN>, 1 )
Do remember to place a marker to make it work. No idea as to what the internal ID name for the B-4 203mm is yet though. Also, I found another way of abandoning vehicles using:
Cmd_CriticalHit(World_GetPlayerAt(1), <SQUAD GROUP>, CRIT.VEHICLE_ABANDON, 1)
Posts: 2
Posts: 2454 | Subs: 2
Posts: 3
Posts: 2454 | Subs: 2
Posts: 3
------------------------------------------------------------------------------------
function OnInitID()
--Population cap override value
g_popCapOverRide = 200
for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
Player_SetPopCapOverride(player, g_popCapOverRide)
end
-- [[ Markers ]]
-- [[ Squad Groups ]]
sg_soldiers = SGroup_CreateIfNotFound("sg_soldiers")
sg_vehicles = SGroup_CreateIfNotFound("sg_vehicles")
-- [[ Entity Groups ]]
eg_weapons = EGroup_CreateIfNotFound("eg_weapons")
Util_CreateEntities(nil, eg_pak43, EBP.GERMAN.PAK43_88MM_AT_GUN_MP, <MARKER ALLY SPAWN>, 1 )
end
------------------------------------------------------------------------------------
and What is <MARKER ALLY SPAWN> ??
plz... More detail~~~
Posts: 2454 | Subs: 2
Place one and save, so that you will see the marker ID under -- [[ Markers ]] and before -- [[ Squad Groups ]]. Take that ID and place it instead of <MARKER ALLY SPAWN>.
Posts: 3
Posts: 2454 | Subs: 2
Posts: 16
*Edit
All vehicles are listed below that were used:
Sturmtiger, jagdtiger, panther, t-34/76 -2 of them, t-34/85, is-2, Zis 6 trucks-8 of them,
luchs, regular sherman, easy eight(sherman),
*Another Edit
Welp, I solved my own problem, I repeated the same vehicle twice, now it works.. Thanks for the tutorial though.
Posts: 3421 | Subs: 11
Here's an up to date version of this tutorial which uses a better method: http://www.coh2.org/guides/18069/worldbuilder-totw13-abandoned-vehicles
Posts: 11
function OnInit()
Cmd_CriticalHit(World_GetPlayerAt(1), eg_vehicles, CRIT.VEHICLE_ABANDON, 90)
end
Scar_AddInit(OnInit)
like this?
Posts: 3421 | Subs: 11
Posts: 16
Posts: 3421 | Subs: 11
Posts: 16
I tried setting their player thing in world builder to the according player, but it does not work.
Livestreams
7 | |||||
177 |
Ladders Top 10
-
#Steam AliasWL%Streak
- 1.655231.739+15
- 2.842223.791+5
- 3.943411.696-1
- 4.715.934+12
- 5.35659.858+2
- 6.599234.719+7
- 7.278108.720+29
- 8.307114.729+3
- 9.269143.653+2
- 10.10629.785+7
Replay highlight
- cblanco ★
- 보드카 중대
- VonManteuffel
- Heartless Jäger
Board Info
13 posts in the last week
32 posts in the last month
Welcome our newest member, Tamrio32892
Most online: 2043 users on 29 Oct 2023, 01:04 AM