Login

russian armor

How-to: Abandoned vehicles in a custom map [OLD]

11 Jan 2014, 16:41 PM
#1
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

OUTDATED, PLEASE USE THIS TUTORIAL INSTEAD: http://www.coh2.org/guides/18069/worldbuilder-totw13-abandoned-vehicles





11 Jan 2014, 18:06 PM
#2
avatar of vintyara

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
Code
sbps/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
Code
t_AbandondedVehicles = {sg_panther}
so it matches your squad group name(s).
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
1 Feb 2014, 21:55 PM
#3
avatar of Bodytrauma

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?
2 Feb 2014, 08:45 AM
#4
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

I did some experiments with howitzers. I managed to "abandon" them. They had the UI showing up which displays how many soldiers you need to crew it. Clicking the howitzer does nothing. It seems like the squad is unable to crew it even though the speech plays ("now that is a big howitzer").

I'll keep doing some testing later on.
2 Feb 2014, 16:58 PM
#5
avatar of Yukiko
Admin Red  Badge

Posts: 2454 | Subs: 2

You can spawn an abandoned German arty using:
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. :P 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)
11 Feb 2014, 22:16 PM
#6
avatar of Bodytrauma

Posts: 2

Thanks Yukiko, this worked perfectly :-)
12 Feb 2014, 22:33 PM
#7
avatar of Yukiko
Admin Red  Badge

Posts: 2454 | Subs: 2

Glad to hear it. Don't thank me though, thank Matt Philip for making the Don River scenario. He placed an abandoned artillery piece there and I merely dug through the scar file to find it.
15 Feb 2014, 13:44 PM
#8
avatar of moonmire

Posts: 3

pak43 doesn't work... Do you know why?
15 Feb 2014, 21:36 PM
#9
avatar of Yukiko
Admin Red  Badge

Posts: 2454 | Subs: 2

You probably used a squad Pak43, SBP.GERMAN.PAK43_88MM_AT_GUN_SQUAD, instead of the Pak43 gun entity; EBP.GERMAN.PAK43_88MM_AT_GUN_MP. Plug the entity in and it should work.
16 Feb 2014, 01:57 AM
#10
avatar of moonmire

Posts: 3

Like this?

------------------------------------------------------------------------------------
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~~~
16 Feb 2014, 12:45 PM
#11
avatar of Yukiko
Admin Red  Badge

Posts: 2454 | Subs: 2

Oh, the <MARKER ALLY SPAWN> is a place holder for a marker ID of type; ally spawn. You can place markers in the Worldbuilder onto the map, that is where the Pak43 will spawn.
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>.
16 Feb 2014, 14:35 PM
#12
avatar of moonmire

Posts: 3

THANKS YOU~ THANKS YOU~ THANKS YOU~
16 Feb 2014, 14:47 PM
#13
avatar of Yukiko
Admin Red  Badge

Posts: 2454 | Subs: 2

It seems it worked for you, have fun with your map! :3
25 Jul 2014, 03:19 AM
#14
avatar of Tyknapp

Posts: 16

I am having problems with the whole Abandoned vehicle situation. I used the commands and such as mentioned in the tutorial and most of the map's vehicles that are suppose to be abandoned are not. Every time I go ahead and load the map as well, it gives me a Scar error message and pauses the game, help?

*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.
25 Jul 2014, 08:59 AM
#15
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

I'm glad you managed to solve your problem on your own!

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
9 Sep 2014, 13:13 PM
#16
avatar of bogatyrsiluwka

Posts: 11

how to make the abandoned vehicles damaged for 90 percent?

function OnInit()
Cmd_CriticalHit(World_GetPlayerAt(1), eg_vehicles, CRIT.VEHICLE_ABANDON, 90)
end

Scar_AddInit(OnInit)


like this?
9 Sep 2014, 14:43 PM
#17
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

Assuming if that parameter is the removed health, it should be 0.9 instead of 90.
25 Oct 2014, 16:45 PM
#18
avatar of Tyknapp

Posts: 16

I don't know what category this fits into, so I am just placing this here. Is there a way to place units that are hostile to all players on the map?
25 Oct 2014, 16:47 PM
#19
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

I don't think that's possible as technically there's only 3 teams: 0, 1, and neutral.
5 Nov 2014, 22:34 PM
#20
avatar of Tyknapp

Posts: 16

How would I add infantry for a set team, like I want some volks for player 1 when the game starts, how do I do so?

I tried setting their player thing in world builder to the according player, but it does not work.
1 user is browsing this thread: 1 guest

Livestreams

unknown 8
Germany 1

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

478 users are online: 1 member and 477 guests
aerafield
0 post in the last 24h
6 posts in the last week
38 posts in the last month
Registered members: 49060
Welcome our newest member, starkindustries
Most online: 2043 users on 29 Oct 2023, 01:04 AM