Author Topic: [Tutorial] Push Mode  (Read 17252 times)

Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
[Tutorial] Push Mode
« on: 18-05-2009, 23:05:16 »
This tutorial is basically about adding push mode to a map. I'll try to make it understandable even for someone who doesn't have any idea about the very basics of coding.

#1 Mapdata.py
Mapdata.py is a file that makes FH2's custom scripts by map possible. Create a blank text file, name it "mapdata.py" and place in your map folder. From now on the game will run scripts you insert there on your map.


#2 Import needed plugins into your mapdata.py
The first step to do with your mapdata.py is to import needed plugins. Let's say that besides push mode we want to have kit limits in our map (to make it more complicated and thus teaching you more about how to add custom scripts in future). You add this line at the beginning of mapdata.py:
Code: [Select]
from game.plugins import plugin, limitKit, pushAs you can see it imports "plugin", "limitKit" nad "push" plugins. You can add further plugins by keeping the template.


#3 Providing data for plugins
First we define the kitlimit one. This is not the subject of this tutorial, if it is needed I'll write about this later (is it?). Just after import part you type in (for example):
Code: [Select]
kit_limits_64 = [
    plugin(limitKit, team = 2, slot = 3, kit = 'BA_Limited_Support_Bren_No4', limit = 0.2),
    plugin(limitKit, team = 1, slot = 3, kit = 'GA_Limited_Support_MG34_K98', limit = 0.2),
    plugin(limitKit, team = 2, slot = 5, kit = 'BA_ATBoys_Limited', limit = 0.2),
    plugin(limitKit, team = 1, slot = 5, kit = 'GA_ATPzB39_Limited', limit = 0.2),   
]

Then, goes our push mode, and here I'll try to explain everything:
Code: [Select]
name_of_code = [
    plugin(push, source = 'Sorce_controlpoint_name', target = 'Target_controlpoint_name', attacker = n),
]

name_of_code is just a name. Name it as you want, so you will recognize what's in it (like "push_64").

Sorce_controlpoint_name is the name of control point which is required to be taken for the attack on target control point to be possible.

Target_controlpoint_name is the target CP.

n is the ID of the attacking team.


#4 More features.
Nice thing about this code is that we can set multiple arguments for the same flag, like this:
Code: [Select]
plugin(push, source = 'flag1', target = 'flag3', attacker = 2),
plugin(push, source = 'flag2', target = 'flag3', attacker = 2),

Which means both flag 1 and 2 have to be taken by team 2 for the attack on flag 3 to be possible. Something like one flag opening attack route for multiple flags is also possible.

One more thing... if you want to have the flag takeable only once, go to gameplayobjects.con of your map, find the control point of your interest there and add this line to it's code:
Code: [Select]
ObjectTemplate.onlyTakeableByTeam nn being the attacker team Id of course.


#5 Mini-map markers
You don't place them. The push script does this automatically.


#6 Enabling the scripts
At the bottom of your mapdata.py you have to tell the game which scripts to run in which game mode and mapsize (let me take only conquest in consideration). The template is simple:
Code: [Select]
gpm_cq = {
  64: name1 + name2 + name3,
  16: name1 + name2,
  32: name1,
}

Once again you may add as many things to run for desired game mode or map size as you want.


#7 The example
OK, time to show how it works all-in-one. Let's say we have 4 flags: flag1, flag2, flag3 and flag4. 1 and 2 are front flags, they open the attack on 3 together. 3 opens an attack on 4. Moreover, we want to have 1 and 2 capturable only once. We want kit limits in our map as well (in all mapsizes). Push mode we need only in 32 and 64 size. The attacking team is team 2.

This would be my mapdata.py:
Code: [Select]
from game.plugins import plugin, limitKit, push

kit_limits = [
    plugin(limitKit, team = 2, slot = 3, kit = 'BA_Limited_Support_Bren_No4', limit = 0.2),
    plugin(limitKit, team = 1, slot = 3, kit = 'GA_Limited_Support_MG34_K98', limit = 0.2),
    plugin(limitKit, team = 2, slot = 5, kit = 'BA_ATBoys_Limited', limit = 0.2),
    plugin(limitKit, team = 1, slot = 5, kit = 'GA_ATPzB39_Limited', limit = 0.2),
]

push_mode = [
plugin(push, source = 'flag1', target = 'flag3', attacker = 2),
plugin(push, source = 'flag2', target = 'flag3', attacker = 2),
plugin(push, source = 'flag3', target = 'flag4', attacker = 2),
]

gpm_cq = {
  64: kit_limits + push_mode,
  32: kit_limits + push_mode,
  16: kit_limits,
}

Of course I'd add
Code: [Select]
ObjectTemplate.onlyTakeableByTeam 2 to the definition of flag 1 and 2 in gameplayobjects.con

One more note: Make sure you have proper FH2 standardised tmp.con, otherwise it will crash. You can find out how to setup this here (point 9): http://fenring.bf1942.cl/tutorials/mappingstandards.php

======================

That's it, hope it's heplful :)
« Last Edit: 16-01-2010, 15:01:21 by Spit »

Offline Krätzer

  • Developer
  • ******
  • Posts: 621
  • Bitter Lemon
    • View Profile
Re: [Tutorial] Push Mode
« Reply #1 on: 19-05-2009, 16:05:49 »
Great but with Push Mode the Map Crash  :o
Without not =(

Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
Re: [Tutorial] Push Mode
« Reply #2 on: 19-05-2009, 17:05:16 »
Great but with Push Mode the Map Crash  :o
Without not =(
Adding the pushmode to the mapdata.py is the only difference between crashing and not crashing version?

Also, can you run your fh2 in window mode and post the error it gives when crashing here?

Offline Krätzer

  • Developer
  • ******
  • Posts: 621
  • Bitter Lemon
    • View Profile
Re: [Tutorial] Push Mode
« Reply #3 on: 19-05-2009, 18:05:01 »
It dont show error ind window Mode, only crash to Desktop. With the messages FH2 crashed.

Quote
push_64 = [
    plugin(push, source = 'irakleia', target = 'dhamasta', attacker = 1),
    plugin(push, source = 'dhamasta', target = 'hot_springs', attacker = 1),
    plugin(push, source = 'hot_springs', target = 'factory', attacker = 1),
    plugin(push, source = 'factory', target = 'alamana_bridge', attacker = 1),
    plugin(push, source = 'factory', target = 'thermopyles', attacker = 1),
]

And the adding is the only difference
« Last Edit: 19-05-2009, 18:05:47 by Krätzer »

Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
Re: [Tutorial] Push Mode
« Reply #4 on: 19-05-2009, 18:05:21 »
Can I have your gameplayobjects.con and full mapdata.py?

Offline Krätzer

  • Developer
  • ******
  • Posts: 621
  • Bitter Lemon
    • View Profile
Re: [Tutorial] Push Mode
« Reply #5 on: 19-05-2009, 18:05:56 »
Oke, but its not my map. I only try to Edit a Push Mode to it for a Event^^


Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
Re: [Tutorial] Push Mode
« Reply #6 on: 19-05-2009, 18:05:44 »
Hmm yeah I'd be guessing Natty's Thermopyles guessing on CP names.

Anyway, I can't see anything wrong in those files atm :/ When exactly does it crash?

EDIT: On second look, you have controlpoints in the static objects layer, which isn't good.
« Last Edit: 19-05-2009, 18:05:37 by [F|H]Spit »

Offline Krätzer

  • Developer
  • ******
  • Posts: 621
  • Bitter Lemon
    • View Profile
Re: [Tutorial] Push Mode
« Reply #7 on: 19-05-2009, 19:05:27 »
Sometimes it crash by load 100% or after 2 Minutes playtime. Im on the map can do all and then crash.

I only load original Thermopyles, kick some Vehicles or change them.
Dont know what controlpoints in static layers are. I dont change something on the points..

Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
Re: [Tutorial] Push Mode
« Reply #8 on: 19-05-2009, 19:05:09 »
Mhm, did you ever manage to see push mode markers on minimap in that map? Or it always crashes before they spawn?

Offline Krätzer

  • Developer
  • ******
  • Posts: 621
  • Bitter Lemon
    • View Profile
Re: [Tutorial] Push Mode
« Reply #9 on: 19-05-2009, 21:05:04 »
We play over Hamachi, they dont spawn. Because the Game never starts. I look at Supercharge there they only spawn by me then the Game starts. But no one can join my Game cause it crash before.

Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
Re: [Tutorial] Push Mode
« Reply #10 on: 19-05-2009, 21:05:36 »
Well, I really can't help much more remotely. You may send me your version of map if you want and I'll try to find some time to look into it's push.

Offline Krätzer

  • Developer
  • ******
  • Posts: 621
  • Bitter Lemon
    • View Profile
Re: [Tutorial] Push Mode
« Reply #11 on: 19-05-2009, 21:05:35 »
Mhm no its not so important, we play now the Map on Sunday with the Rule to Cap Flag by Flag.
But thank u very much. I learn something new thats cool.

I think i will try it on the next Map again and if I have porblems i will ask here again  :)

Work this with the normal Vanilla Maps? Or could they make Problems?

Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
Re: [Tutorial] Push Mode
« Reply #12 on: 19-05-2009, 21:05:51 »
It works only in FH2.

Offline Lobo

  • Developer
  • ******
  • Posts: 736
    • View Profile
Re: [Tutorial] Push Mode
« Reply #13 on: 01-07-2009, 13:07:55 »
It crashes because you must add a tmp.con file in your map folder

Code: [Select]
run ClientArchives.con
run ../../objects/Common/CommonSpawners.con

windmanager.globalWindSpeed 1
windmanager.globalWinddirection 1/0/1
physics.airDensityZeroAtHeight 3000

Offline fh_spitfire

  • Developer
  • ******
  • Posts: 421
  • FHer since 0.6 | aka spitfire05
    • View Profile
Re: [Tutorial] Push Mode
« Reply #14 on: 04-07-2009, 11:07:33 »
Thx Lobo I forgot about pointing out to set up FH2 common spawners (tbh I didn't think anyone making FH2 map can not have them ^^). Added to first post.