@@ -867,13 +867,53 @@ void Lightning::strikeRandomPoint()
867867}
868868
869869// --------------------------------------------------------------------------
870- void Lightning::strikeObject (ShapeBase*)
870+ void Lightning::strikeObject (ShapeBase* targetObj )
871871{
872872 AssertFatal (isServerObject (), " Error, client objects may not initiate lightning!" );
873873
874- AssertFatal (false , " Lightning::strikeObject is not implemented." );
875- }
874+ Point3F strikePoint = targetObj->getPosition ();
875+ Point3F objectCenter;
876+
877+ Box3F wb = getWorldBox ();
878+ if (!wb.isContained (strikePoint))
879+ return ;
880+
881+ Point3F targetRel = strikePoint - getPosition ();
882+ Point3F length (wb.len_x () / 2 .0f , wb.len_y () / 2 .0f , wb.len_z () / 2 .0f );
883+
884+ Point3F strikePos = targetRel / length;
885+
886+ bool playerInWarmup = false ;
887+ Player *playerObj = dynamic_cast < Player * >(targetObj);
888+ if (playerObj)
889+ {
890+ if (!playerObj->getControllingClient ())
891+ {
892+ playerInWarmup = true ;
893+ }
894+ }
895+
896+ if (!playerInWarmup)
897+ {
898+ applyDamage_callback (targetObj->getWorldSphere ().center , VectorF (0.0 , 0.0 , 1.0 ), targetObj);
899+ }
900+
901+ SimGroup* pClientGroup = Sim::getClientGroup ();
902+ for (SimGroup::iterator itr = pClientGroup->begin (); itr != pClientGroup->end (); itr++) {
903+ NetConnection* nc = static_cast <NetConnection*>(*itr);
904+ if (nc != NULL )
905+ {
906+ LightningStrikeEvent* pEvent = new LightningStrikeEvent;
907+ pEvent->mLightning = this ;
908+
909+ pEvent->mStart .x = strikePoint.x ;
910+ pEvent->mStart .y = strikePoint.y ;
911+ pEvent->mTarget = targetObj;
876912
913+ nc->postNetEvent (pEvent);
914+ }
915+ }
916+ }
877917
878918// --------------------------------------------------------------------------
879919U32 Lightning::packUpdate (NetConnection* con, U32 mask, BitStream* stream)
0 commit comments