- Joined
- May 2, 2013
- Messages
- 96
- Reaction score
- 141
Here's how I made it.
- Golden Aura
- Shield icon
- Can't shoot while in spawn protection
- Zombies do not attack
- Blocks grenade damage
Code marked in red is what you should add or change.
In WarZ.sln
UserProfile.h
Code:
enum {
GAMEFLAG_NearPostBox = (1 << 0),
[COLOR=#FF0000] GAMEFLAG_SpawnProtection = (1 << 1),[/COLOR]
};
AI_Player.CPP
Code:
{
if(r3dGetTime() < m_MorhineShotTime && m_AuraType == AT_NONE)
m_AuraType = AT_MORHINE;
if(m_AuraType == AT_MORHINE && r3dGetTime() > m_MorhineShotTime)
m_AuraType = AT_NONE;
[COLOR=#FF0000] if(m_AuraType == AT_SPAWNPROTECTION)
if(!(CurLoadout.GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection))
m_AuraType = AT_NONE;
if(CurLoadout.GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection)
m_AuraType = AT_SPAWNPROTECTION;[/COLOR]
}
AI_Player.CPP
Code:
{
float bloodAlpha = 1.0f-R3D_MIN(r3dGetTime()-lastTimeHit, 1.0f);
hudMain->setBloodAlpha(bloodAlpha);
}
bAllowToUseWeapons = true;
[COLOR=#FF0000] if((CurLoadout.GameFlags & wiCharDataFull::GAMEFLAG_NearPostBox) || (CurLoadout.GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection))
bAllowToUseWeapons = false;[/COLOR]
hudMain->showSafeZoneWarning(!bAllowToUseWeapons);
hudMain->setVisibility(lifeProperties.getPlayerVisibility());
hudMain->setHearing(lifeProperties.getPlayerHearRadius());
AI_Player.CPP
Code:
bool canDamageTarget(const GameObject* obj)
{
[COLOR=#FF0000] if(obj->isObjType(OBJTYPE_Human) && !(((obj_Player*)obj)->CurLoadout.GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection))[/COLOR]
return true;
In WarZ_Server.sln
obj_ServerPlayer.cpp
Code:
// can't fire in safe zones
[COLOR=#FF0000] if((loadout_->GameFlags & wiCharDataFull::GAMEFLAG_NearPostBox) || (loadout_->GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection) || profile_.ProfileData.isGod)[/COLOR]
{
return false;
}
obj_ServerPlayer.cpp
Code:
void obj_ServerPlayer::UpdateGameWorldFlags()
{
loadout_->GameFlags = 0;
[COLOR=#FF0000] if((((r3dGetTime() - startPlayTime_) <= 30.0f))) // 30 second spawn protection
loadout_->GameFlags |= wiCharDataFull::GAMEFLAG_SpawnProtection;[/COLOR]
ServerGameLogic.cpp
Code:
// state is grabbed from the dynamics. [0] is from player in the air, [1] is target player in the air
bool ServerGameLogic::ApplyDamageToPlayer(GameObject* fromObj, obj_ServerPlayer* targetPlr, const r3dPoint3D& dmgPos, float damage, int bodyBone, int bodyPart, bool force_damage, STORE_CATEGORIES damageSource, int airState )
{
r3d_assert(fromObj);
r3d_assert(targetPlr);
if(targetPlr->loadout_->Alive == 0 || targetPlr->profile_.ProfileData.isGod)
return false;
if(fromObj->isObjType(OBJTYPE_Human) && ((obj_ServerPlayer*)fromObj)->profile_.ProfileData.isGod)
return false;
[COLOR=#FF0000] // can't damage players in safe zones (postbox now act like that)
if(((targetPlr->loadout_->GameFlags & wiCharDataFull::GAMEFLAG_NearPostBox) || (targetPlr->loadout_->GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection)) && !force_damage)
return false;[/COLOR]
ServerGameLogic.cpp
Inside IMPL_PACKET_FUNC(ServerGameLogic, PKT_C2S_Temp_Damage)
Code:
GameObject* target = GameWorld().GetNetworkObject(n.targetId);
if(!target)
{
//r3dOutToLog("PKT_C2S_Temp_Damage: targetPlr is NULL\n");
return;
}
[COLOR=#FF0000] obj_ServerPlayer* targetPlr = IsServerPlayer(target);
if(targetPlr && ((targetPlr->profile_.ProfileData.isDevAccount && targetPlr->profile_.ProfileData.isGod) || (targetPlr->loadout_ && (targetPlr->loadout_->GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection))))
{
return;
}[/COLOR]
const WeaponConfig* wc = g_pWeaponArmory->getWeaponConfig(101310);
ServerGameLogic.cpp
Code:
bool ServerGameLogic::CanDamageThisObject(const GameObject* targetObj)
{
[COLOR=#FF0000] obj_ServerPlayer* plr = (obj_ServerPlayer*)IsServerPlayer(targetObj);
if(plr && ((plr->profile_.ProfileData.isDevAccount && plr->profile_.ProfileData.isGod) || (plr->loadout_->GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection)))
{
return false;
}[/COLOR]
If you want zombies to ignore spawn protected players:
sobj_Zombie.cpp
Code:
bool obj_Zombie::IsPlayerDetectable(const obj_ServerPlayer* plr, float dist)
{
[COLOR=#FF0000] if(plr->loadout_->Alive == 0 || plr->profile_.ProfileData.isGod || (plr->loadout_->GameFlags & wiCharDataFull::GAMEFLAG_SpawnProtection))[/COLOR]
return false;
Last edited:

