How to retreive the troop_id?

Users who are viewing this thread

Ritter Dummbatz

Grandmaster Knight
I digging through code and what not but I didn't manage to come up with a way to retreive a troop id from outside the party menu.

I wanna call the 'script_game_get_troop_wage' which requires the troop_id as param1.
Am I missing something?

I hope I made myself clear.
Thanks in advance!



 
in partys you can get it like this: (party_stack_get_troop_id, ":stack_troop",":party",":stack_no"),

or with agents: (agent_get_troop_id, ":troop_id", ":agent_no"),
 
Or you can try_for_range of troops:

(try_for_range, ":cur_troop", mercenary_troops_begin, mercenary_troops_end),
  (call_script, "script_game_get_troop_wage", ":cur_troop"),

  # Do something with the wage. The troop wage will be stored in reg0 after the script calling.

(try_end),

There are several ways to get troop_id depending on what you are dealing with.

 
Thanks you both.

My problem is I am in a simple menu and call the script from there. If I understand things right I don't have a stack and no use for agents... I may be wrong of course since I am not used to this scripting language yet.

I think the try the loop. The header file doesn't say if it's the Id that is stored but I will figure that out quite soon.

thanks again much appreciated!

 
A "stack" is simply what a party consists of. Each troop type in a party is a "stack" within that party.
But you're right, if you aren't dealing in a scene (a battle, a tavern, what have you) then you aren't dealing with agents.

Still, it's unclear where the question is coming from--do you need the troop id for someone the player is interacting with?

Each troop has an "id" or name as assigned within module_troops. They are referenced "trp_troopname". (Technically this is turned into a index number, but referencing them by name makes more sense sometimes.) For instance, the player's troop ID is "trp_player".

It might be helpful for you to take a look at my Mod System Syntax post (linked in my sig below) if you haven't already.
 
It might be helpful for you to take a look at my Mod System Syntax post (linked in my sig below) if you haven't already.

That has been of great help already many times. Thank you for your efforts on that one!  :cool:

Ok, didn't know it is not clear enough. Well, the thing is I want to know the wages of a recruit who is not yet a partymember. Practically displayed in the window before I click 'recruit them'.

The try_for_range on a soldier_begin soldiers_end array, getting the name of each one of them and compare the name with the name I get from the volunteers slot stored in the village party is the way that came up my mind. Haven't tried it to code it but I will as soon as I finished this post.

May be I stop if you say there is a much better way.
 
Ritter Dummbatz said:
Just the weekly wage of a recruit shall be displayed that's all.
For example, village recruit troop_id is stored in "slot_center_volunteer_troop_type". Tavern mercanary troop_id is stored in "slot_center_mercenary_troop_type". For center type, pull the troop_id from slot.
 
Ritter Dummbatz said:
The try_for_range on a soldier_begin soldiers_end array, getting the name of each one of them and compare the name with the name I get from the volunteers slot stored in the village party is the way that came up my mind. Haven't tried it to code it but I will as soon as I finished this post.

You wouldn't need a loop for that then. The volunteers slot will give you the troop id. Just feed what you get from the slot into the script.


EDIT: Heh. Ninja'd. As Phoenix said.
 
For example, village recruit troop_id is stored in "slot_center_volunteer_troop_type". Tavern mercanary troop_id is stored in "slot_center_mercenary_troop_type". For center type, pull the troop_id from slot.


No, it doesn't seem to be that way although the constants file says so.

I threw that one in the script but it returns an error message in the game. On the other hand it shows different wages but still I get this message refering to wrong use of parameters in script_wages_stuff.
That's why I posted at the first place.  :razz:
 
Thanks again!

Didn't wanted to sound like a smartass btw.  :neutral:


My script is pretty much the same.

(party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
(call_script, "script_game_get_troop_wage", ":volunteer_troop"),

Just without the check.
I checked it again with different troops and yes, it does its job as it did before. There is still that error though

Script on OPCode 22: Invalid Script Parameter ID:1, Line No:1:
At script game_get_troop_wage

No clue right now about that one. I thought it is because variable is taken from a party_slot and not from a troop_slot. I shall see if I can figure it out.
 
Yay, that did the trick.

Well, now this odysee comes to an end and it is done with 2 lines! The best thing is that I started this procedure with the correct variable and two parameters, well something must have been wrong. But all my efforts from then on started pretty much at the point where I now am.  :shock:

However, you guys were worth the try.

Thanks to everybody!

 
Back
Top Bottom