tedi88
General
Blitzkrieg State Prosecutor
Posts: 1,228
|
Post by tedi88 on Aug 5, 2014 18:01:19 GMT 1
Kevin: I just tried it. You can switch the players via ChangePlayer Command in script. Furthermore it works, allied troops support you and enemies allies will fight you. Only catch is you have to give them ScriptID in Map editor then use a script command. Gunners will change as well depending on what side have you set up in Map editor. Hope it helps, EDIT: I'm not certain who just gave me rep so I'll rep both Kevin and Stanenberg.
|
|
|
Post by Kevin on Aug 5, 2014 18:07:48 GMT 1
Sure it helps!! Would you mind posting a few code line to see how it works? I think we should gather this and the night effect in a small tutorial...
|
|
|
Post by Stanenberg on Aug 5, 2014 18:11:17 GMT 1
The map is "shtrafbat2".
I think I don't need to post screens here anymore, as tedi88 already found how to do it.
I would also appreciate a tutorial for this "allied player" thing
|
|
|
Post by Kevin on Aug 5, 2014 18:18:11 GMT 1
|
|
tedi88
General
Blitzkrieg State Prosecutor
Posts: 1,228
|
Post by tedi88 on Aug 5, 2014 18:24:33 GMT 1
You're welcome. I've written this as a small tutorial. For test purposes I assigned an arty piece, a truck and an infantry squad ScriptID of 4998 for change into allied forces, while an identical force had ScriptID 4999. It doesn't matter if you place a unit under Player 1 or Player 0 ( I used Player 1 for initial forces). So after that's done in Map Editor, I added sides in Diplomacy tabs so it looked like this: 0 - 0 - Player Forces 1 - 1 - Enemy Forces 2 - 0 - Player Allies 3 - 1 - Enemy Allies 4 - 2 - Neutral So next step is: in Lua script in FunctionInit (but it can be used anywhere) i added the following lines: function Init() ChangeWarFog(4); ------------ This is by default 2 (when there are two players)/ to disable it place ChangeWarFog(0) this will reset the Fog of War ChangePlayer(4998, 2); ------ this one changes units into Player Allies/ 4998 - ScriptID 2 -Side ChangePlayer(4999, 3); ------ this one changes units into Enemy Allies/ 4999 - ScriptID 3 - Side Suicide(); end; Strafbat Script uses other ScriptID (obviously) and is called via a separate script but is the same otherwise: function change() ChangePlayer (100, 2); ChangePlayer (200, 2); RunScript( "poragenieT34", 3000); RunScript( "poragenieGrant", 3000); Suicide(); end; PoragenieT34 and poragenieGrant are controling parameters for failing the mission. I hope it's clear enough
|
|
|
Post by Kevin on Aug 5, 2014 18:35:07 GMT 1
o.O Brilliant tedi88! Thank you both! I gonna try it out with some of my units.
|
|
tedi88
General
Blitzkrieg State Prosecutor
Posts: 1,228
|
Post by tedi88 on Aug 5, 2014 18:39:30 GMT 1
No problems Kevin. I forgot to mention one thing: you don't have to place: 2 - 0 - Player Allies 3 - 1 - Enemy Allies You can also use: 2 - 1 - for player 3 - 0 - for enemy allies or any other combination (depends on a number of players).
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,124
|
Post by kaoz on Aug 5, 2014 23:15:58 GMT 1
Yes, you can use sort of an ally. In the MapEditor you can add a new party and set its side (friend or fo). A new neutral party will be automatically set. I have used it in some maps also, indeed mostly for (paratrooper) planes, so they won't become shot down.
I used it on infantry as well and they do attack and are being attacked, but they remain unseen, in case you have the sight to player0 that is... i've never tried to used both ChangeWarFog(0); and ChangeWarFog(2); because it seems unlogic that this would work, but i shouldn't write in stone without testing of course.
Besides, i believe setting the parties in MapEditor is meant for multiplayer, but it works in singleplayer also, with some limitations.
*Edit*
OK, so you did some testing already... didn't read 2nd page before posting my message...
|
|
tedi88
General
Blitzkrieg State Prosecutor
Posts: 1,228
|
Post by tedi88 on Aug 6, 2014 15:05:28 GMT 1
I used it on infantry as well and they do attack and are being attacked, but they remain unseen, in case you have the sight to player0 that is... i've never tried to used both ChangeWarFog(0); and ChangeWarFog(2); because it seems unlogic that this would work, but i shouldn't write in stone without testing of course.
kaoz: Thanks for pointing that out. However as far as I noticed, if you place a change player script you will be able to see what your allies see. At least that worked for me in the tests. On the other hand you are right ChangeWarFog(0); and ChangeWarFog(2); can't be used at the same time. What I meant was (maybe it wasn't clear enough) ChangeWarFog(0) is to disable ChangeWarFog(2) which is used in this case to simulate night effects.
|
|
|
Post by Kevin on Aug 6, 2014 16:04:28 GMT 1
I was going to post that "tutorial" is CSLA's blog, but it appears it's blocked and goes really slow since last night...
|
|
tedi88
General
Blitzkrieg State Prosecutor
Posts: 1,228
|
Post by tedi88 on Aug 6, 2014 16:29:39 GMT 1
I was going to post that "tutorial" is CSLA's blog, but it appears it's blocked and goes really slow since last night... Kevin if you want and while the blog gets unblocked, I can try to "reshape" the tutorial a little; maybe add a couple of pictures (not that it's needed, but still) to make it more comprehensible. What do you think?
|
|
|
Post by Kevin on Aug 6, 2014 16:40:16 GMT 1
You're idea's good.
Here's what I was going to post:
[Tutorial] LUA scripts for night and an allied IA
The first part of this little tutorial couldn't have been done without the help of ElGotele, whose script for his Pegasus Bridge map included in OBM 1.0 was the key to learn how a night effect using LUA scripts can be done in Blitzkrieg without need of changing tiles or skins (even thought maybe the result isn't as good as it was in Desert's Operation Vampire).
The code is as simple as what follows:
function DebugView() Password( "www.dtf.ru" ); ChangeWarFog(2); -- Night. Suicide(); end;
function Init() RunScript("DebugView", 0000); end;
The second part of this tutorial explains how an allied IA can be created in Blitzkrieg. It's basically a copy of what tedi88 posted on Blitz Srbija, so all the credits of this part go to him (well, we should also mention Stanenberg who helped to understand how it works and provided examples). Here are his wise words:
You can switch the players via ChangePlayer Command in script. Furthermore it works, allied troops support you and enemies allies will fight you. Only catch is you have to give them ScriptID in Map editor then use a script command. Gunners will change as well depending on what side have you set up in Map editor.
For test purposes I assigned an arty piece, a truck and an infantry squad ScriptID of 4998 for change into allied forces, while an identical force had ScriptID 4999.
It doesn't matter if you place a unit under Player 1 or Player 0 ( I used Player 1 for initial forces). So after that's done in Map Editor, I added sides in Diplomacy tabs so it looked like this:
0 - 0 - Player Forces 1 - 1 - Enemy Forces 2 - 0 - Player Allies 3 - 1 - Enemy Allies 4 - 2 - Neutral
You don't have to place:
2 - 0 - Player Allies 3 - 1 - Enemy Allies
You can also use:
2 - 1 - for player 3 - 0 - for enemy allies
or any other combination (depends on a number of players).
So next step is: in Lua script in FunctionInit (but it can be used anywhere) I added the following lines:
function Init() ChangeWarFog(4); ------------ This is by default 2 (when there are two players)/ to disable it place ChangeWarFog(0) this will reset the Fog of War ChangePlayer(4998, 2); ------ this one changes units into Player Allies/ 4998 - ScriptID 2 -Side ChangePlayer(4999, 3); ------ this one changes units into Enemy Allies/ 4999 - ScriptID 3 - Side Suicide(); end;
Moreover, here's Kaoz's intervention about this issue:
"You can use sort of an ally. In the MapEditor you can add a new party and set its side (friend or no). A new neutral party will be automatically set. I have used it in some maps also, indeed mostly for (paratrooper) planes, so they won't become shot down.
I used it on infantry as well and they do attack and are being attacked, but they remain unseen, in case you have the sight to player0 that is..."
|
|
tedi88
General
Blitzkrieg State Prosecutor
Posts: 1,228
|
Post by tedi88 on Aug 6, 2014 16:49:48 GMT 1
It looks nice, . Alright, i'll reshape the part about ChangePlayer command, and i'll post it here when it's done (in a couple of hours). Then if you approve it you can post it, if not then i'll change it again...
|
|
|
Post by Kevin on Aug 6, 2014 16:54:22 GMT 1
|
|
|
Post by Kevin on Aug 6, 2014 20:35:07 GMT 1
|
|