Forgotten Hope 2 > Modding

[Tutorial] Push Mode

(1/5) > >>

fh_spitfire:
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: ---from game.plugins import plugin, limitKit, push
--- End code ---
As 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: ---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),   
]
--- End code ---

Then, goes our push mode, and here I'll try to explain everything:

--- Code: ---name_of_code = [
    plugin(push, source = 'Sorce_controlpoint_name', target = 'Target_controlpoint_name', attacker = n),
]
--- End code ---

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: --- plugin(push, source = 'flag1', target = 'flag3', attacker = 2),
plugin(push, source = 'flag2', target = 'flag3', attacker = 2),
--- End code ---

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: ---ObjectTemplate.onlyTakeableByTeam n
--- End code ---
n 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: ---gpm_cq = {
  64: name1 + name2 + name3,
  16: name1 + name2,
  32: name1,
}
--- End code ---

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: ---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,
}
--- End code ---

Of course I'd add
--- Code: ---ObjectTemplate.onlyTakeableByTeam 2
--- End code ---
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 :)

Krätzer:
Great but with Push Mode the Map Crash  :o
Without not =(

fh_spitfire:

--- Quote from: Krätzer on 19-05-2009, 16:05:49 ---Great but with Push Mode the Map Crash  :o
Without not =(

--- End quote ---
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?

Krätzer:
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),
]
--- End quote ---

And the adding is the only difference

fh_spitfire:
Can I have your gameplayobjects.con and full mapdata.py?

Navigation

[0] Message Index

[#] Next page

Go to full version