Login

russian armor

World Builder - Only Infantry Scripting?

4 Mar 2014, 17:07 PM
#1
avatar of AGPHeaddikilla

Posts: 9

Hello CoH2 Community,

I have an question: How does it work, that only one Team have no Vehicles and no mortars on their side. The other Team is normally equipped.

Please can anyone help me?


Vincent

-_-
4 Mar 2014, 17:12 PM
#2
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

Yep, this is possible. Here's my tutorial on how to disable all vehicles for all players: http://www.coh2.org/guides/13451/how-to-infantry-only-mode-in-a-custom-map
4 Mar 2014, 17:15 PM
#3
avatar of AGPHeaddikilla

Posts: 9

Must I enter the ID's of the possible units, that I want to change? Or do you know how the ID of the Mortar is?...

And how can I get it work on ONE side?

But Thanks for the Link

;D
4 Mar 2014, 17:41 PM
#4
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

You would have to extract AttributeArchive in order to get your hands to luaconstsauto.scar - it contains all ID's.

One side?
Code

for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
--team 0 or 1
if Player_GetTeam(player) == 0 then
-- disable vehicles
end
end
4 Mar 2014, 17:52 PM
#5
avatar of AGPHeaddikilla

Posts: 9

Should it looks like this format? Or I dont understand it.

Code
for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
--team 0 or 1
if Player_GetTeam(player) == 1 then
-- disable vehicles
"su_85_mp","t_34_76_green_mp","t_34_76_mp","t_34_85_mp","t_34_85_red_banner_mp","t_70m_mp","us6_truck_mp","zis_6_transport_mp",
end
end
4 Mar 2014, 18:00 PM
#6
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

You should get started with learning the basics of lua first:
Quide: http://www.lua.org/pil/1.html
Browser demo to run Lua code for testing: http://www.lua.org/demo.html
4 Mar 2014, 18:08 PM
#7
avatar of AGPHeaddikilla

Posts: 9

I wont get on nerves, but I need the answer quickly.
Can you give me an example for my Problem?


I want to learn Lua and I know i need a lot of time and I cant learn all on a day.

But please send me an example

:D

EDIT: And I'm sorry about your Text Mark(--disable vehicles), I understood it as:

Code
--disable vehicles
(here the ID's)


Or was my idea right?
4 Mar 2014, 18:32 PM
#8
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

You should take a look at the code in this tutorial http://www.coh2.org/guides/13451/how-to-infantry-only-mode-in-a-custom-map and see what is going on.
Basically it scans SBP tables from luaconstsauto and spawns them for testing. If the spawned squad is a vehicle, it will be disabled:
Player_SetSquadProductionAvailability(World_GetPlayerAt(i), sbp, ITEM_REMOVED)
And then removed from the map. All of this is happening in less than a second.
4 Mar 2014, 18:58 PM
#9
avatar of AGPHeaddikilla

Posts: 9

And how can I add one Infantry Unit to the "BlackList"?

4 Mar 2014, 19:03 PM
#10
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

You could add it to the _skip_sbp table, e.g.
Code

[3] = {
name = "pm-82_41_mortar_squad_mp",
isVehcle = true,
},


Note the increasing table key [n]
4 Mar 2014, 19:14 PM
#11
avatar of AGPHeaddikilla

Posts: 9

Is this right(With the one Team):
Code
for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
--team 0 or 1
if Player_GetTeam(player) == 0 then
local _vehicleAbilities = {
"mechanized_grenadier_group", "supply_truck", "tiger_tank", "mortar_halftrack", "elefant_unlock", "tiger_tank_ace", "stug_short_barrel", "stug_iii_e", "armor_commander",
"mechanized_assault_group", "cmd_kv-8_unlock_mp", "cmd_advanced_t34_85_medium_tank", "cmd_t34_85_medium_tank", "cmd_isu-152", "cmd_is2_heavy_tank", "cmd_kv-1_unlock","kv-2",
}

local SBP_IsVehicle = function(sbp)
--Skip problematic squads (pak creates splats, panzer_iii causes an error due to not existing yet)
local _skip_sbp = {
[1] = {
name = "pak43",
isVehcle = true,
},
[2] = {
name = "panzer_iii",
isVehcle = true,
},
[3] = {
name = "pm-82_41_mortar_squad_mp",
isVehcle = true,
},
[4] = {
name = "hm-120_38_mortar_squad_mp",
isVehcle = true,
},
[5] = {
name = "partisan_squad_granatewerfer_34_81mm_mortar_mp",
isVehcle = true,
},
[6] = {
name = "partisan_squad_pm-82_41_mortar_mp",
isVehcle = true,
},
[7] = {
name = "granatewerfer_34_81mm_mortar_mp",
isVehcle = true,
},
}
local isVehcle = false
local pos = World_Pos(-512, -512, -512)
local skipSBP = false

for key, _sbp in ipairs(_skip_sbp) do
if string.find(BP_GetName(sbp), _sbp.name) then
isVehcle = _sbp.isVehcle
skipSBP = true
end
end

if not skipSBP then
local squad = Squad_CreateAndSpawnToward(sbp, World_GetPlayerAt(1), 1, pos, pos)
local entity = Squad_EntityAt(squad, 0)
if Entity_IsOfType(entity, "vehicle") and not Entity_IsOfType(entity, "team_weapon") then
isVehcle = true
else
isVehcle = false
end
Squad_Destroy(squad)
end
return isVehcle
end

for key, race in pairs(SBP) do
for key, sbp in pairs(race) do
if SBP_IsVehicle(sbp) then
for i = 1, World_GetPlayerCount() do
Player_SetSquadProductionAvailability(World_GetPlayerAt(i), sbp, ITEM_REMOVED)
end
end
end
end

for key, abp in ipairs(_vehicleAbilities) do
for i = 1, World_GetPlayerCount() do
Player_SetAbilityAvailability(World_GetPlayerAt(i), BP_GetAbilityBlueprint(abp), ITEM_REMOVED)
end
end
end
end


or this:
Code
for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
--team 0 or 1
if Player_GetTeam(player) == 0 then
-- disable vehicles
end
end

local _vehicleAbilities = {
"mechanized_grenadier_group", "supply_truck", "tiger_tank", "mortar_halftrack", "elefant_unlock", "tiger_tank_ace", "stug_short_barrel", "stug_iii_e", "armor_commander",
"mechanized_assault_group", "cmd_kv-8_unlock_mp", "cmd_advanced_t34_85_medium_tank", "cmd_t34_85_medium_tank", "cmd_isu-152", "cmd_is2_heavy_tank", "cmd_kv-1_unlock","kv-2",
}

local SBP_IsVehicle = function(sbp)
--Skip problematic squads (pak creates splats, panzer_iii causes an error due to not existing yet)
local _skip_sbp = {
[1] = {
name = "pak43",
isVehcle = true,
},
[2] = {
name = "panzer_iii",
isVehcle = true,
},
[3] = {
name = "pm-82_41_mortar_squad_mp",
isVehcle = true,
},
[4] = {
name = "hm-120_38_mortar_squad_mp",
isVehcle = true,
},
[5] = {
name = "partisan_squad_granatewerfer_34_81mm_mortar_mp",
isVehcle = true,
},
[6] = {
name = "partisan_squad_pm-82_41_mortar_mp",
isVehcle = true,
},
[7] = {
name = "granatewerfer_34_81mm_mortar_mp",
isVehcle = true,
},
}
local isVehcle = false
local pos = World_Pos(-512, -512, -512)
local skipSBP = false

for key, _sbp in ipairs(_skip_sbp) do
if string.find(BP_GetName(sbp), _sbp.name) then
isVehcle = _sbp.isVehcle
skipSBP = true
end
end

if not skipSBP then
local squad = Squad_CreateAndSpawnToward(sbp, World_GetPlayerAt(1), 1, pos, pos)
local entity = Squad_EntityAt(squad, 0)
if Entity_IsOfType(entity, "vehicle") and not Entity_IsOfType(entity, "team_weapon") then
isVehcle = true
else
isVehcle = false
end
Squad_Destroy(squad)
end
return isVehcle
end

for key, race in pairs(SBP) do
for key, sbp in pairs(race) do
if SBP_IsVehicle(sbp) then
for i = 1, World_GetPlayerCount() do
Player_SetSquadProductionAvailability(World_GetPlayerAt(i), sbp, ITEM_REMOVED)
end
end
end
end

for key, abp in ipairs(_vehicleAbilities) do
for i = 1, World_GetPlayerCount() do
Player_SetAbilityAvailability(World_GetPlayerAt(i), BP_GetAbilityBlueprint(abp), ITEM_REMOVED)
end
end
end


Or did I misunderstood it again.... :(
4 Mar 2014, 19:19 PM
#12
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

Learn Lua and post again. Seriously, someone else might be willing to help you step by step but you are not even getting the basic idea. Learn how stuff like variables, functions, loops, and if statements work.
4 Mar 2014, 20:18 PM
#13
avatar of AGPHeaddikilla

Posts: 9

Learn Lua and post again. Seriously, someone else might be willing to help you step by step but you are not even getting the basic idea. Learn how stuff like variables, functions, loops, and if statements work.


I know this from C++, but i dont know the COH2 codes/commands Librarys. I can read the scripts and I know what is meant, but I dont know how to Script WITH COH2.
I dont know how CoH2 basically was maded. It gaves so many scope.

Pls can you help me now?

You know what I mean?

-_-
4 Mar 2014, 22:21 PM
#14
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

Then in that case you should take a look at example files, like scripts for SP missions and the whole SCAR system & luaconstauto.scar in AttribArchive.
You can extract archives in COH2 install directory using following commands with batch (.bat or cmd window)

archive.exe -a _path_to_sga_file -e _path_to_extract_folder_
e.g.
archive.exe -a CoH2\Archives\MPScenarios.sga -e CoH2\Data

I would recommend extracting Data.sga, AttribArchive.sga, SPScenariosEF.sga

Edit: coh scar documentation: http://www.europeinruins.com/ScarDoc/
4 Mar 2014, 23:34 PM
#15
avatar of AGPHeaddikilla

Posts: 9

Thanks for this help. I think thats a good help to understand CoH2 Scripts. Thanks so much for this. :D

4 Mar 2014, 23:37 PM
#16
avatar of AGPHeaddikilla

Posts: 9

1 user is browsing this thread: 1 guest

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

1071 users are online: 1071 guests
0 post in the last 24h
10 posts in the last week
26 posts in the last month
Registered members: 49993
Welcome our newest member, vip8scom
Most online: 2043 users on 29 Oct 2023, 01:04 AM