Jump to content

Adding new APIs to H&S


Karen

Recommended Posts

but what is this API?

Application Program Interface.

New script hooks/functions in simple words. Will be applied at next patch.

 

List of existed functions:

https://forum.nival.com/rus/showpost.php?p=...30&postcount=84

List of existed hooks:

https://forum.nival.com/rus/showpost.php?p=...16&postcount=90

 

to-do list at this moment:

 

functions:

 

bHasCrit, nDiff, nTime UnitHasCritical(unit, nCritID )

bool UnitIsSelected( unit )

UI_ID FocusCameraEx( unit/position, nRod = 0, nYaw = 0, nPitch = 100 ) -- dinamic camera creation

nX,nY,nZ PosToVector3D( position ) -- dinamic position creation

position Vector3DToPos( nX, nY, nZ ) -- dinamic position creation

 

hooks:

 

OnOpenShop()

OnCloseShop()

OnOpenStore()

OnCloseStore()

OnOpenLoot()

OnCloseLoot()

OnOpenCharacter()

OnCloseCharacter()

OnOpenPerks()

OnClosePerks()

OnOpenBiography()

OnCloseBiography()

OnOpenStatistics()

OnCloseStatistics()

Link to comment
Share on other sites

Ahhaa! Great! Thanks. :cool:

 

I dunno yet about new H&S functions or scripting it but I have missed these functions in S^3 (nothing special but...):

------------------------------------------------------------------------------------------------------------------------------------

-FullRetreat( unit, "waypoint" ) = Better that existin' UnitSetRetreatLogic( unit ). Should run like hell and doesn't attack at all.

I have tried with UnitAIMode( unit, false ) + UnitMoveToWaypoint( unit, "w") but mob just freeze after a turn.

-FullMeleeUnit( unit ) = If unit have melee weapon in hand then always try to barge to close combat + use melee

((-UnitSeeDead( unit, group ) = Returns true if unit have spotted any stunned/killed group's unit... maybe to custom Auto Load?))

------------------------------------------------------------------------------------------------------------------------------------

 

Perhaps those functions are not 'necessary' to anybody else... (?) ;)

 

That's all for now... I will be back with better time (and if I will remember my other 'ideas').

Link to comment
Share on other sites

All of this functions can be writing on existing API. Example:

 

FullRetreat( unit, "waypoint" )

function isDone(unit)
local ret = not (IsValid(unit) and UnitCanFight(unit))
return(ret)
end

MIN_DISTANCE = 1.0

function FullRetreatThread( unit, waypoint )
if(isDone(unit)) then return end
local wPos = GetWaypointPos(waypoint)
UnitMoveToWaypoint(unit,waypoint)
local dist = GetDistance(GetPos(unit),wPos)
local oldDist = dist 
while((dist>MIN_DISTANCE) and (not isDone(unit))) do
	if(IsRealTime()) then
		Sleep(40)
	else
		SleepForTurn()
	end
	dist = GetDistance(GetPos(unit),wPos)
	if(isDone(unit)) then break end
	if((oldDist==dist) and (not PassCalcerIsActive())) then
		UnitMoveToWaypoint(unit,waypoint)
	end
	oldDist = dist
end
end

function FullRetreat( unit, waypoint )
StartThread(FullRetreatThread, unit, waypoint)
end

FullMeleeUnit( unit )\UnitSeeDead( unit, group )

I can write it too, but listing is long. You really need it?

Link to comment
Share on other sites

Wow, that was truly helpful - thanks a lot and more. :cool: I really needed that.

I can write it too, but listing is long. You really need it?
No. I think I know how to write those... If I encounter problems, I just hope a piece of help and ask a solution.

 

. . . One function what I dunno how to do is:

UnitLooseItems( unit ) = Takes all weapons/items from unit's slots and inventory (to emptiness).

There is a function UnitRemoveInventoryToStore( unit ) but it's not what I need. I'm looking for

a way to get captured/imprisoned and that's why all items should be taken from player's character/s.

 

Thanks again.

Link to comment
Share on other sites

UnitLooseItems( unit )

function destroyItemInBackpack(unit)
local item = UnitGetFirstItem(unit)
if(IsValid(item)) then
	local itemID = UnitGetItemID( unit, item )
	UnitRemoveInventoryItem( unit, itemID )
	WaitForUnit(unit)
	return(true)
end
return(false)
end

function destroyAllItems(unit)
while(destroyItemInBackpack(unit)) do end
UnitActivateWeapon(unit,false)
WaitForUnit(unit)
UnitTakeOffSlotItem( unit, 0 )
UnitTakeOffSlotItem( unit, 1 )
UnitUpdateAnimation(unit) -- H&S only function, correct unit's hands animation
end

Escuse me, i don't remember - works this on S^3 or not. On H&S this code is OK.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...