Forgotten Hope Public Forum

Forgotten Hope 2 => Modding => Topic started by: fh_spitfire on 18-05-2009, 23:05:16

Title: [Tutorial] Push Mode
Post by: fh_spitfire 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 :)
Title: Re: [Tutorial] Push Mode
Post by: Krätzer on 19-05-2009, 16:05:49
Great but with Push Mode the Map Crash  :o
Without not =(
Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire 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?
Title: Re: [Tutorial] Push Mode
Post by: Krätzer 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
Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire on 19-05-2009, 18:05:21
Can I have your gameplayobjects.con and full mapdata.py?
Title: Re: [Tutorial] Push Mode
Post by: Krätzer 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^^

Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire 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.
Title: Re: [Tutorial] Push Mode
Post by: Krätzer 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..
Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire 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?
Title: Re: [Tutorial] Push Mode
Post by: Krätzer 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.
Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire 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.
Title: Re: [Tutorial] Push Mode
Post by: Krätzer 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?
Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire on 19-05-2009, 21:05:51
It works only in FH2.
Title: Re: [Tutorial] Push Mode
Post by: Lobo 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
Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire 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.
Title: Re: [Tutorial] Push Mode
Post by: Lobo on 06-07-2009, 02:07:59
A small reminder

ObjectTemplate.onlyTakeableByTeam 2

The editor doesn't save this line, so you must write it manually in your GamePlayObjects.con each time you do a change to your objects
Title: Re: [Tutorial] Push Mode
Post by: [130.Pz]S.Lainer on 06-10-2010, 03:10:48
I seem to be failing.....Or maybe asking to much from push mode.

Code: [Select]
from game.plugins import plugin, push



   
push_64 = [
plugin(push, source = 'Seal_Cove', target = 'Bass_Harbor', attacker = 1),
plugin(push, source = 'Seal_Cove', target = 'Northeast_Harbor', attacker = 1),
plugin(push, source = 'Seal_Cove', target = 'Cadillac_Mountain', attacker = 1),
plugin(push, source = 'Trenton', target = 'Southwest_Harbor', attacker = 2),
plugin(push, source = 'Trenton', target = 'Sargent_Mountain', attacker = 2),
plugin(push, source = 'Trenton', target = 'Mcfarland_Mountain', attacker = 2),
plugin(push, source = 'Bass_Harbor', target = 'Seawall', attacker = 1), 
plugin(push, source = 'Seawall', target = 'Southwest_Harbor', attacker = 1),
plugin(push, source = 'Southwest_Harbor', target = 'Seawall', attacker = 2),
plugin(push, source = 'Seawall', target = 'Bass_Harbor', attacker = 2),
plugin(push, source = 'Cadillac_Mountain', target = 'Bar_Harbor', attacker = 1),
plugin(push, source = 'Bar_Harbor', target = 'Mcfarland_Mountain', attacker = 1),
plugin(push, source = 'Mcfarland_Mountain', target = 'Bar_Harbor', attacker = 2),
plugin(push, source = 'Bar_Harbor', target = 'Cadillac_Mountain', attacker = 2),
plugin(push, source = 'Northeast_Harbor', target = 'Jordan_Pond', attacker = 1),
plugin(push, source = 'Jordan_Pond', target = 'Sargent_Mountain', attacker = 1),
plugin(push, source = 'Sargent_Mountain', target = 'Jordan_Pond', attacker = 2),
plugin(push, source = 'Jordan_Pond', target = 'Northeast_Harbor', attacker = 2),
]

gpm_cq = {
  64: push_64   
}

  Now the code itself seems to be work just how I wanted.  The flag layout is basically 3 sets of 3 flags.  At round start the USA and krouts can rush for only 3 flags, getting that flag opens up the next one in the group until you get to the last one.  On the other hand if your side gets pushed right out of the whole mess the other team just needs to hold the starting flag for your team and the others are locked.  Your team can push from  one of the other flag groups if they have any flags there or come at it from main again (Seal_Cove and Trenton are the mains).

Like I said it all works fine in play just does not look right on the map.
(http://img.photobucket.com/albums/v213/Jeremiahthor/FH2%20Mapping/screen044-1.png)

As you get playing it all works itself out......(southern western group of flags.)
(http://img.photobucket.com/albums/v213/Jeremiahthor/FH2%20Mapping/screen043-1.png)


Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire on 09-10-2010, 22:10:16
This happens when target of push "link" is a flag that starts grey. This can be partially avoided by adding "wants_source_marker = False" to each link that has grey flag as target. Like that:
Code: [Select]
plugin(push, source = 'Trenton', target = 'Mcfarland_Mountain', attacker = 2, wants_source_marker = False),But if there are only grey flags as target, you can end up with having no markers at all. Well, this problem is yet to be solved :)

Also, you should avoid setting "reversed" links. Like this two, this is pointless, one is enough:
Code: [Select]
plugin(push, source = 'Seawall', target = 'Southwest_Harbor', attacker = 1),
plugin(push, source = 'Southwest_Harbor', target = 'Seawall', attacker = 2),
Title: Re: [Tutorial] Push Mode
Post by: [130.Pz]S.Lainer on 15-10-2010, 06:10:59
  Thanks Spit.  I tried the "wants_source_marker" bit and it did not seem to change anything.  Just for my own curiosity are there any other groovy variables in that push code?

As to the "reversed" links.....With those 3 flags the two teams start pushing from opposite directions so I thought I needed them.
Title: Re: [Tutorial] Push Mode
Post by: fh_spitfire on 15-10-2010, 16:10:17
There is only one more
Code: [Select]
display_arrow = FalseWill make the arrow not show up for that link.
Title: Re: [Tutorial] Push Mode
Post by: Senshi on 19-12-2010, 11:12:35
Stumbled upon an issue:

Push mode. Two flags are avaible to attack at the start. Now I want the third flag to be "opened" once ONE of the two flags is conquered. How can I achieve this? Setting two "push" links makes both flags mandatory for the third flag, but I want only one to be required. Is this where the linkCPs come in? If yes, some explanation on those would be nice. Or is there a way to use "OR" in those push settings?
Title: Re: [Tutorial] Push Mode
Post by: [KamiKaze] Destroyer on 09-05-2012, 00:05:22
Hello :)

So you can choose about Arrow Visiblity, how about visibility of the X marks and O marks?

My map is simple, and doesint need marks, its straight forward which order the flags should be taken without marks in other words. However, the push mode i really need :] So, any ideas what is the code for this?
Title: Re: [Tutorial] Push Mode
Post by: Rabbit032 on 06-11-2012, 16:11:58
Code: [Select]
from game.plugins import plugin, limitKit, push
 

kit_limits = [
  plugin(limitKit, team = 1, slot = 1, kit = 'GS_SMGAssault_Limited', limit = 0.25),
  plugin(limitKit, team = 2, slot = 1, kit = 'UW_SMGAssault_Limited', limit = 0.25),
  plugin(limitKit, team = 1, slot = 3, kit = 'GA_Limited_Support_MG34_K98', limit = 0.15),
  plugin(limitKit, team = 2, slot = 3, kit = 'UW_LMG_Limited', limit = 0.15),
  plugin(limitKit, team = 1, slot = 5, kit = 'GW_RifleAssault_G43_Limited', limit = 0.1),
  plugin(limitKit, team = 2, slot = 5, kit = 'UW_SMGAssault_Limited_GGun', limit = 0.1),
]

push_64 = [
    plugin(push, source = 'US', target = 'WN_72', attacker = 2),
    plugin(push, source = 'US', target = 'WN_67', attacker = 2),
   
    plugin(push, source = 'WN_72', target = 'Church', attacker = 2,),
    plugin(push, source = 'WN_67', target = 'Cross_Roads', attacker = 2,),
   
    plugin(push, source = 'Church', target = 'Vierville_Sur_Mer', attacker = 2,),
  ]

  gpm_cq = {
  64: kit_limits + push_64,
}
Any idea why my push code doesn't show up in conquest mode 64 player?
-032
Title: Re: [Tutorial] Push Mode
Post by: Mudzin on 15-07-2014, 15:07:18
Is it possible to make such push code where 1 flag opens 2nd and capping that 2nd wouldn't make the first uncap?
Title: Re: [Tutorial] Push Mode
Post by: sn00x on 15-09-2014, 16:09:40
Very nice and such a simple tutorial! I had my Push exactly how i wanted in 5minutes! :D