View Full Version : Spawning units with upgrades
21st Jan 10, 2:34 PM
Hello I was wondering if there was any way to Spawn units with upgrades we choose using the scar files not rbf's?
21st Jan 10, 4:26 PM
Yes, there is. It seems that most of your problems can be solved by a quick look through the SCARDoc, so if you don't already have it, here it is (http://cohpatch.relic.com/relic/dow2/dow2scardoc.zip)
The function you want is
Util_CreateSquads( PlayerID player, SGroupID sgroup, SquadBlueprint/Table sbp, Integer/String level, Marker/Pos/SGroup/EGroup spawn_point[, Position destination, Integer numsquads, Integer loadout, WargearTable wargear] )
The last argument is a table of wargear that the squad will start the game with. If you really want an upgrade, and not wargear, then you'll have to apply one just after the squad is spawned by using
Cmd_InstantSquadUpgrade( SGroupID sgroup, UpgradeID upgradeid[, Integer count] ) .
Remember to use the SCARDoc ;)
21st Jan 10, 4:42 PM
Wow thanks man!
22nd Jan 10, 12:10 AM
Thanks for the ScarDoc Miguel, just what I needed! :)
I've actually tried with exactly that method, without any luck. I'm trying to spawn a tac marine squad with the sergeant. No luck so far. I'm thinking that maybe the restrictions (in this case, level 2 hq for sergeant upgrade) is blocking. I'm still a newbie with this modding thing, so I'm not sure yet whether these scar methods can ignore any requirements, or not.
EDIT: Or maybe this is what's making it not work: "Note that this command will do nothing if called from within scenario initialization. It will only work if the simulation is already running."
22nd Jan 10, 1:03 AM
Ah, well if you're adding leaders, that's a bit different.
There is a function SGroup_AddLeaders( SGroupID sgroup ), but I'm not sure if it actually works (some functions Relic have half made, but didn't finish)
As for using Cmd_InstantSquadUpgrade(), yes, you'll have to do that a but not inside the OnGameSetup() and OnInit() methods. Try using a one shot rule (Rule_AddOneShot(), look it up in the SCARDoc) that fires less than a second after.
22nd Jan 10, 1:24 AM
Thanks, I'll try playing around with those fine ideas when I get back from work!
I actually never did find a OnGameSetup or OnInit method, but well, it works anyway I guess! :rofl:
22nd Jan 10, 2:17 AM
Well I'd seriously consider using the OnInit() function so that its all setup before the game actually starts.
You have to add OnInit functions by using the AddInit() function, but you can name your function whatever you want. E.G:
--Insert Code Here
Whereas the On Game Setup method is automatically called, but it has to be named the same thing each time:
--Insert Code Here
24th Jan 10, 5:18 AM
Well, I got it working now!
It looks like the problem was: "It will only work if the simulation is already running". I've moved it to my "tick" method, so the first time the method is called, all units are upgraded with the selected upgrades (including adding a sergeant).
So the method I use is: Cmd_InstantSquadUpgrade
24th Jan 10, 4:42 PM
How often is that tick function? I'd be careful not to make it an every frame rule.
25th Jan 10, 12:15 AM
It's a 2 sec tick, but the upgrades are only added the first time it runs! I'll probably move it to a "run once" rule. But for now I'm good.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.