Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Store a random variable and assign a different particle system based on the result. Or, preferably, use the list-based indexing of the entire ModSys: put all of the particle systems you need in order, then (pseudo MBscript):
Code:
(assign, ":psys_to_use", "psys_lanse"), # The first one in the list = offset 0
(store_random_in_range, ":offset", 0, 4), # offset ∈ [0, 3] IIRC
(val_add, ":psys_to_use", ":offset"),
(particle_system_burst, ":psys_to_use", pos1, 3),
Everything is essentially a list, and (almost) everything can be iterated in a similar manner. It's one of the few really neat things about the ModSys in general. :smile:

half-ninja
 
Lumos said:
Or, preferably, use the list-based indexing of the entire ModSys: put all of the particle systems you need in order, then (pseudo MBscript):
In this case you can define the range directly, which saves operating time.
Code:
(store_random_in_range, ":psys_to_use", "psys_lanse", "psys_end"),
(particle_system_burst, ":psys_to_use", pos1, 3),
 
Lumos said:
Would one or two operations really make that much of a difference when it comes to performance? :razz:
Not that much, but imagine those little optimizations all over the MS... it would result a noticeable performance boost.
However, both variants work and thats what matters... for the most people.  :wink:
 
That's an interesting question, because I'm not quite sure what you mean. I'll assume you've got a regular fraction with a numerator, line, and denominator. If you want to convert it to a decimal, feed it through a calculator or perform manual division number by number. But I usually prefer keeping things in fractionals. It's more useful in general. :smile:
If you've got a large numerator and you want to convert it into a mixed fraction, as in 23/4: Divide the numerator by the denominator with remainder. The remainder is now the numerator, and the number you got is the quotient. 23/4 = 5 (rem. 3) => 23/4 = 5*(3/4). Easy peasy!

That doesn't "remove" the fraction per se, but changes the way it's written. Removing a fraction usually involves rounding up or down, but that leads to data corruption and loss of precision. 23/4 is 5.75, which you could usually round up to 6. Still, it's a bit less precise, but that might be okay depending on what you want your number for.


And if you want to remove factions instead, use Google and imbibe the wisdom of the mentors past and current:
Lav said:
Delete their culture and kingdom entries in module_factions.

Then, for each module_*whatever*.py file, open it and search for "fac_kingdom_" text. Wherever you find it, edit/remove as appropriate. For module_items you want to remove all faction assignments from items (and maybe set new ones). With module_troops you'll probably want to do a complete make-over, also lords and other NPCs need to be edited. In all other files, just find the code which assumes there are 6 factions in the game, and fix the code to run properly with just 2 factions.
(The answer references "just 2 factions", which was in relation to the original question; you'll obviously edit it to fit however many factions you want.)
 
How can I make sure that an agent moves back to the position I want him to be in IF he gets moved (by a kick or by being pushed around)?

Code:
                (spawn_agent,"trp_gate_aggravator"),
		(assign, "$gate_aggravator_agent", reg0),
		(agent_set_speed_limit, "$gate_aggravator_agent", 1),
		(agent_set_team, "$gate_aggravator_agent", 6),
		(team_give_order, 6, grc_everyone, mordr_hold),
		(team_give_order, 6, grc_everyone, mordr_stand_ground),
		(team_set_order_position, 6, grc_everyone, pos1),
                (agent_set_scripted_destination_no_attack,"$gate_aggravator_agent",pos1,1,1),

I use agent_set_scripted_destination_no_attack to make sure that the agent is at pos1, but how do I make him rethink where he is then move back to pos1 if he is no longer there?
 
troycall said:
How to make troops use certain weapons only during night-time and or daylight time?

Detect the time of day and remove/add gear to the agent inventory (0-4 for weapons). A trigger on your mission template can do this.

You can filter by type of weapon, specific flags, etc. Depends on how you are coding them on your module_items.py.

Once you have a prototype bring code here if you need help with some details.
 
kalarhan said:
troycall said:
How to make troops use certain weapons only during night-time and or daylight time?

Detect the time of day and remove/add gear to the agent inventory (0-4 for weapons). A trigger on your mission template can do this.

You can filter by type of weapon, specific flags, etc. Depends on how you are coding them on your module_items.py.

Once you have a prototype bring code here if you need help with some details.

How to detect time of day?
Would this operation work?
Code:
store_time_of_day          = 2271  # (store_time_of_day, <destination>),
                                   # Stores current day hour (value in 0..24 range).
 
I got some code close to a prototype:

Code:
        		  (try_begin), 
          (store_time_of_day, ":cur_hour"),
          (ge, ":cur_hour", 21), #greater then 9 PM
          (lt, ":cur_hour", 5), #lower then 5 AM
			 				(store_random_in_range, ":random_in_range_1_10", 1, 10), #1 in a 10 chance of item being assigned
							(try_begin),
							(assign, ":rand", "random_in_range_1_10"),
							(eq, ":rand", 1),
							(assign, "itm_torch", trp_player), #Obtain item slot 0-4 and replace in here (Not sure what im doing here)
							(else_try),
							#Else try
							(try_end),
							(try_end),

What I need help with is: the actual assign above, i'm not sure on how to assign to slot 0 to 4, as you can see itm_torch is the itm I want assigned.
 
Earl Frensez Arzhur said:
Still can't find what i'm looking for.

How do I get rid of factions; I only want two factions.
Could you literally look at the previous page? :roll:

(Sorry, I just wanted an excuse to use that smiley "properly". Besides, you deserve it. Use google or your eyes next time.)


@troycall: When you want to do something, search for the relevant operations in header_operations. That file is your Bible and Encyclopaedia Britannica combined in one. Searching for "inventory_slot" might be a good idea here.
 
troycall said:
I got some code close to a prototype:

1) Please use proper indentation. Much easier to read  :mrgreen: . Check the process_line_correction.py to make it automatic ...

Code:
(try_begin), 
  (store_time_of_day, ":cur_hour"),
  (ge, ":cur_hour", 21), #greater then 9 PM
  (lt, ":cur_hour", 5), #lower then 5 AM
  (store_random_in_range, ":random_in_range_1_10", 1, 10), #1 in a 10 chance of item being assigned
  
  (try_begin),
    (assign, ":rand", "random_in_range_1_10"),
    (eq, ":rand", 1),
    (assign, "itm_torch", trp_player), #Obtain item slot 0-4 and replace in here (Not sure what im doing here)
  (else_try),#Else try

  stuff ...

  (try_end),
(try_end),

2) You are missing the ":" on this line
Code:
(assign, ":rand", "random_in_range_1_10"),

3) If you want 10% (1 in 10), you need to change that range. Its 0 (zero) based, and (end-1). So a
(range, 1, 10) -> [1,2,3,4,5,6,7,8,9]  -> no 10 in there. That makes 1/9 (11.1%)
Usually you will see this
Code:
(store_random_in_range, ":random", 0, 10),
If you really want use 1, then go to 11
Code:
(store_random_in_range, ":random", 1, 10+1),

4) Not sure why you are reassing the rand to another variable to use it. That is not necessary. Why:
Code:
(assign, ":rand", "random_in_range_1_10"),
?

5) Troop inventory starts counting from the gear (weapons, armor, horse, food) and then moves to the backpack/chest/whetever you want to call it. See the constants on header_items.py
Code:
#equipment slots
ek_item_0 = 0
ek_item_1 = 1
ek_item_2 = 2
ek_item_3 = 3
ek_head   = 4
ek_body   = 5
ek_foot   = 6
ek_gloves = 7
ek_horse  = 8
ek_food   = 9


max_inventory_items = 96
num_equipment_kinds = ek_food + 1
ek_item_0 is the first weapon (top right), and so on...

A agent follows the same system for the gear. And you have operations to remove/add items to a agent (just as you do to a troop). The important part here is that the agent is temporary, so you won't affect the savegame.

Download Lav's module and check section Z22. Remember you need to remove a item (if it is there) before giving a new one.

6) Your time test won't work. Check this operation:
Code:
is_between                 = 33      # (is_between, <value>, <lower_bound>, <upper_bound>),
                                     # Checks that lower_bound <= value < upper_bound
or
Code:
is_currently_night         = 2273  # (is_currently_night),
                                   # Checks that it's currently night in the game on worldmap
 
I got this error after replacing swadian_recruit with kedalin_peasant_levy in every place I could find... what do I do I want to cry  :sad:
http://imgur.com/MyZA5Br
What does Illegal Identifiers mean
Also how do I associate sublime with the py, it says i Have to associate with the defualt programes used to open it? how?
It worked thanks so much!  :lol:
 
Hi, I'd like to bump my question :smile:

Khamukkamu said:
How can I make sure that an agent moves back to the position I want him to be in IF he gets moved (by a kick or by being pushed around)?

Code:
                (spawn_agent,"trp_gate_aggravator"),
		(assign, "$gate_aggravator_agent", reg0),
		(agent_set_speed_limit, "$gate_aggravator_agent", 1),
		(agent_set_team, "$gate_aggravator_agent", 6),
		(team_give_order, 6, grc_everyone, mordr_hold),
		(team_give_order, 6, grc_everyone, mordr_stand_ground),
		(team_set_order_position, 6, grc_everyone, pos1),
                (agent_set_scripted_destination_no_attack,"$gate_aggravator_agent",pos1,1,1),

I use agent_set_scripted_destination_no_attack to make sure that the agent is at pos1, but how do I make him rethink where he is then move back to pos1 if he is no longer there?
 
TheDragonknight said:
I got this error after replacing swadian_recruit with kedalin_peasant_levy in every place I could find... what do I do I want to cry  :sad:
http://imgur.com/MyZA5Br

Read the error message. It usually gives you a good idea of where things are broken.

You said you replaced the troop everywhere.
But the compiler is still trying to use it a few times. That means you did not replaced it everywhere  :razz:
Search for it and finish your first step. Use a proper IDE/Text Editor like Sublime, Visual Studio Code, Notepad++ With Project Explorer plugin, etc

Sublime, as a example: CTRL+SHIFT+F will search in ALL files of your project



Khamukkamu said:
Hi, I'd like to bump my question :smile:
Khamukkamu said:
How can I make sure that an agent moves back to the position I want him to be in IF he gets moved (by a kick or by being pushed around)?

Code:
                (spawn_agent,"trp_gate_aggravator"),
		(assign, "$gate_aggravator_agent", reg0),
		(agent_set_speed_limit, "$gate_aggravator_agent", 1),
		(agent_set_team, "$gate_aggravator_agent", 6),
		(team_give_order, 6, grc_everyone, mordr_hold),
		(team_give_order, 6, grc_everyone, mordr_stand_ground),
		(team_set_order_position, 6, grc_everyone, pos1),
                (agent_set_scripted_destination_no_attack,"$gate_aggravator_agent",pos1,1,1),

I use agent_set_scripted_destination_no_attack to make sure that the agent is at pos1, but how do I make him rethink where he is then move back to pos1 if he is no longer there?

Err best not to bump unless your question is burried a few pages back  :razz:
Are you sure the troop is moving from position? As in, do you have data showing it? Did the troop changed AI behaviour after?
I don't have your code, so a workaroud that may work (quick and dirty) is to put a trigger checking every few seconds for that troop position, and ordering it back to where you want if it moved away.

Code:
agent_is_in_special_mode
is it?

Code:
agent_get_position
did it move away?

Code:
agent_set_position
can you teleport it back? If its a invisible troop (this is a teleport, not a walk back there!)


did you try make it a statue?
Code:
agent_set_no_dynamics

did you calculate AI after giving scripted orders?
Code:
agent_force_rethink
 
Whoa earl, chill.. the answer to your question was there. (was referring to a now deleted but very rude message)

kalarhan, thanks. I'll make sure not to bump until really buried.

I'll try first to make it into a statue, kick it around and see if it moves.

Yes, it is invisible.

--

Update: making it a statue works, and it is what I'll use. Thanks again.
 
Status
Not open for further replies.
Back
Top Bottom