Update:
I think I figured out the objectives part. I can change it for different players by getting the local player. The objective functions grab the local player if no player is provided.
I'm completely lost for the sound part, though.
I've tried using Actor_PlaySpeech() and this works, but it plays for all players and sound only plays if I initialize the following variable: g_MissionSpeechPath = "botb/gameplay"
Is there any way to add speech files from outside the folder provided in that variable or to add another folder?
Other than Actor_PlaySpeech(), I've tried using Sound_Play2D() like I've seen used in aabattle_vptickerwin-annihilate_functions.scar, but I never got any sound to play, even if the code was executed. |
Hello modding community,
I'm trying to add sounds and objectives to my win condition, but I can't figure out how to add them to specific players.
I think the VP condition scar plays different sounds for different players, because I see it checks the value of a currentVictoryBalance variable and then tells the winners they're winning and the losers that they're losing, at the same time, but I can't figure out how and I don't see where it iterates through players.
Can anyone help? |
Alright, I figured it out. This works:
function CheckTanksKilled(victim, killer)
if Table_Contains(t_tanklist, Squad_GetBlueprint(victim)) then
local adjustedTicker = VPTicker_GetTeamTickers(Player_GetTeam(Util_GetPlayerOwner(victim))) - 50
VPTicker_SetTeamTickers(Player_GetTeam(Util_GetPlayerOwner(victim)), math.max(adjustedTicker, 0), true)
end
Apparently, Rule_AddGlobalEvent(myFunction, GE_SquadKilled) passes 2 variables called victim and killer to myFunction. This is great, but I never would've figured it out. I assume most events pass variables like this, but is there a list somewhere?
Thanks for pointing me in the right direction! |
Thank you for replying,
So, if I got this right, this will trigger myFunction when a squad is killed, right?
Rule_AddGlobalEvent(myFunction, GE_SquadKilled)
How do I reference the squad killed that triggers the event inside myFunction?
I assume I can then do Player_GetTeam(GetPlayerOwner(squad)), but I don't know how to reference the killed squad.
|
Hello,
I'm trying to make a victory condition mod that works like normal VP but reduces tickets based on losing units. This is my first attempt at modding and I've run into several issues I'd like to ask for help with.
I'm using aabattle_vptickerwin-annihilate_functions.scar as the basis for my main.scar file. I just pasted all of it in there since I couldn't get my main.scar to import another .scar file. Is that possible and if so, how? Is this a good approach?
At the moment, I'm checking the infantry lost stat every time VPTicker_MainRule() is called, but I'd like to be able to keep track of different unit types and I need some help here.
I tried the following bit of code:
local inftroops1 = EGroup_Count(Player_GetEntitiesFromType( World_GetPlayerAt(1), "infantry" ))
PrintOnScreen("Player1 has " .. inftroops1 .. " troops ")
The expected behavior is that it creates an EGroup with all the entities that have the type "infantry" owned by player 1, then counts all its members and prints the result.
The actual behavior is that it always prints 0. If I replace the part where it checks if an entity has the type "infantry" and make it just count all the entities owned by a player, the result is a number that changes depending on the number of all owned entities as I play. This leads me to believe that infantry entities don't have a type called "infantry", but that soldiers are entities, because afterwards I tried the following code:
infantryAmount = 0
squadgroup = Player_GetSquads(World_GetPlayerAt(1))
squadcount = SGroup_CountSpawned(squadgroup)
for i = 1, squadcount do
local squad = SGroup_GetSpawnedSquadAt( squadgroup, i )
for j = 0, (Squad_Count(squad)-1) do
local entity = Squad_EntityAt(squad, j)
if Entity_IsOfType(entity, "infantry") then
infantryAmount = infantryAmount + 1
end
end
end
This checks if an entity has a type "infantry". infantryamount is incremented according to the number of infantry entities I spawn in a game. The problem here is US vehicles (and I suspect garrisons in general), because entities despawn when they enter vehicles and I can't check through both spawned and despawned squads at the same time because there is no function like SGroup_GetSquad().
Is there a way to iterate through squads in an SGroup without a function?
something like: squad = someSGroup.squad[0]
Also, I don't really understand EGroups and SGroups. They're objects that can hold entity type objects, right? But SGroups can also hold squad type objects, which in turn, can hold entity objects?
tl,dr: I want to check all of a player's entities for a certain type. If I get the entities from an EGroup of all the player's entities, it doesn't work. If I get the entities from every spawned squad from an SGroup of all the player's spawned squads, it works and I don't understand why, since it's a bunch of entities in both cases.
I think the mod tools are great, but it would really help to be able to talk to someone knowledgeable about scar so... help, please? |