KnightHawk75
Posts: 1450
Joined: 11/15/2018 Status: offline
|
unit entering area triggers event for the type\types of units they are grouped by. Then check triggering Unit for type|class| dbid you want whatever to make sure you got the one(s) you want.. Then then loop through mounts on said unit, if a mount match the ones you want, award a points for each found, if not ignore. local function awardPointsPerMount(u,awardside,thedbid,mountid,pointsper,msg)
if pointsper == nil then pointsper = 1; end
if msg == nil then msg = "Points awarded." end
if ((u ~= nil) and u.mounts ~=nil) and u.dbid == thedbid then --if valid and a "Inf"
local matchingMountCount = 0;
for _,v in pairs(u.mounts) do -- run thought the mounts.
if v.mount_dbid == mountid then --Infantry Section [7.62mm MG/Unguided Infantry Anti Tank Weapon]
matchingMountCount = matchingMountCount + 1;
end
end
if matchingMountCount > 0 then
ScenEdit_SetScore(awardside,ScenEdit_GetScore(awardside) + (matchingMountCount * pointsper),msg);
end
end
end
u = ScenEdit_UnitX()
awardPointsPerMount(u,"Argentina",2987,2884,1,"Airdrop points awarded.") Just an example for "inf", and a inf sec 7.62 mount,point side being Argentina with 1 point per. Adjust as needed of course, like if you want a scoring entry per point remove the counting and just put the score line into the if contained in the for instead of the batched way I have it.
< Message edited by KnightHawk75 -- 3/22/2021 2:18:20 AM >
|