gregdwilson Posted May 11, 2015 Share Posted May 11, 2015 I've been making a breathe fire action for my character and had it working wonderfully when the player is the server, but when I try and run this as a client both the client and the server crash. The biggest problem is that there are no errors in the log. I tried placing print("Checkpoint1") throughout the code and it seems to be running all of the code before crashing. I've also tried getting ride of portions. It I get rid of the on hit function then it doesn't crash on the server but it crashes on the client and then gives the error Assert failure 'false && "cNetworkConnection::AllocReplica Invalid Prefab"' at ..\source\networklib\NetworkConnection.cpp(121): Trace follows... but nothing follows. Any help or direction would be appreciated. Here is the code for the action. I have no problem running it on the client and if I change the entire function to just make the character say something it works so I know its something to do with the projectiles.local BREATHEFIRE = AddAction("BREATHEFIRE", "Breathe Fire", function(act) local target = act.target local attacker = act.doerif not attacker:HasTag("oncooldown") then local hunger_percent = act.doer.components.hunger:GetPercent() local facing_angle = attacker.Transform:GetRotation() * GLOBAL.DEGREES local targetPos = GLOBAL.Vector3(target.Transform:GetWorldPosition()) local attackerPos = GLOBAL.Vector3(attacker.Transform:GetWorldPosition()) + GLOBAL.Vector3(target.Transform:GetWorldPosition()) + GLOBAL.Vector3(0, 3*hunger_percent, 0 ) local x, y, z = attacker.Transform:GetWorldPosition() math.randomseed( x*hunger_percent*100 ) local dx = targetPos.x - x local dz = targetPos.z - z local rangesq = dx * dx + dz * dz local maxrange = 20 local speed = easing.linear(rangesq, 15, 4, maxrange * maxrange) attacker.SoundEmitter:PlaySound("dontstarve/wilson/fireball_explo") for i = 1, 50, 1 do local projectile = GLOBAL.CreateEntity() projectile.entity:AddTransform() projectile.entity:AddAnimState() projectile.entity:AddNetwork() projectile.entity:AddPhysics() projectile.entity:AddLight() projectile.Light:Enable(true) projectile.Light:SetRadius(2.5) projectile.Light:SetColour(200/255, 50/255, 50/255) projectile.Light:SetFalloff(.5) projectile.Light:SetIntensity(0.75) projectile.AnimState:SetBank("projectile") projectile.AnimState:SetBuild("staff_projectile") projectile.AnimState:PlayAnimation("fire_spin_loop", true) if bloom ~= nil then projectile.AnimState:SetBloomEffectHandle("shaders/anim.ksh") end projectile.entity:SetPristine() projectile:AddComponent("complexprojectile") projectile:AddComponent("weapon") projectile:AddComponent("locomotor") projectile.entity:SetPristine() projectile.persists = false projectile.components.complexprojectile:SetHorizontalSpeed(speed*hunger_percent) projectile.components.complexprojectile:SetGravity(-10) projectile.components.complexprojectile:SetLaunchOffset({ x = 0 * math.cos(facing_angle), y = 3*hunger_percent, z = 0 * math.sin(facing_angle) }) projectile.components.complexprojectile:SetTargetOffset({ x = 0, y =0, z = 0 }) projectile.components.complexprojectile.usehigharc = false projectile.components.complexprojectile.attacker = attacker projectile.Transform:SetPosition(attacker.Transform:GetWorldPosition()) projectile:AddComponent("groundpounder") projectile.components.groundpounder.numRings = 2 projectile.components.groundpounder.burner = true projectile.components.groundpounder.groundpoundfx = "firesplash_fx" projectile.components.groundpounder.groundpounddamagemult = 2 projectile.components.groundpounder.groundpoundringfx = "firesplash_fx" -- "firering_fx" projectile.Transform:SetScale(2*hunger_percent,2*hunger_percent,2*hunger_percent) projectile.components.complexprojectile:SetOnHit(function(projectile, attacter) local x, y, z = projectile.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, 3) -- or we could include a flag to the search? for i, target in ipairs(ents) do if target ~= attacter and target.entity:IsVisible() then if target then if target.components.burnable and not target.components.burnable:IsBurning() then if target.components.freezable and target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() else if target.components.fueled and target:HasTag("campfire") and target:HasTag("structure") then -- Rather than worrying about adding fuel cmp here, just spawn some fuel and immediately feed it to the fire local fuel = SpawnPrefab("cutgrass") if fuel then target.components.fueled:TakeFuelItem(fuel) end else target.components.burnable:Ignite(true) end end end if target.components.freezable then target.components.freezable:AddColdness(-1) --Does this break ice staff? if target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() end end if target.components.sleeper and target.components.sleeper:IsAsleep() then target.components.sleeper:WakeUp() end if target.components.combat then target.components.combat:SuggestTarget(attacker) end target:PushEvent("attacked", {attacker = attacker, damage = 0}) end end end projectile.components.groundpounder:GroundPound() projectile:Remove() end) projectile.components.complexprojectile:SetOnLaunch(function() projectile:AddTag("NOCLICK") projectile.persists = false projectile.AnimState:PlayAnimation("fire_spin_loop", true) projectile.Physics:SetMass(1) projectile.Physics:SetCapsule(0.01, 0.01) projectile.Physics:SetFriction(0) projectile.Physics:SetDamping(0) projectile.Physics:SetCollisionGroup(GLOBAL.COLLISION.CHARACTERS) projectile.Physics:ClearCollisionMask() projectile.Physics:CollidesWith(GLOBAL.COLLISION.WORLD) projectile.Physics:CollidesWith(GLOBAL.COLLISION.OBSTACLES) projectile.Physics:CollidesWith(GLOBAL.COLLISION.ITEMS) projectile.Physics:CollidesWith(GLOBAL.COLLISION.CHARACTERS) projectile.Physics:CollidesWith(GLOBAL.COLLISION.SMALLOBSTACLES) projectile.Physics:CollidesWith(GLOBAL.COLLISION.GIANTS) projectile.Physics:CollidesWith(GLOBAL.COLLISION.GROUND) end) projectile.components.complexprojectile:Launch(targetPos, attacker) local pos = projectile.components.complexprojectile.inst:GetPosition() projectile.components.complexprojectile.owningweapon = owningweapon or projectile.components.complexprojectile pos.x = pos.x + 4 * math.cos(facing_angle)*hunger_percent pos.y = pos.y + 1.5*hunger_percent pos.z = pos.z - 4 * math.sin(facing_angle)*hunger_percent projectile.Transform:SetPosition(pos:Get()) targetPos.x = targetPos.x - 1 + 2*math.random() targetPos.y = targetPos.y - 1 + 2*math.random() targetPos.z = targetPos.z - 1 + 2*math.random() projectile.components.complexprojectile:CalculateTrajectory(pos, targetPos, projectile.components.complexprojectile.horizontalSpeed) if projectile.components.complexprojectile.onlaunchfn ~= nil then projectile.components.complexprojectile.onlaunchfn(projectile.components.complexprojectile.inst) end projectile.components.complexprojectile.inst:StartUpdatingComponent(projectile.components.complexprojectile) end attacker:AddTag("oncooldown") attacker:PushEvent("dragoncast")end return true end)Sorry if the code is messy, I'm still developing it so I haven't commented it and such. Any help would be appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/53835-need-help-unknown-crash-on-server-and-client/ Share on other sites More sharing options...
DarkXero Posted May 12, 2015 Share Posted May 12, 2015 You are creating an undefined new entity on the go, in an action.The game has no clue how to allocate resources for the replica generated. You need to set up a projectile prefab and then modify everything you want. I attach an example.files.zip Link to comment https://forums.kleientertainment.com/forums/topic/53835-need-help-unknown-crash-on-server-and-client/#findComment-636738 Share on other sites More sharing options...
Sarcen Posted May 12, 2015 Share Posted May 12, 2015 (edited) Looks like you are just creating an entity right there and then, one without a name. It can't network that. You should create a projectile prefab for that. Also anything that comes after the first "projectile.entity:SetPristine()" should probably only be run on the server side (TheWorld.ismastersim) *edit* @DarkXero, you beat me to it Edited May 12, 2015 by Sarcen Link to comment https://forums.kleientertainment.com/forums/topic/53835-need-help-unknown-crash-on-server-and-client/#findComment-636739 Share on other sites More sharing options...
gregdwilson Posted May 12, 2015 Author Share Posted May 12, 2015 Thank You!!!! That makes sense why the client was giving that error now. I think I might be starting to understand this host client thing now. You can check out the finished mod "Shadow Dragons" on the steam workshop. I'll make sure to mention both of you in the mod. You helped immensely. Thanks again. Link to comment https://forums.kleientertainment.com/forums/topic/53835-need-help-unknown-crash-on-server-and-client/#findComment-636818 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now