Login

russian armor

Single Player Script: Bounty

7 Aug 2015, 11:02 AM
#1
avatar of IronMedic

Posts: 318

note: This is a re-writen/updated script that was used in vCoH's ToV La Fière


This Script checks whenever player2 loses a squad and reward player1 whit manpower, munition and fuel.


How to use:


This script ether be appended directly into your already existing "mapname".scar
or
Import into your "mapname".scar.

If you append the directly into "mapname".scar you can export the map as normal using the worldbuilder. To do this simply copy paste the bounty script at the end of "mapname".scar.

If you wish to keep your "mapname".scar a bit more tidy copy the script file into the same folder as your map and ad import("bounty.scar") to the beginning of "mapname".scar, but this will require you to create a scenario pack using the CoH2 Mod Builder

Variables Of The Script


g_playerToRewardForSquadWhipe = The player who gets rewarded when the player defined as "g_playerEnemyAI" losses a squad.

g_playerEnemyAI = The enemy of "g_playerToRewardForSquadWhipe".

These multipliers will be applied on the base "cost" value for each resource type
g_MunitionMultiplier = Affects the amount of Munition.
g_ManpowerMultiplier = Affects the amount of Manpower.
g_FuelMultiplier = Affects the amount of Fuel.

g_textString =This is the text string displayed as the Reward "Kicker" and has to be formatted like this "+%1AMOUNT%:MP\n +%2AMOUNT%:MU\n +%3AMOUNT%:FU" the text highlighted in red is the most important part of this text string and will break the script if missing from the string.

g_vehKillCount =completely optional, and if defined this script can track vehicles destroyed for objectives.

The table cost is used to define the base value of the bounty.

The table BountyRewards is used to define each unit. I've defined the most common units in full script, the script contains a few example unit.

Download the full script:the_bounty_script.zip


--This is a re-writen/updated script that was used in CoH ToV La Fière Campaign, re-writen/updated by IronMedic @coh2.org.
function BountyInit()

sg_Bounty = SGroup_CreateIfNotFound("sg_Bounty")
sg_Kicker = SGroup_CreateIfNotFound("sg_Kicker")
sg_temp = SGroup_CreateIfNotFound("sg_temp")

g_playerToRewardForSquadWhipe = player1
g_playerEnemyAI= player2
g_HasSyncWeapon = false
--g_vehKillCount = 0


--these multipliers will be applied on the base "cost" value for each resource type
g_MunitionMultiplier = 1
g_ManpowerMultiplier = 0.8
g_FuelMultiplier = 0.2


--"+%1AMOUNT%:MP\n +%2AMOUNT%:MU\n +%3AMOUNT%:FU" or $uniqueModID:lineInLocaleLanguageFile"
--g_textString = "$024741c43f0f47a783f888eaf1983d4a:3"
t_Bounty = {
cost = {
--bounty reward for:
--basic infantry.
basicInf = 15,
--elite infantry.
eliteInf = 25,
--light and medium vehicles.
LMVeh = 55,
--buildings and team weapons.
TWorBuilding = 75,
--"heavy medium" and heavy vehicles.
MHVeh = 100,
},
}
t_Bounty.BountyRewards = {
--infantry
{
sbp = SBP.AEF.RIFLEMEN_SQUAD_MP,
value = t_Bounty.cost.basicInf,
},
--team weapons
{
sbp = SBP.AEF.M1_57MM_AT_GUN_SQUAD_MP,
value = t_Bounty.cost.TWorBuilding,
teamweapon = true,
},
--vehicles
{
sbp = SBP.AEF.DODGE_WC51_50CAL_SQUAD_MP,
value = t_Bounty.cost.LMVeh,
vehicle = true,
},
}


SGroup_Clear(sg_Bounty)
Rule_AddInterval(Bounty_RuleAdd, 5)

end

Scar_AddInit(BountyInit)

function Bounty_SetSGroupKicker(sgroup)

SGroup_Clear(sg_Kicker)
SGroup_AddGroup(sg_Kicker, sgroup)

end

function Bounty_DeathEvent(squad)

for k, this in pairs(t_Bounty.BountyRewards) do
-- if squad that's dead is a heavyMG or a mortar
if Squad_GetBlueprint(squad) == this.sbp and this.teamweapon ==true then

if g_HasSyncWeapon == false then

Player_AddResource(g_playerToRewardForSquadWhipe, RT_Munition, this.value * g_MunitionMultiplier)
Player_AddResource(g_playerToRewardForSquadWhipe, RT_Manpower, (this.value * g_ManpowerMultiplier))
Player_AddResource(g_playerToRewardForSquadWhipe, RT_Fuel, (this.value * g_FuelMultiplier))
print("Someone killed "..this.value )
if g_textString ~= nil then
local num1 = Loc_ConvertNumber(math.floor(this.value * g_ManpowerMultiplier))
local num2 = Loc_ConvertNumber(math.floor(this.value * g_MunitionMultiplier))
local num3 = Loc_ConvertNumber(math.floor(this.value * g_FuelMultiplier))

local text = Loc_FormatText(g_textString, num1, num2, num3)

UI_CreateColouredPositionKickerMessage( g_playerToRewardForSquadWhipe, Squad_GetPosition( squad ), text, 198, 120, 74, 0)
--UI_CreateColouredPositionKickerMessage( g_playerToRewardForSquadWhipe, Squad_GetOffsetPosition( squad, 5, 5), "teameWeapon", 250, 120, 74, 0)
end
-- switches flag to true so that it skips the next duplicated team weapon squad
g_HasSyncWeapon = true

if Rule_Exists(Bounty_RestoreSyncWeapon) == false then

Rule_Add(Bounty_RestoreSyncWeapon)

end

end
break
elseif Squad_GetBlueprint(squad) == this.sbp then
Player_AddResource(g_playerToRewardForSquadWhipe, RT_Munition, this.value * g_MunitionMultiplier)
Player_AddResource(g_playerToRewardForSquadWhipe, RT_Manpower, (this.value * g_ManpowerMultiplier))
Player_AddResource(g_playerToRewardForSquadWhipe, RT_Fuel, (this.value * g_FuelMultiplier))
print("Someone killed "..this.value )
if g_textString ~= nil then
local num1 = Loc_ConvertNumber(math.floor(this.value * g_ManpowerMultiplier))
local num2 = Loc_ConvertNumber(math.floor(this.value * g_MunitionMultiplier))
local num3 = Loc_ConvertNumber(math.floor(this.value * g_FuelMultiplier))
--"+%1AMOUNT%:MP\n +%2AMOUNT%:MU\n +%3AMOUNT%:FU"
local text = Loc_FormatText(g_textString, num1, num2, num3)
UI_CreateColouredPositionKickerMessage( g_playerToRewardForSquadWhipe, Squad_GetPosition( squad ), text, 198, 120, 74, 0)
--UI_CreateColouredPositionKickerMessage( g_playerToRewardForSquadWhipe, Squad_GetOffsetPosition( squad, 5, 5), "squad", 250, 120, 74, 0)
end
-- track the number of vehicles the player has killed for the first mission
if this.vehicle == true then

if g_vehKillCount ~= nil then
g_vehKillCount = g_vehKillCount + 1
local textKill = ("Vehicles Killed: "..g_vehKillCount )
--UI_CreateColouredPositionKickerMessage( g_playerToRewardForSquadWhipe, Squad_GetOffsetPosition( squad, 6, 6), textKill, 250, 120, 74, 0)
end

end
break
end
end

end

function Bounty_RestoreSyncWeapon()
-- restores the flag so that the next sync weapon equipped squad can be counted
if g_HasSyncWeapon == true then

g_HasSyncWeapon = false
Rule_RemoveMe()
end

end

function Bounty_RuleAdd()

SGroup_Clear(sg_temp)
Player_GetAll(g_playerEnemyAI, sg_temp)
SGroup_RemoveGroup(sg_temp, sg_Bounty)

if SGroup_IsEmpty(sg_temp) == false then
Rule_AddSGroupEvent(Bounty_DeathEvent, sg_temp, GE_SquadKilled)
end

SGroup_AddGroup(sg_Bounty, sg_temp)

end
7 Aug 2015, 21:47 PM
#2
avatar of Sirlami
Donator 11

Posts: 422 | Subs: 3

Very nice feature!
9 Aug 2015, 01:54 AM
#3
avatar of IronMedic

Posts: 318

Added a download to the full script, and a quite simple tutorial.
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

427 users are online: 427 guests
0 post in the last 24h
8 posts in the last week
34 posts in the last month
Registered members: 49107
Welcome our newest member, Falac851
Most online: 2043 users on 29 Oct 2023, 01:04 AM