Skip to content

Commit

Permalink
[added] Field faction change functionality when attacking an opposing
Browse files Browse the repository at this point in the history
faction npc while not being the correct faction status

Change-Id: Id5ff65e3f687d5537911ea77b4030be92fa2643e
  • Loading branch information
Miztah committed Feb 23, 2016
1 parent def80c8 commit 6ade91e
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,36 @@ class CombatQueueCommand : public QueueCommand {
PlayerObject* ghost = creature->getPlayerObject();

if (ghost != NULL) {
if (ghost->isOnLoadScreen()) {
if (ghost->isOnLoadScreen())
ghost->setOnLoadScreen(false);
}

if (ghost->isAFK()) {
if (ghost->isAFK())
return GENERALERROR;

ManagedReference<TangibleObject*> targetTano = targetObject.castTo<TangibleObject*>();

if (targetTano != NULL && creature->getFaction() != 0 && targetTano->getFaction() != 0 && targetTano->getFaction() != creature->getFaction() && ghost->getFactionStatus() != FactionStatus::OVERT) {
if (targetTano->isCreatureObject()) {
ManagedReference<CreatureObject*> targetCreature = targetObject.castTo<CreatureObject*>();

if (targetCreature != NULL) {
if (targetCreature->isPlayerCreature()) {
PlayerObject* targetGhost = targetCreature->getPlayerObject();

if (targetGhost != NULL && targetGhost->getFactionStatus() == FactionStatus::OVERT) {
ghost->doFieldFactionChange(FactionStatus::OVERT);
}
} else {
if (ghost->getFactionStatus() == FactionStatus::ONLEAVE)
ghost->doFieldFactionChange(FactionStatus::COVERT);
}
}
} else {
if (ghost->getFactionStatus() == FactionStatus::ONLEAVE && !(targetTano->getPvpStatusBitmask() & CreatureFlag::OVERT))
ghost->doFieldFactionChange(FactionStatus::COVERT);
else if ((targetTano->getPvpStatusBitmask() & CreatureFlag::OVERT))
ghost->doFieldFactionChange(FactionStatus::OVERT);
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions MMOCoreORB/src/server/zone/objects/player/PlayerObject.idl
Original file line number Diff line number Diff line change
Expand Up @@ -1763,5 +1763,7 @@ class PlayerObject extends IntangibleObject {
}

public native boolean hasEventPerk(final string templatePath);

public native void doFieldFactionChange(int newStatus);
}

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#include "server/zone/objects/tangible/deed/eventperk/EventPerkDeed.h"
#include "server/zone/managers/player/QuestInfo.h"
#include "server/zone/objects/player/events/ForceMeditateTask.h"
#include "server/zone/objects/player/sui/callbacks/FieldFactionChangeSuiCallback.h"

void PlayerObjectImplementation::initializeTransientMembers() {
IntangibleObjectImplementation::initializeTransientMembers();
Expand Down Expand Up @@ -2569,3 +2570,44 @@ bool PlayerObjectImplementation::hasEventPerk(const String& templatePath) {

return false;
}

void PlayerObjectImplementation::doFieldFactionChange(int newStatus) {
int curStatus = getFactionStatus();

if (curStatus == FactionStatus::OVERT || curStatus == newStatus)
return;

CreatureObject* parent = cast<CreatureObject*>(_this.getReferenceUnsafeStaticCast()->getParent().get().get());

if (parent == NULL)
return;

uint32 pvpStatusBitmask = parent->getPvpStatusBitmask();

if (pvpStatusBitmask & CreatureFlag::CHANGEFACTIONSTATUS)
return;

if (hasSuiBoxWindowType(SuiWindowType::FIELD_FACTION_CHANGE))
closeSuiWindowType(SuiWindowType::FIELD_FACTION_CHANGE);

ManagedReference<SuiInputBox*> inputbox = new SuiInputBox(parent, SuiWindowType::FIELD_FACTION_CHANGE);
inputbox->setCallback(new FieldFactionChangeSuiCallback(server->getZoneServer(), newStatus));
inputbox->setPromptTitle("@gcw:gcw_status_change"); // GCW STATUS CHANGE CONFIRMATION
inputbox->setUsingObject(_this.getReferenceUnsafeStaticCast());
inputbox->setCancelButton(true, "@cancel");

if (newStatus == FactionStatus::COVERT) {
if (curStatus == FactionStatus::OVERT) {
parent->sendSystemMessage("@gcw:cannot_change_from_combatant_in_field"); // You cannot change you status to combatant in the field. Go talk to a faction recruiter.
return;
}

inputbox->setPromptText("@gcw:gcw_status_change_covert"); // You are changing your GCW Status to 'Combatant'. This transition will take 30 seconds. It will allow you to attack and be attacked by enemy NPC's. Type YES in this box to confirm the change.
} else if (newStatus == FactionStatus::OVERT) {
inputbox->setPromptText("@gcw:gcw_status_change_overt"); // You are changing your GCW Status to 'Special Forces'. This transition will take 5 minutes. It will allow you to attack and be attacked by hostile players and NPC's.Type YES in this box to confirm the change.
}

addSuiBox(inputbox);
parent->sendMessage(inputbox->generateMessage());
}

Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ class SuiWindowType {
DROID_ADD_STRUCTURE_AMOUNT = 1036,
PET_FIX_DIALOG = 1037,
JUKEBOX_SELECTION = 1038,
SHUTTLE_BEACON = 1039
SHUTTLE_BEACON = 1039,
FIELD_FACTION_CHANGE = 1040
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#ifndef FIELDFACTIONCHANGESUICALLBACK_H_
#define FIELDFACTIONCHANGESUICALLBACK_H_

#include "server/zone/objects/player/sui/SuiCallback.h"
#include "server/zone/objects/player/FactionStatus.h"
#include "engine/task/ScheduledTask.h"

class FieldFactionChangeSuiCallback : public SuiCallback {
private:
int newStatus;
public:
FieldFactionChangeSuiCallback(ZoneServer* server, int status)
: SuiCallback(server) {
newStatus = status;
}

void run(CreatureObject* player, SuiBox* suiBox, uint32 eventIndex, Vector<UnicodeString>* args) {
bool cancelPressed = (eventIndex == 1);

if (cancelPressed || args->size() < 1) {
player->sendSystemMessage("@gcw:abort_field_change"); // You cancel your factional change.
return;
}

String arg1 = args->get(0).toString();

if (arg1.toLowerCase() != "yes") {
player->sendSystemMessage("@gcw:abort_field_change"); // You cancel your factional change.
return;
}

uint32 pvpStatusBitmask = player->getPvpStatusBitmask();

if (pvpStatusBitmask & CreatureFlag::CHANGEFACTIONSTATUS)
return;

ManagedReference<PlayerObject*> ghost = player->getPlayerObject();

if (ghost == NULL)
return;

int curStatus = ghost->getFactionStatus();

if (curStatus == newStatus)
return;

if (newStatus == FactionStatus::COVERT) {
if (curStatus == FactionStatus::OVERT) {
player->sendSystemMessage("@gcw:cannot_change_from_combatant_in_field"); // You cannot change you status to combatant in the field. Go talk to a faction recruiter.
return;
}

player->sendSystemMessage("@gcw:handle_go_covert"); // You will be flagged as a Combatant in 30 seconds.
player->setPvpStatusBitmask(CreatureFlag::CHANGEFACTIONSTATUS);

ManagedReference<CreatureObject*> creo = player->asCreatureObject();

SCHEDULE_TASK_2(creo, newStatus, 30000, {
if (creo_p != NULL) {
Locker locker(creo_p);

PlayerObject* ghost = creo_p->getPlayerObject();

if (ghost != NULL)
ghost->setFactionStatus(newStatus_p);
}
});
} else if (newStatus == FactionStatus::OVERT) {
player->sendSystemMessage("You will be flagged as Special Forces in 5 minutes."); // No string available for overt.
player->setPvpStatusBitmask(CreatureFlag::CHANGEFACTIONSTATUS);

ManagedReference<CreatureObject*> creo = player->asCreatureObject();

SCHEDULE_TASK_2(creo, newStatus, 300000, {
if (creo_p != NULL) {
Locker locker(creo_p);

PlayerObject* ghost = creo_p->getPlayerObject();

if (ghost != NULL)
ghost->setFactionStatus(newStatus_p);
}
});
}
}
};

#endif /* FIELDFACTIONCHANGESUICALLBACK_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ void ShuttleBeaconImplementation::spawnShuttle(CreatureObject* player, int type)
return;

SCHEDULE_TASK_2(tempBeacon, player, 250, {
Locker locker(tempBeacon_p);
tempBeacon_p->landShuttle(player_p);
if (tempBeacon_p != NULL) {
Locker locker(tempBeacon_p);
tempBeacon_p->landShuttle(player_p);
}
});
}

Expand Down Expand Up @@ -193,8 +195,10 @@ void ShuttleBeaconImplementation::landShuttle(CreatureObject* player) {
shuttleStatus = 1;

SCHEDULE_TASK_1(tempBeacon, 40000, {
Locker locker(tempBeacon_p);
tempBeacon_p->setReadyToTakeOff(true);
if (tempBeacon_p != NULL) {
Locker locker(tempBeacon_p);
tempBeacon_p->setReadyToTakeOff(true);
}
});
}

Expand Down Expand Up @@ -227,8 +231,10 @@ void ShuttleBeaconImplementation::dismissShuttle(CreatureObject* player) {
player->sendSystemMessage("@event_perk:shuttle_is_leaving"); // Transmission Recieved: Shuttle is leaving the area.

SCHEDULE_TASK_2(tempBeacon, player, 20000, {
Locker locker(tempBeacon_p);
tempBeacon_p->destroyShuttle(player_p);
if (tempBeacon_p != NULL) {
Locker locker(tempBeacon_p);
tempBeacon_p->destroyShuttle(player_p);
}
});
}

Expand Down

0 comments on commit 6ade91e

Please sign in to comment.