Jump to content


Photo

Addind new scar in wincondition (Bodycount) only display on screen

scar bodycount new wincondition error dawn of war soulstorm

1 reply to this topic

#1 MarTAU_CZ

MarTAU_CZ
  • Members
  • 16 posts

Posted 04 June 2018 - 05:30 PM

Hello revora forum. Can you help me with one scar code? This scar code is like wincondition but it's not wincodition like annihilate. It's win condition like game timer. Just addon.
This is call like bodycounts.scar. It shows how many enemies was killed by (player 1 2 3 4 5 6 7 8) so for each player. I did it only for 2 players. simply becaseu it was taken from survival mod where that kills is displayed on the screen. I tried this but i received a scar error. 
If you can please help me to do this corretly to work for each player. 
Thx for any tips.
 
 
 
-----------------------------------------------------------------------------------------------------------------------------------
--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--OPENING CODE AND CONFIGURATION
--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----------------------------------------------------------------------------------------------------------------------------------
import("ScarUtil.scar")
import("WXPScarUtil.scar")
function OnInit()
 
g_player_1_kills = 0
g_player_2_kills = 0
Rule_AddInterval(Rule_BodyCount_TriggerP1,3)
Rule_AddInterval(Rule_BodyCount_TriggerP2,3)
end
 
 
Scar_AddInit(OnInit)
 
 
-----------------------------------------------------------
--Bodycounts and level warnings definitions
-----------------------------------------------------------
 
function Rule_BodyCount_TriggerP1()
g_player_1_kills = Stats_PlayerUnitsKilled(Player_GetID(g_Player1))
 
if not WinWarning_Exists("P1_body_count" ) then
WinWarning_Add( "P1_body_count", g_Player1, "", "wincondition_name", "help tip text" )
Rule_AddInterval(Rule_BodyCount_P1,1)
end
end
 
function Rule_BodyCount_TriggerP2()
g_player_2_kills = Stats_PlayerUnitsKilled(Player_GetID(g_Player2))
 
if not WinWarning_Exists("P2_body_count" ) then
WinWarning_Add( "P2_body_count", g_Player2, "", "wincondition_name", "help tip text" )
Rule_AddInterval(Rule_BodyCount_P2,1)
end
end
 
 
function Rule_BodyCount_P1()
g_player_1_kills = Stats_PlayerUnitsKilled(Player_GetID(g_Player1))
WinWarning_SetText( "P1_body_count", "Player one body count - "..g_player_1_kills )
end
 
function Rule_BodyCount_P2()
g_player_2_kills = Stats_PlayerUnitsKilled(Player_GetID(g_Player2))
WinWarning_SetText( "P2_body_count", "Player two body count - "..g_player_2_kills )
end
 
 
 
 
 
 
 
 
 
 


#2 Gambit

Gambit

    title available

  • Members
  • 5,619 posts
  • Location:Athens, Greece

Posted 04 June 2018 - 05:50 PM

For a stand-alone win condition, ... It is not properly coded brother...

I would use only only one rule, for example.

 

Anyway, from a quick look, I saw 2 inconsistencies:

1] g_Player1 and g_Player2 are not defined. These are the player IDs, and you must use World_GetPlayerAt(slot)

2] This is serious: You used Rule_AddInterval, to call a rule that also has a Rule_AddInterval !!!!

Which means that on the second pass of the first one, the second will be recalled. And you get a DUPLICATE rule error.

So, instead of

Rule_AddInterval(Rule_BodyCount_P1,1)

try

Rule_BodyCount_P1()

This you must do for P2 of course.

 

 

-----------------------------------------

 

 

I have recoded it in the new Survival, you can have a look there :grad:

The Rule_BodyCount_Players function does the trick, and it includes more players!

You just have to slightly modify it, and add the two lines first from the previous function:

local pID = World_GetPlayerAt(Tut_GetLocalPlayerIndex())
    WinWarning_Add( "Player_body_count_surv", pID, "", "wincondition_name", "help tip text" )

If you still have issues, I can try and code it for you - but for two more weeks I will be extra busy (exams time!).


-In search of Papasmurf...



Reply to this topic



  



Also tagged with one or more of these keywords: scar, bodycount, new wincondition, error, dawn of war, soulstorm

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users