Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Ok, WHERE should I declare global variables?

In the constant files I see varname = value declarations.

Is this valid for varaibles, as well?

I am currently just assigning them as I go, but it would be much better to put them all in one place with default values.
 
I usually just use a trigger that fires once at the beginning of the mod to initialise stuff.

You could also do it in the character-creation game menus. Specifically, you can chuck stuff in the preconditions block of the gender selection menu.
 
fisheye said:
I usually just use a trigger that fires once at the beginning of the mod to initialise stuff.

You could also do it in the character-creation game menus. Specifically, you can chuck stuff in the preconditions block of the gender selection menu.

Ok, I was going to try suggestion one as a hack, but suggestion 2 is a very good idea.  Thanks!
 
Hmm, actually that will not work because they won't get initialzed every time you start the game - or am I wrong in this?  Do the variables retain state game to game.  Actually, I suppose they must or else everything would fall apart.  Nevermind - still getting used to the M&B mod system....
 
By the way everything is initialized to 0 on first access; you only need to initialize something if you want to start with a nonzero value.
 
Quoting this for reference and as an explanation of the question I'm about to ask:

Escorpion said:
Dynamite_cow said:
The big arena: Would it be possible to make an all out battle where everyone is your enemy? AFAIK they had these battles in Colosseum, I saw a document about it a while ago, the last man standing was the winner.

Well, yes, it's somehow possible... in one of the combat types I've made there are 4 fighters, each one is in a different "team" so that combat only ends when only one of the fightes is standing and the other 3 are down. I've put the entry points of the two couples of fighters in a manner that the 1 and 2 are close one each other and far away from 3 and 4 (that are also close one each other). My intended result was that fighter 1 fights against 2 and 3 fights against 4, and only when one finish his closest enemy charges to the other fighters, but sometimes all fighters eventually get close and they form a confusing melee.  :lol:

Anyway, two couples of fighters seems few to me, and I'd like to have at least 4 couples of fighters. I've not tried so far, but the problem is making the teams... we need 8 teams but according to header_mission_template.py:

#filter flags
mtef_enemy_party        = 0x00000001
mtef_ally_party          = 0x00000002
mtef_scene_source        = 0x00000004
mtef_conversation_source = 0x00000008
mtef_visitor_source      = 0x00000010
mtef_defenders          = 0x00000040
mtef_attackers          = 0x00000080
mtef_no_leader          = 0x00000100
mtef_no_companions      = 0x00000200
mtef_no_regulars        = 0x00000400
#mtef_team_0              = 0x00001000
mtef_team_1              = 0x00001000
mtef_team_2              = 0x00002000
mtef_team_3              = 0x00003000
mtef_team_4              = 0x00004000
mtef_team_member_2      = 0x00008000
mtef_reverse_order      = 0x01000000

We only have mtef_team_1, mtef_team_2, mtef_team_3, mtef_team_4... I was tempted with declaring:

mtef_team_5              = 0x00005000
mtef_team_6              = 0x00006000
mtef_team_7              = 0x00007000
mtef_team_8              = 0x00008000

But I don't know if that will work, because I suspect that the hex codes are hard coded and it will be useless that I declare them here if the code doesn't knows what to do with them...  :roll: Also, as you can see, mtef_team_8 hex value have the same that mtef_team_member_2 and I'm concerned about that (despite I can't find where mtef_team_member_2 is used... if used at all). Anyway, these are only my thoughts, maybe I'll try it and I'll tell if it works and I've managed to set 8 teams in a battle.

After trying this, I've found that mtef_team_8 won't work, as I supposed. It doesn't works even when mtef_team_member_2 is deleted from the code. So I decided to have 3 couples of fighters via 6 teams (1 team per fighter)... but then I found another problem. The arenas game types can be terminated if the player dies or there is only 1 team. The game uses (num_active_teams_le,1) to check if there is only 1 team left... but it seems that it's hardcoded to check only the existence of teams 1-4, so despite I've declared mtef_team_5 and mtef_team_6 it keeps ending the arena fight when there is only 1 team left from 1-4 (fighter in teams 5 and 6 are ignored in that check).

Now, I would like to know if a workaround would be possible with try_for_agents. I haven't used that statement yet and I don't know how it works. Can be used try_for_agents to check that there is only one agent of one of the teams alive? Mind that the player can be part of the teams of an observer... Can you give me a guideline to write the code?

Thanks in advance.
 
Hey, do the 6 teams actually attack each other? I always thought the game only supported 4 teams.

A horrible, horrible way to hack the mission end thing is to have a trigger that sets an agent slot at time 0.01 for every agent that is within a specified radius of a given entry point. That way you can flag friendlies and nonfriendlies with different values for the agent slot and just check their aliveness later.
 
fisheye said:
Hey, do the 6 teams actually attack each other? I always thought the game only supported 4 teams.

Yes, it works with 6 teams, after I added to header_mission_template.py:

mtef_team_5              = 0x00005000
mtef_team_6              = 0x00006000

I also added this hoping to have 8 teams:

mtef_team_7              = 0x00007000
mtef_team_8              = 0x00008000

But as I explained in a couple of posts before, the mtef_team_8 doesn't work so I ended with 7 gladiators figthing each other and 1 standing still as a statue. So I couldn't have 4 couples of gladiators and removed teams 7 and 8 so at least I could have 3 couples that fight to the last man standing... well, they try to do so but if eventually tree of the four fighters of the teams 1, 2, 3 and 4 die, the fight ends, even if the fighters in the teams 5 and 6 are still alive.

You can see here a pic of the 3 couples fight:

http://escorpion.no-ip.com/Mele6.jpg

fisheye said:
A horrible, horrible way to hack the mission end thing is to have a trigger that sets an agent slot at time 0.01 for every agent that is within a specified radius of a given entry point. That way you can flag friendlies and nonfriendlies with different values for the agent slot and just check their aliveness later.

Yes, that wouldn't be too elegant but at least could be done. I'm still learning the code of this game, so if you could write that bit of code or at least give me a guideline of the functions to use, I'll be thankful.

Thanks in advance.
 
fisheye said:
Have you tried team 0?

That would be mtef_team_0 = 0.

Yes, I also tried, but I doesn't work. The fighter act as a statue like with mtef_team_8. I think that the range for teams is hardcoded in some way and it only allow from 0x00001000 to 0x00007000, that is 7 team max. Anyway, the function (num_active_teams_le,1) only checks teams 1, 2, 3 and 4. Pretty strange, but as all we know this game is on beta stage...

So it seems that we can only have a playable 6 fighter last man standing if we can do a workaround of (num_active_teams_le,1), maybe in the way you proposed. Could you lend me a hand with the code? (maybe not the whole code, but at least what functions should do the needed operations)
 
the easiest way is to ask winter for the source, but you said in his thread you don't want to use python, if so forget it.
 
I'm wondering as to the use of "store_encountered_party" First of all I should make sure I know what it does. I'm guessing it stores the party id  of the party you just encountered on the world map to a variable so as to be able to reference it later. Is this correct.

The second thing I want to ask is can it be used both in game menus and dialogues or just dialogues, or can it be used anywhere and it just stores the last party you encountered regardless of where you use it?

the reason why I ask is because I want to rewrite the vanilla encounter game menu so that the size of random map is determined by the sum of how many troops are in your and the opposing party. Obviously it won't be a continous transition but perhaps about five to six different map sizes to represent the range from just you versus some other single troop up to the battlefield needed for two full fledged armies.

Additional questions: How would you go about storing both an enemy parties id and an allies party id as in when you come across a battle in progress? Is this where you would use "store_encountered_party2"?
 
basically, the answer to all these is yes.  I have done something similar already. 

there shoud be a trigger that uses it like this:
  (ti_on_party_encounter, 0, 0, [],
  [
      (store_encountered_party, reg(1)),
      (store_encountered_party2,reg(2))

Now, just modify the trigger to set up whatever you want.
 
I've retaken the problen I left unsolved for my 6 fighter free for all arena fight.

As 'num_active_teams_le' doesn't work with more than 4 teams, I have to do this: finish the battle when there is only 1 fighter alive (or when the player dies, but this is an easy one). I'm trying to use try_for_agents to count the agents in the scene, taking into account that the player can spectate and not be part of the fight, I need to end the mission when there is 1 agent alive (the fighting player) or 2 agents alive (the spectating player and the winner fighter).

I tried this code for my mission:

  (
    "arena_fight_b",mtf_arena_fight,-1,
    "You are about to enter the arena.",
    [
      (0,mtef_visitor_source,af_override_horse|af_override_weapons|af_override_head,0,1,[]),
      (1,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
      (4,mtef_visitor_source|mtef_team_2,af_override_horse,aif_start_alarmed,1,[]),
      (7,mtef_visitor_source|mtef_team_3,af_override_horse,aif_start_alarmed,1,[]),
      (9,mtef_visitor_source|mtef_team_4,af_override_horse,aif_start_alarmed,1,[]),
      (12,mtef_visitor_source|mtef_team_5,af_override_horse,aif_start_alarmed,1,[]),
      (15,mtef_visitor_source|mtef_team_6,af_override_horse,aif_start_alarmed,1,[])
    ],
    [
      (1, 3, ti_once, [(main_hero_fallen,0)],
      [(assign,"$arena_fight",1),(assign,"$arena_fight_result",1),(jump_to_scene,"scn_zendar_center")]),
      (1, 3, ti_once, [(store_mission_timer_a,reg(1)),(ge,reg(1),1),(assign,reg(2),0),(try_for_agents,reg(0)),(agent_is_alive, reg(0)),(agent_is_human, reg(0)),(val_add,reg(2),1),(try_end),(try_begin),(eq,"$arena_fight_spectate",0),(eq,reg(2),1),(else_try),(eq,"$arena_fight_spectate",1),(eq,reg(2),2),(try_end),(neg|main_hero_fallen,0)],
      [(assign,"$arena_fight",1),(assign,"$arena_fight_result",1),(try_begin),(eq,"$arena_fight_spectate",0),(assign,"$arena_fight_pay",15),(assign,"$arena_fight_won",1),(try_end),(jump_to_scene,"scn_zendar_center")])
    ],
  ),

As you can see, I just replaced the (num_active_teams_le,1) function with the code in bold. But the mission ends at starts, because somehow the code seems to evaluate as true... I'm still trying to understand this languaje and what the operations and functions do, so I need some help to debug that code in bold (the rest of the code works fine, I've tested that).

Thanks in advance.
 
Does the code always evaluate as true, or on every try after the first one? The latter happens because ti_once is bugged, but I've managed to code a workaround for it for Storymod (that didn't make it into Craftmod because I forgot).

Also, you're using try_for_agents in a conditions block. I wouldn't. Some operations won't work when placed in conditions blocks. Best to put it in a try statement in your consequences block.

Felicitously,
Winter
 
I think your problem might be that it doesn't matter if a try block is true or false inside a condition block. You have to set a flag inside the try block that then will either be evaluated as true or false in the condition block after the try blocks run. In other words you could have any number of try blocks come up false in a condition block but if there isn't a simple evaluation statement ie. (eq,re(2),2) outside of the try blocks, the trigger will run every single time.

Roughly the code layout would look something like this

[(assign,"$flag1",0),(assign,"flag2",0),
(try_begin),
      (conditionals),
      (assign,"$flag1",1),
(else_try),
      (conditionals),
      (assign,"$flag2",1),
(try_end),

(this_or_next|eq,"$flag1",1),(eq,"$flag2",1)]

Note: you can use registers for the flags instead but you must make sure that at the begining of the condition block that you set them to zero.

Edit: You should actually have the flags be zeroed as well since this code would be used over and over again. Above has been changed to reflect that

Hope this helps
Ahadhran
 
Ah yes, what Ahadhran said -- he's hit the nail right on the head. I wasn't looking close enough.

For keeping things simple, you should do as I said -- move your whole try_for_agents stuff into a try statement in the consequences block. That'll let you use your else_try stuff without setting another unnecessary register/variable.

Literally,
Winter
 
I posted this in the warhammer mod thread, but with no luck, so I thought I'd see if anyone here has any ideas;

I had a fiddle about with Luigi's wonderful hats, in order to optimise the poly count and add some feathers.
I sorted the alpha on the feathers, imported it into BRFEdit as a multimesh and it displayed fine:

nohat.jpg


However, when I went in-game, the hat appeared like this in the inventory;

nohat2.jpg


And like this when I put it on.

nohat3.jpg


The same's happened to any other objects I've tried to use multimeshes on recently.
However, multi-meshed objects that I've done before continue to show up fine. What's the problem?

:???:
 
Status
Not open for further replies.
Back
Top Bottom