Skip to content

Telekinesis lifts and steers the focused item - #1059

Open
Solessfir wants to merge 1 commit into
Try:masterfrom
Solessfir:telekinesis
Open

Solessfir wants to merge 1 commit into
Try:masterfrom
Solessfir:telekinesis

Conversation

@Solessfir

@Solessfir Solessfir commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Implement item movement for Gothic I Telekinesis (#661, item 3). The Gothic I script handles mana investment, and the engine moves the focused item.

  • With no item in focus, the hero shrugs. With an item in focus, the cast plays the authored entry animation.
  • Holding Action + Forward lifts the item and draws it within about 1 meter of the caster. Left and Right steer it sideways as it rises.
  • Releasing the cast drops the item and uses one scroll if the item was lifted.
  • Saving or changing worlds finishes the cast and settles the item on the ground.

Built OpenGothic and Spacer. In Gothic I, tested three consecutive casts, including brief casts, and verified the hero lowers his hands after the final scroll. Quicksaving during a lift consumed one scroll both when continuing and after loading the save.

@Try

Try commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Hi, @Solessfir !

spellFxInstanceNames->get_string(uint16_t(splId))=="Telekinesis";

I'm sorry, but it generally wrong: engine has to execute based on spell/effect descriptors such as C_Spell_Proto. Any form of hardcoded names must be avoided unless there is an evidence of hardcode in original game.
For example: if you change vanilla script (Telekinesis -> MyTelekinesis) and recompile - will it break or continue to work?

@Solessfir

Copy link
Copy Markdown
Contributor Author

Good point, thanks! Switched it to the spell id. In vanilla G1 this one is hardcoded too: the engine moves the item for spell id 10 (SPL_TELEKINESIS) and the script only invests mana. SpellManager, which re-implements those engine paths, lists G1 telekinesis among the hardcoded id checks: https://github.com/fyryNy/SpellManager#readme

Same approach as the existing SPL_STORMFIST check in Item::isSpellShoot, G1 only. So renaming the script instance keeps working, while changing the id wouldn't, same as in the original.

@Solessfir
Solessfir force-pushed the telekinesis branch 2 times, most recently from ffe8103 to c83dac1 Compare November 15, 2026 15:44
@Abendlied

Copy link
Copy Markdown
Contributor

@Solessfir thank you for this PR, a spell long missing in OpenGothic!

I have tested it using the statuette in orc city.
Observation: Ray bridge effect missing, statuette does not get lower, no arc courve of the item yet.
Spell can also be casted without an item in sight, not sure if that is original behaviour.

When the caster looks into the general direction of an item with Telekinesis spell wielding, it takes items into focus automatically and at a much larger range than usual, even if it is out of the screen on top, item still focused, item name still visible.

Ray bridge effect missing,

Fair if missing, I thing OpenGothic spells can as of now only track NPCs as target (see Npc::currentTarget), I noticed when looking into Control spell. Can probably be a follow up PR if we want to segment this.

statuette does not get lower,

This is is in playercontrol

 const float step = speed*float(dt)/1000.f;
  const float head = pl.position().y + 2.f*(pl.centerPosition().y-pl.position().y);
  if(pos.y<head)
    pos.y = std::min(pos.y+step,head);
  dp.y = 0;
  const float flat = dp.length();
  if(flat>0.f)
    pos += dp*(std::min(step,flat)/flat);
  it->setPosition(pos.x,pos.y,pos.z);
  }

the item is raised to head height but then moves to side only, never lower.
Should it instead move towards the player? Then all three directions are needed.

When the caster looks into the general direction of an item with Telekinesis spell wielding, it takes items into focus automatically and at a much larger range than usual, even if it is out of the screen on top, item still focused, item name still visible.

@Try Do you think this is an engine gap? Items up to 3000 units away (Focus_Magic, Content/Anims/Focus.d). But worldobjects.cpp never checks for up or down angle, even if they are horizontally over the player. Should we fix?

Details ``` template bool WorldObjects::testObj(T &src, const Npc &pl, const WorldObjects::SearchOpt &opt,float& rlen){ const float qmax = opt.rangeMax*opt.rangeMax; const float qmin = opt.rangeMin*opt.rangeMin; const float plAng = pl.rotationRad(); const float ang = float(std::cos(double(opt.azi)*M_PI/180.0));

auto& npc=deref(src);
if(reinterpret_cast<void*>(&npc)==reinterpret_cast<const void*>(&pl))
return false;

if(!checkFlag(npc,opt.flags))
return false;
if(!checkTargetType(npc,opt.collectType))
return false;

float l = pl.qDistTo(npc);
if(l>qmax || l<qmin)
return false;

auto pos = npc.position();
auto dpos = pos - pl.position();
auto angle = std::atan2(dpos.z,dpos.x);

if(std::cos(plAng-angle)<ang && !bool(opt.flags&SearchFlg::NoAngle))
return false;

l = std::sqrt(l);
if(l<rlen && (bool(opt.flags&SearchFlg::NoRay) || canSee(pl,npc))){
rlen=l;
return true;
}
return false;
}

@Solessfir

Solessfir commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor Author

@Abendlied thanks for testing! I compared everything with the original Gothic 1 and reworked the PR.

statuette does not get lower / no arc courve of the item yet

I rechecked the movement and updated the PR. Holding the cast lifts the item and draws it toward the hero. The pull stops about a meter away while the item keeps rising. Left and Right steer it sideways, and releasing the cast drops it for normal pickup.

Spell can also be casted without an item in sight

The original doesn't cast without an item in focus, the hero just shrugs. The PR now does that too, so no mana is spent on nothing.

Ray bridge effect missing

Agreed, spell effects can only bind to an NPC target right now, so this needs an item target first. I'd do it as a follow-up.

items into focus automatically and at a much larger range than usual

The range comes from Focus_Magic in the scripts, so that part is intended. The vertical part is an engine gap that affects every focus, not just telekinesis: the Focus instances define npc_elevup/npc_elevdo, item_elevup/item_elevdo and mob_elevup/mob_elevdo, but WorldObjects::testObj only checks the horizontal angle. That fits a separate PR.

@Solessfir Solessfir changed the title Telekinesis pulls the focused item to the caster Telekinesis lifts and steers the focused item Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants