Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
Re: B27 Bug Reports
Specific example?
Mon Jul 02, 2012 10:06 pm
Miggles
Data Realms Elite
Joined: Mon Jul 12, 2010 5:39 am Posts: 4558
Re: B27 Bug Reports
I don't think this is a bug, but if it's a feature it's the most annoying feature in this entire game. Pressing ESC once in the main menu goes to an exit screen. Pushing it twice exits the game. Now I don't know about you, but this isn't how it works in any other game ever. What SHOULD happen is when you press ESC twice, it exits the exit screen. Not the game. This really annoys me because sometimes I accidentally press ESC and try to exit the menu with ESC, but it quits the game. That doesn't make any sense, and it's really aggravating.
Mon Jul 02, 2012 10:35 pm
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
Re: B27 Bug Reports
Quote:
Specific example?
This fails:
Code:
require("Actors/AI/HumanAI")
function Update(self) --Just here to see notifications of this running. --print("running the movement script!")
--Create the necessary variables. if self.timer == nil then self.timer = Timer(); end
--Start our loop, every 10-30ms. Randomly spaced for (slightly) better load distribution. local randomTimer = math.random(10,30); if self.timer:IsPastSimMS(randomTimer) then local p = Vector();
--Core of the Movement script starts here. --Important bit here- adjust the altitude value until it's stable and not too floaty. --This specific altitude should be slightly lower than the AHuman's hip center to the ground. local altCheck = 19 local heightCheck = 30 local sideCheck = 10 local upPush = 0.35 local downPush = 0.7 local downCheck = false local upCheck = false
--Air / Ground movement speeds and the limit where Actors can use faster air speeds. local airLimit = 150 local air_speed_max = 12.0 local air_accel = 1.25 local speed_max = 8.0 local accel = 1.0
--Jumping variables. local jump_speed_max = 16.0 local jump_accel = 8.0
--Safety code, because we get -1 if no obstacles if centerAlt < 0 then centerAlt = 1000 end if frontAlt < 0 then frontAlt = 1000 end if backAlt < 0 then backAlt = 1000 end
--Now that we know the heights to obstacles, it's time to perform some logic. --May need to alter the velPushfor best performance depending on mass. --Please note that this allows for ducking and prone and even movement while body is lowered; let go of the control... --...and the character "stands" back up again. if (centerAlt < altCheck or frontAlt < altCheck or backAlt < altCheck) and not self:GetController():IsState(Controller.MOVE_DOWN) then downCheck = true elseif self:GetController():IsState(Controller.MOVE_DOWN) then self.Vel.Y = self.Vel.Y + 0.1 end
--Do a raytest vs. hitting top of the Actor on things. If buried, push down, hard. local ray = SceneMan:CastObstacleRay(self.Pos, Vector(4,-heightCheck), p, p, self.ID, 0, 0, 0); if ray < heightCheck and ray ~= -1 then upCheck = true end ray = SceneMan:CastObstacleRay(self.Pos, Vector(-4,-heightCheck), p, p, self.ID, 0, 0, 0); if ray < heightCheck and ray ~= -1 then upCheck = true end
--If we're supposed to push DOWN or UP, do one or the other, but if both conditions... --...are true or false, do NOTHING. Prevents odd behaviors underground if downCheck == true and upCheck == false then self.Vel.Y = self.Vel.Y - upPush end if downCheck == false and upCheck == true then self.Vel.Y = self.Vel.Y + downPush end
--Jump Script; alters Y velocity when jumping. if self:GetController():IsState(Controller.MOVE_UP) or self:GetController():IsState(Controller.BODY_JUMPSTART) or self:GetController():IsState(Controller.BODY_JUMP) then if upCheck == false and self.JetTimeLeft > TimerMan.DeltaTimeMS * 3 then self.Vel.Y = math.max(self.Vel.Y - jump_accel,-jump_speed_max) end end
--Do raytests to the right and left to make sure we're not running through walls. --This isn't exactly super-reliable, but it's better'n nothin'. local rightLeft = 0 ray = SceneMan:CastObstacleRay(self.Pos, Vector(sideCheck,0), p, p, self.ID, 0, 0, 0); if ray < sideCheck and ray ~= -1 then rightLeft = rightLeft -1 end ray = SceneMan:CastObstacleRay(self.Pos, Vector(-sideCheck,0), p, p, self.ID, 0, 0, 0); if ray < sideCheck and ray ~= -1 then rightLeft = rightLeft + 1 end --If we want to push right OR left, but NOT push right AND left, then push right or left. --Sorry for the logic joke. if rightLeft == -1 then self.Vel.X = self.Vel.X - 1.0 end if rightLeft == 1 then self.Vel.X = self.Vel.X + 1.0 end
--Brute-force change in velocity over time. --If accel is set really high, bad things will happen ;-) --Now allows for faster movement / accel if in the air. local airAlt = SceneMan:CastObstacleRay(self.Pos, Vector(0,airLimit), p, p, self.ID, 0, 0, 0); if airAlt == nil then airAlt = -1 end if self:GetController():IsState(Controller.MOVE_LEFT) and rightLeft == 0 then if airAlt == -1 then self.Vel.X = math.max(self.Vel.X - air_accel,-air_speed_max) else self.Vel.X = math.max(self.Vel.X - accel,-speed_max) end end if self:GetController():IsState(Controller.MOVE_RIGHT) and rightLeft == 0 then if airAlt == -1 then self.Vel.X = math.min(self.Vel.X + air_accel,air_speed_max) else self.Vel.X = math.min(self.Vel.X + accel,speed_max) end end
if self.Controller == nil then self.Controller = self:GetController() end --Regulate how fast we travel downwards. if self.Vel.Y > 8.0 then self.Controller:SetState(Controller.BODY_JUMP, true) self.Vel.Y = self.Vel.Y - 0.5 end
--Brute-force adjustments of RotAngles, to prevent funky behaviors. if self.RotAngle > 0.2 then self.RotAngle = 0.2 end if self.RotAngle < - 0.2 then self.RotAngle = - 0.2 end
--Brute-force removal of "falling through the earth"; troops hit "bedrock". if self.Pos.Y > SceneMan.SceneHeight - 40 then self.Pos.Y = SceneMan.SceneHeight - 42 self.Vel.Y = -1.0 end
--Reset our 10ms timer self.timer:Reset(); --End our loop end --End the Update() cycle end
If I put HumanAI's code and all of the dependencies it requires in the same script body, it functions correctly. Took multiple tests to figure out what was wrong; weird bug. It's making maintenance... difficult, to put it mildly.
Instead of using that require you can double define scriptpath, or use dofile instead. Both should work.
Mon Jul 02, 2012 10:49 pm
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
Re: B27 Bug Reports
I didn't know ScriptPath could be defined multiple times... hmm...
I'll test that; I would really rather keep the control code separated from the AI code if at all possible, it's going to make maintenance really yucky otherwise.
Mon Jul 02, 2012 11:16 pm
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
Re: B27 Bug Reports
Defining ScriptPath twice fails; the second script is loaded, but not the first.
Oh ok, my mistake. I had seen scriptpath defined twice previously and assumed it had worked just fine.
Mon Jul 02, 2012 11:47 pm
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
Re: B27 Bug Reports
It's cool, that was actually super-helpful to try it out.
I'm pretty desperate to not have to maintain thousands of lines of code that should be standardized
Even better yet, dofile works:
Code:
dofile("Base.rte/Actors/AI/HumanAI.lua")
Functions as you'd expect require would, including the code then loading the required sections from within Base.rte. Yay, that's one major hassle solved, thanks a lot
Mon Jul 02, 2012 11:54 pm
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
Re: B27 Bug Reports
Interesting. dofile works, but only so long as the path is in Base.rte.
If you do this:
Code:
dofile("Dummy.rte/Crafts/Rocklet.lua")
It doesn't work. Oh well, it was just that one file anyhow, and if I write any core AI stuff, it can go into Base.rte.
Tue Jul 03, 2012 2:26 am
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
Re: B27 Bug Reports
PresetMan:ReloadAllScripts()
Doesn't appear to be re-loading anything in base. I kept wondering why my changes weren't applying, lol. Then I reloaded, and sure enough, I, erm, screwed it up by pushing too many variables around. Thank goodness for backups, lol.
Kind of makes it hard to tune the AI, heh. Any fix for that?
I've gotten weird PresetMan:ReloadAllScripts() stuff (as in it just didn't do anything) too though mine was with scripts on an attachable (on an actor). You can probably solve this with MovableObject:ReloadScripts(), just stick it in the relevant script and trigger it with a keypress or something. Note that despite what the description says it doesn't seem to update the presetman so that all future objects have the newly reloaded script so you'll have to do it again when you get a new actor/object.
Tue Jul 03, 2012 6:57 am
xenoargh
Joined: Fri Dec 30, 2011 3:33 am Posts: 276
Re: B27 Bug Reports
Yeah, I was, er, just a little shocked when I realized how badly I'd hosed things, lol.
Also, while I'm talking about things not loading, could we please, please, please have a way to reload the properties (and script) of Items that an Actor is holding in the Actor Viewer? It really is a huge time-waster to have to restart CC every time I want to change an offset...
Tue Jul 03, 2012 7:54 am
Azukki
Joined: Sat Nov 03, 2007 9:44 pm Posts: 1916 Location: Flint Hills
Re: B27 Bug Reports
I imagine this isn't a new issue to B27, but an attachable attached to an HDFirearm doesn't make it any heavier.
An actor can walk around carrying millions of kg, if it's in the form of an attachable on his gun.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum