86 return m_Src.GetItem();
100 if (validation.m_IsRemote || validation.m_IsJuncture)
115 case HandEventID.TAKE:
return new HandEventTake(p, src);
116 case HandEventID.MOVETO:
return new HandEventMoveTo(p, src);
117 case HandEventID.DROP:
return new HandEventDrop(p, src);
118 case HandEventID.THROW:
return new HandEventThrow(p, src);
119 case HandEventID.SWAP:
return new HandEventSwap(p, src);
120 case HandEventID.FORCESWAP:
return new HandEventForceSwap(p, src);
121 case HandEventID.DESTROY:
return new HandEventDestroy(p, src);
122 case HandEventID.CREATED:
return new HandEventCreated(p, src);
123 case HandEventID.DESTROYED:
return new HandEventDestroyed(p, src);
124 case HandEventID.REPLACE:
return new HandEventDestroyAndReplaceWithNew(p, src);
125 case HandEventID.REPLACE2:
return new HandEventDestroyAndReplaceWithNewElsewhere(p, src);
126 case HandEventID.REPLACE3:
return new HandEventDestroyElsewhereAndReplaceWithNewInHands(p, src);
127 case HandEventID.REPLACED:
return new HandEventReplaced(p, src);
128 case HandEventID.ANIMEVENT_CHANGE_HIDE:
return HandAnimEventChanged(p, src);
129 case HandEventID.HUMANCOMMAND_ACTION_FINISHED :
return HandEventHumanCommandActionFinished(p, src);
130 case HandEventID.HUMANCOMMAND_ACTION_ABORTED :
return HandEventHumanCommandActionAborted(p, src);
132 Error(
"[hndfsm] HandEventFactory - unregistered hand event with id=" +
id);
139 if (!ctx.Read(eventID))
141 Error(
"[hndfsm] CreateHandEventFromContext - cannot read eventID");
145 if (!ctx.Read(player))
147 Error(
"[hndfsm] CreateHandEventFromContext - cannot read player");
150 InventoryLocation src;
154 if (!ctx.Read(animID))
156 Error(
"[hndfsm] CreateHandEventFromContext - cannot read animID");
162 b.m_AnimationID = animID;
163 b.ReadFromContext(ctx);
185 if (il && !
m_Player.GetHumanInventory().HasInventoryReservation(il.GetItem(),il))
206 m_Player.GetHumanInventory().ClearInventoryReservationEx(il.GetItem(), il);
240 if (validation.m_IsJuncture)
247 #ifdef ENABLE_LOGGING
257 return super.CanPerformEventEx(validation);
268 Error(
"[hndfsm] HandEventTake. AcquireInventoryJunctureFromServer: no src or dst for ev=" +
DumpToString());
281 m_Dst =
new InventoryLocation;
282 super.ReadFromContext(ctx);
283 m_Dst.ReadFromContext(ctx);
287 super.WriteToContext(ctx);
288 m_Dst.WriteToContext(ctx);
291 override InventoryLocation
GetDst () {
return m_Dst; }
295 if (!GameInventory.CheckRequestSrc(
m_Player,
GetSrc(), GameInventory.c_MaxItemDistanceRadius))
305 if(
m_Src && m_Dst &&
m_Src.GetItem() != m_Dst.GetItem())
308 return GameInventory.CheckMoveToDstRequest(
m_Player,
m_Src, m_Dst, GameInventory.c_MaxItemDistanceRadius);
313 if (!GameInventory.LocationCanMoveEntity(
GetSrc(),
GetDst()))
315 #ifdef ENABLE_LOGGING
316 if ( LogManager.IsInventoryHFSMLogEnable() )
328 InventoryLocation src =
GetSrc();
329 InventoryLocation dst =
GetDst();
334 Error(
"[hndfsm] HandEventMoveTo. AcquireInventoryJunctureFromServer: no src or dst for ev=" +
DumpToString());
340 string res =
"{ HandEventMoveTo id=" +
typename.EnumToString(
HandEventID,
GetEventID()) +
" pl=" +
Object.GetDebugName(
m_Player) +
" src=" + InventoryLocation.DumpToStringNullSafe(
m_Src) +
" dst=" + InventoryLocation.DumpToStringNullSafe(m_Dst) +
" }";
348 override InventoryLocation
GetDst ()
355 if (!GameInventory.CheckRequestSrc(
m_Player,
GetSrc(), GameInventory.c_MaxItemDistanceRadius))
357 #ifdef ENABLE_LOGGING
358 if ( LogManager.IsInventoryHFSMLogEnable() )
360 Debug.InventoryHFSMLog(
"Check src - failed, src = " + InventoryLocation.DumpToStringNullSafe(
GetSrc()),
typename.EnumToString(
HandEventID,
GetEventID()) ,
"n/a",
"CheckRequestSrc",
m_Player.ToString() );
370 if(
m_Src && m_Dst &&
m_Src.GetItem() != m_Dst.GetItem())
373 return GameInventory.CheckMoveToDstRequest(
m_Player,
m_Src, m_Dst, GameInventory.c_MaxItemDistanceRadius);
378 InventoryLocation src =
GetSrc();
379 InventoryLocation dst =
GetDst();
383 #ifdef ENABLE_LOGGING
384 if ( LogManager.IsInventoryHFSMLogEnable() )
394 #ifdef ENABLE_LOGGING
395 if ( LogManager.IsInventoryHFSMLogEnable() )
397 Debug.InventoryHFSMLog(
"CANNOT perform. Dst location type is UNKNOWN!",
typename.EnumToString(
HandEventID,
GetEventID()) ,
"n/a",
"CanPerformEvent",
m_Player.ToString() );
403 if (!GameInventory.LocationCanMoveEntity(src, dst))
405 #ifdef ENABLE_LOGGING
406 if ( LogManager.IsInventoryHFSMLogEnable() )
418 InventoryLocation src =
GetSrc();
419 InventoryLocation dst =
GetDst();
424 Error(
"[hndfsm] HandEventThrow. AcquireInventoryJunctureFromServer: no src or dst for ev=" +
DumpToString());
428 ref InventoryLocation m_Dst;
436 m_CanPerformDrop =
true;
444 super.ReadFromContext(ctx);
446 ctx.Read(m_CanPerformDrop);
453 super.WriteToContext(ctx);
455 ctx.Write(m_CanPerformDrop);
469 if (!m_CanPerformDrop)
475 return super.CheckRequestEx(validation);
481 if (validation.m_Mode ==
InventoryMode.JUNCTURE && !validation.m_IsJuncture && !validation.m_IsRemote &&
g_Game.IsClient())
493 if (!m_CanPerformDrop)
498 return super.CanPerformEventEx(validation);
501 bool m_CanPerformDrop;
517 entity.GetTransform(mat);
518 m_Dst.SetGround(entity, mat);
522 Error(
"[hndfsm] HandEventThrow src entity null!");
529 super.ReadFromContext(ctx);
531 m_Dst =
new InventoryLocation;
532 m_Dst.ReadFromContext(ctx);
545 super.WriteToContext(ctx);
547 m_Dst.WriteToContext(ctx);
549 ctx.Write(m_Force[0]);
550 ctx.Write(m_Force[1]);
551 ctx.Write(m_Force[2]);
554 void SetForce(vector force) { m_Force = force; }
555 vector GetForce() {
return m_Force; }
563 ref InventoryLocation m_Dst;
564 ref InventoryLocation m_Src2;
565 ref InventoryLocation m_Dst2;
566 int m_Animation2ID = -1;
568 void HandEventSwap (Man p = null, InventoryLocation src = null, InventoryLocation src2 = null, InventoryLocation dst = null, InventoryLocation dst2 = null)
578 super.ReadFromContext(ctx);
580 m_Src2 =
new InventoryLocation;
581 m_Dst =
new InventoryLocation;
582 m_Dst2 =
new InventoryLocation;
584 m_Src2.ReadFromContext(ctx);
585 m_Dst.ReadFromContext(ctx);
586 m_Dst2.ReadFromContext(ctx);
587 ctx.Read(m_Animation2ID);
592 super.WriteToContext(ctx);
594 m_Src2.WriteToContext(ctx);
595 m_Dst.WriteToContext(ctx);
596 m_Dst2.WriteToContext(ctx);
597 ctx.Write(m_Animation2ID);
600 override InventoryLocation
GetDst ()
617 return m_Src2.GetItem();
624 if (!GameInventory.CheckRequestSrc(
m_Player,
GetSrc(), GameInventory.c_MaxItemDistanceRadius))
629 if (!GameInventory.CheckRequestSrc(
m_Player, m_Src2, GameInventory.c_MaxItemDistanceRadius))
631 if (LogManager.IsSyncLogEnable())
syncDebugPrint(
"[cheat] HandleInputData man=" +
Object.GetDebugName(
m_Player) +
" failed src2 check with cmd=" +
typename.EnumToString(
HandEventID,
GetEventID()) +
" src2=" + InventoryLocation.DumpToStringNullSafe(m_Src2));
639 if (
m_Src && m_Dst &&
m_Src.GetItem() != m_Dst.GetItem())
642 if (m_Src2 && m_Dst2 && m_Src2.GetItem() != m_Dst2.GetItem())
645 if (!GameInventory.CheckSwapItemsRequest(
m_Player,
m_Src, m_Src2, m_Dst, m_Dst2, GameInventory.c_MaxItemDistanceRadius))
647 #ifdef ENABLE_LOGGING
648 if ( LogManager.IsInventoryHFSMLogEnable() )
654 else if (!
m_Player.GetHumanInventory().CanAddSwappedEntity(
m_Src, m_Src2, m_Dst, m_Dst2))
656 #ifdef ENABLE_LOGGING
657 if ( LogManager.IsInventoryHFSMLogEnable() )
671 if (GameInventory.CanForceSwapEntitiesEx(
GetSrc().
GetItem(), m_Dst, m_Src2.GetItem(), m_Dst2))
674 #ifdef ENABLE_LOGGING
675 if ( LogManager.IsInventoryHFSMLogEnable() )
690 return "{ HandEventSwap id=" +
typename.EnumToString(
HandEventID,
GetEventID()) +
" pl=" +
Object.GetDebugName(
m_Player) +
" src1=" + InventoryLocation.DumpToStringNullSafe(
m_Src) +
" src2=" + InventoryLocation.DumpToStringNullSafe(m_Src2) +
" dst1=" + InventoryLocation.DumpToStringNullSafe(m_Dst) +
" dst2=" + InventoryLocation.DumpToStringNullSafe(m_Dst2) +
" }";
693 void CheckAndExecuteForceStandUp()
695 DayZPlayer player = DayZPlayer.Cast(
m_Player);
696 player.ForceStandUpForHeavyItemsSwap(
m_Src.GetItem(), m_Src2.GetItem() );
701 if (!
m_Player.GetHumanInventory().HasInventoryReservation(m_Dst.GetItem(), m_Dst) && !
m_Player.GetHumanInventory().HasInventoryReservation(m_Dst2.GetItem(), m_Dst2))
703 if (
m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst.GetItem(), m_Dst, GameInventory.c_InventoryReservationTimeoutShortMS))
705 if (
m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS))
711 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
720 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
721 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
731 if(
m_Src && m_Dst &&
m_Src.GetItem() != m_Dst.GetItem())
734 if(m_Src2 && m_Dst2 && m_Src2.GetItem() != m_Dst2.GetItem())
739 if (
GetSrcEntity() && inHands && m_Dst && m_Dst.IsValid())
742 #ifdef ENABLE_LOGGING
756 #ifdef ENABLE_LOGGING
776 void HandEventCreated (Man p = null, InventoryLocation src = null) {
m_EventID =
HandEventID.CREATED; }
781 void HandEventDestroyed (Man p = null, InventoryLocation src = null) {
m_EventID =
HandEventID.DESTROYED; }
787 ref ReplaceItemWithNewLambdaBase m_Lambda;
789 void HandEvengReplaceWithNewBase (Man p = null, InventoryLocation src = null, ReplaceItemWithNewLambdaBase lambda = NULL) {
m_EventID =
HandEventID.REPLACE; m_Lambda = lambda; }
793 super.ReadFromContext(ctx);
795 Error(
"[hndfsm] HandEventDestroyAndReplaceWithNew - Cannot serialize lambda (read)");
799 super.WriteToContext(ctx);
801 Error(
"[hndfsm] HandEventDestroyAndReplaceWithNew - Cannot serialize lambda (write)");
806 override InventoryLocation
GetDst ()
808 InventoryLocation dst =
new InventoryLocation;
815 string res =
"{ HandEvenReplaceWithNewBase id=" +
typename.EnumToString(
HandEventID,
GetEventID()) +
" pl=" +
Object.GetDebugName(
m_Player) +
" src=" + InventoryLocation.DumpToStringNullSafe(
GetSrc()) +
" lambda=" + m_Lambda +
" dst=" + InventoryLocation.DumpToStringNullSafe(
GetDst()) +
" }";
837 void HandEventReplaced (Man p = null, InventoryLocation src = null) {
m_EventID =
HandEventID.REPLACED; }
844 void HandAnimEventChanged (Man p = null, InventoryLocation src = null) {
m_EventID =
HandEventID.ANIMEVENT_CHANGE_HIDE; }
851 case WeaponEvents.CHANGE_HIDE:
return new HandAnimEventChanged(p, src);
852 case WeaponEvents.CHANGE_SHOW:
return new HandAnimEventChanged(p, src);
859class HandEventHumanCommandActionFinished
extends HandEventBase
861 void HandEventHumanCommandActionFinished (Man p = null, InventoryLocation src = null) {
m_EventID =
HandEventID.HUMANCOMMAND_ACTION_FINISHED; }
865class HandEventHumanCommandActionAborted
extends HandEventBase
867 void HandEventHumanCommandActionAborted (Man p = null, InventoryLocation src = null) {
m_EventID =
HandEventID.HUMANCOMMAND_ACTION_ABORTED; }
void syncDebugPrint(string s)
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
InventoryValidationReason
eBleedingSourceType m_Type
@ UNKNOWN
24 - Any other error. Can be returned from any call.
Super root of all classes in Enforce script.
script counterpart to engine's class Inventory
const int c_InventoryReservationTimeoutShortMS
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
const float c_MaxItemDistanceRadius
anti-cheats
static proto native bool CheckSwapItemsRequest(notnull Man requestingPlayer, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
static proto native bool CheckMoveToDstRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
static proto native bool CheckRequestSrc(notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
Abstracted event, not to be used, only inherited.
base class for transformation operations (creating one item from another)
DayZPlayerInstanceType
defined in C++
Serializer ParamsReadContext
Serializer ParamsWriteContext
void Error(string err)
Messagebox with error message.
EntityAI GetSecondSrcEntity()
InventoryLocation GetSrc()
ref InventoryLocation m_Src
InventoryLocation GetSecondDst()
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
void ReadFromContext(ParamsReadContext ctx)
bool CanPerformEventEx(InventoryValidation validation)
InventoryLocation GetSecondSrc()
void WriteToContext(ParamsWriteContext ctx)
bool CheckRequestEx(InventoryValidation validation)
@ HUMANCOMMAND_ACTION_FINISHED
@ HUMANCOMMAND_ACTION_ABORTED
@ SWAP
swapping from ground
void HandEventBase(Man p=null, InventoryLocation src=null)
bool AcquireInventoryJunctureFromServer(notnull Man player)
InventoryLocation GetDst()
void ClearInventoryReservation()
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
InventoryLocationType
types of Inventory Location
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)