Page 4 of 5 FirstFirst 12345 LastLast
Results 151 to 200 of 212

[How To] Some Basic Scar for Mappers

  1. #151
    For Wehr: (by player)

    Code:
    Cmd_InstantUpgrade(PLAYER, UPG.AXIS.VETERANCY.INFANTRY1, ITEM_UNLOCKED)
    Use 2/3 etc for level. For types use: INFANTRY / SUPPORT_INF / VEHICLE / TANK

    e.g. UPG.AXIS.VETERANCY.TANK3

    For Americans: (by squad)

    SGroup_IncreaseVeterancyRank(SGROUP, NO_OF_UPGRADES, SKIP_REQUIREMENTS)

    e.g.
    Code:
    SGroup_IncreaseVeterancyRank(sg_test, 2, true) --2 stripes
    British obviously use officers for this. For Panzer Elite (by squad)...

    Code:
    Cmd_InstantUpgrade(SGROUP, UPG.ELITE.INFANTRY.OFFENSIVE1, ITEM_UNLOCKED)
    Use OFFENSIVE2 or OFFENSIVE3 or DEFENSIVE1/2/3 etc for higher levels.

    For vehicles, just replace INFANTRY. e.g. UPG.ELITE.VEHICLE.OFFENSIVE1

    You can use multiple lines to get the desired effect with PE, e.g. 2 points in offence, 1 in defence. AFAIK scar doesn't like it if you try to use a World_GetRand() number on the end of the upgrade, so you'd have to program and if/else using rands if you want them all to be different. e.g.

    Code:
    vetlevel = World_GetRand(1,2)
    
    if vetlevel == 1 then 
    
    Cmd_InstantUpgrade(SGROUP, UPG.ELITE.INFANTRY.OFFENSIVE1, ITEM_UNLOCKED)
    Cmd_InstantUpgrade(SGROUP, UPG.ELITE.INFANTRY.DEFENSIVE2, ITEM_UNLOCKED)
    
    elseif vetlevel == 2 then 
    
    Cmd_InstantUpgrade(SGROUP, UPG.ELITE.INFANTRY.OFFENSIVE2, ITEM_UNLOCKED)
    Cmd_InstantUpgrade(SGROUP, UPG.ELITE.INFANTRY.DEFENSIVE1, ITEM_UNLOCKED)
    
    end
    ---

    To get the required delay, you'd need to add a new custom function, and then add a oneshot rule for it from the OnGameSetup()

    e.g. Rule_AddOneShot(AddVet, 600) -- 600 as the time is in seconds

    Code:
    function AddVet()
    
    Cmd_InstantUpgrade(PLAYER1, UPG.AXIS.VETERANCY.INFANTRY1, ITEM_UNLOCKED)
    
    end
    Last edited by Sando; 21st Jan 12 at 5:20 AM.

  2. #152
    Member ChickenNuggets's Avatar
    Join Date
    Mar 2011
    Location
    Your closet
    Hey, I was hoping somebody here could help me out and tell me how I would go about disabling HQ's? In some of the relic missions (And in some custom missions) there are no HQ's present on the map. So, If anybody comes by with some helpful info I would greatly appreciate it.
    Last edited by ChickenNuggets; 9th Jan 12 at 6:05 PM.

  3. #153
    I pm'd you about this, but for anyone else who needs to know, in WB use "ebps\gameplay\sp_invisible_control_structure" instead of a normal HQ - it allows the player to still have a start sector, get command points and collect resources properly, but doesn't appear on the map or allow them to build/upgrade from it.

  4. #154
    Member ernesto-m's Avatar
    Join Date
    Jul 2011
    Location
    Karlsruhe / Germany
    Hi folks,

    how can I realize an Day/Night cycle on a Map with Scar-Scripts? ( Day/Dusk/Night/Dawn/Day/...)

  5. #155
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    As far as I know this is not possible via scar. Scar is missing such type of functions. This you'll have to make via map (athmosphere?) settings.

  6. #156
    Member ChickenNuggets's Avatar
    Join Date
    Mar 2011
    Location
    Your closet
    @Jagdpanther, yes, it is very much possible.
    @ernesto-m,
    Code:
             function weather()
    
              Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/cxp2_oosterbeek_predawn_00.aps", 100)
    
              end
    There is an example, You have start it with a rule or something as it's a custom function. Notice the "100" at the end, that means how much time it will take after the function is run for it to fully transition over to that atmosphere.
    So if the function runs 10 mins into the game (or after another thing happens) it will begin transitioning taking anywhere from 1-1 000 000 seconds to get to it.

  7. #157
    Member ernesto-m's Avatar
    Join Date
    Jul 2011
    Location
    Karlsruhe / Germany
    Thank you for this fine hint.

    I found in a Map :
    VEULES_EVENING
    VEULES_SUNRISE
    VEULES_NIGHT
    VEULES_NIGHT_MOON
    VEULES_MORNING_SUN
    VEULES_DAY
    VEULES_AFTERNOON

    Now the question is where are this files located? May be in an original file of CoH ?

    @ ChickenNuggets, ok I understand, for every Day/Night-cycle I have to load a different Atmosphere.aps.

  8. #158
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    @ChickenNuggets: Argh, I know there was a function like this, but on yesterday search i couldn't find it.

    @ernesto-m: those presets are looking very similar to those of PlaymoBills "Veules_les_Rose". This map uses the cycles above. This should be custom presets. But the short way is to ask him directly.

    Edit: yepp they are part of the map. You can see they, if you open up the sga archive separately with corsix ms. In "data\art\scenarios\presets\atmosphere" are all those presets located.
    Last edited by Jagdpanther; 2nd Feb 12 at 4:20 AM.

  9. #159
    Yeah you can either set them up as usual through WB, or you can include premade atmosphere's from the existing game maps using the code above (you can use any of them in any combination, but they may do funny things to the lighting/shadows when from different maps). I'd imagine you could probably include custom atmosphere's this way too, but would probably need to make some kind of mini-mod to get it working.

    There's a complete list of premade ones if you open the WW2Art archive (in WW2 | Archives) and look in art/scenarios/presets/atmosphere. There's no descriptions so you'd have to try them out to see how they look - using the seconds timer set very low you can quickly get an idea - normally you'd want quite a long time for these transistions so it doesn't look weird! (30-60 minutes is not out of the question!)

    There's no limit on how many you can use (just rack them up in oneshot rules that trigger the next one) - although you dont want too many in too short a time for performance reasons. You can also use the code to trigger things like rain/thunder at dramatic moments in the game - some of the oosterbeek ones work for this as they have nighttime, rain, and thunder ones which work well together.

  10. #160
    Member hockeyshooter's Avatar
    Join Date
    Dec 2007
    Location
    nr Milton Keynes, England
    Just starting to play with spawning then getting the spawned squad to rush off on a mission. Its easier with a 2-player map because obviously both start positions have to be occupied. But for 4- 6- and 8-player you have to test for the existence of that player before you assign anything to it otherwise you'll get a scar error. I know how to check the "race" of a player but how do you check if a player slot is even occupied, or if its assigned to AI?

  11. #161
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    You can check this before with:
    Code:
    for i = 1, World_GetPlayerCount() do
    	Player_ID = World_GetPlayerAt(i)
            -- do some actions here
    end
    This will use only filled player slots. Before you assign any action to a player test his existence with Player_IsAlive(Player_ID). The type of the player (AI or human) you can get with
    Code:
    player_type	 = Player_GetAIType(player_id)
    -- possible AI-types are: AII_Normal, AII_LocalHumanTakeover, AII_RemoteAITakeover, AII_RemoteHumanTakeover (or -1 for human players)

  12. #162
    Member hockeyshooter's Avatar
    Join Date
    Dec 2007
    Location
    nr Milton Keynes, England
    That's great Jagdpanther - will test that this weekend.

  13. #163
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    Pleasure.

    Btw. The returns of the ai-type are numbers and are equivalent to the constants (AII_xxxx).

  14. #164
    Member ernesto-m's Avatar
    Join Date
    Jul 2011
    Location
    Karlsruhe / Germany
    Many thanks for your Hints, the Day / Night - Cycle works. ;o))

    To test the different *.aps, 24 hours are compressed in 1440 Sec.

    "watch_counter" is the Clock. Map - time starts at 4 am ( watch_counter=240 ), function is called every 60 Sec. ( = 1 hour ).

    For more realistic behavior I scale the "watch_counter".

    A Problem is, that the Map laggs massiv when Day/Night-Cycle is aktiv, because i have a lot of functions on the Map who are call every Second or shorter. The Map simulates the Flight Traffic on an Axis Airfield, with three Henschel Aircrafts and when Day/Night - Cycle runs, then the Plains are running out of order ;o))



    Code:
    function day_cycle()
            if 	watch_counter==240 then
              Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/cxp2_oosterbeek_daybreak_00.aps", 120)
    		end
    		if watch_counter==360 then
    		  Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/coho_invasion_morning.aps", 120)
    		end
    		if watch_counter==600 then	
    		  Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/coho_irreville_day.aps", 120)
    		end
    		if watch_counter==840 then
    		  Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/coho_citybattle_afternoon.aps", 120)
    		end
    		if watch_counter==1080 then
              Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/cxp2_oosterbeek_predawn_00.aps", 120)
    		end
    		if watch_counter==1320 then
    		  Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/cxp2_oosterbeek_night_00.aps", 120)
    		end
    		watch_counter=watch_counter+60
    		if watch_counter>=1440 then
    			watch_counter=0
    		end
    end
    Rule_AddInterval(day_cycle,60)
    Last edited by ernesto-m; 13th Feb 12 at 3:21 AM.

  15. #165
    Member stalkerblaze's Avatar
    Join Date
    Dec 2008
    Location
    Wrocław, Poland
    Two questions, one easy and one probably not so easy.

    1. What is the easiest way to print a text via scar (not to console or log but on the game screen)?
    2. Let's say I want to ask a Yes/No question via scar to which a player. Is there a way to capture chat with SCAR? Is it possible to create a dialog box? Or is the only way to make something strange like: add explosives on the building with "Detonate me" via scar, if the building is standing 5s later than the answer was yes?

  16. #166
    Printing on screen, the easiest way is to use these custom functions:

    Code:
    function Util_CreateLocString(text)
    	local tmpstr = LOC(text)
    	tmpstr[1] = text
    	return tmpstr
    end
    
    function Util_GlobalMessage(title, displaytime, nosound)
    	local _ShowMsg = function()
    		CTRL.Game_TextTitleFade(title, 0, displaytime, 2, "")
    		CTRL.WAIT()
    	end
    
    Util_StartIntel(_ShowMsg)
    
    end
    Include them in your file somewhere - it doesn't matter where exactly. Then use this kind of code to present the messages:

    Code:
    allywin1msg = Util_CreateLocString("Well Done Commander! Our forces have captured the port")
    Util_GlobalMessage(allywin1msg, 5)
    The variable can be called whatever you like.

    The Yes/No, I'm not so sure about. Things like explosives detonated can be checked thou:

    Cmd_SetDemolitions( SGroupID sgroupid, EGroupID targetid[, Boolean skipCostPrereq, Boolean queued] )

    Then check whether player set off the charges:

    EGroup_NotifyOnPlayerDemolition( EGroupID id, LuaFunction function )

    (the egroup is an entity group you've setup already)

  17. #167
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    A Problem is, that the Map laggs massiv when Day/Night-Cycle is aktiv, because i have a lot of functions on the Map who are call every Second or shorter. The Map simulates the Flight Traffic on an Axis Airfield, with three Henschel Aircrafts and when Day/Night - Cycle runs, then the Plains are running out of order ;o))
    The question is, why do you whish to trigger this via scar instead of setting up your map properly.

  18. #168
    Member ernesto-m's Avatar
    Join Date
    Jul 2011
    Location
    Karlsruhe / Germany
    @ Jagdpanther ,..I tried but don´t work, may be I am to foolish ;o))

    After redesigned of some Scripts, every thing works fine.

  19. #169
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    This sounds good mate. So the problem was more in your script?

  20. #170
    Member ernesto-m's Avatar
    Join Date
    Jul 2011
    Location
    Karlsruhe / Germany
    @ Jagdpanther, yes I think so, some routines in Debug mode ( display Text on Screen) was the Problem.

  21. #171
    First of ALL,thank you all of your help with these Scar tut!
    then I made Scar for myself.I want the AI Spawn a SU85 from mrk_SU85_Spawn once the player1 unit get into the mrk_near of 30 radio every 20 seconds.When the player1 leave this area AI will stop Spawn the SU85.I find ingame this Scar work find in the beginning,SU85 appear every 20 seconds when player1 walk into the area,the process seem to be work fine,but when the player1 leave this area for some seconds,the Scar go into vital error.this is my Code:
    import("scarutil.scar")
    function OnInit()

    Rule_AddInterval(IsPlayer1Near, 20)


    end

    Scar_AddInit(OnInit)


    function IsPlayer1Near()

    if Prox_ArePlayersNearMarker(World_GetPlayerAt(1), mrk_near, false, 30) then

    types_tank = {SBP.SOVIET.SU85}

    sg_spectank = SGroup_CreateIfNotFound("sg_spectank")

    Util_CreateSquads(World_GetPlayerAt(2), sg_spectank, types_tank, mrk_SU85_Spawn, nil, 1)

    Cmd_AttackMove(sg_spectank, Util_GetPosition(mrk_Tarket), true)

    end

    end
    In this place I dont use "Rule_RemoveMe()" because I want the SU85 appear everytime the player1 move in this area.

    PLZ HELP ME
    Last edited by coh; 11th Feb 12 at 1:14 AM.

  22. #172
    I cant see anything obviously wrong with your code coh (take it ur running the EF mod?) - if you press CTRL ALT and ~ when it does the fatal error, it should give you a message saying why. Alternatively look in C:\Users\**USER**\Documents\My Games\Company of Heroes\LogFiles in Warnings file - if you can find the fatal error in there, and post it up here, can probably help more...

  23. #173
    HI?Sando,thank you for your help.I retry it some times and find that sometime this error come out but sometime are not.
    and this is what I get from game.
    fatalscarerror:[string"EASTERN_FRONT\DATA\SCAR\AICONTROL.SCAR"]:141:attempt to index field'?'(a nil value)
    SCAR-FATAL SCAR ERROR WHILE RUNNING RULES

    Btw I try this code later and find it can run without a error.I change the SU85 to STUG and it work perfect.
    import("scarutil.scar")
    function OnInit()

    Rule_AddInterval(IsPlayer1Near, 20)


    end

    Scar_AddInit(OnInit)


    function IsPlayer1Near()

    if Prox_ArePlayersNearMarker(World_GetPlayerAt(1), mrk_near, false, 30) then

    sg_spectank = SGroup_CreateIfNotFound("sg_spectank")

    Util_CreateSquads(World_GetPlayerAt(2), sg_spectank, SBP.AXIS.STUG, mrk_SU85_Spawn, nil, 1)

    Cmd_AttackMove(sg_spectank, Util_GetPosition(mrk_Tarket), true)

    end

    end

  24. #174
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    Looks like the problem comes from the third parameter of "Util_CreateSquads". It's described to can be used either with a table or a squad blueprint, but it seems to work in your case only correct if you use a blueprint there.

    You can check this by using directly SBP.SOVIET.SU85 instead of SBP.AXIS.STUG as the third parameter.

    One additional note: you should always check, if the player you will act with, is already existing. See post #161, otherwise your script will crash.

    btw. what is line #141 in your script, which is the line number from the scar error?

  25. #175
    Hi! Jagdpanther
    Thank you for your advice in the Script
    and this is all the info in the scar log
    -- Log file for all error messages related to the Scar --

    Starting SCAR...

    *FATAL SCAR ERROR: [string "EASTERN_FRONT\DATA\Scar\aicontrol.scar"]:141: attempt to index field '?' (a nil value)
    Could not execute rule:
    FATAL Scar Error while running rules - Execution has been paused.
    Shutting Down SCAR...
    I think you will be right,will try it out later.

  26. #176
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    What I meant with the line number is, what is the content of this line inside your script. The scripting part you show us, don't show us the line numbers. So we don't know exactly which line of code cause the error.

  27. #177
    in fact this is all the script in my Scar

    import("scarutil.scar")
    function OnInit()

    Rule_AddInterval(IsPlayer1Near, 20)


    end

    Scar_AddInit(OnInit)


    function IsPlayer1Near()

    if Prox_ArePlayersNearMarker(World_GetPlayerAt(1), mrk_near, false, 30) then

    types_tank = {SBP.SOVIET.SU85}

    sg_spectank = SGroup_CreateIfNotFound("sg_spectank")

    Util_CreateSquads(World_GetPlayerAt(2), sg_spectank, types_tank, mrk_SU85_Spawn, nil, 1)

    Cmd_AttackMove(sg_spectank, Util_GetPosition(mrk_Tarket), true)

    end

    end
    I just wander where the 141 line come from?

    btw I try your advice that using directly SBP.SOVIET.SU85 instead of SBP.AXIS.STUG as the third parameter.That work perfect without any error.Thank you for your great help!

    ----------

    All credit to Sando in his Scar in #99,this is a very simple script to make the AI Spawn some Unit if this Unit is not exit in map,and the AI will never Spawn it again utill the Unit is all killed.it work fine for me.May it help you.


    import("scarutil.scar")
    function OnInit()

    Rule_AddInterval(SpawnTank, 20)


    end

    Scar_AddInit(OnInit)


    function SpawnTank()

    sg_specTank = SGroup_CreateIfNotFound("sg_specTank ");

    if ( SGroup_IsEmpty(sg_specTank ) ) then

    Util_CreateSquads(World_GetPlayerAt(2), sg_specTank , SBP.SOVIET.SU85, mrk_SU85_Spawn, nil, 1);

    Cmd_Move(sg_specTank , Util_GetPosition(mrk_Tarket), true);

    else
    Cmd_Move(sg_specTank , Util_GetPosition(mrk_Tarket), true);

    end

    end
    all have fun!!
    Last edited by coh; 11th Feb 12 at 10:57 PM.

  28. #178
    ernesto-m have made his way to make a Day/Night swicth Script.And I try in my own way,still not good enought.But still fine with me.Hope that can help.the map will turn day every about 20 munites.
    import("ScarUtil.scar")
    import("WCUtil.scar")
    g_CheckAnnihilate = true

    function OnInit()
    Rule_AddOneShot(night_cycle, 1400)
    Rule_AddInterval(daynight, 2800)

    end

    function daynight()

    Rule_AddOneShot(day_cycle, 0)
    Rule_AddOneShot(night_cycle, 1400)

    end

    Scar_AddInit(OnInit)

    function day_cycle()
    Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/coho_irreville_day.aps", 200)
    end


    function night_cycle()
    Game_LoadAtmosphere("data:art/scenarios/presets/atmosphere/cxp2_oosterbeek_night_00.aps", 200)
    end
    Last edited by coh; 12th Feb 12 at 3:58 AM.

  29. #179
    Member ernesto-m's Avatar
    Join Date
    Jul 2011
    Location
    Karlsruhe / Germany
    @ coh, many thanks for your hint. My Day/Night-Cycle now runs properly, without lagging. The Problem was in some Debug-Routines.

  30. #180
    Member stalkerblaze's Avatar
    Join Date
    Dec 2008
    Location
    Wrocław, Poland
    @Sando Thanks.

    Another question: Is there a way to have a SCAR listener for example: every time a civilian building is destroyed, that listener would perform specified function with that building as an parameter? It doesn't need to be map universal (so code or map adjustment may be still needed). I could do different function for each building, but I'm just looking for more efficient and easier way to do it.

  31. #181
    You can do it, but afaik you'd need to egroup each building you wanted checked, and add a number to each one, i.e.

    civ_build1, civ_build2, 3, etc

    Then write some code which loops a checker for them, something like:

    for i = 1, *number of buildings to check* do
    local eg_temp = "civ_build" .. i

    EGroup_NotifyOnPlayerDemolition(eg_temp, *function to run*(eg_temp))

    end

    Then have your function to run feeding in the eg_temp group to do the response. e.g.

    function DetonationChecker(egroup)

    --STUFF which uses the egroup

    end

  32. #182
    Member stalkerblaze's Avatar
    Join Date
    Dec 2008
    Location
    Wrocław, Poland
    Thx once again

  33. #183
    Does anyone know the code to store all valid PlayerID's into a table? I expected World_GetPlayerAt() to return nil for nonexistent players but when playing 8 player map with 5 players it returned valid table for all 8.

  34. #184
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    USA
    This is how I cycle through players.

    Code:
    for p = 1, World_GetPlayerCount() 
    do	
    	local player = World_GetPlayerAt(p);
    	local playerID = Player_GetID(player) - 999;
    
    	-- do stuff here
    end
    Only works for active players.

  35. #185
    Member ChickenNuggets's Avatar
    Join Date
    Mar 2011
    Location
    Your closet
    LyonRailStation

    I am trying to get the relic encounter missions to work, I added the map to the normandy campaign, it loads fine (thank god) and works, the first thing it does is focuses the camera on 3 small riflemen squads, then to the railroad and I think it is then supposed to return to default view but get's a SCAR error. I will show the code in which the error occurs.

    Code:
    function LyonRail_MissionStart()
    	
    	Util_AutoNISlet(NISLET_BLACK2GAME, t_LyonRail.nislet_railStart)
    	
    	-- delay initial troop movement
    	Rule_AddOneShot(LyonRail_MissionStart_DelayMove, 5)
    	
    end
    The error is coming from the delay move function.

    Code:
    function LyonRail_MissionStart_DelayMove()
    	
    	-- move squads
    	local moveto = {0, 1, 7}
    	for i = 1, 3 do
    		Cmd_MoveToPosOffset(sg_rail01_p1Starters[i], Marker_GetPosition(mkr_rail01_playerstart), moveto[i], World_GetRand(7, 9))
    	end
    	
    	-- delay first objective
    	Rule_Add(LyonRail_DelayCapStation)
    Apparently the error is something to do with the Cmd_MoveToOffsetPos bit, which I am not sure as to whether it is correct or not.
    It links it to sg_rail01_p1Starters which is found in the mission_presets function. And to the marker mkr_rail01_playerstart which matches the one on the map.

    Code:
    function LyonRail_MissionPreset()
    
    	sg_rail01_p1Starters = SGroup_CreateTable("sg_rail01_p1Starters%d", 3)
    	sg_rail01_p1All = SGroup_CreateIfNotFound("sg_rail01_p1All")
    	sg_snipe01_p2All = SGroup_CreateIfNotFound("sg_snipe01_p2All")
    	eg_snipe01_p2All = EGroup_CreateIfNotFound("eg_snipe01_p2All")
    
    	-- create the temperary starting units for player 1
    	for i = 1, 3 do
    		Util_CreateSquadsAtMarkerFacing(player1, sg_rail01_p1Starters[i], SBP.ALLIES.RIFLEMEN, mkr_rail01_playerstart, mkr_rail01_hmgfirepoint, 1, World_GetRand(4, 5))
    		SGroup_AddGroup(sg_rail01_p1All, sg_rail01_p1Starters[i])
    	end
    	
    	t_LyonRail = {
    		pos_rail02_axTank01 = false,
    	}
    	local pos1 = EGroup_GetPosition(eg_rail01_playergoal)
    	local pos2 = Marker_GetPosition(mkr_rail01_playerstart)
    	t_LyonRail.nislet_railStart = {
    		{camPos = pos1, waitType = NISLET_TIME, waitValue = 5},
    		{camPos = pos2, waitType = NISLET_TIME, waitValue = 3},
    	}
    	local posA = EGroup_GetPosition(eg_snipe01_playerhouse)
    	local posB = Marker_GetPosition(mkr_snipe01_bridge)
    	local posC = Marker_GetPosition(mkr_snipe01_mine02)
    	t_LyonRail.nislet_sniperStart = {
    		{camPos = posA, waitType = NISLET_TIME, waitValue = 3},
    		{camPos = posB, waitType = NISLET_TIME, waitValue = 3},
    		{camPos = posC, waitType = NISLET_TIME, waitValue = 3},
    		{camPos = posB, waitType = NISLET_TIME, waitValue = 2},
    	}
    	local posG = Marker_GetPosition(mkr_hold01_hq)
    	local posH = Marker_GetPosition(mkr_snipe01_bridge)
    	t_LyonRail.nislet_holdStart = {
    		{camPos = posG, waitType = NISLET_TIME, waitValue = 3},
    		{camPos = posH, waitType = NISLET_TIME, waitValue = 3},
    		{camPos = posG, waitType = NISLET_TIME, waitValue = 3},
    	}
    
    	-- if areas of your script need to be kicked off early
    	CapStation_Init()
    	CapStation_Preset()
    	--EncounterName_Init()
    	
    	-- despawn preplaced units - NO TEAM WEAPONS
    	if SGroup_IsEmpty(sg_rail02_axTank01) == false then
    		t_LyonRail.pos_rail02_axTank01 = SGroup_GetPosition(sg_rail02_axTank01)
    		SGroup_DeSpawn(sg_rail02_axTank01)
    	end
    	-- despawn preplaced egroups
    	local egroups = {eg_snipe01_opelAll, eg_snipe01_pakAll, eg_hold01_hq, eg_hold01_point}
    	for k, v in pairs(egroups) do
    		EGroup_DeSpawn(v)
    	end
    end
    I figured that if there was anywhere to get help it would be from here. I tried editing a couple things which I thought might of been causing the errors but just got more errors :P
    I'm used to reading Sando's type of code, Relic's coders seem to use a different style I suppose. It is hard trying to read someone else's code when your'e as bad at coding as me!

  36. #186
    Interesting. Trying to call Player_GetID for PlayerID's that were returned during OnGameSetup crashes, but doing the same for PlayerID's returned during OnInit works. Also, World_GetPlayerCount returns 8 during OnGameSetup and real number during OnInit.

  37. #187
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    Cmd_MoveToPosOffset seems to be not a part of the standard command set. So I think it has to do with the mission archive. There are more scar stuff inside than only the map scar. There are some additional files, they partially overwrite original files from the standard like a custom luaconsts. This is why you receive this error. you have to extract the full content, comparing all files they also exist in the standard for differences and add the missing files to the standard.

    But all this differs from mission to mission and I don't know any mission by name.

  38. #188
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    USA
    @FaTony
    Probably because the players haven't been set up yet in OnGameSetup. I run my code in a function called from Annihilate_OnInit().

  39. #189
    Ok, now I can't get this to work:
    PHP Code:
    Modify_EntityCost(player1SBP.ALLIES.SNIPERRT_Manpower100
    Any ideas?

  40. #190
    Yep they're probably old commands that are no longer valid - you can either replace them with the new commands, or include these kind of translators somewhere in your code:

    Code:
    function Cmd_MoveToMarker(sgroup, marker)
    	Cmd_Move(sgroup, marker, false)
    end

  41. #191
    Member ChickenNuggets's Avatar
    Join Date
    Mar 2011
    Location
    Your closet
    I was wondering about that, I will try to fix it up and make it playable. And FaTony, I think that function requires blueprints, doesn't it?

    ----------

    Jagdpanther, are you saying I have to extract other files from a different location aside from just the map itself? Where would I find these files? Do you know? Otherwise I will do what Sando said and modernize it. (So to speak)

    I am now finding errors on multiple lines, so the only way to get this mission to run would be to do what Jagdpanther's talking about I guess.
    Last edited by ChickenNuggets; 28th Feb 12 at 5:47 PM.

  42. #192
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    A while back I was stumbling over these files by searching something others. For example you can open up one of the dlc archives (eg. "DLC1\Archives\DLC1Data.sga") in corsix-ms. There you will see many additional stuff alongside with the map. Take a closer look into the scar or the scenario folders and you will see what I mean.

    Don't know from which archive your mission is coming, so I can't point you direct. I'm not a mission player.

  43. #193
    @FaTony - eliw00d is right. OnGameSetup is where you can setup your own players (overriding what the game is requesting) so until that function runs none of the players are really valid. OnInit runs after that function and thus the players are valid by that point.
    "There's no explaination for why I survived and others didn't other than when your number is up its your time to go. So now, every morning when I get up - I change my number."

    Unknown Pearl Harbor Survivor

  44. #194
    @Jaffar, can I create AI players there? Or move humans into different slots? Also, is there somewhere a list of functions that can be called during OnGameSetup? It looks like most of the functions do not exist at that time (oh, Lua). Or should I presume that these are that start with Setup_?

  45. #195
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    USA
    @FaTony
    That has nothing to do with Lua and everything to do with the initialization of Relic functions and variables. There is not a list of functions that can be called during OnGameSetup because there is no need for one. Simply do what you need to do after the game has properly initialized and you will not have problems.

  46. #196
    Only thing I ever do in there is call Setup_Player.

    You can setup AI players and move players around just by setting them up using that function.

    The one thing that WILL cause errors is obviously trying to create more players than the map is setup for.

  47. #197
    @eliw00d Yes, it has. Lua has first-class functions unlike C and C++. In fact, you can overwrite Relic functions at runtime to point to your own code (if I understood Lua tutorial correctly).

    Thanks everyone for replies. I'm going to experiment further.

    EDIT: Btw, here's what I've come up with:
    PHP Code:
    local NumPlayers
    local Players 
    = {}

    function 
    OnInit()
        
    NumPlayers World_GetPlayerCount()
        for 
    1NumPlayers
        
    do
            
    Players[i] = World_GetPlayerAt(i)
        
    end
    end 
    EDIT2: I wrote this code before I learned about # operator, I think it can be rewritten with #Players. It'll waste a few CPU cycles to get the size of table but is easier to maintain.
    Last edited by FaTony; 5th Mar 12 at 3:30 AM.

  48. #198
    Member Jagdpanther's Avatar
    Join Date
    Dec 2008
    Location
    Berlin
    @FaTony: I don't think so. Lua is of course able to use code from other dll's, but for what reason you will "overwrite" Relic functions? A really "overwrite" is not possible, you only can extend Relic's functions. This means not you can add several players, the map or the game is made for. There is another stuff involved that is simply missing and you can't create it.

  49. #199
    PHP Code:
    function MyHack()
        --
    some code
    end

    function OnGameSetup()
        
    World_GetPlayerAt MyHack
        
    --At this point all calls to World_GetPlayerAt will be forwarded to MyHack
        
    --and Relic's code for World_GetPlayerAt should fall victim to garbage collection
        --which will completely erase it from Lua'
    s virtual machine.
        -- 
    A complete overwrite.
    end 
    This can be useful if you want to alter code of 3rd party maps without editing them. Importing your own file which overrides Relic code at the end of ScarUtils.scar should do the trick.

    Again, I was talking about a bit awkward nature of Lua. I prefer to think in framework of int main() or callbacks. The ability to call Scar_AddInit() outside of any functions seems so strange.

  50. #200
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    USA
    @FaTony
    Yes, you can overwrite Relic's functions with your own, but that wasn't my point. The reason you were having trouble to begin with is because you were trying to loop through variables that were not properly initialized. That part has nothing to do with Lua. Sure, you can replace a few Relic functions, but why would you do that when you can just call your functions after everything is properly initialized?

Page 4 of 5 FirstFirst 12345 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •