Skip to content

Commit

Permalink
Add extra arguments to LaunchArrow
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Aug 4, 2024
1 parent cb69e27 commit c59d9ed
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
Binary file modified Papyrus/Scripts/PO3_SKSEFunctions.pex
Binary file not shown.
4 changes: 2 additions & 2 deletions Papyrus/Source/scripts/PO3_SKSEFunctions.psc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Scriptname PO3_SKSEFunctions Hidden

Function KillNoWait(Actor akActor) global native

Function LaunchArrow(Actor akActor, Ammo akAmmo, Weapon akWeapon, String asNodeName = "") global native
Function LaunchArrow(Actor akActor, Ammo akAmmo, Weapon akWeapon, String asNodeName = "", int aiSource = -1, ObjectReference akTarget = None, Potion akPoison = None) global native

Function LaunchSpell(Actor akActor, Spell akSpell, int aiSource) global native

Expand Down Expand Up @@ -750,7 +750,7 @@ Scriptname PO3_SKSEFunctions Hidden

Function RemoveAllModItems(ObjectReference akRef, String asModName, bool abOnlyUnequip = false) global native

Function RemoveListFromContainer(ObjectReference akRef, FormList akList, bool abNoEquipped = false, bool abNoFavorited = false, bool abNoQuestItem = false, ObjectReference akDestination = NONE) global native
Function RemoveListFromContainer(ObjectReference akRef, FormList akList, bool abNoEquipped = false, bool abNoFavorited = false, bool abNoQuestItem = false, ObjectReference akDestination = None) global native

bool Function RemoveKeywordFromRef(ObjectReference akRef, Keyword akKeyword) global native

Expand Down
50 changes: 35 additions & 15 deletions include/Papyrus/Functions/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ namespace Papyrus::Actor
return isBeingSoulTrapped;
}

inline void LaunchArrow(STATIC_ARGS, RE::Actor* a_actor, RE::TESAmmo* a_ammo, RE::TESObjectWEAP* a_weapon, RE::BSFixedString a_nodeName)
inline void LaunchArrow(STATIC_ARGS, RE::Actor* a_actor, RE::TESAmmo* a_ammo, RE::TESObjectWEAP* a_weapon, RE::BSFixedString a_nodeName, std::int32_t a_source, RE::TESObjectREFR* a_target, RE::AlchemyItem* a_poison)
{
if (!a_actor) {
a_vm->TraceStack("Actor is None", a_stackID);
Expand All @@ -806,20 +806,37 @@ namespace Papyrus::Actor
return;
}

SKSE::GetTaskInterface()->AddTask([a_actor, a_ammo, a_weapon, a_nodeName]() {
SKSE::GetTaskInterface()->AddTask([a_actor, a_ammo, a_weapon, a_nodeName, a_source, a_target, a_poison]() {
RE::NiAVObject* fireNode = nullptr;
auto root = a_actor->IsPlayerRef() ? a_actor->GetCurrent3D() : a_actor->Get3D2();
RE::NiAVObject* fireNode{};
if (!a_nodeName.empty()) {
if (root) {
fireNode = root->GetObjectByName(a_nodeName);
}
} else {
if (const auto currentProcess = a_actor->currentProcess) {
const auto& biped = a_actor->GetBiped2();
fireNode = a_weapon->IsCrossbow() ? currentProcess->GetMagicNode(biped) : currentProcess->GetWeaponNode(biped);
} else {
fireNode = a_weapon->GetFireNode(root);
switch (a_source) {
case -1:
{
if (!a_nodeName.empty()) {
if (root) {
fireNode = root->GetObjectByName(a_nodeName);
}
} else {
if (const auto currentProcess = a_actor->currentProcess) {
const auto& biped = a_actor->GetBiped2();
fireNode = a_weapon->IsCrossbow() ? currentProcess->GetMagicNode(biped) : currentProcess->GetWeaponNode(biped);
} else {
fireNode = a_weapon->GetFireNode(root);
}
}
}
break;
case 0:
fireNode = root ? root->GetObjectByName(RE::FixedStrings::GetSingleton()->npcLMagicNode) : nullptr;
break;
case 1:
fireNode = root ? root->GetObjectByName(RE::FixedStrings::GetSingleton()->npcRMagicNode) : nullptr;
break;
case 2:
fireNode = root ? root->GetObjectByName(RE::FixedStrings::GetSingleton()->npcHeadMagicNode) : nullptr;
break;
default:
break;
}
RE::NiPoint3 origin;
RE::Projectile::ProjectileRot angles{};
Expand All @@ -833,8 +850,11 @@ namespace Papyrus::Actor
angles.x = a_actor->GetAimAngle();
angles.z = a_actor->GetAimHeading();
}
RE::ProjectileHandle handle{};
RE::Projectile::LaunchArrow(&handle, a_actor, a_ammo, a_weapon, origin, angles);
RE::ProjectileHandle handle{};
RE::Projectile::LaunchData launchData(a_actor, origin, angles, a_ammo, a_weapon);
launchData.desiredTarget = a_target;
launchData.poison = a_poison;
RE::Projectile::Launch(&handle, launchData);
});
}

Expand Down

0 comments on commit c59d9ed

Please sign in to comment.