RDNWiki: DOWScar/Tutorials/Advanced/WinConditions ...

RDN Wiki Home | Page Index | Recent Changes | Recently Commented | Users | Registration | Login:  Password:  

Win Conditions


Contents

Introduction

Win conditions are the set of rules used for the multiplayer games in Dawn of War. Things such as annihilation, strategic victory or take and hold victory are all governed by these rules. This document will describe what is necessary to setup proper winconditions.

File Format


Winning conditions require two files. <Winconditions>.scar and <Wincondition>_local.lua, both of which need to be placed within the /Data/Scar/Winconditions folder. These two files need to contain the following:


<Wincodition>_local.lua

Localization = 
{
title= "MyWinCondition",
win_message = "You have won due to some wincodition",
lose_message = "You have lost due to some win condition",
description= "Description goes here",
always_on= false
}

What this does is create a wincondition, with the name "MyWinCondition" (this will be displayed in both the skirmish menu and the multiplayer menu).


The <Wincondition>.scar file, obviously, contains the information about the win conditions that need to be triggered. As with any scar file it needs to contain an Scar_AddInit call. Which typically adds the name of your win condition. Other then that the trickiest bit is keeping track of the status of each player, which involves going through an array with each entry in the array, and making sure that the win conditions aren’t violated/overruled by some other win conditions. For example, in economic victory, if you manage to annihilate your opponent, it doesn’t seem right that you should continue playing, since he has no units or buildings that he can build or attack you with.
As an example, here’s the total annihilation win condition (scar file), which state that a player will survive as long as they have one unit:


<Wincondition>.scar

import("ScarUtil.scar");

function Annihilate2()

-- wait 0.25 secs before adding this rule. this is so it is not executed
-- on the same frame as the other win conditions
Rule_AddOneShot( Annihilate_AddMainRule, 0.25 )

obj_table_P1 = { title_id = 60000, short_desc_id = 60300, help_tip_id = 60300 }

Objective_Add( obj_table_P1, 1 )

end

function Annihilate_AddMainRule()
Rule_AddInterval(CheckAnnihilate, 2)
end

_Annihilate = 
{
--don't count these when counting the number of buildings owned
g_annihilate_exceptions = 
{
"eldar_listening_post",
"chaos_mine_field",
"eldar_mine_field",
"ork_mine_field",
"space_marine_mine_field",
"eldar_webway_gate",
"eldar_support_platform_scatterlaser",
"chaos_listening_post",
"chaos_turret_bolter",
"ork_gork_totem",
"ork_waagh_banner",
"space_marine_listening_post",
"space_marine_turret_bolter"
},

-- at least this number of units if no buildings
g_NumUnits = 1,
}

function CheckAnnihilate()

-- total number of players
local count = World_GetPlayerCount();

--check for annihilated dudes
for i = 0, count-1
do
-- check if player has been annihilated
local player = World_GetPlayerAt(i);

--if no buildings and less than g_NumUnits, then you die
if( Player_IsAlive(player) ) then
if( Player_HasBuildingsExcept(player, _Annihilate.g_annihilate_exceptions) == false ) then
 if( Player_GetUnitCount(player) < _Annihilate.g_NumUnits ) then
Player_Kill(player);
 end
end
end
end

-- check if only one team left -- if only one team left, they win and everybody else loses
Util_CheckOneTeamLeft("annihilate");
end

Scar_AddInit(Annihilate2)

NOTE: The annihilation WC that shipped with the game (and as of 1.10) states g_NumUnits = 0, meaning that you would have to have less than 0 units to trigger that – so it's never triggered. -theBlind

Links


SCAR
Wiki Home

End of Page


Referring pages: DOWScar
DOWScar/Tutorials
DOWScar/Tutorials/Advanced

There are no files on this page. [Display files/form]
There is no comment on this page. [Display comments/form]