| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /******************************************************************************
- *
- * FILE
- * GroupScript.cpp
- *
- * DESCRIPTION
- * Group script
- *
- * PROGRAMMER
- * Denzil E. Long, Jr.
- *
- * VERSION INFO
- * $Author: Rich_d $
- * $Revision: 2 $
- * $Modtime: 6/14/00 12:55p $
- * $Archive: /Commando/Code/Scripts/GroupScript.cpp $
- *
- ******************************************************************************/
- #include "scripts.h"
- #include "groupcontrol.h"
- #include "group.h"
- #include "customevents.h"
- #include "dprint.h"
- DECLARE_SCRIPT(MXX_Group_Member_DEL, "GroupName:string")
- {
- const char* mGroupName;
- // Add the object to the group when it is created.
- void Created(GameObject* owner)
- {
- mGroupName = Get_Parameter("GroupName");
- assert(mGroupName != NULL);
- GroupController* controller = GroupController::Instance();
- assert(controller != NULL);
- controller->AddToGroup(mGroupName, owner);
- }
-
- // Remove the object from the group when it is destroyed.
- void Destroyed(GameObject* owner)
- {
- GroupController* controller = GroupController::Instance();
- assert(controller != NULL);
- controller->RemoveFromGroup(mGroupName, owner);
- }
- // Notify group that a member was killed.
- void Killed(GameObject* owner, GameObject* killer)
- {
- GroupController* controller = GroupController::Instance();
- assert(controller != NULL);
- GroupEventInfo info;
- info.GroupName = mGroupName;
- info.Event = GROUP_MEMBER_KILLED;
- info.Object = killer;
- Group* group = controller->FindGroup(mGroupName);
- assert(group != NULL);
- group->SendCustomEvent(owner, SCMD_GROUP_EVENT, (int)&info);
- }
-
- // Notify group that a member was damaged.
- void Damaged(GameObject* owner, GameObject* damager)
- {
- GroupController* controller = GroupController::Instance();
- assert(controller != NULL);
- GroupEventInfo info;
- info.GroupName = mGroupName;
- info.Event = GROUP_MEMBER_DAMAGED;
- info.Object = damager;
- Group* group = controller->FindGroup(mGroupName);
- assert(group != NULL);
- group->SendCustomEvent(owner, SCMD_GROUP_EVENT, (int)&info);
- }
- // Notify group that a member heard a sound.
- void Sound_Heard(GameObject* owner, const CombatSound& sound)
- {
- GroupController* controller = GroupController::Instance();
- assert(controller != NULL);
- GroupEventInfo info;
- info.GroupName = mGroupName;
- info.Event = GROUP_MEMBER_HEARD;
- info.Sound = &sound;
- Group* group = controller->FindGroup(mGroupName);
- assert(group != NULL);
- group->SendCustomEvent(owner, SCMD_GROUP_EVENT, (int)&info);
- }
- // Notify group that a member saw the enemy.
- void Enemy_Seen(GameObject* owner, GameObject* enemy)
- {
- GroupController* controller = GroupController::Instance();
- assert(controller != NULL);
- GroupEventInfo info;
- info.GroupName = mGroupName;
- info.Event = GROUP_MEMBER_SAW;
- info.Object = enemy;
- Group* group = controller->FindGroup(mGroupName);
- assert(group != NULL);
- group->SendCustomEvent(owner, SCMD_GROUP_EVENT, (int)&info);
- }
- #ifdef _DEBUG
- void Custom(GameObject* owner, int event, int data, GameObject* sender)
- {
- if (SCMD_GROUP_EVENT == event)
- {
- GroupEventInfo* info = (GroupEventInfo*)data;
- assert(info != NULL);
- int senderID = Commands->Get_ID(sender);
- int objectID = Commands->Get_ID(info->Object);
- switch (info->Event)
- {
- case GROUP_MEMBER_DAMAGED:
- DebugPrint("Group %s member %d damaged by object %d\n",
- info->GroupName, senderID, objectID);
- break;
- case GROUP_MEMBER_KILLED:
- DebugPrint("Group %s member %d killed by object %d\n",
- info->GroupName, senderID, objectID);
- break;
- case GROUP_MEMBER_HEARD:
- {
- const CombatSound* sound = info->Sound;
- objectID = Commands->Get_ID(sound->Creator);
- DebugPrint("Group %s member %d heard a sound from object %d\n",
- info->GroupName, senderID, objectID);
- }
- break;
- case GROUP_MEMBER_SAW:
- DebugPrint("Group %s member %d saw object %d\n",
- info->GroupName, senderID, objectID);
- break;
- default:
- break;
- }
- }
- }
- #endif
- };
|