Results 1 to 12 of 12

Thread: what's the "cqi"?

  1. #1

    Default what's the "cqi"?

    In "wrath of sparta",the game designer wants to spawn some army and free the upkeep cost for persian in special time,but I found that the script for decreasing upkeep cost

    couldn't work in time,it means when the army is too many to feed,the AI will dismiss some of them.It's not expected,I don't know what happened in backstage.Here is my test,I spawned


    some army using sparta,then freed the upkeep cost of my new army.The scripts referred are below:


    function spawn_sparta_army ()
    spawn_army(0, 0,"pel_sparta",unit_list["1"],"1",false);
    spawn_army(0, 0,"pel_sparta",unit_list["1"],"2",false);
    spawn_army(0, 0,"pel_sparta",unit_list["1"],"3",false);
    end


    "spawn_army()" is defaut script which already contains the function freeing the upkeep cost,but it only works for the first spawned army,maybe doesn't work for the rest ones.Here


    is my words to free the cost of the rest:


    function decrease_sparta_upkeep ()
    local faction_list = cm:model():world():faction_list();
    for i = 0, faction_list:num_items() - 1 do
    local current_faction = faction_list:item_at(i);
    if current_faction:name() == "pel_sparta" then
    for j = current_faction:military_force_list():num_items() - 3, current_faction:military_force_list():num_items() - 1 do
    local char = current_faction:military_force_list():item_at(j):general_character():cqi();
    cm:apply_effect_bundle_to_characters_force("pel_persian_army_upkeep",char,-1); --free upkeep cost.
    end
    end
    end
    end


    I fired them every turn in sequence,but the "decrease_sparta_upkeep ()" only worked one turn later,it should work immediately,diden't it?So what's the "cqi" and why it can't play in time?

  2. #2

    Default Re: what's the "cqi"?

    Now I find that if you use nested scripts, the "cqi" will play in time, just like this below:

    function spawn_and_free ()
    cm:create_force("pel_sparta", unit_list["2"],"pel_lakedaimon_sparta", 349 ,238 , "1", true,
    function(cqi)
    cm:apply_effect_bundle_to_characters_force("pel_persian_army_upkeep",cqi,-1);
    cm:create_force("pel_sparta",unit_list["2"],"pel_lakedaimon_sparta", 350 ,238 , "2", true,
    function(cqi)
    cm:apply_effect_bundle_to_characters_force("pel_persian_army_upkeep",cqi,-1);
    end);
    end);
    end

    However, when you nest too many times( maybe 6 or not ), the same problem will take place again. Could anyone give me some advice?

  3. #3
    Inevitability won
    Patrician Citizen

    Join Date
    Mar 2010
    Posts
    9,594

    Default Re: what's the "cqi"?

    Where are you calling your function, where do CA call their function? It could be that you're calling the function at a point in the turn where it's too late to adjust the upkeep, just a guess.

    This has nothing to do with the CQI of a character though, the CQI just is the unique identifier of a character, I don't know exactly what the acronym stands for but I've coined it the "Character uniQue Identifier" which I imagine isn't far wrong.

    As you can see you can get this from any character, with "character():cqi()".

    I'm afraid I just don't understand your question or indeed your problem.

    At any point at which you get the CQI of a character it means the character is of course alive, otherwise you wouldn't be able to get it, so its nothing to do with getting the CQI 'too late'.

  4. #4

    Default Re: what's the "cqi"?

    Quote Originally Posted by .Mitch. View Post
    I'm afraid I just don't understand your question or indeed your problem.
    er...Thanks Mitch, the information you mentioned are very useful. Now I think maybe it was too early(not late) to use CQI when the army was created but the general had not been created yet, so the CQI was useless as you said.


    I call my fuction(just a test) in "pel_start", it will be fired when game is loaded. CA call their fuction in "persian_escalation", it's fired by any one condition of three. We create new troops, then give an effect to the generals of the troops in order to free the upkeep cost, both of us mentioned this words:


    cm:apply_effect_bundle_to_characters_force("pel_persian_army_upkeep",cqi,-1);


    However not all of the generals new created get this effect after executed, then AI will dismiss redundant troops which can't be maintened.


    This problem can be improved(not resolved) by nesting the structure of scripts. I mean if you script one by one, usually only the general of the first troop new created can get the effect, scripts seems to be useless to the rest generals, but if you nest the scripts creating troop B into the scripts creating troop A and so on, almost all of the generals will get the effect. I have showed the scripts above.


    I don't know why, maybe just a bug. I used to doubt CQI, but as you said CQI seems to be a simple ID, so maybe there is a time problem that I use sth when it doesn't exist yet, whatever it is, it's beyond my ability.

  5. #5
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: what's the "cqi"?

    I think that effect bundle needs to apply to the force not the character. Also, you use -1 at the end. isn't that the number of turns the effect applies for so shouldn't it be 1 rather than -1 ?

    edit: or does -1 mean a permanent effect?

    and why you have cm: in front? (i know what this does in lua, i just dont know if you need it for this function)

    I dont have WOS to see original script but got this looking at the effect bundles tables and junction table
    Last edited by Col.KanKrusha; February 03, 2015 at 12:42 AM.
    ~ Too soon old, too late smart ~

  6. #6

    Default Re: what's the "cqi"?

    Quote Originally Posted by Col.KanKrusha View Post
    I think that effect bundle needs to apply to the force not the character. Also, you use -1 at the end. isn't that the number of turns the effect applies for so shouldn't it be 1 rather than -1 ?

    edit: or does -1 mean a permanent effect?

    and why you have cm: in front? (i know what this does in lua, i just dont know if you need it for this function)

    I dont have WOS to see original script but got this looking at the effect bundles tables and junction table
    Thank you KanKrusha, I have tried in your method but nothing seems to happen, the CQI must be general's. Besides, I'm not sure about the "-1", maybe it means the effect will take place immediately.

  7. #7
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: what's the "cqi"?

    It is listed as a hidden effect in the table, maybe you are not meant to see anything happen. Are you testing against your actual income?

    i would guess that because the effect takes place at the end of the turn that when you press end turn your actual treasury will be higher than the predicted was
    ~ Too soon old, too late smart ~

  8. #8

    Default Re: what's the "cqi"?

    If it happened, the effect will work immediately, I can directly check whether the upkeep cost has been changed. It works on troop upkeep cost not the faction treasury.

  9. #9
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: what's the "cqi"?

    If you use pel_persian_army_upkeep i think it will happen when you start a new turn

    edit - ignore this comment. I just remembere your whole script is on faction turn start
    Last edited by Col.KanKrusha; February 04, 2015 at 11:48 AM.
    ~ Too soon old, too late smart ~

  10. #10

    Default Re: what's the "cqi"?

    Quote Originally Posted by Col.KanKrusha View Post
    I just remembere your whole script is on faction turn start
    Not faction turn start, in my test it's on game loading. It doesn't matter now, I do it in another way, so thanks again!

  11. #11

    Default Re: what's the "cqi"?

    Quote Originally Posted by ajaccio131 View Post
    Not faction turn start, in my test it's on game loading. It doesn't matter now, I do it in another way, so thanks again!
    Glad to hear you got it working! Any change you could fill me in on the difference between "cm:" vs say, "context"? When during scripting can you use cm:? Thanks!
    "What? Men dodging this way for single bullets? What will you do when they open fire along the whole line? I am ashamed of you. They couldn't hit an elephant at this distance. " - John Sedgewick, Union General, his last words before being killed by a sniper.

  12. #12

    Default Re: what's the "cqi"?

    Quote Originally Posted by .Mitch. View Post
    I don't know exactly what the acronym stands for but I've coined it the "Character uniQue Identifier" which I imagine isn't far wrong.
    The Attila kit calls it the command_queue_index.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •