Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Does anybody know about a way to make a division appear in the list of divisions without manually editing it? In other words what would it need to make the group "Axeman" automatically  appear as group #4 in the party menu?
 
Ritter Dummbatz said:
Does anybody know about a way to make a division appear in the list of divisions without manually editing it? In other words what would it need to make the group "Axeman" automatically  appear as group #4 in the party menu?
But not necessarily have any troops assigned to it?

I think you could just do
(str_store_string, s0, "@Axemen"),
(class_set_name, 3, s0),

Then, when you go to your party window, it won't say "Unnamed 1" after "Cavalry", but "Axemen".
Is that what you're after?

EDIT-Ninja cmpxchg8b.
 
Yeap, that's what I am after. You are the hero of the day for me!



Operation bug? I remember I had problems using this operation a little while ago when I was trying to do accomplish what I am now trying again. This time I started my project by asking before trying.  :razz:
 
class_set_name only works with a string input of an index <128 (I believe this is how cmpxchg8b described it earlier when 1.134 came out). This means any new quick strings "@ " will be out of range for the operation, so it won't work correctly. Similarly only the first 128 "str_ " strings (or the first 128 quick strings declared) would work.

String registers are numbered 0 to something below 128, so storing a quick string into a string register, and then using class_set_name with the string register is the only way to add your own text as a class name.
 
And that is exactly what I did and therefor failed. Now it works fine. Thanks again!

Weird stuff is still going on with the agent_set_division command though. The troops usually switch to another group but not always, which is something I don't know why right now and if they switch their group everything is fine until I manually chose their former group.

Like cavalry dismounted then switched to infantry. But for whatever reasons if I have pressed key #3 they switch back after a few seconds. I temporarily switched off all my scripts that do those switches just to make sure it's not them doing this. In case you or someone else knows what the cause may be for this it would save probably quite some time.

Here is the code I am currently using:
(ti_on_agent_dismount, 5, 0,
[
(store_trigger_param_1, ":agent"),
(agent_is_non_player, ":agent"),
],

        [
(store_trigger_param_1, ":agent"),
(agent_get_troop_id, ":troop", ":agent"),
(try_begin),
(troop_is_guarantee_ranged, ":troop"),
(agent_set_division, ":agent", grc_archers),
(else_try),
(agent_set_division, ":agent", grc_infantry),
(try_end),
        ]),


Right now I have put that right at the end of "lead_charge".
 
Is it possible in Multiplayer to kill a rider of a horse (someone who is invisible, to be exactly) when the Horse dies? And the other way round, kill the horse when the rider dies (it would be no problem to put a script for example on the armour, killing the bot's horse when he dies, but i dont really know how. And the biggest problem for me is killing the rider when his hore dies.)
 
To kill a rider when his horse dies, you will have needed to store the rider's agent ID in an agent slot for the horse as agent_get_rider returns -1 for a dead horse.

See my de-horsed division reassignment code (in the mod sys link in my sig) for ideas on how to do this.
I'd both store the agent ID into a rider agent_slot on spawn AND using ti_on_agent_mount if you are using this in multiplayer, since it is possible the original owner of the horse won't be the one riding it when the horse dies.


@Ritter D...
That code looks good, though I'm unsure why you have a 5 second delay between conditions block and consequence. Doesn't seem necessary in my mind...but perhaps that's just me. I've never seen agent_set_division be so flakey. I've used it to dynamically switch horse archers to their own division and it was persistent throughout a battle. So something must be up.
 
I had trouble with having troops partly assigned to another group. When I increased the delay it worked fine...
The assignment of troops to another groop when the battle initiates works fine...but the dynamic change during battle has flaws in my code at least.

Thanks for checking it out.
 
Good to know, and I was wrong, it doesn't work. To make it work I should never chose the group again for too long. Sometimes it stays how it should be but sometimes not....

But I face really weird problems lately. Like I add a check to prevent the rest of the script from executing. A few days later I remove that check and the script is still not executed although I recompiled, started new game.
Or I created a routine and because it is redundant I exported it to module_scripts. I am sure it is not missing parameters since it uses globals but it didn't work. After all despite redundancy I put the script back to its old places where it passed the tests but now it doesn't work either....  :shock:

Oh, well... back to clean up my mess.


EDIT: Alright, the only weird thing is that I although I know better always try code when I am tired. Everything works fine just the not the dynamic groups changes...for now.
 
I watn to make a scene Prop for Multiplayer that refills your ammo when you use it, and one that repairs your shield (only when it is not completely broken, so only when you still have the shield) How can i do this the best? I know how to put a script on a scene Prop, but not really anything that would help with these scripts.
 
Hello, I have two questions for you

1. It is normal that the operation get_angle_between_positions have return values that vary from -15.000 to +17.000?
(just to tell 2 values that I've seen in my test)
or it is my fault?
can someone tell me the exact range returned by this operation?

this was the code I've tried in a ti_on_agent_hit trigger
Code:
(store_trigger_param_1, ":agent"),
(store_trigger_param_2, ":attacker"),

...

(agent_get_look_position, pos1, ":agent"),
(agent_get_look_position, pos2, ":attacker"),
(get_angle_between_positions, ":alpha", pos1, pos2),

2. How can i get the module of the speed of an agent?
the get_agent_speed seems to return a position and I don't know how to get the module from that  :oops:
 
Status
Not open for further replies.
Back
Top Bottom