@@ -262,27 +262,38 @@ private void OnToTeleport(PlayerConnection playerConnection, Vector3 targetPos)
262
262
Logger . Trace ( $ "Teleporting to { targetPos } ") ;
263
263
}
264
264
265
- private void OnStartTravel ( PlayerConnection playerConnection , PrototypeId powerId )
265
+ private bool OnStartTravel ( PlayerConnection playerConnection , PrototypeId powerId )
266
266
{
267
- var conditionSerializationFlags = ConditionSerializationFlags . NoCreatorId | ConditionSerializationFlags . NoUltimateCreatorId
268
- | ConditionSerializationFlags . NoConditionPrototypeRef | ConditionSerializationFlags . HasCreatorPowerIndex | ConditionSerializationFlags . HasOwnerAssetRef ;
269
-
270
- ulong avatarEntityId = playerConnection . Player . CurrentAvatar . Id ;
267
+ Avatar avatar = playerConnection . Player . CurrentAvatar ;
271
268
272
269
switch ( powerId )
273
270
{
274
271
case ( PrototypeId ) PowerPrototypes . Travel . GhostRiderRide :
272
+ Condition ghostRiderRideCondition = avatar . ConditionCollection . GetCondition ( 666 ) ;
273
+ if ( ghostRiderRideCondition != null ) return Logger . WarnReturn ( false , "OnStartTravel(): ghostRiderRideCondition != null" ) ;
274
+
275
275
Logger . Trace ( $ "EventStart GhostRiderRide") ;
276
+
276
277
// Player.Avatar.EvalOnCreate.AssignProp.ProcProp.Param1
277
- AddConditionArchive conditionArchive = new ( avatarEntityId , 666 , conditionSerializationFlags , powerId , TimeSpan . Zero ) ; // TODO: generate and save Condition.Id
278
- conditionArchive . Condition . CreatorPowerIndex = 0 ;
278
+ // Create and add a ride condition
279
+ ghostRiderRideCondition = avatar . ConditionCollection . AllocateCondition ( ) ;
280
+ ghostRiderRideCondition . InitializeFromPowerMixinPrototype ( 666 , powerId , 0 , TimeSpan . Zero ) ;
281
+ avatar . ConditionCollection . AddCondition ( ghostRiderRideCondition ) ;
282
+
283
+ // Notify the client
284
+ AddConditionArchive conditionArchive = new ( )
285
+ {
286
+ ReplicationPolicy = AOINetworkPolicyValues . DefaultPolicy ,
287
+ EntityId = avatar . Id ,
288
+ Condition = ghostRiderRideCondition
289
+ } ;
279
290
280
291
playerConnection . SendMessage ( NetMessageAddCondition . CreateBuilder ( )
281
292
. SetArchiveData ( conditionArchive . SerializeToByteString ( ) )
282
293
. Build ( ) ) ;
283
294
284
295
playerConnection . SendMessage ( NetMessagePowerCollectionAssignPower . CreateBuilder ( )
285
- . SetEntityId ( avatarEntityId )
296
+ . SetEntityId ( avatar . Id )
286
297
. SetPowerProtoId ( ( ulong ) PowerPrototypes . GhostRider . RideBikeHotspotsEnd )
287
298
. SetPowerRank ( 0 )
288
299
. SetCharacterLevel ( 60 )
@@ -301,32 +312,57 @@ private void OnStartTravel(PlayerConnection playerConnection, PrototypeId powerI
301
312
case ( PrototypeId ) PowerPrototypes . Travel . BladeRide :
302
313
case ( PrototypeId ) PowerPrototypes . Travel . AntmanFlight :
303
314
case ( PrototypeId ) PowerPrototypes . Travel . ThingFlight :
315
+ Condition rideCondition = avatar . ConditionCollection . GetCondition ( 667 ) ;
316
+ if ( rideCondition != null ) return Logger . WarnReturn ( false , "OnStartTravel(): rideCondition != null" ) ;
317
+
304
318
Logger . Trace ( $ "EventStart Ride") ;
305
- conditionArchive = new ( avatarEntityId , 667 , conditionSerializationFlags , powerId , TimeSpan . Zero ) ;
306
- conditionArchive . Condition . CreatorPowerIndex = 0 ;
319
+
320
+ // Create and add a ride condition
321
+ rideCondition = avatar . ConditionCollection . AllocateCondition ( ) ;
322
+ rideCondition . InitializeFromPowerMixinPrototype ( 667 , powerId , 0 , TimeSpan . Zero ) ;
323
+ avatar . ConditionCollection . AddCondition ( rideCondition ) ;
324
+
325
+ // Notify the client
326
+ conditionArchive = new ( )
327
+ {
328
+ ReplicationPolicy = AOINetworkPolicyValues . DefaultPolicy ,
329
+ EntityId = avatar . Id ,
330
+ Condition = rideCondition
331
+ } ;
332
+
307
333
playerConnection . SendMessage ( NetMessageAddCondition . CreateBuilder ( )
308
334
. SetArchiveData ( conditionArchive . SerializeToByteString ( ) )
309
335
. Build ( ) ) ;
336
+
310
337
break ;
311
338
}
339
+
340
+ return true ;
312
341
}
313
342
314
343
private void OnEndTravel ( PlayerConnection playerConnection , PrototypeId powerId )
315
344
{
316
- ulong avatarEntityId = playerConnection . Player . CurrentAvatar . Id ;
345
+ Avatar avatar = playerConnection . Player . CurrentAvatar ;
317
346
318
347
switch ( powerId )
319
348
{
320
349
case ( PrototypeId ) PowerPrototypes . Travel . GhostRiderRide :
350
+ if ( avatar . ConditionCollection . GetCondition ( 666 ) == null ) return ;
351
+
321
352
Logger . Trace ( $ "EventEnd GhostRiderRide") ;
322
353
354
+ // Remove the ride condition
355
+ avatar . ConditionCollection . RemoveCondition ( 666 ) ;
356
+ // TODO: Remove the power from the collection
357
+
358
+ // Notify the client
323
359
playerConnection . SendMessage ( NetMessageDeleteCondition . CreateBuilder ( )
324
- . SetIdEntity ( avatarEntityId )
360
+ . SetIdEntity ( avatar . Id )
325
361
. SetKey ( 666 )
326
362
. Build ( ) ) ;
327
363
328
364
playerConnection . SendMessage ( NetMessagePowerCollectionUnassignPower . CreateBuilder ( )
329
- . SetEntityId ( avatarEntityId )
365
+ . SetEntityId ( avatar . Id )
330
366
. SetPowerProtoId ( ( ulong ) PowerPrototypes . GhostRider . RideBikeHotspotsEnd )
331
367
. Build ( ) ) ;
332
368
@@ -340,9 +376,16 @@ private void OnEndTravel(PlayerConnection playerConnection, PrototypeId powerId)
340
376
case ( PrototypeId ) PowerPrototypes . Travel . BladeRide :
341
377
case ( PrototypeId ) PowerPrototypes . Travel . AntmanFlight :
342
378
case ( PrototypeId ) PowerPrototypes . Travel . ThingFlight :
379
+ if ( avatar . ConditionCollection . GetCondition ( 667 ) == null ) return ;
380
+
343
381
Logger . Trace ( $ "EventEnd Ride") ;
382
+
383
+ // Remove the ride condition
384
+ avatar . ConditionCollection . RemoveCondition ( 667 ) ;
385
+
386
+ // Notify the client
344
387
playerConnection . SendMessage ( NetMessageDeleteCondition . CreateBuilder ( )
345
- . SetIdEntity ( avatarEntityId )
388
+ . SetIdEntity ( avatar . Id )
346
389
. SetKey ( 667 )
347
390
. Build ( ) ) ;
348
391
@@ -443,23 +486,33 @@ private void OnEndThrowing(PlayerConnection playerConnection, PrototypeId powerI
443
486
444
487
private void OnDiamondFormActivate ( PlayerConnection playerConnection )
445
488
{
446
- var conditionSerializationFlags = ConditionSerializationFlags . NoCreatorId | ConditionSerializationFlags . NoUltimateCreatorId | ConditionSerializationFlags . NoConditionPrototypeRef
447
- | ConditionSerializationFlags . HasCreatorPowerIndex | ConditionSerializationFlags . HasOwnerAssetRef | ConditionSerializationFlags . OwnerAssetRefOverride ;
489
+ Avatar avatar = playerConnection . Player . CurrentAvatar ;
448
490
449
- var diamondFormCondition = ( PrototypeId ) PowerPrototypes . EmmaFrost . DiamondFormCondition ;
450
- AddConditionArchive conditionArchive = new ( playerConnection . Player . CurrentAvatar . Id , 111 , conditionSerializationFlags , diamondFormCondition , TimeSpan . Zero ) ;
491
+ Condition diamondFormCondition = avatar . ConditionCollection . GetCondition ( 111 ) ;
492
+ if ( diamondFormCondition != null ) return ;
451
493
452
494
Logger . Trace ( $ "Event Start EmmaDiamondForm") ;
453
495
454
- PrototypeId emmaCostume = playerConnection . Player . CurrentAvatar . Properties [ PropertyEnum . CostumeCurrent ] ;
455
-
496
+ // Get the asset id for the current costume to set the correct owner asset id override
497
+ PrototypeId emmaCostume = avatar . Properties [ PropertyEnum . CostumeCurrent ] ;
456
498
// Invalid prototype id is the same as the default costume
457
499
if ( emmaCostume == PrototypeId . Invalid )
458
- emmaCostume = GameDatabase . GetPrototypeRefByName ( "Entity/Items/Costumes/Prototypes/EmmaFrost/Modern.prototype" ) ;
500
+ emmaCostume = GameDatabase . GetPrototypeRefByName ( "Entity/Items/Costumes/Prototypes/EmmaFrost/Modern.prototype" ) ; // MarvelPlayer_EmmaFrost_Modern
501
+
502
+ AssetId costumeAsset = emmaCostume . As < CostumePrototype > ( ) . CostumeUnrealClass ;
503
+
504
+ // Create and add a condition for the diamond form
505
+ diamondFormCondition = avatar . ConditionCollection . AllocateCondition ( ) ;
506
+ diamondFormCondition . InitializeFromPowerMixinPrototype ( 111 , ( PrototypeId ) PowerPrototypes . EmmaFrost . DiamondFormCondition , 0 , TimeSpan . Zero , true , costumeAsset ) ;
507
+ avatar . ConditionCollection . AddCondition ( diamondFormCondition ) ;
459
508
460
- var asset = GameDatabase . GetPrototype < CostumePrototype > ( emmaCostume ) . CostumeUnrealClass ;
461
- conditionArchive . Condition . OwnerAssetRef = asset ; // MarvelPlayer_EmmaFrost_Modern
462
- conditionArchive . Condition . CreatorPowerIndex = 0 ;
509
+ // Notify the client
510
+ AddConditionArchive conditionArchive = new ( )
511
+ {
512
+ ReplicationPolicy = AOINetworkPolicyValues . DefaultPolicy ,
513
+ EntityId = avatar . Id ,
514
+ Condition = diamondFormCondition
515
+ } ;
463
516
464
517
playerConnection . SendMessage ( NetMessageAddCondition . CreateBuilder ( )
465
518
. SetArchiveData ( conditionArchive . SerializeToByteString ( ) )
@@ -468,40 +521,62 @@ private void OnDiamondFormActivate(PlayerConnection playerConnection)
468
521
469
522
private void OnDiamondFormDeactivate ( PlayerConnection playerConnection )
470
523
{
524
+ Avatar avatar = playerConnection . Player . CurrentAvatar ;
525
+
471
526
// TODO: get DiamondFormCondition Condition Key
527
+ if ( avatar . ConditionCollection . GetCondition ( 111 ) == null ) return ;
528
+
529
+ Logger . Trace ( $ "EventEnd EmmaDiamondForm") ;
530
+
531
+ // Remove the condition server-side
532
+ avatar . ConditionCollection . RemoveCondition ( 111 ) ;
533
+
534
+ // Notify the client
472
535
playerConnection . SendMessage ( NetMessageDeleteCondition . CreateBuilder ( )
473
536
. SetKey ( 111 )
474
- . SetIdEntity ( playerConnection . Player . CurrentAvatar . Id )
537
+ . SetIdEntity ( avatar . Id )
475
538
. Build ( ) ) ;
476
-
477
- Logger . Trace ( $ "EventEnd EmmaDiamondForm") ;
478
539
}
479
540
480
- private void OnStartMagikUltimate ( PlayerConnection playerConnection , NetStructPoint3 position )
541
+ private bool OnStartMagikUltimate ( PlayerConnection playerConnection , NetStructPoint3 position )
481
542
{
482
- ulong avatarEntityId = playerConnection . Player . CurrentAvatar . Id ;
543
+ Avatar avatar = playerConnection . Player . CurrentAvatar ;
483
544
484
- var conditionSerializationFlags = ConditionSerializationFlags . NoCreatorId | ConditionSerializationFlags . NoUltimateCreatorId | ConditionSerializationFlags . NoConditionPrototypeRef
485
- | ConditionSerializationFlags . HasCreatorPowerIndex | ConditionSerializationFlags . HasOwnerAssetRef | ConditionSerializationFlags . HasDuration ;
545
+ Condition magikUltimateCondition = avatar . ConditionCollection . GetCondition ( 777 ) ;
546
+ if ( magikUltimateCondition != null ) return Logger . WarnReturn ( false , "OnStartMagikUltimate(): magikUltimateCondition != null" ) ;
486
547
487
548
Logger . Trace ( $ "EventStart Magik Ultimate") ;
488
549
489
- AddConditionArchive conditionArchive = new ( avatarEntityId , 777 , conditionSerializationFlags , ( PrototypeId ) PowerPrototypes . Magik . Ultimate , TimeSpan . Zero ) ;
490
- conditionArchive . Condition . Duration = TimeSpan . FromMilliseconds ( 20000 ) ;
491
- conditionArchive . Condition . CreatorPowerIndex = 0 ;
492
-
493
- playerConnection . SendMessage ( NetMessageAddCondition . CreateBuilder ( )
494
- . SetArchiveData ( conditionArchive . SerializeToByteString ( ) )
495
- . Build ( ) ) ;
550
+ // Create and add a condition for the ultimate
551
+ magikUltimateCondition = avatar . ConditionCollection . AllocateCondition ( ) ;
552
+ magikUltimateCondition . InitializeFromPowerMixinPrototype ( 777 , ( PrototypeId ) PowerPrototypes . Magik . Ultimate , 0 , TimeSpan . FromMilliseconds ( 20000 ) ) ;
553
+ avatar . ConditionCollection . AddCondition ( magikUltimateCondition ) ;
496
554
555
+ /*
556
+ // Create the arena entity
497
557
WorldEntity arenaEntity = _game.EntityManager.CreateWorldEntityEmpty(
498
558
playerConnection.AOI.Region.Id,
499
559
(PrototypeId)PowerPrototypes.Magik.UltimateArea,
500
560
new(position.X, position.Y, position.Z), new());
501
561
502
- // we need to store this state in the avatar entity instead
562
+
563
+ // Save the entity id for the arena entity (we need to store this state in the avatar entity instead)
503
564
playerConnection.MagikUltimateEntityId = arenaEntity.Id;
565
+ */
566
+
567
+ // Notify the client
568
+ AddConditionArchive conditionArchive = new ( )
569
+ {
570
+ ReplicationPolicy = AOINetworkPolicyValues . DefaultPolicy ,
571
+ EntityId = avatar . Id ,
572
+ Condition = magikUltimateCondition
573
+ } ;
504
574
575
+ playerConnection . SendMessage ( NetMessageAddCondition . CreateBuilder ( )
576
+ . SetArchiveData ( conditionArchive . SerializeToByteString ( ) )
577
+ . Build ( ) ) ;
578
+
579
+ /*
505
580
playerConnection.SendMessage(arenaEntity.ToNetMessageEntityCreate());
506
581
507
582
playerConnection.SendMessage(NetMessagePowerCollectionAssignPower.CreateBuilder()
@@ -514,31 +589,53 @@ private void OnStartMagikUltimate(PlayerConnection playerConnection, NetStructPo
514
589
.SetItemVariation(1)
515
590
.Build());
516
591
517
- playerConnection . SendMessage ( Property . ToNetMessageSetProperty ( arenaEntity . Properties . ReplicationId , new ( PropertyEnum . AttachedToEntityId ) , avatarEntityId ) ) ;
592
+ playerConnection.SendMessage(Property.ToNetMessageSetProperty(arenaEntity.Properties.ReplicationId, new(PropertyEnum.AttachedToEntityId), avatar.Id));
593
+ */
594
+
595
+ return true ;
518
596
}
519
597
520
- private void OnEndMagikUltimate ( PlayerConnection playerConnection )
598
+ private bool OnEndMagikUltimate ( PlayerConnection playerConnection )
521
599
{
600
+ // Make sure we still get Magik in case the player switched to another avatar
601
+ Avatar avatar = playerConnection . Player . AvatarList . FirstOrDefault ( avatar => avatar . PrototypeDataRef == ( PrototypeId ) AvatarPrototypeId . Magik ) ;
602
+ if ( avatar == null ) return Logger . WarnReturn ( false , "OnEndMagikUltimate(): avatar == null" ) ;
603
+
604
+ Condition magikUltimateCondition = avatar . ConditionCollection . GetCondition ( 777 ) ;
605
+ if ( magikUltimateCondition == null ) return Logger . WarnReturn ( false , "OnEndMagikUltimate(): magikUltimateCondition == null" ) ;
606
+
522
607
Logger . Trace ( $ "EventEnd Magik Ultimate") ;
523
- ulong avatarEntityId = playerConnection . Player . CurrentAvatar . Id ;
608
+
609
+ // Remove the ultimate condition
610
+ avatar . ConditionCollection . RemoveCondition ( 777 ) ;
611
+
612
+ /*
613
+ // TODO: Removed the hotspot effect power from the arena's power collection
614
+
615
+ // Destroy the arena entity
524
616
ulong arenaEntityId = playerConnection.MagikUltimateEntityId;
617
+ var entity = _game.EntityManager.GetEntityById(arenaEntityId);
618
+ entity?.Destroy();
619
+ */
525
620
621
+ // Notify the client
526
622
playerConnection . SendMessage ( NetMessageDeleteCondition . CreateBuilder ( )
527
- . SetIdEntity ( avatarEntityId )
623
+ . SetIdEntity ( avatar . Id )
528
624
. SetKey ( 777 )
529
625
. Build ( ) ) ;
530
626
627
+ /*
531
628
playerConnection.SendMessage(NetMessagePowerCollectionUnassignPower.CreateBuilder()
532
629
.SetEntityId(arenaEntityId)
533
630
.SetPowerProtoId((ulong)PowerPrototypes.Magik.UltimateHotspotEffect)
534
631
.Build());
535
632
536
- var entity = _game . EntityManager . GetEntityById ( arenaEntityId ) ;
537
- entity ? . Destroy ( ) ;
538
-
539
633
playerConnection.SendMessage(NetMessageEntityDestroy.CreateBuilder()
540
634
.SetIdEntity(arenaEntityId)
541
635
.Build());
636
+ */
637
+
638
+ return true ;
542
639
}
543
640
544
641
private void OnGetRegion ( PlayerConnection playerConnection , Region region )
0 commit comments