FOnline Development > Questions and Answers

FOnline SDK - Question

<< < (93/93)

Vice Dice:
If I'm not mistaken, void Action is a server side function that has to do something else than you're trying to. If you follow the documentation, this function calls client local binded "critter_action" func with send arguments. I think that if you are working with client side, you might consider using SetChosenActions function instead, it's pretty simple and effective when it comes to scripting player character behaviour.

Like, i.e if you want a player critter to move armor item from armor slot to inventory you might doing it like this:
                   
   
--- Code: ---uint[] actions = {CHOSEN_MOVE_ITEM, item.Id, 1, SLOT_INV, 0,0};
SetChosenActions(actions);
--- End code ---

Try searching through your scripts for CHOSEN_MOVE_ITEM to find all list of possible types of actions and their arguments.

P.S As I get the logic chain, both Critter.Action on server side and SetChosenAction on client side ends up in some code on client side. Critter.Action might possible be used when you want a server to ask a client to do something that server can't. Also for Critter.Action aswell as SetChosenActions you might probably to create your own logic in critter_action that will process recieved arguments as you wish.

P.P.S Looking at my own critter_action, it seems like it helps to perform some "additional" stuff on top of hardcoded thingies that happen when you use those methods.

Zinthos:

--- Quote from: Vice Dice on March 18, 2018, 05:37:20 pm ---If I'm not mistaken, void Action is a server side function that has to do something else than you're trying to. If you follow the documentation, this function calls client local binded "critter_action" func with send arguments. I think that if you are working with client side, you might consider using SetChosenActions function instead, it's pretty simple and effective when it comes to scripting player character behaviour.

Like, i.e if you want a player critter to move armor item from armor slot to inventory you might doing it like this:
                   
   
--- Code: ---uint[] actions = {CHOSEN_MOVE_ITEM, item.Id, 1, SLOT_INV, 0,0};
SetChosenActions(actions);
--- End code ---

Try searching through your scripts for CHOSEN_MOVE_ITEM to find all list of possible types of actions and their arguments.

P.S As I get the logic chain, both Critter.Action on server side and SetChosenAction on client side ends up in some code on client side. Critter.Action might possible be used when you want a server to ask a client to do something that server can't. Also for Critter.Action aswell as SetChosenActions you might probably to create your own logic in critter_action that will process recieved arguments as you wish.

P.P.S Looking at my own critter_action, it seems like it helps to perform some "additional" stuff on top of hardcoded thingies that happen when you use those methods.

--- End quote ---

thanks, managed to make it work that way.

here it is, if anyone is interested


--- Code: (client_interface.fos, include chosen_actions_h.fos) ---if(GUI_GetActiveScreen() == CLIENT_SCREEN_INVENTORY && GUI_IsKeyPressed(0x1D)) // CTRL click equip/consume/use
{
if(item.GetProtoId()==PID_ADVANCED_BENCH || item.GetProtoId()==PID_WORKBENCH_RAIDERS || item.GetProtoId()==PID_AMMO_FACILITY || item.GetProtoId()==PID_WORKBENCH || item.GetProtoId()==PID_MED_MACHINE ||  item.GetProtoId()==PID_WORKBENCH_PRIMITIVE || item.GetType()==ITEM_TYPE_CONTAINER)
return "";

if(item.CritId > 0 && valid(item) && item.CritId == chosen.Id)
{
if((item.GetType() == ITEM_TYPE_ARMOR) && ((item.GetProtoId() >= 719) && (item.GetProtoId() <= 749)) ) // check for helmet, 723 and 724 *should* probably be excluded
{
Item@ slotItem = chosen.GetItem(0, SLOT_HEAD);
if(valid(slotItem) && (item.Id == slotItem.Id) )    // check if the clicked item is in one of the inventory slots
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_INV, 0, 0, 0};    // if yes, put it back to the inventory
SetChosenActions(action);
}
else
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_HEAD, 0, 0, 0};    // if not, put it in an active slot
SetChosenActions(action);
}

}
else if(item.GetType() == ITEM_TYPE_ARMOR)
{
Item@ slotItem = chosen.GetItem(0, SLOT_ARMOR);
if(valid(slotItem) && (item.Id == slotItem.Id) )
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_INV, 0, 0, 0};
SetChosenActions(action);
}
else
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_ARMOR, 0, 0, 0};
SetChosenActions(action);
}

}
if(item.GetType() == ITEM_TYPE_WEAPON)
{
Item@ slotItem = chosen.GetItem(0, SLOT_HAND1);
if(valid(slotItem) && (item.Id == slotItem.Id) )
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_INV, 0, 0, 0};
SetChosenActions(action);
}
else
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_HAND1, 0, 0, 0};
SetChosenActions(action);
}

}
if(item.GetType() == ITEM_TYPE_MISC || item.GetType() == ITEM_TYPE_AMMO || item.GetType() == ITEM_TYPE_KEY)
{
Item@ slotItem = chosen.GetItem(0, SLOT_HAND2);
if(valid(slotItem) && (item.Id == slotItem.Id) )
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_INV, 0, 0, 0};
SetChosenActions(action);
}
else
{
array<uint> action = {CHOSEN_MOVE_ITEM, item.Id, item.GetCount(), SLOT_HAND2, 0, 0, 0};
SetChosenActions(action);
}

}
if(item.GetType() == ITEM_TYPE_DRUG)
{
array<uint> action = {CHOSEN_USE_ITEM, item.Id, item.GetProtoId(), TARGET_SELF, chosen.Id, ITEM_MODE_USE, 0};    // Use drugs via ctrl+click
SetChosenActions(action);

}
}
}


--- End code ---



i'm curious whether similiar implementation can be applied to Barter dialog or not

Zinthos:
Is it possible to animate a critter in a range of frames?

For example, i choose an animation set, like USE and i specify that only the frames 3,4,5 will play

Voiddweller:

--- Quote from: Wipe on September 04, 2013, 12:08:01 pm ---You can collect all town Locations inside start() function and set turn based mode for every Map inside. Assuming that every town exists only in one copy:

--- Code: ---array<uint> tbTowns = { LOCATION_Den, LOCATION_Klamath, LOCATION_Whatever };
for( uint t=0, tLen=tbTowns.length(); t<tLen; t++ )
{
    Location@ location = GetLocationByPid( tbTowns[t], 0 );
    if( valid(location) )
    {
        for( uint m=0, mLen=location.GetMapCount(); m<mLen; m++ )
        {
            Map@ map = location.GetMapByIndex(m);
            if( valid(map) )
            {
                map.SetTurnBasedAvailability( true );
            }
        }
    }
}
--- End code ---

--- End quote ---

While this works unexpectingly (works on all maps for me, regardless of added to the list or not) the AI somewhat lacking when it can't reach you, so you have to wait until it's panic ends with a timeout.
Anyone tried to optimize AI for a turn based mode?

Navigation

[0] Message Index

[*] Previous page

Go to full version