Skip to content

Commit aeb9038

Browse files
committed
Revert "ladder"
This reverts commit b262256.
1 parent b262256 commit aeb9038

8 files changed

Lines changed: 32 additions & 118 deletions

File tree

game/game/movealgo.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,10 @@ void MoveAlgo::tickMobsi(uint64_t dt) {
4444
return;
4545

4646
auto dp = animMoveSpeed(dt);
47-
auto pos = npc.position();
48-
if(npc.interactive()->isLadder()) {
49-
auto rotY=-npc.rotationY();
50-
if (std::abs(rotY)>0.001 && std::abs(dp.y)>0.001) {
51-
if (dp.y<0.001)
52-
rotY*=-2;
53-
float rot = npc.rotationRad();
54-
float s = std::sin(rot)*rotY, c = std::cos(rot)*rotY;
55-
dp+=Tempest::Vec3(s,0,-c);
56-
}
57-
}
58-
else
47+
if(!npc.interactive()->isLadder())
5948
dp.y = 0;
6049

50+
auto pos = npc.position();
6151
pos += dp;
6252
npc.setPosition(pos);
6353
setAsSlide(false);

game/game/playercontrol.cpp

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,6 @@ void PlayerControl::onKeyReleased(KeyCodec::Action a) {
176176
} else {
177177
std::memset(actrl,0,sizeof(actrl));
178178
}
179-
180-
if(pl!=nullptr && pl->interactive()!=nullptr) {
181-
auto inter = pl->interactive();
182-
if (inter->isLadder()) {
183-
bool g1c=Gothic::inst().settingsGetI("GAME","USEGOTHIC1CONTROLS")!=0 ;
184-
if (a==KeyCodec::ActionGeneric && !g1c) {
185-
inter->nextState(*pl,4);
186-
return;
187-
}
188-
if ((a==KeyCodec::Forward || a==KeyCodec::Back) && (g1c || (!g1c && isPressed(KeyCodec::ActionGeneric))))
189-
inter->nextState(*pl,0);
190-
}
191-
}
192179
}
193180

194181
bool PlayerControl::isPressed(KeyCodec::Action a) const {
@@ -209,13 +196,12 @@ void PlayerControl::tickFocus() {
209196
currentFocus = findFocus(&currentFocus);
210197
setTarget(currentFocus.npc);
211198

212-
if(!ctrl[Action::ActionGeneric] || Gothic::inst().world()->player()->interactive()!=nullptr)
199+
if(!ctrl[Action::ActionGeneric])
213200
return;
214201

215202
auto focus = currentFocus;
216203
if(focus.interactive!=nullptr && interact(*focus.interactive)) {
217-
if (!focus.interactive->isLadder())
218-
clearInput();
204+
clearInput();
219205
}
220206
else if(focus.npc!=nullptr && interact(*focus.npc)) {
221207
clearInput();
@@ -812,10 +798,9 @@ void PlayerControl::implMoveMobsi(Npc& pl, uint64_t /*dt*/) {
812798
}
813799

814800
if(inter->isStaticState() && !inter->isDetachState(pl)) {
815-
auto stateId=inter->stateId();
816-
bool ladder=inter->isLadder() && stateId==inter->stateCount();
817-
if(inter->canQuitAtState(pl,stateId-ladder))
818-
pl.setInteraction(nullptr,ladder);
801+
if(inter->canQuitAtState(pl,inter->stateId())) {
802+
pl.setInteraction(nullptr,false);
803+
}
819804
}
820805
}
821806

@@ -870,31 +855,13 @@ void PlayerControl::processPickLock(Npc& pl, Interactive& inter, KeyCodec::Actio
870855
}
871856

872857
void PlayerControl::processLadder(Npc& pl, Interactive& inter, KeyCodec::Action key) {
873-
bool g1c=Gothic::inst().settingsGetI("GAME","USEGOTHIC1CONTROLS")!=0 ;
874-
875-
if(key==KeyCodec::ActionGeneric) {
876-
ctrl[key] = true;
877-
if (g1c) {
878-
pl.stopAnim("");
879-
pl.setInteraction(nullptr);
880-
ctrl[key] = false;
881-
}
882-
else {
883-
inter.nextState(pl,0);
884-
}
885-
return;
886-
}
887-
if (!g1c && !isPressed(KeyCodec::ActionGeneric))
888-
return;
889-
if(key==KeyCodec::Forward ) {
890-
inter.nextState(pl,1);
858+
if(key==KeyCodec::Back) {
859+
pl.setInteraction(nullptr);
891860
return;
892861
}
893-
if(key==KeyCodec::Back) {
894-
if (g1c)
895-
inter.nextState(pl,2);
896-
else
897-
inter.nextState(pl,3);
862+
863+
if(key==KeyCodec::Forward) {
864+
inter.nextState(pl);
898865
}
899866
}
900867

game/graphics/mdlvisual.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ const Animation::Sequence* MdlVisual::startAnimAndGet(Npc& npc, AnimationSolver:
591591
auto inter = npc.interactive();
592592
const Animation::Sequence *sq = solver.solveAnim(inter,a,*skInst);
593593
if(sq!=nullptr){
594-
auto bs=sq->name.find("T_LADDER")==0 ? BS_CLIMB : BS_MOBINTERACT;
595-
if(skInst->startAnim(solver,sq,comb,bs,Pose::NoHint,npc.world().tickCount()))
594+
if(skInst->startAnim(solver,sq,comb,BS_MOBINTERACT,Pose::NoHint,npc.world().tickCount())) {
596595
return sq;
596+
}
597597
}
598598
return nullptr;
599599
}

game/ui/inventorymenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void InventoryMenu::close() {
105105
}
106106

107107
void InventoryMenu::open(Npc &pl) {
108-
if(pl.isDown() || pl.isMonster() || pl.isInAir() || pl.isSlide() || pl.interactive()!=nullptr)
108+
if(pl.isDown() || pl.isMonster() || pl.isInAir() || pl.isSlide() || (pl.interactive()!=nullptr))
109109
return;
110110
if(pl.weaponState()!=WeaponState::NoWeapon) {
111111
pl.stopAnim("");

game/world/objects/interactive.cpp

Lines changed: 13 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void Interactive::tick(uint64_t dt) {
209209
auto prev = state;
210210
setState(state-1);
211211
loopState = (prev==state);
212-
}
212+
}
213213
return;
214214
}
215215

@@ -227,23 +227,11 @@ void Interactive::implTick(Pos& p, uint64_t /*dt*/) {
227227
Npc& npc = *p.user;
228228
if(!p.started) {
229229
// STAND -> S0
230-
if (isLadder()) {
231-
float x0 = 0 , y0 = 0 , z0 = 0;
232-
float x1 = 0 , y1 = 0 , z1 = 1;
233-
auto mat = nodeTranform(npc,p);
234-
mat.project(x0,y0,z0);
235-
mat.project(x1,y1,z1);
236-
npc.setDirectionY(y1-y0);
237-
wait = true;
238-
}
239230
auto sq = npc.setAnimAngGet(Npc::Anim::InteractFromStand);
240231
uint64_t t = sq==nullptr ? 0 : uint64_t(sq->totalTime());
241232
waitAnim = world.tickCount()+t;
242233
p.started = sq!=nullptr;
243-
if (state<1)
244-
setState(std::min(stateNum,state+1));
245-
else
246-
setState(std::max(0,state-1));
234+
setState(std::min(stateNum,state+1));
247235
return;
248236
}
249237

@@ -260,10 +248,7 @@ void Interactive::implTick(Pos& p, uint64_t /*dt*/) {
260248
}
261249
}
262250

263-
if(isLadder() && wait && p.started)
264-
return;
265-
266-
if((!attach && state==0) || (isLadder() && attach && state==stateNum-1)) {
251+
if(!attach && state==0) {
267252
implQuitInteract(p);
268253
return;
269254
}
@@ -306,49 +291,22 @@ void Interactive::implTick(Pos& p, uint64_t /*dt*/) {
306291
loopState = (prev==state);
307292
}
308293

309-
void Interactive::nextState(Npc& npc, const uint8_t st) {
310-
wait = !st;
311-
switch(st){
312-
case 1 :
313-
reverseState=false;
314-
return;
315-
case 2 :
316-
reverseState=true;
317-
return;
318-
case 3 :
319-
if (state==0)
320-
wait=true;
321-
else
322-
reverseState=true;
323-
return;
324-
case 4 :
325-
if (state<1) {
326-
reverseState=true;
327-
return;
328-
}
329-
if (state>stateNum-2) {
330-
reverseState=false;
331-
return;
332-
}
333-
npc.stopAnim("");
334-
npc.setInteraction(nullptr);
335-
}
294+
void Interactive::nextState(Npc& npc) {
295+
const int prev = state;
296+
if(!setAnim(&npc,Anim::In))
297+
return;
298+
setState(std::min(stateNum,state+1));
299+
loopState = (prev==state);
336300
}
337301

338302
void Interactive::implQuitInteract(Interactive::Pos &p) {
339303
if(p.user==nullptr)
340304
return;
341305
Npc& npc = *p.user;
342306
const Animation::Sequence* sq = nullptr;
343-
if(state==0 || (isLadder() && state==stateNum-1)) {
307+
if(state==0) {
344308
// S0 -> STAND
345309
sq = npc.setAnimAngGet(Npc::Anim::InteractToStand);
346-
if (isLadder() && state==stateNum-1) {
347-
waitAnim=world.tickCount()+uint64_t(sq->totalTime());
348-
setState(stateNum);
349-
npc.setDirectionY(0);
350-
return;
351-
}
352310
}
353311
if(sq==nullptr && !(npc.isDown() || npc.setAnim(Npc::Anim::Idle)))
354312
return;
@@ -922,10 +880,10 @@ const Animation::Sequence* Interactive::animNpc(const AnimationSolver &solver, A
922880

923881
if(t==Anim::FromStand) {
924882
st[0] = -1;
925-
st[1] = state<1 ? 0 : stateNum - 1;
926-
}
883+
st[1] = 0;
884+
}
927885
else if(t==Anim::ToStand) {
928-
st[0] = state<1 ? 0 : stateNum - 1;
886+
st[0] = 0;
929887
st[1] = -1;
930888
}
931889

game/world/objects/interactive.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Interactive : public Vob {
7676
auto animNpc(const AnimationSolver &solver, Anim t) -> const Animation::Sequence*;
7777
void marchInteractives(DbgPainter& p) const;
7878

79-
void nextState(Npc& npc, const uint8_t st);
79+
void nextState(Npc& owner);
8080

8181
protected:
8282
Tempest::Matrix4x4 nodeTranform(std::string_view nodeName) const;
@@ -151,7 +151,6 @@ class Interactive : public Vob {
151151
int stepsCount = 0;
152152

153153
int32_t state = -1;
154-
bool wait = false;
155154
bool reverseState = false;
156155
bool loopState = false;
157156
bool isLockCracked = false;

game/world/objects/npc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ void Npc::setDirectionY(float rotation) {
409409
if(rotation<-90)
410410
rotation = -90;
411411
rotation = std::fmod(rotation,360.f);
412-
if(!mvAlgo.isSwim() && !(interactive()!=nullptr && interactive()->isLadder()))
412+
if(!mvAlgo.isSwim())
413413
return;
414414
angleY = rotation;
415415
durtyTranform |= TR_Rot;
@@ -2975,7 +2975,7 @@ bool Npc::rotateTo(float dx, float dz, float step, bool noAnim, uint64_t dt) {
29752975

29762976
const auto sgn = std::sin(double(da)*M_PI/180.0);
29772977
if(sgn<0) {
2978-
setAnimRotate(1);
2978+
setAnimRotate( 1);
29792979
setDirection(angle-step);
29802980
} else
29812981
if(sgn>0) {

game/world/spaceindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void BaseSpaceIndex::implFind(Vob** v, size_t cnt, uint8_t depth,
102102

103103
auto mid = cnt/2;
104104
auto pos = v[mid]->position();
105-
auto qR = (R+675.0);//v[mid]->extendedSearchRadius());
105+
auto qR = (R+500.0);//v[mid]->extendedSearchRadius());
106106

107107
if((pos-p).quadLength()<=qR*qR) {
108108
func(ctx,v[mid]);

0 commit comments

Comments
 (0)