Skip to content

Commit

Permalink
order: Change Vacate to Disband order
Browse files Browse the repository at this point in the history
  • Loading branch information
wallabra committed Jan 15, 2025
1 parent 5c180f5 commit b2821ef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
6 changes: 3 additions & 3 deletions KeyConf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defaultbind kp. "summonfriend zetabot 0"
defaultbind p "summon ZTBotAttackOrder 0"
defaultbind o "summon ZTBotFollowMeOrder 0"
defaultbind i "summon ZTBotFollowOrder 0"
defaultbind u "summon ZTBotVacateOrder 0"
defaultbind u "summon ZTBotDisbandOrder 0"
defaultbind y "summon ZTBotFleeOrder 0"

//----------
Expand All @@ -26,11 +26,11 @@ addmenukey "Kill All Bots" "kill ZetaBotPawn"
addkeysection "ZetaBot Orders" "zetabots_order"

addmenukey "Order: Attack Looked" "summon ztbotattackorder"
addmenukey "Order: Follow Self" "summon ztbotfollowmeorder"
addmenukey "Order: Follow Me" "summon ztbotfollowmeorder"
addmenukey "Order: Follow Looked" "summon ztbotfolloworder"
addmenukey "Order: Wander" "summon ztbotwanderorder"
addmenukey "Order: Flee Looked" "summon ztbotfleeorder"
addmenukey "Order: Vacate Own Orders" "summon ztbotvacateorder"
addmenukey "Order: Disband from Me" "summon ztbotdisbandorder"


addkeysection "ZetaBot Pathing" "zetabots_paths"
Expand Down
45 changes: 30 additions & 15 deletions ZScript.zs
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,26 @@ class ZTBotOrder play {
"hunt",
"attack",
"follow",
"flee"
"flee",
"disband"
};

static const String BStatePast[] = {
"wandered",
"hunted",
"attacked",
"followed",
"fled"
"fled",
"disbanded"
};

static const String BStateContinuous[] = {
"wandering",
"hunting",
"attacking",
"following",
"chickening"
"chickening",
"disbanding"
};

void Apply(ZTBotController bot) {
Expand Down Expand Up @@ -252,11 +255,7 @@ class ZTBotOrderCode: Actor {
}

ZTBotOrder ConcoctOrder(Actor subject) {
if (mySubject != ST_NOORDER) {
return ZTBotOrder.Make(Owner, subject, orderType);
}

return null;
return ZTBotOrder.Make(Owner, subject, orderType);
}

int GiveOrder(Actor subject) {
Expand All @@ -273,11 +272,16 @@ class ZTBotOrderCode: Actor {
continue;
}

if ((
(cont.commander == null && mySubject != ST_NOORDER)
|| cont.commander == Owner
|| Owner is "PlayerPawn"
) && zbp.Distance2D(owner) < owner.radius + zbp.radius + 300 && !zbp.cont.IsEnemy(zbp, owner) && zbp.CheckSight(owner)) {
if (
(
(cont.commander == null && mySubject != ST_NOORDER)
|| cont.commander == Owner
|| Owner is "PlayerPawn"
) &&
zbp.Distance2D(owner) < owner.radius + zbp.radius + 300 &&
!zbp.cont.IsEnemy(zbp, owner) &&
zbp.CheckSight(owner)
) {
if (order != null) {
order.Apply(cont);
}
Expand Down Expand Up @@ -380,9 +384,10 @@ class ZTBotFollowMeOrder : ZTBotFollowOrder {
}
}

class ZTBotVacateOrder : ZTBotOrderCode {
class ZTBotDisbandOrder : ZTBotOrderCode {
// Vacate bots around of any orders.
Default {
ZTBotOrderCode.OrderType 5; // ZetaBotPawn.ORDER_DISBAND
ZTBotOrderCode.SubjectType 2; // ZTBotOrderCode.ST_NOORDER
}
}
Expand Down Expand Up @@ -462,7 +467,8 @@ class ZTBotController : Actor {
BS_HUNTING,
BS_ATTACKING,
BS_FOLLOWING,
BS_FLEEING
BS_FLEEING,
ORDER_DISBAND
};

mixin DebugLog;
Expand Down Expand Up @@ -1245,6 +1251,11 @@ class ZTBotController : Actor {
ZTBotOrder orderGiven;

void SetOrder(ZTBotOrder newOrder) {
if (newOrder != null && newOrder.orderType == ORDER_DISBAND) {
SetCommander(null);
newOrder = null;
}

if (newOrder != null && newOrder.orderer != null) {
if (newOrder.orderer == possessed || Commands(newOrder.orderer)) {
return;
Expand All @@ -1254,6 +1265,10 @@ class ZTBotController : Actor {

if (newOrder.orderer != commander && (zbpc == null || !zbpc.cont.Commands(newOrder.orderer))) {
SetCommander(newOrder.orderer);

if (PlayerPawn(newOrder.orderer) != null) {
zbpc.cont.SetCommander(newOrder.orderer);
}
}
}

Expand Down

0 comments on commit b2821ef

Please sign in to comment.