PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

grailknighthero said:
Amarillo said:
<huge redundant quote>

Will that spawn regular troops as well?

No. Other triggers already take care of that. The purpose of this hastily written trigger is to circumvent the bug/feature(?) in 0.89x were heroes don't spawn properly without regular troops in the party.
 
Amarillo said:
grailknighthero said:
Amarillo said:
<huge redundant quote>

Will that spawn regular troops as well?

No. Other triggers already take care of that. The purpose of this hastily written trigger is to circumvent the bug/feature(?) in 0.89x were heroes don't spawn properly without regular troops in the party.

Ah great.  I was thinking about trying to fix this bug as well but you already did it.
 
Mirathei said:
With all the talk about formations, I reckon this is the right time for this. Since Highlander's code is long, somewhat buggy, and slow to act, I made my own formation script. It supports as many men in formation at once as m+b can handle, they react quicker, and will never give any error messages, in addition to being somewhat more user friendly. Best of all, it can even be used to make a wedge. The wedge will not be usefull for now, but with cavalry being scriptable in the new version, it will be soon.

The efficient, improved formation code:

  ("formation",
   [(get_player_agent_no,reg(10)),
    (agent_get_position,1,reg(10)),
    (assign,":collumn",1),
    (position_move_x,1,100),
    (try_for_agents,reg(5)),
       (agent_is_ally,reg(5)),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_set_scripted_destination,reg(5),1),
       (position_move_x,1,100),
       (try_begin),
          (eq,":collumn",10),
          (position_move_x,1,-10*100),
          (position_move_y,1,-100),
          (assign,":collumn",1),
       (else_try),
          (val_add,":collumn",1),
       (end_try),
    (end_try)]),

Red: distance between agents left and right.
Blue: distance between agents front and back.
Green: number of men in one row.

Screenie with more men than the current formation code supports:


The wedge formation code:

  ("formation_wedge",
   [(get_player_agent_no,reg(10)),
    (agent_get_position,1,reg(10)),
    (assign,":collumn",1),
    (assign,":nc",3),
    (position_move_x,1,-100),
    (position_move_y,1,-100),
    (try_for_agents,reg(5)),
       (agent_is_ally,reg(5)),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_set_scripted_destination,reg(5),1),
       (try_begin),
          (eq,":collumn",":nc"),
          (val_mul,":nc",-100),
          (position_move_x,1,":nc"),
          (position_move_y,1,-100),
          (assign,":collumn",1),
          (val_div,":nc",-100),
          (val_add,":nc",2),
       (else_try),
          (position_move_x,1,100),
          (val_add,":collumn",1),
       (end_try),
    (end_try)]),

Red: distance side to side.
Blue: distance front to back.
This will need to be modified for cavalry with the new version. To use this, set up a trigger in module_mission_templates.py under the "lead_charge" mission which will call this script every tenth of a second when the conditions are right, thus moving the formation according to the player. It becomes a bit rough when moving, but its really not all that bad.

Screenie:


To get enemies to form a line:

  ("ai_formation",
   [(assign,"$formed",1),(try_for_agents,reg(5)),
    (agent_is_alive, reg(5)),
    (neg|agent_is_ally,reg(5)),
    (agent_is_human, reg(5)),
    (agent_get_position,1,reg(5)),
    (try_end),
    (assign,":collumn",1),
    (position_move_x,1,75),
    (try_for_agents,reg(5)),
       (neg|agent_is_ally,reg(5)),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_set_scripted_destination,reg(5),1),
       (position_move_x,1,75),
       (try_begin),
          (eq,":collumn",10),
          (position_move_x,1,-10*75),
          (position_move_y,1,-50),
          (assign,":collumn",1),
       (else_try),
          (val_add,":collumn",1),
       (end_try),
    (end_try)]),

Give the enemies a weapon which will call this script. The distances are slightly different from the formation above, but works the same way. It picks a random enemy infantryman and uses him as the starting point for the formation.

When formations clash :twisted: :

Mirathei, I know you posted this a while back, but is there any way to code at least one of these formations to a specific button? Like the inverntory button, the action button (f) ?
 
(0, 0, 0, [(key_pressed,whatever_key),],[(call_script,"script_whichever_formation_script"),]),

Does that make any sense?
 
Don't you need to make the line of code check to see if I am in battle?

And I would put that in module_Scripts.py?
 
Mirathei said:
(0, 0, 0, [(key_pressed,whatever_key),],[(call_script,"script_whichever_formation_script"),]),

Does that make any sense?

So this would work for the sqaure formation?

(0, 0, 0, [(key_pressed,"s"),],[(call_script,"formation"),]),
 
Should be "script_formation".
Haven't checked this one out myself, but I think it should also be key_s. (no quotes)

Also, I don't recommend using one of the movement controls.
 
I forgot that s was the default key for movement. I have my controls altered.

I will try and test this in just a bit.

Does it matter where I put the code line in module_battle_mission_templates?
 
And just to clarify, the actual formation script goes in module_scripts.py, right?


Edit: just checked it out, and key_pressed is not a valid code. What should I do?
 
Yes.

EDIT:
Check header_triggers?

EDIT2: First of all, you might as just well keep editing while its just the two of us posting here, and secondly, that means that either I made a formatting error in the trigger or that you pasted it in the wrong place.
 
I guess you didn't see my edit, so I'm posting again.

What should I do?
 
Sorry for the double post, but I tried to do what you said, and I get errors. (please note, I changed the word formation to squareformation in both module_scrpits and module_mission_templates.

They are...

errorgj6.jpg





Edit: I guess so, but its hard for me to know when you have edited your post.

And I pasted the formation code in module_scripts, and the code to use the formation in battle in module_mission_templates.

Btw, I got the key pressing to work.
 
Jallon, by looking at the process files, I think you are giving an integer when the there is supposed to be a string (maybe you are missing quotation marks).

Edit: I know for sure you are giving an integer when there is supposed to be a string because that is what the error message in the compiler says....so what I just typed above isnt necessary...

I replicated the error by doing this

(
    "lead_charge",mtf_battle_mode,charge,
    1,
    [
    (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
    (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ],
    [

which should be
(
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [
    (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
    (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ],
    [

It could be any of your mission templates.

Edit again:  I also replicated it by doing this:
(
    "lead_charge",mtf_battle_mode,charge,
    s1,
    [
    (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
    (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ],
    [
which should be:
(
    "lead_charge",mtf_battle_mode,charge,
    "{s1}",
    [
    (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
    (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ],
    [
 
Well, the code for mission templates is very short. Maybe it needs more stuff. After looking throught mission templates, it doesn't seem to look how it should. It doesn't have an Id, or anything.

Here is the code..

Code:
(0, 0, 0, [(key_clicked,key_f),],[(call_script,"script_formation"),]),
 
Back
Top Bottom