*

Account

Welcome, Guest. Please login or register.
Did you miss your activation email?
June 25, 2024, 09:49:42 pm

Login with username, password and session length

Resources

Recent posts

[June 22, 2024, 06:49:40 am]

[March 08, 2024, 12:13:38 am]

[March 08, 2024, 12:12:54 am]

[March 08, 2024, 12:09:37 am]

[December 30, 2023, 08:00:58 pm]

[February 04, 2023, 11:46:41 am]

[December 25, 2022, 11:36:26 am]

[December 14, 2022, 12:10:06 am]

[September 22, 2022, 06:57:30 am]

[August 22, 2022, 05:10:35 pm]
Pages: [1] 2   Go Down
  Print  
Author Topic: SCAR help  (Read 9437 times)
0 Members and 3 Guests are viewing this topic.
frsd Offline
EIR Veteran
Posts: 109


« on: December 27, 2007, 10:40:07 am »

I just started trying to learn scar coding so im pretty much an newbie in it,
i made a map with 2 scar markers on it and typed in the following code and saved it under mymap.scar in the mp folder with it but somehow it doesnt seem to work Huh
Code:
import("ScarUtil.scar")

function OnGameSetup()
 
 --Disables annhiliate mod
 g_CheckAnnihilate = false
 
end

function OnInit()

--Give resources
Player_SetResource(player1, RT_Munition, 650)
Player_SetResource(player2, RT_Munition, 650)
Player_SetResource(player3, RT_Munition, 650)
Player_SetResource(player4, RT_Munition, 650)
Player_SetResource(player5, RT_Munition, 650)
Player_SetResource(player6, RT_Munition, 650)

--Override Popcap
Player_SetPopCapOverride(player1, 255)
Player_SetPopCapOverride(player2, 255)
Player_SetPopCapOverride(player3, 255)
Player_SetPopCapOverride(player4, 255)
Player_SetPopCapOverride(player5, 255)
Player_SetPopCapOverride(player6, 255)

--enable upgrades
Player_SetAbilityAvailability(player1, BP_GetAbilityBlueprint("abilities/ally_throw_grenade.lua"), ITEM_UNLOCKED)
Player_SetAbilityAvailability(player1, BP_GetAbilityBlueprint("abilities/ally_throw_sticky_bombs.lua"), ITEM_UNLOCKED)
Player_SetAbilityAvailability(player2, BP_GetAbilityBlueprint("abilities/axis_throw_grenade.lua"), ITEM_UNLOCKED)

--Spawnarmies
sg_allied_forces = SGroup_CreateIfNotFound("sg_allied_forces")
Util_CreateSquadsAtMarker(player1, sg_allied_forces, SBP.ALLIES.RIFLEMEN, mkr_1, 5)
Util_CreateSquadsAtMarker(player1, sg_allied_forces, SBP.ALLIES.RANGER, mkr_1, 4)
Util_CreateSquadsAtMarker(player1, sg_allied_forces, SBP.ALLIES.SHERMAN, mkr_1, 4)
Cmd_Move(sg_allied_forces, mkr_2)

sg_axis_forces = SGroup_CreateIfNotFound("sg_axis_forces")
Util_CreateSquadsAtMarker(player2, sg_axis_forces, SBP.AXIS.VOLKSGRENADIER, mkr_2, 6)
Util_CreateSquadsAtMarker(player2, sg_axis_forces, SBP.AXIS.GRENADIER, mkr_2, 5)
Util_CreateSquadsAtMarker(player2, sg_axis_forces, SBP.AXIS.PANZER, mkr_2, 3)
Cmd_Move(sg_axis_forces, mkr_1)

end
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #1 on: December 27, 2007, 10:50:02 am »

what are you trying to do? il take a peek.
Logged
fldash Offline
Founder
*
Posts: 9755


« Reply #2 on: December 27, 2007, 10:52:14 am »

You aren't defining the player numbers anywhere...

Do this:
Code:
	for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i);
Player_SetResource(player, RT_Munition, 650)
end
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #3 on: December 27, 2007, 10:54:14 am »

if you haven't allready read this, people said they found it useful.

http://forums.relicnews.com/showthread.php?t=171503
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #4 on: December 27, 2007, 10:55:31 am »

You aren't defining the player numbers anywhere...

Do this:
Code:
	for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i);
Player_SetResource(player, RT_Munition, 650)
end

@ frsd: i wouldn't try to use loops YET unless you allready know other code stuff, took me quite a while to get my head round it....
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #5 on: December 27, 2007, 10:57:09 am »

no offence fl-, but when you first start the simple but longer stuff might be easier... i may be wrong but this might be easier to understand

Code:
 -- Imports all the important scar helper functions and stuff for our use
import("ScarUtil.scar")

function OnGameSetup()
-- disable annihilate check that ends game if no critical buildings are in game
   g_CheckAnnihilate = false

-- define player variables used by various functions
  player1 = World_GetPlayerAt(1)
  player2 = World_GetPlayerAt(2)
-- add as many as you want.
end

which reminds me, i need to dig up my convoy mission and finish it...
« Last Edit: December 27, 2007, 10:58:49 am by |-| Cozmo |-| » Logged
frsd Offline
EIR Veteran
Posts: 109


« Reply #6 on: December 27, 2007, 11:01:00 am »

the link you gave i have already checked through, but there was no full example except the mission which was pretty complicated, but thanks for responding
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #7 on: December 27, 2007, 11:02:18 am »

i have to say that mission is VERY simple. no offence, its just a lot of words. My RTC code even confuses me sometimes...  Undecided
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #8 on: December 27, 2007, 11:02:52 am »

anyway, what do you want done and il give you an example.
Logged
frsd Offline
EIR Veteran
Posts: 109


« Reply #9 on: December 27, 2007, 11:08:54 am »

hmm still something doesnt seem to work Cry

but i think an working example should do
« Last Edit: December 27, 2007, 11:12:10 am by frsd » Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #10 on: December 27, 2007, 11:09:55 am »

as in NOTHING happens, is the file name correct and all that stuff, and what do you want to happen? tell me and il give you an example...
Logged
frsd Offline
EIR Veteran
Posts: 109


« Reply #11 on: December 27, 2007, 11:19:02 am »

well it should normally give all players 650MU unlock grenades(for both sides) and stickies and spawn

5 Riflemen
4 Ranger's
4 Sherman's
---
6 Volk's
5 Grenadier's
3 PanzerIV's

later on i wanted to add a win condition if one of the armies would die.

the map is called "6p_own_town.sgb" and the scar file "6p_own_town.scar", so that should be right
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #12 on: December 27, 2007, 11:19:54 am »

thats easy, gimme a sec...
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #13 on: December 27, 2007, 11:39:25 am »

ok there is propibly some syntax errors in there since i dont have CoH Installed and therefore cannot open corsix to check for syntax errors... also it might not work becuse it came off the top of my head... just test and tweek...


Code:
 -- Imports all the important scar helper functions and stuff for our use
import("ScarUtil.scar")

function OnGameSetup()
-- disable annihilate check that ends game if no critical buildings are in game
  g_CheckAnnihilate = false

-- define player variables used by various functions
  player1 = World_GetPlayerAt(1)
  player2 = World_GetPlayerAt(2)
  player3 = World_GetPlayerAt(3)
  player4 = World_GetPlayerAt(4)
  player5 = World_GetPlayerAt(5)
  player6 = World_GetPlayerAt(6)
end

function OnInit()

-- give all players the Mun
for i = 1, World_GetPlayerCount() do
local Plr = World_GetPlayerAt(i);
Player_SetResource(player, RT_Munition, 650)
end

-- override pop
for i = 1, World_GetPlayerCount() do
local Plr = World_GetPlayerAt(i);
Player_SetPopCapOverride(plr, 255)
end

-- Unlock nades, stickies etc.
local player = Game_GetLocalPlayer()

if Player_GetRace(player) == 0 or Player_GetRace(player) == 1 then
for i = 1, World_GetPlayerCount() do
local plr = World_GetPlayerAt(i);
Player_SetAbilityAvailability(plr, BP_GetAbilityBlueprint("abilities/ally_throw_grenade.lua"), ITEM_UNLOCKED)
Player_SetAbilityAvailability(plr, BP_GetAbilityBlueprint("abilities/ally_throw_sticky_bombs.lua"), ITEM_UNLOCKED)

elseif Player_GetRace(player) == 2 or Player_GetRace(player) == 3  then
Player_SetAbilityAvailability(player2, BP_GetAbilityBlueprint("abilities/axis_throw_grenade.lua"), ITEM_UNLOCKED)
end


-- spawn armies
for i = 1, World_GetPlayerCount() do
Local Plr = World_GetPlayerAt(i)
if Player_GetRace(Plr) == 0 or Player_GetRace(Plr) == 1 then
sg_allied_forces = SGroup_CreateIfNotFound("sg_allied_forces")
Util_CreateSquadsAtMarker(Plr, sg_allied_forces, SBP.ALLIES.RIFLEMEN, mkr_1, 5)
Util_CreateSquadsAtMarker(plr, sg_allied_forces, SBP.ALLIES.RANGER, mkr_1, 4)
Util_CreateSquadsAtMarker(plr, sg_allied_forces, SBP.ALLIES.SHERMAN, mkr_1, 4)
Cmd_Move(sg_allied_forces, mkr_2)

elseif Player_GetRace(Plr) == 2 or Player_GetRace(Plr) == 3 then
sg_axis_forces = SGroup_CreateIfNotFound("sg_axis_forces")
Util_CreateSquadsAtMarker(plr, sg_axis_forces, SBP.AXIS.VOLKSGRENADIER, mkr_2, 6)
Util_CreateSquadsAtMarker(plr, sg_axis_forces, SBP.AXIS.GRENADIER, mkr_2, 5)
Util_CreateSquadsAtMarker(plr2, sg_axis_forces, SBP.AXIS.PANZER, mkr_2, 3)
Cmd_Move(sg_axis_forces, mkr_1)
end
end
end
Scar_AddInit(OnInit)
Logged
frsd Offline
EIR Veteran
Posts: 109


« Reply #14 on: December 27, 2007, 11:58:10 am »

i checked the syntax and found 2 errors and repaired them, but now when i test it i get a fatal error message Shocked
and does the "if" need at "end"?
because of my scar skill im having problems repairing it
----------Fixed!!!!!!!!!!!!!!!!!!
yuhu, scar variables are pretty case sensitive as i have now noticed and as i have expierience with BlitzBasic i just change the Variables so they all worked, thanks for the example cozmo
« Last Edit: December 27, 2007, 12:12:45 pm by frsd » Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #15 on: December 27, 2007, 11:59:16 am »

guessed so, what are they? the scar errors?
Logged
frsd Offline
EIR Veteran
Posts: 109


« Reply #16 on: December 27, 2007, 12:31:29 pm »

well the 2 errors where line 40 you forgot "End" to close the "for" loop
and line 47 you wrote "Local" which the case wasn't right, right is "local"
then the scar errors where that sometimes you used "Plr" or "plr" at will and also mixing them up so you mostly had 2 variables instead of 1.
Logged
|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #17 on: December 27, 2007, 01:26:57 pm »

well then edit it:), you can do what ever you want with it.
Logged
Skunker Offline
Koenigstiger Panzerfuehrer
EIR Veteran
Posts: 993


« Reply #18 on: December 27, 2007, 02:55:50 pm »

no offence fl-, but when you first start the simple but longer stuff might be easier... i may be wrong but this might be easier to understand

Code:
 -- Imports all the important scar helper functions and stuff for our use
import("ScarUtil.scar")

function OnGameSetup()
-- disable annihilate check that ends game if no critical buildings are in game
   g_CheckAnnihilate = false

-- define player variables used by various functions
  player1 = World_GetPlayerAt(1)
  player2 = World_GetPlayerAt(2)
-- add as many as you want.
end

which reminds me, i need to dig up my convoy mission and finish it...
Lol, a loop is easy to understand if you wrap your head around it and it is only a few lines of code, as opposed to many.
Logged

|-|Cozmo|-| Offline
Lieutenant General of all Ninja's.
EIR Veteran
Posts: 4950


« Reply #19 on: December 27, 2007, 03:06:31 pm »

long ones are not. i was learning on mannerheims DDay code....
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!
Page created in 0.049 seconds with 35 queries.