Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
I want each player to have his own stats and items from the database(mysql).
So right now each time player joins the server, it loads his items and puts them in trp_player_(playerid) troop inventory and sets the troop id.
Problem is with the stats, such as Athletics, Agility... etc.
Each time a player joins server, i send a url request and it goes to game_receive_url_response with his stats. then, on game_receive_url_response i send a network message to the player using
multiplayer_send_3_int_to_player with an event i made to raise the troop stat (Agility,strength,athletics...).
Problem is the actual player doesnt really have those stats event tho i sent the data...
I dont understand whats wrong here? i used troop_raise_attribute and troop_raise_skill
Please help ive tried to solve this problem for a few days now :/

My client events:
Code:
(else_try),
      (eq, ":event_type", multiplayer_event_send_updated_troop_attribute),
      (try_begin),
      (store_script_param, ":troop_id", 3),
      (store_script_param, ":att_id", 4),
      (store_script_param, ":level", 5),
      (val_sub, ":level", 3),
      (troop_raise_attribute, ":troop_id", ":att_id", ":level"),
      (try_end),
      (else_try),
      (eq, ":event_type", multiplayer_event_send_updated_troop_prof),
      (try_begin),
      (store_script_param, ":troop_id", 3),
      (store_script_param, ":prof_no", 4),
      (store_script_param, ":value", 5),
      (troop_raise_proficiency_linear, ":troop_id", ":prof_no", ":value"),
      (try_end),
      (else_try),
      (eq, ":event_type", multiplayer_event_send_updated_troop_skill),
      (try_begin),
      (display_message, "@PASS!"),
      (store_script_param, ":troop_id", 3),
      (store_script_param, ":skill_id", 4),
      (store_script_param, ":value", 5),
      (troop_raise_skill, ":troop_id", ":skill_id", ":value"),
      (try_end),

The game_receive_url_response:
Code:
 (eq, ":event", 7), #get attributes, skills, proficiencies and load them
        (try_begin),
            (assign, ":str", reg3),
            (assign, ":agi", reg4),
            (assign, ":powerstrike", reg5),
            (assign, ":powerdraw", reg6),
            (assign, ":powerthrow", reg7),
            (assign, ":athletics", reg8),
            (assign, ":ironflesh", reg9),
            (assign, ":onehanded", reg10),
            (assign, ":twohanded", reg11),
            (assign, ":polearm", reg12),
            (assign, ":archery", reg13),
            (assign, ":crossbow", reg14),
            (assign, ":throwing", reg15),
        (display_message, "@Athletics recieved: {reg8}"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_str, ":str", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_agi, ":agi", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_powerstrike, ":powerstrike", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_ironflesh, ":ironflesh", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_powerdraw, ":powerdraw", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_powerthrow, ":powerthrow", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_athletics, ":athletics", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_onehanded, ":onehanded", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_twohanded, ":twohanded", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_polearm, ":polearm", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_archery, ":archery", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_crossbow, ":crossbow", ":local_id"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_player_slot, slot_player_throwing, ":throwing", ":local_id"),
        (val_sub, ":str", 3),
          (val_sub, ":agi", 3),
        (store_add, ":troop_id", "trp_player_0", ":local_id"),
         (troop_raise_attribute, ":troop_id", ca_strength, ":str"),
         (troop_raise_attribute, ":troop_id", ca_agility, ":agi"),
         (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_troop_attribute, ":troop_id", ca_strength, ":str"),
         (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_troop_attribute, ":troop_id", ca_agility, ":agi"),
        (troop_raise_skill, ":troop_id", skl_athletics, ":athletics"),
        (multiplayer_send_3_int_to_player, ":local_id", multiplayer_event_send_updated_troop_skill, ":troop_id", skl_athletics, ":athletics"),

As you can see ive tried couple ways to make that work... tried with sending player slots to the client and then setting it, tried with directly sending a client message with the stats... idk what to do
 
The Dark Robin said:
How is it actually detected inside of dialogs where the player is talking to a prisoner in order to start the prison break to see if the player has keys of the dungeon? All the keys to the dungeon code has is a display message thing. :???:

Code:
   (ti_on_agent_killed_or_wounded, 0, 0, [],
   [
     (store_trigger_param_1, ":dead_agent_no"),
     (store_trigger_param_2, ":killer_agent_no"),
     #(store_trigger_param_3, ":is_wounded"),
        
     (agent_get_troop_id, ":dead_agent_troop_no", ":dead_agent_no"),
     (agent_get_troop_id, ":killer_agent_troop_no", ":killer_agent_no"),
                
     (try_begin), 
       (this_or_next|eq, ":dead_agent_troop_no", "trp_swadian_prison_guard"),
       (this_or_next|eq, ":dead_agent_troop_no", "trp_vaegir_prison_guard"),
       (this_or_next|eq, ":dead_agent_troop_no", "trp_khergit_prison_guard"),
       (this_or_next|eq, ":dead_agent_troop_no", "trp_nord_prison_guard"),
       (this_or_next|eq, ":dead_agent_troop_no", "trp_rhodok_prison_guard"),
       (eq, ":dead_agent_troop_no", "trp_sarranid_prison_guard"),
          
       (eq, ":killer_agent_troop_no", "trp_player"),
          
       (display_message, "@You got keys of dungeon."),
     (try_end),
   ]),
Asking again
 
The prison dialogs are triggered when (eq, "$talk_context", tc_prison_break), which is in turn first assigned here
Code:
  [anyone,"prison_guard_visit_break", [], "Help! Help! Prison break!", "close_window",[
  (call_script, "script_activate_town_guard"),
  (assign, "$g_main_attacker_agent", "$g_talk_agent"),
  (assign, "$talk_context", tc_prison_break),
...
There is no apparent connection, but whenever you enter a passage the corresponding menu is consulted. In the consequence of town_dungeon those two variables are checked, and if you've killed off $g_main_attacker_agent then it lets you in. Otherwise it tells you it's locked, and you have no way to access the dungeon to talk to lords imprisoned there.
 
SnRolls said:
I want each player to have his own stats and items from the database(mysql).
So right now each time player joins the server, it loads his items and puts them in trp_player_(playerid) troop inventory and sets the troop id.
Problem is with the stats, such as Athletics, Agility... etc.
Each time a player joins server, i send a url request and it goes to game_receive_url_response with his stats. then, on game_receive_url_response i send a network message to the player using
multiplayer_send_3_int_to_player with an event i made to raise the troop stat (Agility,strength,athletics...).
Problem is the actual player doesnt really have those stats event tho i sent the data...
I dont understand whats wrong here? i used troop_raise_attribute and troop_raise_skill
Please help ive tried to solve this problem for a few days now :/

*snip*

As you can see ive tried couple ways to make that work... tried with sending player slots to the client and then setting it, tried with directly sending a client message with the stats... idk what to do
As far as I can see, you're receiving the stats data on the server (you verified this worked with debug messages I assume?) but then you're sending those stats to the player, which then try to adjust their attributes client-side. Attributes and skills however are handled server-side (they should be, to prevent cheating).
So, just skip out on the send_int_3_to_player and call the script directly.
 
Arch3r said:
SnRolls said:
I want each player to have his own stats and items from the database(mysql).
So right now each time player joins the server, it loads his items and puts them in trp_player_(playerid) troop inventory and sets the troop id.
Problem is with the stats, such as Athletics, Agility... etc.
Each time a player joins server, i send a url request and it goes to game_receive_url_response with his stats. then, on game_receive_url_response i send a network message to the player using
multiplayer_send_3_int_to_player with an event i made to raise the troop stat (Agility,strength,athletics...).
Problem is the actual player doesnt really have those stats event tho i sent the data...
I dont understand whats wrong here? i used troop_raise_attribute and troop_raise_skill
Please help ive tried to solve this problem for a few days now :/

*snip*

As you can see ive tried couple ways to make that work... tried with sending player slots to the client and then setting it, tried with directly sending a client message with the stats... idk what to do
As far as I can see, you're receiving the stats data on the server (you verified this worked with debug messages I assume?) but then you're sending those stats to the player, which then try to adjust their attributes client-side. Attributes and skills however are handled server-side (they should be, to prevent cheating).
So, just skip out on the send_int_3_to_player and call the script directly.

Wow, you actually noticed my message  :shock:
I always liked your work and got inspired by it.
That explains a lot... Ive seen in a couple posts people said you need to send the data client side...
But you are probably right, ill let you know if it works :wink:
Thanks again master  :grin:

Edit:
Seems like Speed(athletics), health(ironflesh) and proficiencies doesnt work... are you sure i dont need to send them client side?
 
How come no option to use a scene prop comes up?
Code:
  ("game_get_use_string",
   [
     (store_script_param, ":instance_id", 1),

     (prop_instance_get_scene_prop_kind, ":scene_prop_id", ":instance_id"),

     (try_begin),
       (eq, ":scene_prop_id", "spr_chest_b_bonus_4"),
	   (str_store_string, s0, "str_attempt_lockpick"),
     (else_try),
       (this_or_next|eq, ":scene_prop_id", "spr_winch_b"),

....

Code:
  ("chest_b_bonus_4",spr_use_time(5),"chest_b","bo_chest_b", [
   (ti_on_scene_prop_use,
    [
      (try_begin),
	  		 (store_skill_level, ":skill", "skl_lockpick", "trp_player"),
			 (ge, ":skill", 1),
			 (display_message,"str_door_lockpicked",0x3B7534),
			 (change_screen_loot, "trp_bonus_chest_4"),
	  (else_try),
			 (display_message,"str_door_locked",0xFFFFAAAA),
	  (try_end),
    ]),
  ]),

Is there any more code that I need to put in? The prop just behaves like a normal one, no option to interact with it at all.
 
The Dark Robin said:
How come no option to use a scene prop comes up?

(...snip...)

Is there any more code that I need to put in? The prop just behaves like a normal one, no option to interact with it at all.
If you're testing it in singleplayer, you need to modify your module.ini file to enable usable props.
 
What is the point of a destination again? Like why is it that when you store a relation, it requires a destination? Why is it suppose to be? Or am I missing something and it is a variable?
 
Code:
store_relation                  = 2190  # (store_relation, <destination>, <faction_id_1>, <faction_id_2>),
                                        # Retrieves relation between two factions. Relation is in -100..100 range.

As you can see, despite it being named 'store' relation, it actually retrieves it into the variable you specify as the destination. Most 'get' type operations have the 'destination' as the first parameter, as far as I know.

So

Code:
(store_relation, ":relation_value", fac_kingdom_1, fac_kingdom_2),
(assign, reg0, ":relation_value"),
(display_message, "@{reg0}"),

Would display the relation between those kingdoms.

Sounds like you might want to use

Code:
set_relation                    = 1270  # (set_relation, <faction_id_1>, <faction_id_2>, <value>),
                                        # Sets relation between two factions. Relation is in -100..100 range.
 
Thanks, i get it now. Another question, recently I've been playing around with module_parties and module_party_templates. I don't understand the difference between them. If templates are suppose to be templates then wouldn't that mean that the troops would be added in the templates for the parties instead of in module_parties? I'm not trying to say that module_troop should be in party template, I'm just trying to understand why module_parties and module_party_templates are so similiar.

About set_relation. What if I want only one faction to gain a relation increase?
 
epicboy12332 said:
Another question, recently I've been playing around with module_parties and module_party_templates. I don't understand the difference between them. If templates are suppose to be templates then wouldn't that mean that the troops would be added in the templates for the parties instead of in module_parties? I'm not trying to say that module_troop should be in party template, I'm just trying to understand why module_parties and module_party_templates are so similiar.
Someone more knowledgeable can help you out with this, although off the top of my head, the template would be the type of party, and the party itself would be an instance of the template, right?

epicboy12332 said:
About set_relation. What if I want only one faction to gain a relation increase?

The very concept of a relation or relationship requires two things to be involved  :lol:

What are you actually trying to get done?
 
epicboy12332 said:
What if I wanted a faction to gain 1 relation while the other gains 2 relation?
That doesnt make any sense...
Faction 1 relation to faction 2 and faction 2 to 1 will be the same...
Since its a relation... god
 
epicboy12332 said:
About set_relation. What if I want only one faction to gain a relation increase?
Relations between the factions are used to handle parties AI on the map. If you have unequal relations, it is possible that faction A's parties are attacking faction B's parties, while the latter do not attempt to flee or retaliate, which does not make sense. So any relation between any two factions is the same for both of them. If you have to make them unequal, you'll have to code your own modifiers on top of the existing system.

epicboy12332 said:
Thanks, i get it now. Another question, recently I've been playing around with module_parties and module_party_templates. I don't understand the difference between them. If templates are suppose to be templates then wouldn't that mean that the troops would be added in the templates for the parties instead of in module_parties? I'm not trying to say that module_troop should be in party template, I'm just trying to understand why module_parties and module_party_templates are so similiar.
A party may be based on a party template. If you spawn a party from a party template, the newly created party will use information from party template to auto-generate all information (party faction, flags, map icon, starting troops etc). This is why parties and party templates are so similar.

Party may be not based on any party template. A lot of pre-defined parties in module_parties.py are exactly like that. Just think of them as if they're based on a "zero" template, which has all parameters set to zero. :smile:
 
How would one go about preventing the G key from dropping your wielded item in multiplayer?

Or failing that, how would one be able to detect when a player drops an item?


Edit: Oh I found the ti_on_item_dropped used in the napoleonic wars module system. This would answer the second question, but the first one is more important to me.
 
Lav said:
If you're testing it in singleplayer, you need to modify your module.ini file to enable usable props.
Thank you!

Somebody said:
The prison dialogs are triggered when (eq, "$talk_context", tc_prison_break), which is in turn first assigned here
Code:
  [anyone,"prison_guard_visit_break", [], "Help! Help! Prison break!", "close_window",[
  (call_script, "script_activate_town_guard"),
  (assign, "$g_main_attacker_agent", "$g_talk_agent"),
  (assign, "$talk_context", tc_prison_break),
...
There is no apparent connection, but whenever you enter a passage the corresponding menu is consulted. In the consequence of town_dungeon those two variables are checked, and if you've killed off $g_main_attacker_agent then it lets you in. Otherwise it tells you it's locked, and you have no way to access the dungeon to talk to lords imprisoned there.
Thank you!
 
SnRolls said:
Seems like Speed(athletics), health(ironflesh) and proficiencies doesnt work... are you sure i dont need to send them client side?
You should probably set them all the same both server side and for each client connected, so that the server combat calculations and any client side prediction calculations match up.
 
Does anyone have an idea how to make an agent that wont spawn at the start, like a temp agent just to spawn my invasion troops without him spawning too?
Cuz usually if i want my waves to spawn i have to put 1 bot in team 2 but i dont want this guy to spawn.
any ideas?
 
Status
Not open for further replies.
Back
Top Bottom