I am trying to modify the template with example game mode SCAR to progress when a player picks up a relic rather than when a house is built. This is a very quick attempt and a first draft but any input would be very welcome.
- Event happens in game // ie. scout grabs carcass
function call on event // ie. Mod_OnConstructionComplete
function checks parameters // ie. does scout hold carcass, does local player own scout, etc.
if variable is what is required // scout does have carcass, player is local etc
then increase objective bar
elseif var != requirements
- if objective bar == objective goal then end game
The issue i’ve ran into is syntax to specify things like:
A) define which unit to check (creating a table of all the scouts in play and sorting out the ones to check)
-when to specify things like player/team and unit type to reference the table / array contents(oninit or context)(around or within rule)
B) determine which player owns the unit(s) and how many, if any, hold an item (like a carcass or relic)
C) Find out things like which type the unit is (for use in getbytype, getbyblueprint, player_get*, sgroup_get*, etc.)(also which of those to use)
D) What to call an item held by a unit (slot item? sim item? inventory item? entity? squad?
code code code
for i, player in pairs(PLAYERS) do
local player_monks = Player_GetSquadsFromType(player.id, "monk") Squad_GetSlotItemCount("unit_monk_4_") if Squad_GetSlotItemAt(1) = "relic" then Util_SetPlayerOwner("relic", player.id, true) if Entity_GetPlayerOwner("relic") = Player.id then local obj_progress_current = Obj_GetCounterCount(_mod.objective) local obj_progress_new = obj_progress_current + 1 Obj_SetCounterCount(_mod.objective, obj_progress_new) Obj_SetProgress(_mod.objective, obj_progress_new / _mod.objective_requirement) if obj_progress_new == _mod.objective_requirement then for i, player in pairs(PLAYERS) do if Player_ObserveRelationship(player.id, builder.id) == R_ALLY then Core_SetPlayerVictorious(player.id, Mod_WinnerPresentation, WR_CONQUEST) else Core_SetPlayerDefeated(player.id, Mod_LoserPresentation, WR_CONQUEST) end end end
If my intuition is correct, the above would require either to make a new players table within “function mod_Onitempickup” at the beginning then use the table to build a table containing only the monks owned by player.id then check that table for monks ‘holdingentity(“relic”)’ then execute the objective progression adjustments. maybe?
Anybody know why the keep spawns as a box that shoots boxes when spawned using…
--[ --for i, players in.... --player_civ = Player_GetRaceName(player.id) --local ebp_castle --if player_civ == "x" then ebp_castle = BP_GetEntityBlueprint("building_defense_keep_x) --] local spawn_position = Util_GetOffsetPosition(player.town_center.position, 20, 40) -- position from table in Mod_FindTownCenter() local entity1 = Entity_Create(ebp_castle, player.id, spawn_position, false) Entity_Spawn(entity1) Entity_ForceConstruct(entity1) Entity_SnapToGridAndGround(entity1, false)
is it an error in script / cache or whatever, or is it a gpu thing or game settings? I’ve seen the boxes before and they are not consistent, one frame my TC is, well, a TC but the next frame only red-ish box stands in it’s place.(obviously a placeholder of some sort) This does not seem to be discriminate to any specific object aside from the keeps, the in-match villager built keeps render normal but the script spawned ones don’t, even if a script spawned outpost from the unchanged Mod_SpawnBuilding() function renders perfectly at a different offset at the same time as the keep and remains a tower throughout while the keep remains a mystery box.