Is it possible to have a critical which has effects which can only be done via scar? Because I want to have a critical which makes the vehicle unusable but it should explode.. Therefore I want to set it no selectable
Is it possible to have a critical which has effects which can only be done via scar? Because I want to have a critical which makes the vehicle unusable but it should explode.. Therefore I want to set it no selectable
You can set EGroup / SGroup selectable state with the following commands:
Code:EGroup_SetSelectable(egroup, selectable) Result type: Void. Set player selectable state of entities in the egroup ----------------------------------------------------------------------------- SGroup_SetSelectable(sgroupid, selectable) Result type: Void. Set player selectable state of squads in the sgroup -----------------------------------------------------------------------------
Reload Attrib files ingame with SCAR
Do you need help with SCAR?
Do you need help with SCAR? Do you need a SCAR coder for your mod? Feel free to contact me via PM. For external contact, please click here.
i have another question about this: how to get the squadID of a single entity? I tried to use Entity_GetSquad() but it returns a table :O how to solve this?
What are you going to do with the SquadID returned from function Entity_GetSquad() ?
For example this test code works just fine with the returned SquadID:
Code:sg_rifles = SGroup_CreateIfNotFound("sg_rifles") Util_CreateSquads(World_GetPlayerAt(1), sg_rifles, SBP.ALLIES.RIFLEMEN, Player_GetStartingPosition(World_GetPlayerAt(1))) _entity = Squad_EntityAt(SGroup_GetSpawnedSquadAt(sg_rifles, 1), 0) --NOTE! Squad indexes in SGroups starts from 1. Entity indexes in Squads starts from 0. _squad = Entity_GetSquad(_entity) Squad_SetHealth(_squad, 0.5)
I had done this
and got this error:Code:sg_destroyed = SGroup_CreateIfNotFound("sg_destroyed") i = 0; while(World_GetNumEntities() > i) do e = World_GetEntity(i) if(Entity_IsVehicle(e) and Entity_GetHealth(e) == 0 and SGroup_ContainsSquad(sg_destroyed, Entity_GetSquad(e)) == false) SGroup_Add(sg_destroyed, Entity_GetSquad(e)) SGroup_SetSelectable(sg_destroyed, false) end end
*FATAL SCAR ERROR: Invalid parameter 2 (type expected=unsigned long, received=table) in function SGroup_ContainsSquad
Lua Hull_Destroyed.scar Ln 19 (Util_hull_destroyed)
Lua Testmod_Surrender.scar Ln 21 (Util_SurrenderSelection_Units_Check)
Could not execute rule: Util_SurrenderSelection_Units_Check
FATAL Scar Error while running rules - Execution has been paused.
Function SGroup_ContainsSquad appears to cause your fatal error. You don't have to check if SGroup has the squad already while adding a new squad to it, because of the function SGgroup_Add checks it automatically.
Code:----------------------------------------------------------------------------- SGroup_Add(group, squadron) Result type: Void. Adds an squadron to the end of a group if the group doesnt already have it. -----------------------------------------------------------------------------
yeah but I only want to go into this if-Branch if the squad is not in this SGroup.. However the problem lays in the second parameter: expected is an unsigned long but my Entity_GetSquad returns a table.. How to solve this?
What (kind of) units are you trying to collect into this "sg_destroyed" SGroup?
have you tried creating a new squad or something to the position of the entity before "SGroup_Add(sg_destroyed, Entity_GetSquad(e))" ?
That way you could find the position of the entity that was used to get the SquadID.
You could also print entity's blueprint to the console before "SGroup_Add(sg_destroyed, Entity_GetSquad(e))", so you could know what entity was used to get the squadID.
That way you could make sure your filters wont let in any entities that are unable to return squad.
function Entity_GetSquad() might also return null.Code:print(BP_GetName(Entity_GetBlueprint(entity))
Code:----------------------------------------------------------------------------- Entity_GetSquad(pEntity) Result type: SquadID. Returns the Squad for the passed Entity. (May be NULL) -----------------------------------------------------------------------------
the entity blueprint is the one I expected :
ebps\races\axis\vehicles\stug_iv
I think you should use for loop instead of while loop, and run for loop with an interval, like 1 second.
Code:--[[ NOTE: ------------------------------------------------------------------------------------------------------- Remember to subtract 1 from World_GetNumEntities(), because of entity ID numbers starts from 0. Function SGroup_ContainsSquad(group, squadID) needs Unique GameID as second parameter instead of squadID. I'm using health percentage of 0.1, as I spawned a stug to the map with 0.1 health. I replaced EntityIsVehicle() with Blueprint Comparison. ------------------------------------------------------------------------------------------------------- ]]-- sg_destroyed = SGroup_CreateIfNotFound("sg_destroyed") _VehicleFilters = { BP_GetEntityBlueprint("ebps/races/axis/vehicles/stug_iv.lua"), BP_GetEntityBlueprint("ebps/races/axis/vehicles/panther.lua"), BP_GetEntityBlueprint("ebps/races/axis/vehicles/panzer_iv.lua"), } for i = 0, World_GetNumEntities() -1 do _entity = World_GetEntity(i) _squad = Entity_GetSquad(_entity) for j = 1, table.getn(_VehicleFilters) do if Entity_GetBlueprint(_entity) == _VehicleFilters[j] then if _squad ~= nil and not SGroup_ContainsSquad(sg_destroyed, Squad_GetGameID(_squad)) and Entity_GetHealthPercentage(_entity) == 0.1 then SGroup_Add(sg_destroyed, Entity_GetSquad(_entity)) print("a vehicle was added to the SGroup 'sg_destroyed'") end end end end
Last edited by Janne252; 4th Jul 12 at 4:48 AM.
great workthx for help now I should be able to finish the work on my own
However I have two last questions:
1) How to set the Sgroups no longer to be a target for the enemy?
2) How to get the criticalBlueprint? because I want to replace the Entity_GetHealth() with Entity_HasCritical() ?
You'll need an ability that sets action\upgrade_action\change_weapon_target_type.lua to type_target_weapon\tp_infantry_surrender.lua1) How to set the Sgroups no longer to be a target for the enemy?
Then you'll have to use Cmd_Ability(sgroup, BP_GetAbilityBlueprint("your_new_ability_path")) to apply this action to the sgroup.
To enable targeting the sgroup again, you'll need an ability, just like the one above, but this one sets action\upgrade_action\change_weapon_target_type.lua to type_target_weapon\tp_infantry.rgd
or what ever type_target_weapon you think fits best.
And again, apply it to the sgroup with the command Cmd_Ability(sgroup, BP_GetAbilityBlueprint("your_new_ability_path"))
For example2) How to get the criticalBlueprint? because I want to replace the Entity_GetHealth() with Entity_HasCritical() ?
Entity_HasCritical(_entity, CRIT.VEH.DAMAGE_ENGINE)
Here's all vehicle critical hits that are listed in luaconsts:
You can also use BP_GetCriticalBlueprint(pbgPath) to get those that are not listed in luaconsts.Code:CRIT.VEH.DAMAGE_ENGINE CRIT.VEH.MOBILITY_MAJOR CRIT.VEH.MAIN_WEAPON_DESTROYED CRIT.VEH.CONTROL_FAST CRIT.VEH.CONTROL_SLOW CRIT.VEH.AXIS_KILL_TOP_MG CRIT.VEH.IMMOBILIZE
and again thx for your great help
Unfortunately I have another question:
How to get the direction of an entity? I want to Spawn a new entity at exact the same position and looking in the same direction using this code:
But I having trouble with this because the Position is not the same :/Code:Squad_CreateAndSpawnToward(_squad_blueprint ,World_GetPlayerAt(1), 1, Entity_GetPosition(_entity), Entity_GetHeading(_entity))
I'm using randomized position as facing for riflemen for testing purposes.
Code:sg_rifles = SGroup_CreateIfNotFound("sg_rifles") sg_engineers = SGroup_CreateIfNotFound("sg_engineers") _spawnpos = Player_GetStartingPosition(World_GetPlayerAt(1)) _riflemen_facing = Util_GetRandomPosition(Player_GetStartingPosition(World_GetPlayerAt(2)), 6) Util_CreateSquads(World_GetPlayerAt(1), sg_rifles, SBP.ALLIES.RIFLEMEN, _spawnpos, nil, nil, nil, nil, nil, nil, _riflemen_facing) _engineer_facing = Squad_GetOffsetPosition(SGroup_GetSpawnedSquadAt(sg_rifles, 1), 0, 5) --[[ Squad_GetOffsetPosition(squad, offset, distance) offset list: OFFSET_FRONT = 0 OFFSET_FRONT_RIGHT = 1 OFFSET_FRONT_LEFT = 7 OFFSET_BACK = 4 OFFSET_BACK_RIGHT = 3 OFFSET_BACK_LEFT = 5 OFFSET_RIGHT = 2 OFFSET_LEFT = 6 ]]-- Util_CreateSquads(World_GetPlayerAt(1), sg_engineers, SBP.ALLIES.ENGINEER, Squad_GetPosition(SGroup_GetSpawnedSquadAt(sg_rifles, 1)), nil, nil, nil, nil, nil, nil, _engineer_facing)
Last edited by Janne252; 7th Jul 12 at 7:04 AM.
I respawn vehicles so if they look in another direction it is really obviously that they are not the same.. Therefore I need the facing and not a random positon :/ is there any way to get the facing?
Before de-spawning the old vehicle, take its position to a variable, let's say _pos_oldvehicle. Then take offset position from the old vehicle to a variable, let's say _offset_oldvehicle, using function Squad_GetOffsetPosition(squad, 0, 5)
2nd parameter "0" returns a position in front of the squad. This can be used as heading, which can be used to set squad facing while spawning it with function Util_CreateSquads()
Then you can de-spawn the old vechicle, and re-spawn a new one using _pos_oldvehicle as spawn position and _offset_oldvehicle as facing.
Code:_pos_oldvehicle = Squad_GetPosition(_squad) _offset_oldvehicle = Squad_GetOffsetPosition(_squad, 0, 5) Squad_Destroy(_squad) Util_CreateSquads(World_GetPlayerAt(1), sg_newvehicle, SBP.AXIS.STUG, _pos_oldvehicle, nil, nil, nil, nil, nil, nil, _offset_oldvehicle)
oh man! this is great!!! This was exactly what I was looking for
Edit: How to add a critical to the new spawned squad? I tried this :
but it doesn't workCode:Cmd_CriticalHit(World_GetPlayerAt(1), sg_newvehicle, BP_GetCriticalBlueprint("critical/vehicle_hull_destroyed.lua"), 1)![]()
Last edited by berse2212; 7th Jul 12 at 12:27 PM.
Last parameter is DamageBlueprint. luaconsts has these damageblueprints listed, and after testing I included estimated amount of lost HP in critical hit.Code:Cmd_CriticalHit(World_GetPlayerAt(1), sg_newvehicle, BP_GetCriticalBlueprint("critical/vehicle_hull_destroyed.lua"), CRIT.DAMAGE_GREEN)
Oh and remember to clear sg_newvehicle after spawning a unit with it, so you wont call critical hit to all vehicles that have been respawned, as it might look silly if other immobilized tanks in map appear to get critical hits from nothing.Code:CRIT.DAMAGE_GREEN ~ - 10 % HP CRIT.DAMAGE_YELLOW - ~ - 60 % HP CRIT.DAMAGE_RED - ~ - 90 % HP
Might be also a good idea to use custom critical hits for re-spawned vehicles that wont create kicker messages.
I have another question: is there a possibility to get the path of the texture? I have some tanks in my mod with random textures and if I respawn them it may change and this is really obvious :/
I don't know how the random texture system works, but if you can call different scar function for each texture, it could be one way. I think scar functions called via RGD does not support parameters.
Then you would have to create new RGD files for each texture, so the tank can be respawned with correct texture.
the random texture system works with a random action in the .rgo file of the objectivehow do I call a scar function via RGD?
action\ability_action\scar_function_call.lua
How the system would work is when scar function is called, it would find the new spawned tank and take its info to a lua table, and get texture id from the function it self.
Then this info could be used for respawning tanks with correct textures. Only thing is what I am not sure is, is it possible to do different action for each texture?
Last edited by Janne252; 28th Jul 12 at 12:47 PM.
mh not really.. For know its a critical and this is always the same and cannot be different for each texture
Edit:
I have another question: I kill the old vehicle know with this action to make sure that the one who kills him receive experience points and the stats of the unit are updated
However the wreck should be removed right after this action. But it is no longer the squad I saved in my variable and I cannot use the "Squad_Destroy(_squad)" commandCode:Cmd_CriticalHit(_attack_player, _squad, BP_GetCriticalBlueprint("critical/vehicle_make_wreck.lua"), BP_GetDamageBlueprint("damage/damage_red"))
Edit 2:
for now I just move the wreck outside the map which works well but the experience points are not shown..
Last edited by berse2212; 29th Jul 12 at 4:51 AM. Reason: double post
If you want to give xp for killing the tank, use this function to first find who was the last one who attacked the tank:
Code:Squad_GetLastAttacker(squad, group) Result type: Void. Find the last squad attacker on this squad. If found, the squad is added to the sgroup -----------------------------------------------------------------------------Adding XP reward to the player
Then you can get the attacker squad out of that sgroup, and get the player owner of that squad.
Then you can add wanted amount of xp for the player ( you can for example store these values in lua table and compare squad blueprint to get the right XP amount. )
Code:Player_AddResource(playerId, resourceType, value) Result type: Void. Add resource to player, as opposed to just setting it. Possible resource types are RT_Manpower, RT_Munition, RT_Fuel, RT_Action -----------------------------------------------------------------------------
Creating green xp kicker message ( locally )
Then we'll have to create green xp kicker message locally for the player who "killed" the tank.
You could use this function:
example:Code:function ExperienceKicker(player, position, value) local value = Loc_ConvertNumber(value) local text = Loc_FormatText(10000522, value) if Player_GetID(player) == Player_GetID(Game_GetLocalPlayer()) then UI_CreateColouredPositionKickerMessage(player, position, text, 141, 223, 18, 255) end end
ExperienceKicker(Squad_GetPlayerOwner(squad), Squad_GetPosition(squad), xp_amount)
for xp_amount, you could create a lua table as I mentioned above, and run simple loop trough it and compare squad blueprint.
example of how the table could look ( just a rough example ):
Code:XPRewards = { { sbp = SBP.AXIS.STUG, xp = 16, -- example number }, { sbp = SBP.AXIS.PANZER, xp = 21, -- example number }, } for i = 1, table.getn(XPRewards) do if Squad_GetBlueprint(squad) == XPRewards[i].sbp then xp_amount = XPRewards[i].xp end end
Last edited by Janne252; 29th Jul 12 at 9:40 AM.
thx for help again
I started a try to apply random textures in another way. However I got stuck because some strange things are happening..
A part of my code is this:
Huge code :D
Code:function randomSquads() sg_allsquadsAxis = SGroup_CreateIfNotFound("sg_allsquadsAxis") sg_checked = SGroup_CreateIfNotFound("sg_checked") sg_toFilter = SGroup_CreateIfNotFound("sg_toFilter") SGroup_RemoveGroup(sg_allsquadsAxis, sg_checked) SGroup_AddGroup(sg_toFilter, sg_allsquadsAxis) SGroup_AddGroup(sg_checked, sg_allsquadsAxis) local _zeige = function (gID, idx, sID) print(BP_GetName(Squad_GetBlueprint(_squad))) end SGroup_ForEach(sg_toFilter, _zeige) SGroup_Filter(sg_toFilter, BP_GetSquadBlueprint("sbps/races/axis/vehicles/stug_iv_squad"), FILTER_KEEP) if SGroup_CountSpawned(sg_toFilter) > 0 then spawnStug(sg_toFilter) end end Rule_AddInterval(randomSquads, 1) function spawnStug(sg_toFilter) print("größe:" .. SGroup_CountSpawned(sg_toFilter)) local _spawnStug = function (gID, idx, sID) _pos_oldvehicle_new = Squad_GetPosition(sID) _offset_oldvehicle_new = Squad_GetOffsetPosition(sID, 0, 5) owner = Squad_GetPlayerOwner(sID) number = World_GetRand(0, 4) if(number <= 1) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_1") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_1") elseif(number <= 2) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_2") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_2") elseif(number <= 3) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_3") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_3") else _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_4") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_4") end end SGroup_ForEach(sg_toFilter, _spawnStug) -- Repeats for each squad in selection end
this part:
print this:Code:local _zeige = function (gID, idx, sID) print(BP_GetName(Squad_GetBlueprint(_squad))) end SGroup_ForEach(sg_toFilter, _zeige)
However the only units the axis have are two grenadiers and one stug, therefore I want to ask why there are just three grenadiers listed :/sbps\races\axis\soldiers\grenadier_squad
sbps\races\axis\soldiers\grenadier_squad
sbps\races\axis\soldiers\grenadier_squad
Additionally this code:
calls the function spawnStug and the print function thereCode:if SGroup_CountSpawned(sg_toFilter) > 0 then spawnStug(sg_toFilter) end
prints this:Code:print("größe:" .. SGroup_CountSpawned(sg_toFilter))this means that in the SGroup "sg_toFilter" has to be one stug doesn't it?größe:1
But this thought was a mistake: I got a crash
this is logical because I have no grenadier_squad_1 but there shouldn't be any grenadier any longer so why did this happen?*FATAL SCAR ERROR: Cannot find "sbps\races\axis\soldiers\grenadier_squad_1"
Lua Hull_Destroyed.scar Ln 189 ((null))
C =[C] Ln -1 (SGroup_ForEach)
Lua Hull_Destroyed.scar Ln 206 (spawnStug)
Lua Hull_Destroyed.scar Ln 172 (randomSquads)
Part1: confusing usage of variable _squad
Why are you printing blueprint name of _squad instead of sID, as you have defined in the function parameters?
You are using same _squad variable again in local _spawnStug = function (gID, idx, sID), which might be the reason it tries to spawn a grenadier squad.Code:local _zeige = function (gID, idx, sID) print(BP_GetName(Squad_GetBlueprint(_squad))) end
Code:local _spawnStug = function (gID, idx, sID) _pos_oldvehicle_new = Squad_GetPosition(sID) _offset_oldvehicle_new = Squad_GetOffsetPosition(sID, 0, 5) owner = Squad_GetPlayerOwner(sID) number = World_GetRand(0, 4) if(number <= 1) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_1") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_1") elseif(number <= 2) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_2") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_2") elseif(number <= 3) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_3") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_3") else _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_4") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_4") end end
Part2: Suggestions for debugging
Maybe you could run Filtering before SGroup_ForEach(sg_toFilter, _zeige), so you could see what is left in the sgroup.
Code:SGroup_Filter(sg_toFilter, BP_GetSquadBlueprint("sbps/races/axis/vehicles/stug_iv_squad"), FILTER_KEEP) SGroup_ForEach(sg_toFilter, _zeige)
Part3: Fine tuning
This is probably just fine tuning, but I would change
toCode:number = World_GetRand(0, 4) if(number <= 1) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_1") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_1") elseif(number <= 2) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_2") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_2") elseif(number <= 3) then _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_3") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_3") else _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(_squad)).."_4") Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_4") end
Code:number = World_GetRand(1, 4) _squad_blueprint_new = BP_GetSquadBlueprint(BP_GetName(Squad_GetBlueprint(sID)).."_"..number) Util_CreateSquads(owner, sgroupid, _squad_blueprint_new, _pos_oldvehicle_new, nil, nil, nil, nil, nil, nil, _offset_oldvehicle_new) print("stug_"..number)
Last edited by Janne252; 3rd Aug 12 at 12:52 AM.
Part1: I could hate me for this.. If I am to lazy to rewrite a line which I had used before I always just copy them and forgot to change (all) the variables used in this function -.- Thanks for recognizing this
Part2: That was what I had done before but there was only one grenadier printed and I was more confused
Part3: This is a great Idea but what returns this function?
Code:number = World_GetRand(1, 4)
What do you mean by that? It returns an integer, if you meant that.Part3: This is a great Idea but what returns this function?
Code:World_GetRand(min, max) Result type: Integer. Returns a random integer with range [min, max] It is recomended you use this instead of luas math.random function -----------------------------------------------------------------------------
If the min value is 1 does it may return 1 or starts by 2 and if the max is 4 does it may return 4 or only 3? :-P
I believe it will return any value of 1..4 if min and max are 1 and 4.
You can also try running
Here: http://www.lua.org/cgi-bin/demoCode:for i = 1, 10 do print(math.random(1, 4)) end
I tried math.random but I was an unknown function (don't know why) so I decided to use this "World_GetRand( Integer min, Integer max )" because in the description is written this:It is recomended you use this instead of luas math.random function
You could try that by your self in CoH, just make a loop that uses World_GetRand(1, 4) for example 10 times, and print it each time.
Code:for loop = 1, 10 do print(World_GetRand(1, 4)) end
just a simple question about this code: why is the code in the if branch never accomplished, even when an entity receives this critical?Code:function destroyEntities() eg_killed = EGroup_CreateIfNotFound("eg_killed") eg_alle = EGroup_CreateIfNotFound("eg_alle") sg_angreifer = SGroup_CreateIfNotFound("sg_angreifer") eg_spielersquads = EGroup_CreateIfNotFound("eg_spielersquads") for i = 1, World_GetPlayerCount() do Player_GetAll(World_GetPlayerAt(i), eg_spielersquads) EGroup_AddEGroup(eg_alle, eg_spielersquads) end local _checkEntityCritical = function (gID, idx, eID) if Entity_HasCritical(eID, BP_GetCriticalBlueprint("critical/vehicle_make_wreck.lua")) and not EGroup_ContainsEntity(eg_killed, eID) then Entity_GetLastAttacker(eID, sg_angreifer) angreifer = Util_GetPlayerOwner(sg_angreifer) Cmd_CriticalHit(angreifer, eID, BP_GetCriticalBlueprint("critical/vehicle_make_wreck2.lua"), BP_GetDamageBlueprint("damage/damage_red")) print("Entity von anderen zerstört!") elseif Entity_HasCritical(eID, BP_GetCriticalBlueprint("critical/vehicle_make_wreck.lua")) then Entity_Kill(eID) print("Entity killed!") end end EGroup_ForEach(eg_alle, _checkEntityCritical) end
Just like in post #10: Egroup_ContainsEntity / SGroup_ContainsSquad functions require unique GameID for comparison.
Code:Entity_GetGameID(entity) Result type: Integer. Returns the entities unique id in the world -----------------------------------------------------------------------------Code:Squad_GetGameID(squad) Result type: Integer. Returns an integer containing the unqiue squad ID for this squad. -----------------------------------------------------------------------------
okay changed this line but it does not change the problem because the elseif branch and the if branch are never accomplished and the Entity_HasCritical function does not work work the unique id
Changed what? This line should be
-->Code:local _checkEntityCritical = function (gID, idx, eID) if Entity_HasCritical(eID, BP_GetCriticalBlueprint("critical/vehicle_make_wreck.lua")) and not EGroup_ContainsEntity(eg_killed, eID) then
Code:local _checkEntityCritical = function (gID, idx, eID) if Entity_HasCritical(eID, BP_GetCriticalBlueprint("critical/vehicle_make_wreck.lua")) and not EGroup_ContainsEntity(eg_killed, Entity_GetGameID(eID)) then
that was what i had donebut it still does not enter the if or the elseif branch
![]()
When ever I am trying to find out why some parts of the code are not being executed, I print out everything to the console. Every variable that are compared in inf branches and so on.
You should be able to find what variable had a value that your filters wont let to pass, and figure out what causes it to have that kind of value.
okay solved the mistakebut how to kill vehicles by world so no player and no squad receive points for the killed entity? I already tried this one but the last attacker get one tank kill more..
function
Void Entity_Kill( EntityID entity )
Kill the entity. Sets health to 0, and triggers death effects.
You could try instantly spawning a new entity after removing the old one and kill the new entity instantly so it won't have "last attacker"?
great ideathat worked well
thx for help :P
Last edited by berse2212; 21st Sep 12 at 7:31 AM.
have another question: how to reveal a certain area for only one player? I tried: "FOW_RevealArea( Position pos, Real radius, Real durationSecs )" but this works only for all players :/
@eliw00d are you sure calling FOW revealing functions locally in multiplayer won't cause a sync error?
What would happen if a certain area would only be revealed for player 1 and player 1 decides to use a sniper to kill something in the revealed area while other players in same team can't see this area?
Isn't FOW shared for the whole team?
Sorry, I should have said "Try checking to..." instead. Some UI related functions are able to be used by the local player and not cause sync errors, but I suppose this would not be one of them. Disregard.
There are currently 1 users browsing this thread. (0 members and 1 guests)