Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Can anyone help me and tell me why this does not work? Even if you look at someone standing in front of you, he is not targeted. The script should find the next agent in front of you, it was written by someone here in this thread, it was some time ago. Don't know who it was :wink: And now I try to fix it, but i don't know what is the reason why it does not work.

Code:
IT_magic_system_2 = (0, 0, 60, #every frame                      (reset_mission_timer_b),
      [
       (key_clicked, key_j), #could use global var, game_key, or something - see list in header_triggers
       (get_player_agent_no, ":agent"),
       (agent_get_wielded_item, "$staff", ":agent", 0),
      ],
         [
		 			(try_begin),
		        (eq, "$staff", "itm_heal_staff_1"),
         (get_player_agent_no, ":player_agent"),
            
            (assign, ":target_agent", -1),
            (assign, ":close_dist", 9999),
            (agent_get_look_position, pos1, ":player_agent"),		
         (display_message,"@get_look_position",0x6495ed), 			
            (try_for_agents, ":agent"),
               #add in checks for agent being alive, human, ally, whatever you need
               (agent_get_position, pos2, ":agent"),
               (neg|position_is_behind_position, pos2, pos1),
               (position_has_line_of_sight_to_position, pos2, pos1),
               (get_distance_between_positions, ":distance", pos2, pos1),
			            (display_message,"@pos1 + 2",0x6495ed),
               (lt, ":distance", ":close_dist"),
               (assign, ":close_dist", ":distance"),
               (assign, ":target_agent", ":agent"),
               (agent_set_animation, ":player_agent", "anim_defend_shield_right"),			   
			            (display_message,"@assigned!",0x6495ed),
            (try_end),  
				(gt, ":target_agent", -1),
               (store_agent_hit_points,":life",":target_agent",1),
               (val_add,":life",15),
               (agent_set_hit_points,":target_agent",":life",1),
				(multiplayer_send_2_int_to_server, multiplayer_event_anim_made_by_player, "anim_defend_shield_forward", ":player_agent"),		
       
         (display_message,"@Works!",0x6495ed),           			
			(else_try),
		        (eq, "$staff", "itm_curse_staff_1"),
         (display_message,"@Works!",0x6495ed),  				
			(try_end),
				])
 
It looks incomplete to me. You could pull out the collision detection from my autofire mod and just remove what isn't needed.

I have a question, when I was working on the autofire code I tested to see if the position_has_line_of_sight_to_position command detected agents. In my tests it did not, but Theoris seemed to think it did. Could someone confirm this?
 
I will see... Even if i don't know why i should need it, but well. One more question, is it possible to add more "outer_terrains" for maps?
 
Sayd,

So this animation you are using is in its own file? (So the frames go from 0 to 69?)

Then something like this should work (if my brief reading of the animation format is correct):
["animation_name_here", acf_thrust|acf_enforce_all|acf_align_with_ground,
  [4.0, "anim_name_inBRF_here", 0, 69, blend_in_ready], #where 4.0 is how long, in seconds, the animation should take to run through those 69 frames
],
 
3. How can i get player's party id ? Only way i found was going through all the parties and checking for player troop.

4. How can i get ids of all the parties in multiparty battles?
 
rabican said:
3. How can i get player's party id ? Only way i found was going through all the parties and checking for player troop.
The player's party is "p_main_party", which is 0. It is always 0.

rabican said:
4. How can i get ids of all the parties in multiparty battles?
In any battle or just in one that the player is involved in?
Useful commands are
(party_get_attached_to, <destination>, <party_id>),
(party_get_num_attached_parties, <destination>, <party_id>),
(party_collect_attachments_to_party, <party_id>, <destination party_id>),
(party_get_battle_opponent, <destination>, <party_id>)
 
thanks!

One more question : can i rename registers?  I can't keep track of nondescriptive register names. I could use globals but then i would have to assing it to reg for every debug message etc (i think? ).

Just replacing the name in header_common works , but i get  unrecognized token everytime i use the newly named register in string.

 
rabican said:
One more question : can i rename registers?  I can't keep track of nondescriptive register names. I could use globals but then i would have to assing it to reg for every debug message etc (i think? ).
Globals are exactly for that, for keeping track.
Registers are used there and there by all kinds of scripts as a means of transferring values from source to destination. Better leave them at that, else you risk getting your registers overwritten here and there.
On the other hand, if you are able to keep track of register usage throughout all the MS to prevent overwriting, you will have no trouble keeping track of its non-descriptive name.

And yes, everybody assigns globals to registers for debug messages :smile:
 
GetAssista said:
rabican said:
One more question : can i rename registers?  I can't keep track of nondescriptive register names. I could use globals but then i would have to assing it to reg for every debug message etc (i think? ).
Globals are exactly for that, for keeping track.
Registers are used there and there by all kinds of scripts as a means of transferring values from source to destination. Better leave them at that, else you risk getting your registers overwritten here and there.
On the other hand, if you are able to keep track of register usage throughout all the MS to prevent overwriting, you will have no trouble keeping track of its non-descriptive name.

And yes, everybody assigns globals to registers for debug messages :smile:

Yes i am using registers exactly as you described, i don't need them named for any long term storage. The problem is more like that i have short term memory of gold fish when it comes to numbers. For example i have a script that returns 3  values, radius, distance, damage, duration. If i use registers to store them i have to double and triple check the register numbers every time i write call command for the script. If i use global variable then i have to assign it away anyway for gazillion times.  Renaming couple of registers would save a lot of time one way or another.
 
At the bottom of header common, you can create variables that will point to the registers. You can even have more than one variable point to the same register. Like this...
Code:
radius = reg0
distance = reg1
damage = reg2
duration = reg3

return = reg0
eggCount = reg1;
hasFrenchToast = reg2
friesWithThat = reg0


Err, sorry for the variable name...I think I'm hungry.  :lol:
 
Or open up notepad and copy and paste the lines with the regs so you don't need to scroll up 'n down all the time.
That's what I do at times.
 
if i rename register, or do something like radius = reg0 , the new name works fine ,but i can't use it in a string like regular register.
shouldn't have said anything about pointers , have no idea what that even is.
 
Caba`drin said:
Sayd,

So this animation you are using is in its own file? (So the frames go from 0 to 69?)

Then something like this should work (if my brief reading of the animation format is correct):
["animation_name_here", acf_thrust|acf_enforce_all|acf_align_with_ground,
  [4.0, "anim_name_inBRF_here", 0, 69, blend_in_ready], #where 4.0 is how long, in seconds, the animation should take to run through those 69 frames
],


the compiler says

Exporting animations...
Traceback (most recent call last):
  File "process_animations.py", line 61, in <module>
    write_actions(animations,len(action_codes),action_codes,"actions.txt")
  File "process_animations.py", line 30, in write_actions
    file.write(" %s %d %d "%(action_codes[i_action_code],action[1], action[2]))
#print flags
TypeError: %d format: a number is required, not list

 
Status
Not open for further replies.
Back
Top Bottom