Adding flick functions
There are two parts to each function:
- A declaration of the function in world\global\flick\flick_functions.gas
- The code for the function in world\global\flick\commands\fc_xxx.skrit or world\global\flick\conditions\fc_xxx.skrit according to type.
There could also be a dsdll to implement the lower-level stuff, but I'll restrict this note to things that already have engine support.
In my Siegelet's story I needed a character (Grendeline) to join the party. She had to be implemented as a pet, in order to avoid a lot of work preventing her from using equippable items, and that caused conversation problems. The only way I found to resolve the problem was to add a JoinParty function that I could call from a flick.
In fubi.log I found the basic engine call I needed to make. There was a RSAddMemberNow function for the Party object, which I could locate if I passed in the party owner, which would be a flick role. This would be fairly easy.
Declaration in flick_functions.gas
// **JoinParty** [inRole] // Adds the current role to the party of inRole. // Made specifically for the case of Grendeline. [t:flick_command,n:JoinParty] { server_only = true; is_latent = false; can_wait = false; require_this = true; skrit_addr = world/global/flick/commands/fc_role; init_func = RoleJoinParty$; [args*] { type = role; name = "inRole"; doc = "Party host"; } }
Function code in fc_role.skrit
// **************************************************** // *** Role Join Party // **************************************************** bool RoleJoinParty$( flickcontext ctx$ ) { goid thisGoid$ = ctx$.GetThisRoleGoid(); Goid inTarget$ = ctx$.GetRoleGoid("inRole"); if( !thisGoid$.IsValid() ) { report.errorf("CONTENT ERROR: Role[%s] does not have a valid Goid!\n", ctx$.GetThisRoleName() ); return false; } if( !inTarget$.IsValid ) { report.errorf("Cannot have role[%s] join target[%s] because the target role is invalid.\n", ctx$.GetThisRoleName(), ctx$.GetRoleName("inRole") ); return false; // we are done } inTarget$.Go.Parent.GetParty().RSAddMemberNow( thisGoid$.Go ); return false; // finished }
The function is invoked with one parameter - the role owning the party. In my case there would only be the "hero", but I believe this code will work with an existing party member as "owner".