Using variables in BF1942

Ask questions, discuss ideas, get answers
Post Reply
oldtime
Posts: 6
Joined: Sat Mar 13, 2010 2:48 pm
Location: Germany
Contact:

Using variables in BF1942

Post by oldtime »

Hello,
i want work with some variables in my Map, but i dont know how. I can define a variable with

Var v_Name and with v_Name = content put some content in it. Then i can use it to give a parameter to a command.
Like:

Var v_Team
v_Team = 1
Object.setTeam v_Team


And i can make some querys like
if v_Team = 1
ObjectTemplate.setObjectTemplate 2 M1A1
elseif v_Team = 2
ObjectTemplate.setObjectTemplate 2 A10_B
endif

It works with = , < , > , <= , >= and maybe other commands.

My problem is, i dont know how to calculate with a variable. I found no operation that works, except a new v_Team = value
I´ve tested a variable to change the Team nr. With this code i wanted to use random spawner in my Map by changing a tut from your SSM backup.
http://battlefieldmodding.com/ssm/phpBB ... ?f=4&t=552

OST:
ObjectTemplate.create ObjectSpawner dpv
ObjectTemplate.setObjectTemplate 1 DesertPatrolVehicle
ObjectTemplate.setObjectTemplate 2 AH64
ObjectTemplate.setObjectTemplate 3 M2A3
ObjectTemplate.setObjectTemplate 4 T72
ObjectTemplate.setObjectTemplate 5 M1A1
ObjectTemplate.setObjectTemplate 6 M163
ObjectTemplate.setObjectTemplate 7 Shilka
ObjectTemplate.setObjectTemplate 8 Humvee
ObjectTemplate.setObjectTemplate 9 BRDM25
ObjectTemplate.MinSpawnDelay 10
ObjectTemplate.MaxSpawnDelay 30
ObjectTemplate.SpawnDelayAtStart 0
ObjectTemplate.TimeToLive 45
ObjectTemplate.Distance 40
ObjectTemplate.DamageWhenLost 20
ObjectTemplate.MaxNrOfObjectSpawned 2

OS:
Var v_Team
v_Team = CRD_UNIFORM/1/9/0

Object.create DPV
Object.absolutePosition 1570.13/42.7595/1535.08
Object.rotation 134.55/0/0.0685425
Object.setOSId 0
Object.setTeam v_Team

With that Code, no vehikel spawns. Maybe the CRD Code gives a point number back. I don´t know.
Then i tryed various combinations with diffent results:

v_Team = CRD_UNIFORM/1/9/1 - no vehikels
v_Team = 7 - as expected a Shilka spawns
v_Team = CRD_None/9/0/0 - no vehikels
v_Team = CRD_None/1/9/0 - no vehikels
v_Team = CRD_NORMAL/9/1/0 - no vehikels
v_Team = 3 + 5 - no vehikels
v_Team = 3+5 - M2A3spawns(Team3)
v_Team = 3 +5 - no vehikels
v_Team = 3,4 - M2A3spawns(Team3)
v_Team = 6/2 - M163 spawns (Team6)
v_Team = (CRD_UNIFORM/1/9/0) - no vehikels
v_Team = v_Zaehler -(Zaehler was value 9, it spawns vehikel 9)
v_Team = 2*3 - Ah64 spawns (Team2)
v_Team = 2,3 - Ah64 spawns (Team2)
v_Team->v_Team+1 - no vehikels
v_Team = 2&2 - no vehikels
v_Team->CRD_UNIFORM/1/9/0 - no vehikels
v_TeamCRD_UNIFORM/1/9/0 - no vehikels
v_Team = (2+3) - no vehikels
v_Team = CRD_NONE/1/0/0 - no vehikels
CRD_UNIFORM/1/9/0->v_Team - no vehikels
v_Team = CRD_NONE/2/8/1 - no vehikels
v_Team = CRD_UNIFORM/2/8/1 - no vehikels
v_Team = v_eins+v_zwei - no vehikels
Object.setTeam CRD_UNIFORM/2/8/1 - no vehikels
v_Team = v_Team + 1 - no vehikels


Does anybody knows how to calculate with BF 1942 ? Or which CRD_ Code i have to use to get random natural Number without a point?
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: Using variables in BF1942

Post by fo0k »

I have only assumed these variables were used for the basics of setting up the game type of a map. I never stopped to think that they could be modded to achieve other 'wonderous' effects? :O

What outcome are you trying to achieve? I'm intrigued..
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Post by freddy »

when you removetemplate things you have to start the count at zero (0) so i think that may apply here to. i take it you want a random spawned vehicle at mapstart? or is it meant to be dynamic in gameplay?

heres another angle to random spawns, perhaps it could be useful http://bfmods.com/viewtopic.php?f=43&t=56
oldtime
Posts: 6
Joined: Sat Mar 13, 2010 2:48 pm
Location: Germany
Contact:

Re: Using variables in BF1942

Post by oldtime »

fo0k wrote:I have only assumed these variables were used for the basics of setting up the game type of a map. I never stopped to think that they could be modded to achieve other 'wonderous' effects? :O

What outcome are you trying to achieve? I'm intrigued..
Before saw the map pitimultimod i even dont know that you can define or use variables in maps. Do you know this map? This maps works for bf1942, DC, DC_Final, DCX, XPack2, EoD and GCX with the same file and in every mod you have the appropriate weapons and vehicles. Just copy the rfa to another modfolder and it works.

As i unpacked the map and saw the code i was surprised how easy it was. It´s just a - if question.

Init.con:
Var v_modname
game.customGameName -> v_modname

if v_modname == BF1942
run Objects/Objects

game.setTeamSkin 1 JapaneseSoldier
game.setKit 1 0 Jap_Scout
game.setKit 1 1 Jap_Assault
game.setKit 1 2 Jap_AT
game.setKit 1 3 Jap_Medic
game.setKit 1 4 Jap_Engineer

game.setTeamSkin 2 USSoldier
game.setKit 2 0 USMarine_Scout
game.setKit 2 1 UsMarine_Assault
game.setKit 2 2 UsMarine_AT
game.setKit 2 3 USMarine_Medic
game.setKit 2 4 USMarine_Engineer


elseIf v_modname == DC_Final

game.setTeamSkin 1 IraqSoldier
game.setKit 1 0 Iraq_Sniper
game.setKit 1 1 Iraq_Assault
game.setKit 1 2 Iraq_AT
game.setKit 1 3 Iraq_HeavyAssault
game.setKit 1 4 Iraq_Support
game.setKit 1 5 Iraq_SpecOps

game.setTeamSkin 2 USSoldier
game.setKit 2 0 US_Sniper
game.setKit 2 1 US_Assault
game.setKit 2 2 US_AT
game.setKit 2 3 US_HeavyAssault
game.setKit 2 4 US_Support
game.setKit 2 5 US_SpecOps

....
endif

And the same method was used for OST and OS.

This is one possibility what you can do with variables. But i think if you can change the value of a variable you can do everything with a map. For Example: Start an event after a specific time or when someone reached a special position. Or you can make something when a certain player joined the server.
I dont know what i can really realize but i think there is a lot possible.
Last edited by oldtime on Sun Jan 30, 2011 9:21 am, edited 1 time in total.
oldtime
Posts: 6
Joined: Sat Mar 13, 2010 2:48 pm
Location: Germany
Contact:

Re: Using variables in BF1942

Post by oldtime »

Actualy i use the variables to change the file structur of BF Maps. I use just one OS,OST and tweak.con (For Turbo, carbombs and other modding stuff) for all mode.

This works Serverside and has the advantage that you can realy easy and fast make changes to ctf, conquest, coop and tdm. Especially if you thought that one was finished, it was pretty stupid to carry out a the same small change on 4 files.

For this to work I had to search the bf exe after the game mode variable. I found gamePlayMode.

The OS has the following structure:

Var v_Mode
game.gamePlayMode -> v_Mode
Rem *****************************************************************

if v_Mode = GPM_COOP

elseIf v_Mode = GPM_CQ
rem -----------------------------------------
rem --- scoutcarspawner ---
rem -----------------------------------------
Object.create scoutcarspawner
Object.absolutePosition 762.73/12.80/1254.21
Object.rotation -98.00/0.00/0.00
Object.setOSId 3
Object.setTeam 0

elseIf v_Mode = GPM_TDM
rem -----------------------------------------
rem --- heavytankspawner ---
rem -----------------------------------------
Object.create heavytankspawner
Object.absolutePosition 734.10/12.77/1215.16
Object.rotation 59.96/0.00/0.00
Object.setOSId 3
Object.setTeam 0

elseIf v_Mode = GPM_CTF
rem -----------------------------------------
rem --- uraltankerspawner ---
rem -----------------------------------------
Object.create uraltankerspawner
Object.absolutePosition 719.98/12.78/1243.56
Object.rotation -1.46/0.00/0.00
Object.setOSId 7
Object.setTeam 1

endIf

Rem From here come the common spawner
....


Now you only have to change the ctf,coop,tdm and conquest.con to get this to work. just rem out the old OS and OST and put an run OS or OST without a folder in. But dont change the order or your map will crash.

Now add a "run tweaks" to the con and everythink works fine and have also differences between the mode. But beware, remember that to get this serverside working you can not add or rename the Spawners in the OST.



freddy wrote:when you removetemplate things you have to start the count at zero (0) so i think that may apply here to. i take it you want a random spawned vehicle at mapstart? or is it meant to be dynamic in gameplay?

heres another angle to random spawns, perhaps it could be useful http://bfmods.com/viewtopic.php?f=43&t=56
I have allready testet this code, but i didnt get it realy working. Either the cars falling down from the sky like rain, or when i put the willy to the ground, every object spawns after a few seconds. Even when the "old" vehikel is on its place. So in a few time the map is full of car, Tanks and whatever i wanted to have. I dont know what i doing wrong. But if can use variables, i would make random vehikels without a extra spawner object.
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Post by freddy »

yeah it would be best if one could use variables, question is if one can use them dynamic when playing or if they just can read in once when game starts

about the problems your had with jeps falling down etc, its all in the spawners, you got to use the holdobject for the willy spawner and for the other spawners you can limit them with things like SpawnDelay, nrOfObjectToSpawn and such.

"spawns Even when the "old" vehikel is on its place" i didnt find a way to solve that problem in a neat way, but there are some workarounds one can use
oldtime
Posts: 6
Joined: Sat Mar 13, 2010 2:48 pm
Location: Germany
Contact:

Re: Using variables in BF1942

Post by oldtime »

freddy wrote:yeah it would be best if one could use variables, question is if one can use them dynamic when playing or if they just can read in once when game starts

about the problems your had with jeps falling down etc, its all in the spawners, you got to use the holdobject for the willy spawner and for the other spawners you can limit them with things like SpawnDelay, nrOfObjectToSpawn and such.

"spawns Even when the "old" vehikel is on its place" i didnt find a way to solve that problem in a neat way, but there are some workarounds one can use
Its not only the question if one can use them dynamic when playing, i can even can not manipulate them before the game starts. I just can define them.

And for the problem with the falling willy, tanks and so on, Holdobjects doesn´t work fine. Some object stand some seconds or more in the Air, then they beginn to shake around and fall down. Other Objects fall immediately down.

Changing nrOFObjectToSpawn or Spawndelay doesn´t solve the problem. It made the problem a little bit smaller, but i wanted to have many different vehikels, not only 3. And all vehikels spawns gradually. Its funny, but dont really playable.
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Post by freddy »

you can also use radius on a spawner to prevent new vehicles to spawn before the old one has left the defined radius. its all about tweaking the settings.
Post Reply