Jump to content

Client's wilson sg


Recommended Posts

Hey everyone! I'm trying to add my own sg state to Wilson. It works nicely on non-dedicated servers but on dedicated servers something wrong becames with client side :/. So what am I trying to ask... How properly should I add state on client side? I've tried to add to client same state as on server, but it fixed nothing, only added problems. Any help?

Edited by makar5000
  • Like 1
Link to comment
Share on other sites

My code:


shadow_hands = State {
			name = "shadow_hands_teleport",
			tags = {"busy"},

			onenter = function(inst)
				inst.AnimState:PlayAnimation("teleport")

				-- player won't cancel it
				if inst.components.locomotor ~= nil then
					inst.components.locomotor:StopMoving()
				end
				
				if inst.components.playercontroller ~= nil then
					inst.components.playercontroller:RemotePausePrediction()
				end
				
				if inst.components.health then
					inst.components.health:SetInvincible(true)
				end
				
				inst:ShowHUD(false)
				inst:SetCameraDistance(12)
			end,
			
			timeline = {
					TimeEvent(0, function(inst)
						inst.SoundEmitter:PlaySound("dontstarve/common/teleportato/teleportato_pulled")
					end),
					TimeEvent(82 * FRAMES, function(inst)
						inst.SoundEmitter:PlaySound("dontstarve/common/teleportato/teleportato_under")
					end),
				},

			events = {
				EventHandler("animqueueover", function(inst)
					if inst.components.health then
						inst.components.health:SetInvincible(false)
					end
					inst:SnapCamera()
					inst:ScreenFade(true, 4)
					inst:Hide()
					inst.DynamicShadow:Enable(false)
					
					inst:DoTaskInTime(2.15,function()
						a,a1,a2 = inst.Transform:GetWorldPosition()
						local fx = SpawnPrefab("spawn_fx_small_high")
						fx.Transform:SetScale(2,2,2)
						fx.Transform:SetPosition(a,-4,a2)
						
						inst.sg:GoToState("wakeup")
						inst:Show()
						inst:ShowHUD(true)
						inst.DynamicShadow:Enable(true)
						inst:DoTaskInTime(.5,function() inst:SetCameraDistance() end)
					end)
				end),
			},
		}
AddStategraphState("wilson", shadow_hands)
AddStategraphState("wilson_client", shadow_hands)

 

Edited by makar5000
  • Like 1
Link to comment
Share on other sites

You cannot just add the same state to both server and client SG as some stuffs that you are trying to access on the server DG are not accessible on the client side (components.health for instance).

So you have to rethink your state so it display the animation but doesn't perform the task which are the server's job.

Link to comment
Share on other sites

6 hours ago, ZupaleX said:

You cannot just add the same state to both server and client SG as some stuffs that you are trying to access on the server DG are not accessible on the client side (components.health for instance).

So you have to rethink your state so it display the animation but doesn't perform the task which are the server's job.

Yeah, I came up with idea: I'l just coppy the same SG, and'll change some animations.

  • Like 1
Link to comment
Share on other sites

7 hours ago, ZupaleX said:

You cannot just add the same state to both server and client SG as some stuffs that you are trying to access on the server DG are not accessible on the client side (components.health for instance).

So you have to rethink your state so it display the animation but doesn't perform the task which are the server's job.

Oh, and I wanted to ask something. In SGwilson_client I found two new options: Ontimeout and onupdate. When do they trigger, and what they are suppose to do?

Edited by makar5000
  • Like 1
Link to comment
Share on other sites

The game update the status of the entities periodically. The onupdate suggest that it is called when this update occurs.

Some state can time out. Like if you are waiting for something to happen before executing a piece of code, but that something never happens. To prevent the code to hang there, you put a timeout.

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...