Jump to content

Tournament Game Modes - and Mod RPCs


Recommended Posts

  • Developer

Hey everyone,

 

For those of you who watched our twitch stream today (http://www.twitch.tv/kleientertainment), we showed off the Pig Feed Tournament game mode mod. It's available now on the Steam Workshop.

 

http://steamcommunity.com/workshop/filedetails/?id=410100662

 

I'm also releasing the cooperative game mode, the Glutton. Where the object to the game is to eat as much calories as possible as a team. You individually build up a glutton bonus by eating, so to get the most points in the time limit, you'll want to collect resources and feed them into a single player. Team work is important here! Cooking and crock pots will also provide a bonus.

http://steamcommunity.com/workshop/filedetails/?id=410100011

 

 

What this forum is probably more interested in is the usage of the mod RPCs. In both of these game modes, we experimented with a sprinting mechanic. Players can hold shift to sprint.

 

Here's an example of how this works

 

In modmain.lua, add a handler function to receive the call

AddModRPCHandler( "pigfeed", "StartSprint",function(inst)    --inst is the instance of the player who sent the RPC    inst.components.locomotor:SetExternalSpeedMultiplier( inst, "sprinter", 1.5 )    inst.components.hunger.burnrate = 8end )
In a replica component on your player inst (look at sprinter_replicae.lua)

if not sprinting and TheInput:IsKeyDown(KEY_SHIFT) then	SendModRPCToServer( MOD_RPC.pigfeed.StartSprint )	inst:PushEvent("sprinting")	sprinting = trueelseif sprinting and not TheInput:IsKeyDown(KEY_SHIFT) then	SendModRPCToServer( MOD_RPC.pigfeed.StopSprint )	sprinting = falseend
The key point here is see how we describe the RPC id in the first two parameters to AddModRPCHandler ("pigfeed", "StartSprint"), and then it's combined into MOD_RPC.pigfeed.StartSprint for sending.

Please let me know if you have any questions!

Link to comment
Share on other sites

  • Developer
How to send a number from client to server?
 

 

You'll want to look at the RPC code. SendModRPCToServer is the function you'll want to call, and if you include parameters after the rpc code parameter, they'll get sent along too.

In the glutton mod, you can find this code in sprinter_replica.lua (SendModRPCToServer) and in main.lua (AddModRPCHandler).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...