Author Topic: SetChosenActions questions  (Read 2202 times)

SetChosenActions questions
« on: March 21, 2014, 08:24:14 pm »
Once again, no examples in SDK and my divination not working.   :)
1. CHOSEN_MOVE_ITEM_CONT
How to use it (or what action should I use instead) to move items in and from of container. Course I have item.Id and CLIENT_SCREEN_PICKUP hardcoded interface is opened.
Now I have smth like
uint[] uses =  { CHOSEN_MOVE_ITEM_CONT,2026,item.Id, count, 0, 0, 0 }; //2026 - got this container's id from server, still not working
2. How to properly unload weapon using action?

Offline Mayck

  • Rotator
  • ...shhhh...
Re: SetChosenActions questions
« Reply #1 on: March 21, 2014, 11:25:36 pm »
uint[] Reload = { CHOSEN_USE_ITEM, item.Id, 0, TARGET_SELF_ITEM, -1, ITEM_MODE_RELOAD, 0 };
the -1 causes the weapon to unload (0 instead of -1 loads with current ammo)...
(if you want to load weapon with specific ammunition, you can use id of ammo item instead of the -1)

uint[] uses =  { CHOSEN_MOVE_ITEM_CONT, <id of placed or taken item... NOT the container's>, <300 if placing into container/ 301 if taking>, count, 0, 0, 0 };
no idea why are 300 and 301 there... you have to first use the container via the CHOSEN_PICK_ITEM for this to work

I would recomend placing following code into "void critter_action" callback function (in 2238 source this function is in client_mapper_animation.fos)
Code: [Select]
if(cr.IsChosen())
{
        array<uint> actions;
        uint cnt = GetChosenActions(actions);
        if(cnt != 0)
        {
Message(actions[0]+" "+actions[1]+" "+actions[2]+" "+actions[3]+" "+actions[4]+" "+actions[5]+" "+actions[6]);
        }
}
This should give you 7 numbers defining the chosen action everytime(?) your char does some action - they don't tell you much if you have no idea what you are doing, but with help of the comments near the CHOSEN_ACTION #defines it can be deciphered (4billions large number usually means -1 because of the unsigned conversion)

Re: SetChosenActions questions
« Reply #2 on: March 22, 2014, 07:44:56 am »
Thanks, yeah, works great.
I tried to do some callbak, but I was just trying to create queue of actions and then press button to log 'em. It didn't worked properly, somehow GetChosenActions shows only the last one.
Code: [Select]
uint[] actions;
Message("length "+GetChosenActions (actions));
 for( uint i = 0, j = (actions.length()/7); i < j; i++ )
 {
 Message("a "+actions[7*i]);
 Message("c "+actions[7*i+1]);
 Message("i "+actions[7*i+2]);
 Message("co "+actions[7*i+3]);
 }

Offline Wipe

  • Rotator
  • Random is god
Re: SetChosenActions questions
« Reply #3 on: March 22, 2014, 01:22:06 pm »
GetChosenActions shows only the last one.
Sure about that? SetChosenActions() does exactly what its name says - overrides current queue with whatever you pass as arguments. Could it be that you're checking list after overriding it?

Have one unfinished queue thingy, and i'm 100% sure that adding action as last (and 95% sure for adding as first (it was long ago :P)) worked as it should.

Code: [Select]
ChosenAction ChosenActions();
// ... //
array<ItemCl@> items;
uint count = chosen.GetItemsByType( type, items );
for( uint i=0; i<count; i++ )
{
    if( !valid(items[i]) )
continue;

    if( items[i].CritSlot != SLOT_INV )
@items[i] = null;
}

ChosenActions.UseSkill( 212, items, CHOSEN_ACTION_LAST );
Games are meant to be created, not played...

Re: SetChosenActions questions
« Reply #4 on: March 22, 2014, 07:20:18 pm »
Quote
Sure about that?
Well, you right, I was overriding my action list, when I saw "last" action (added by script), but when I was running this script without adding any actions, just when my char in game was busy by dropping items on ground (queue), I got nothing at all.