Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
The_dragon said:
@Nameless Warrior you have a party that is declared wrong (it has few fields). Check you recently modified/added parties and you should find the error.

I never learn my lesson about compiling frequently so issues are easier to identify  :lol: It must be that because when I start the game it is party templates.txt that fails. It all looks good to me after 7 scans but I changed loads so needle in a haystack time.


Edit: Figured it out. I wanted only one of a troop in a party so I put (troop,1), when I should have put (troop,1,1),
 
@Ikaguia try this and spawn missile at pos1 (it should fire a missile above your head (y + 180 is the approx head position)). Also make sure that your code is running (debug messages).
(agent_get_position, pos1, l.agent),
(position_move_y, pos1, 200, 1),

Or even better (to see where the final position is):
Code:
(set_spawn_position, pos1),
(spawn_item, itm.tutorial_short_bow)
 
it seems position_move_y moves it to my Right, instead of up, up and down will probably be Z

Code:
X axis (i.e. whether the position will be moved to it's right/left, or to the global east/west).
Y axis (i.e. whether the position will be moved forward/backwards, or to the global north/south).
Z axis (i.e. whether the position will be moved to it's above/below, or to the global above/below - these directions will be different if the position is tilted).

edit:

I managed to get it spawning in the correct postition but it still does not want to rotate properly
Code:
		(0.1,0,3,[
			(neg|main_hero_fallen),
			(ge,g.throw_potatoes,1),
			(display_message,"@Firing potato!!"),
			(val_sub,g.throw_potatoes,1),
			(get_player_agent_no,l.agent),
			(set_fixed_point_multiplier,200),
			(init_position,pos1),
			(init_position,pos2),
			####(agent_get_bone_position, pos1, l.agent, 9),#get head level, in case player is on horse or jumping ## not working properly when jumping on a horse
			####(position_get_distance_to_ground_level,l.dist,pos1),
			(agent_get_position, pos1, l.agent),
			####(position_move_z, pos1, l.dist, 1),
			(try_begin),
				(agent_get_horse,l.horse,l.agent),
				(agent_is_active,l.horse),
				(agent_is_alive,l.horse),
				(position_move_z, pos1, 50, 1),
			(try_end),
			(position_move_z, pos1, 200, 1),
			(position_rotate_x,pos1,90),
			(position_move_y, pos1, 5, 0),
			(add_missile,l.agent,pos1,1000,itm.tutorial_short_bow,0,itm.tutorial_arrows,0),
			#(set_spawn_position, pos1),
			#(spawn_item, itm.tutorial_short_bow),
			(lt,g.throw_potatoes,1),
		],[]),
 
frozenpainter said:
(0, 0, 0, [(key_clicked, key_f3)],
I want work this code when I press first f1 then press f3, I wrote look like but doesn't work.
(0, 0, 0, [(key_clicked, key_f1),(key_clicked, key_f3)],
Maybe you could do it like this?
Code:
(0, 0, 0, [(key_clicked, key_f1)],
 [
  (assign, "$player_clicked_f1", 1),
 ]
),
(0, 0, 0, [(eq, "$player_clicked_f1, 1),
              (key_clicked, key_f3)],
 [
  (play_sound, "snd_charging"),
  (assign, "$player_clicked_f1", 0),
 ]
),
(0, 0, 0, [(key_clicked, key_esc)],
 [
  (assign, "$player_clicked_f1", 0),
 ]
),
 
Do you want to 'click' F1, the 'click' F2 and then your code will be executed? In this case, you need some variables to keep track of when you clicked F1 (when you click f1, store the current time in a global var. then, when you click f2, check if the current time - store time is greater than an amount of time (1 sec or so?). If true, execute the code).

If you want to hold down F1 and while holding down F1, click F2, then there is the operation key_is_down (this operation checks if the specified key is currently down (aka it is pressed)).
 
just found out my error, the missile speed was 1000/200 = 5, and thus was falling down almost intantly, I buffed it up to 50 and it is now firing forwards :smile:




edit:
can someone more well-versed in python check if this code is correct?
this code
Code:
words = [
	(key_p,key_o,key_t,key_a,key_t,key_o,key_space,key_m,key_g),
	(key_p,key_o,key_t,key_a,key_t,key_o,key_space,key_t,key_h,key_r,key_o,key_w),
]

script_block = [
	(assign,l.result,0),
]

def word_block_insert(block,i,j):
	block += [
			(lt,g.ibcc_text,j+1),
			(assign,l.result,1),
	]
	if j<len(words[i]):
		block += [
			(else_try),
				(troop_slot_eq,trp.ibcc_temp,j,words[i][j]),
				(try_begin),
		]
		word_block_insert(block,i,j+1),
		block += [
				(try_end),
		]

for i in xrange(len(words)):
	script_block += [(try_begin),]
	word_block_insert(script_block,i,0),
	script_block += [(try_end),]
script_block += [
	(try_begin),
		(eq,l.result,0),
		(str_store_string,s0,"@check failed on "),
		(assign,l.temp,1),
		(try_for_range,l.slot,0,l.temp),
			(neg|troop_slot_eq,trp.ibcc_temp,l.slot+1,-1),
			(val_add,l.temp,1),
			(troop_get_slot,l.key,trp.ibcc_temp,l.slot),
			(call_script,script.get_key_name,l.key),
			(str_store_string,s0,"@{s0}{s1}"),
			(neg|troop_slot_eq,trp.ibcc_temp,l.slot+2,-1),
			(str_store_string,s0,"@{s0}, "),
		(try_end),
		(display_message,s0),
	(try_end),
	(eq,l.result,1),
]

scripts = [
	("cf_current_word_is_valid",script_block),
]

should be equivalent to this:
Code:
scripts = [
	("cf_current_word_is_valid",[
		(assign,l.result,1),
		(try_begin),
			(lt,g.ibcc_text,1),
		(else_try),
			(troop_slot_eq,trp.ibcc_temp,0,key_p),
			(try_begin),
				(lt,g.ibcc_text,2),
			(else_try),
				(troop_slot_eq,trp.ibcc_temp,1,key_o),
				(try_begin),
					(lt,g.ibcc_text,3),
				(else_try),
					(troop_slot_eq,trp.ibcc_temp,2,key_t),
					(try_begin),
						(lt,g.ibcc_text,4),
					(else_try),
						(troop_slot_eq,trp.ibcc_temp,3,key_a),
						(try_begin),
							(lt,g.ibcc_text,5),
						(else_try),
							(troop_slot_eq,trp.ibcc_temp,4,key_t),
							(try_begin),
								(lt,g.ibcc_text,6),
							(else_try),
								(troop_slot_eq,trp.ibcc_temp,5,key_o),
								(try_begin),
									(lt,g.ibcc_text,7),
								(else_try),
									(troop_slot_eq,trp.ibcc_temp,6,key_space),
									(try_begin),
										(lt,g.ibcc_text,8),
									(else_try),
										(troop_slot_eq,trp.ibcc_temp,7,key_t),
										(try_begin),
											(lt,g.ibcc_text,9),
										(else_try),
											(troop_slot_eq,trp.ibcc_temp,8,key_h),
											(try_begin),
												(lt,g.ibcc_text,10),
											(else_try),
												(troop_slot_eq,trp.ibcc_temp,9,key_r),
												(try_begin),
													(lt,g.ibcc_text,11),
												(else_try),
													(troop_slot_eq,trp.ibcc_temp,10,key_o),
													(try_begin),
														(lt,g.ibcc_text,12),
													(else_try),
														(troop_slot_eq,trp.ibcc_temp,11,key_w),
														(lt,g.ibcc_text,13),
													(else_try),
														(assign,l.result,0),
													(try_end),
												(else_try),
													(assign,l.result,0),
												(try_end),
											(else_try),
												(assign,l.result,0),
											(try_end),
										(else_try),
											(assign,l.result,0),
										(try_end),
									(else_try),
										(troop_slot_eq,trp.ibcc_temp,7,key_m),
										(try_begin),
											(lt,g.ibcc_text,9),
										(else_try),
											(troop_slot_eq,trp.ibcc_temp,8,key_g),
											(lt,g.ibcc_text,10),
										(else_try),
											(assign,l.result,0),
										(try_end),
									(else_try),
										(assign,l.result,0),
									(try_end),
								(else_try),
									(assign,l.result,0),
								(try_end),
							(else_try),
								(assign,l.result,0),
							(try_end),
						(else_try),
							(assign,l.result,0),
						(try_end),
					(else_try),
						(assign,l.result,0),
					(try_end),
				(else_try),
					(assign,l.result,0),
				(try_end),
			(else_try),
				(assign,l.result,0),
			(try_end),
		(else_try),
			(assign,l.result,0),
		(try_end),
		(try_begin),
			(eq,l.result,0),
			(str_store_string,s0,"@check failed on "),
			(assign,l.temp,1),
			(try_for_range,l.slot,0,l.temp),
				(neg|troop_slot_eq,trp.ibcc_temp,l.slot+1,-1),
				(val_add,l.temp,1),
				(troop_get_slot,l.key,trp.ibcc_temp,l.slot),
				(call_script,script.get_key_name,l.key),
				(str_store_string,s0,"@{s0}{s1}"),
				(neg|troop_slot_eq,trp.ibcc_temp,l.slot+2,-1),
				(str_store_string,s0,"@{s0}, "),
			(try_end),
			(display_message,s0),
		(try_end),
		(eq,l.result,1),
		]),
]
 
ThegnAnsgar said:
No way to do it with the module system?
There's things that can't be done* with a text editor and that can be done with the ModSys. NOT the other way around. Now to the question at hand...
Remember the old M&B tutorial? The one where you get a staff that can't attack? Its item entry is still present. Compare:
Code:
 ["tutorial_staff_no_attack","Staff", [("wooden_staff",0)],itp_type_polearm|itp_offset_lance|itp_primary|itp_penalty_with_shield|itp_wooden_parry|itp_wooden_attack,itc_parry_polearm|itcf_carry_sword_back,9, weight(3.5)|spd_rtng(120) | weapon_length(115)|swing_damage(0,blunt) | thrust_damage(0,blunt),imodbits_none],
 ["tutorial_staff","Staff", [("wooden_staff",0)],itp_type_polearm|itp_offset_lance|itp_primary|itp_penalty_with_shield|itp_wooden_parry|itp_wooden_attack,itc_staff|itcf_carry_sword_back,9, weight(3.5)|spd_rtng(120) | weapon_length(115)|swing_damage(16,blunt) | thrust_damage(16,blunt),imodbits_none],
What we're looking at are the
Code:
itc_*
flags of both weapons. I think "itc(f)" stands for "item capability (flag)" - and the staff that can't attack is lacking any itc_* flags that reference attacks, only the two carrying ones.
In comparison, the real staff has
Code:
itc_staff
, which, in header_items.py, is defined as:
Code:
itc_staff      = itc_parry_polearm| itcf_thrust_onehanded_lance |itcf_thrust_onehanded_lance_horseback| itcf_overswing_polearm |itcf_thrust_polearm|itcf_slashright_polearm|itcf_slashleft_polearm
Bingo.

To disable attacking with a certain weapon, just do the same: remove the itc_* flag that governs its attacking possibilities. If you wish, you may add only ones for parrying. Easy peasy.

* Within reasonable time limits, without need to understand and/or cross-reference compiled entries, and with much greater safety.

a new reply
Jacob is a scrub for using GUI editors, so don't listen to him. Real (Wo)Men Use Text Editors Only™.
 
It sometimes (i.e. once in several hundred uses) messes up the upgrade line, but fixing it was really easy. I mainly use Morgh's because I can never remember all the values and what order they come in. Troops and items are the most tedious and basic thing in the entire module system, and it's more or less a spreadsheet, so a GUI is recommendable.

The only time I ever go into the module files for items or troops is when I want to copy a lot of them at once, or if I want to attach a script to an item.
 
How can I change the point the rider mounts his horse. So I can have the rider mount to the front of the horse not on the saddle.
 
Hi, I can't seem to get the game_get_upgrade_cost to change the upgrade cost of specific units. To test this I tried to change the upgrade to Swadian Militia to 500 denars with this code:

Code:
("game_get_upgrade_cost",
	[
	(store_script_param_1, ":troop_id"),
	
	(try_begin),
		(eq, "troop_id", "trp_swadian_militia"),
		(assign, reg0, 500)
	(try_end),

However it'd seem like the script to calculate cost based on level overrides this. What am I doing wrong?
 
Status
Not open for further replies.
Back
Top Bottom