generated from Jaysyn/ModuleTemplate
313 lines
8.7 KiB
Plaintext
313 lines
8.7 KiB
Plaintext
/*const int SPAWNPOINT_DATA_COUNT=26;
|
|
|
|
int GetDataIntFromSpawn(object oSubject, string sDataString)
|
|
{
|
|
string sData=GetLocalString(oSubject,"Data");
|
|
if(sDataString=="SpawnType")
|
|
{
|
|
return StringToInt(GetSubString(sData,1,2));
|
|
}
|
|
if(sDataString=="AreaID")
|
|
{
|
|
return StringToInt(GetSubString(sData,3,2));
|
|
}
|
|
if(sDataString=="Unique")
|
|
{
|
|
return StringToInt(GetSubString(sData,5,1));
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void SetDataIntToSpawn(object oSubject, string sDataString, int nValue)
|
|
{
|
|
string sData=GetLocalString(oSubject,"Data");
|
|
string sInput;
|
|
if(sDataString=="SpawnType")
|
|
{
|
|
if(nValue<10)
|
|
{
|
|
sInput="0"+IntToString(nValue);
|
|
}
|
|
else
|
|
{
|
|
sInput=GetStringRight(IntToString(nValue),2);
|
|
}
|
|
sData=sInput+GetStringRight(sData,3);
|
|
}
|
|
else if(sDataString=="AreaID")
|
|
{
|
|
if(nValue<10)
|
|
{
|
|
sInput="0"+IntToString(nValue);
|
|
}
|
|
else
|
|
{
|
|
sInput=GetStringRight(IntToString(nValue),2);
|
|
}
|
|
sData=GetStringLeft(sData,2)+sInput+GetStringRight(sData,1);
|
|
}
|
|
else if(sDataString=="Unique")
|
|
{
|
|
sInput=GetStringRight(IntToString(nValue),1);
|
|
sData=GetStringLeft(sData,4)+sInput;
|
|
}
|
|
SetLocalString(oSubject,"Data",sData);
|
|
}
|
|
|
|
void SetSpawnPointSpawnType(object oSubject, int nValue)
|
|
{
|
|
string sData=GetLocalString(oSubject,"Data");
|
|
string sInput;
|
|
int nLength=2;
|
|
int nStart=1;
|
|
if(nValue<10)
|
|
{
|
|
sInput="0"+IntToString(nValue);
|
|
}
|
|
else
|
|
{
|
|
sInput=GetStringRight(IntToString(nValue),nLength);
|
|
}
|
|
sData=GetStringLeft(sData,nStart-1)+sInput+GetStringRight(sData,SPAWNPOINT_DATA_COUNT-(nLength+(nStart-1)));
|
|
SetLocalString(oSubject,"Data",sData);
|
|
}
|
|
|
|
void SetSpawnPointAreaID(object oSubject, int nValue)
|
|
{
|
|
string sData=GetLocalString(oSubject,"Data");
|
|
string sInput;
|
|
int nLength=2;
|
|
int nStart=3;
|
|
if(nValue<10)
|
|
{
|
|
sInput="0"+IntToString(nValue);
|
|
}
|
|
else
|
|
{
|
|
sInput=GetStringRight(IntToString(nValue),nLength);
|
|
}
|
|
sData=GetStringLeft(sData,nStart-1)+sInput+GetStringRight(sData,SPAWNPOINT_DATA_COUNT-(nLength+(nStart-1)));
|
|
SetLocalString(oSubject,"Data",sData);
|
|
}
|
|
|
|
void SetSpawnPointUnique(object oSubject, int nValue)
|
|
{
|
|
string sData=GetLocalString(oSubject,"Data");
|
|
string sInput;
|
|
int nLength=1;
|
|
int nStart=5;
|
|
sInput=GetStringRight(IntToString(nValue),nLength);
|
|
sData=GetStringLeft(sData,nStart-1)+sInput+GetStringRight(sData,SPAWNPOINT_DATA_COUNT-(nLength+(nStart-1)));
|
|
SetLocalString(oSubject,"Data",sData);
|
|
}
|
|
|
|
void SetSpawnPointStrength(object oSubject, int nValue)
|
|
{
|
|
string sData=GetLocalString(oSubject,"Data");
|
|
string sInput;
|
|
int nLength=1;
|
|
int nStart=6;
|
|
sInput=GetStringRight(IntToString(nValue),nLength);
|
|
sData=GetStringLeft(sData,nStart-1)+sInput+GetStringRight(sData,SPAWNPOINT_DATA_COUNT-(nLength+(nStart-1)));
|
|
SetLocalString(oSubject,"Data",sData);
|
|
}*/
|
|
|
|
/*void SetSpawnPointDynamicFaction(object oSubject, string sValue)
|
|
{
|
|
string sData=GetLocalString(oSubject,"Data");
|
|
string sInput;
|
|
int nLength=20;
|
|
int nStart=7;
|
|
if(nValue<10)
|
|
{
|
|
sInput="0"+IntToString(nValue);
|
|
}
|
|
else
|
|
{
|
|
sInput=GetStringRight(IntToString(nValue),nLength);
|
|
}
|
|
sData=GetStringLeft(sData,nStart-1)+sInput+GetStringRight(sData,SPAWNPOINT_DATA_COUNT-(nLength+(nStart-1)));
|
|
SetLocalString(oSubject,"Data",sData);
|
|
}
|
|
|
|
TestStringAgainstPattern*/
|
|
|
|
int TimeStamp()
|
|
{
|
|
int nYear=GetCalendarYear();
|
|
int nMonth=GetCalendarMonth();
|
|
int nDay=GetCalendarDay();
|
|
int nHour=GetTimeHour();
|
|
int nTimeStamp=(((nYear*12)+nMonth-1)*28+nDay-1)*24+nHour;
|
|
return nTimeStamp;
|
|
}
|
|
|
|
int GetIsDynamicFactionActive(object oDynamicFaction)
|
|
{
|
|
int nTemp=1;
|
|
while(GetLocalString(oDynamicFaction,"Area"+IntToString(nTemp))!="")
|
|
{
|
|
object oTemp=GetObjectByTag(GetLocalString(oDynamicFaction,"Area"+IntToString(nTemp)));
|
|
if(oTemp!=OBJECT_INVALID&&GetLocalInt(oTemp,"Activated"))
|
|
{
|
|
return 1;
|
|
}
|
|
nTemp++;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void DynamicFactionGainPower(object oDynamicFaction)
|
|
{
|
|
int nCurrentTime=TimeStamp();
|
|
int nLastUpdate=GetLocalInt(oDynamicFaction,"LastUpdate");
|
|
if(nLastUpdate==0)
|
|
{
|
|
nLastUpdate=GetLocalInt(GetModule(),"LoadTime");
|
|
}
|
|
//Calculate current power
|
|
float fCurrentPower=GetLocalFloat(oDynamicFaction,"CurrentPower");
|
|
int nTimePassed=nCurrentTime-nLastUpdate;
|
|
float fDaysPassed=IntToFloat(nTimePassed)/24.0;
|
|
float fPowerIncreaseConstant=IntToFloat(GetLocalInt(oDynamicFaction,"PowerIncreaseConstant"));
|
|
float fPowerIncreasePercent=IntToFloat(GetLocalInt(oDynamicFaction,"PowerIncreasePercent"));
|
|
float fPowerChange=fDaysPassed*fPowerIncreaseConstant*(pow(1.0+fPowerIncreasePercent/100.0,fDaysPassed))+fCurrentPower*(pow(1.0+fPowerIncreasePercent/100.0,fDaysPassed)-1.0);
|
|
fCurrentPower=fCurrentPower+(fPowerChange*(100.0-fCurrentPower))/(fPowerChange+100.0);
|
|
if(fCurrentPower>100.0)
|
|
{
|
|
fCurrentPower=100.0;
|
|
}
|
|
SetLocalFloat(oDynamicFaction,"CurrentPower",fCurrentPower);
|
|
//Update the time info
|
|
SetLocalInt(oDynamicFaction,"LastUpdate",nCurrentTime);
|
|
}
|
|
|
|
void DynamicFactionLoosePower(object oDynamicFaction)
|
|
{
|
|
float fLoss=GetLocalFloat(oDynamicFaction,"CurrentLoss");
|
|
//float fTotalStrength=GetLocalFloat(oDynamicFaction,"TotalStrength");
|
|
float fCurrentPower=GetLocalFloat(oDynamicFaction,"CurrentPower");
|
|
//fCurrentPower-=(fLoss/fTotalStrength);
|
|
fCurrentPower-=fLoss;
|
|
if(fCurrentPower<0.0)
|
|
{
|
|
fCurrentPower=0.0;
|
|
}
|
|
SetLocalFloat(oDynamicFaction,"CurrentLoss",0.0);
|
|
SetLocalFloat(oDynamicFaction,"CurrentPower",fCurrentPower);
|
|
}
|
|
|
|
void SpawnDeathLoss(object oSpawn)
|
|
{
|
|
object oDynamicFaction=GetLocalObject(oSpawn,"DynamicFaction");
|
|
float fCost=GetLocalFloat(oSpawn,"Cost");
|
|
//float fCR=GetChallengeRating(OBJECT_SELF);
|
|
//int nUpgrade=GetLocalInt(OBJECT_SELF,"Upgrade");
|
|
//float fTotalCost=GetLocalFloat(oDynamicFaction,"TotalCost");
|
|
//float fTotalCost=GetLocalFloat(oDynamicFaction,"TotalCost"+IntToString(nUpgrade));
|
|
//float fCurrentPower=GetLocalFloat(oDynamicFaction,"CurrentPower");
|
|
float fCurrentLoss=GetLocalFloat(oDynamicFaction,"CurrentLoss");
|
|
fCurrentLoss+=fCost;
|
|
/*if(fCurrentLoss>100.0)
|
|
{
|
|
fCurrentLoss=100.0;
|
|
}*/
|
|
SetLocalFloat(oDynamicFaction,"CurrentLoss",fCurrentLoss);
|
|
}
|
|
|
|
|
|
void ConstantEffectOn(object oPlaceable)
|
|
{
|
|
effect eVFX=SupernaturalEffect(EffectVisualEffect(GetLocalInt(oPlaceable,"ConstantEffectVFX")));
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVFX,oPlaceable);
|
|
if(GetLocalInt(oPlaceable,"ConstantEffectVFX2"))
|
|
{
|
|
effect eVFX2=SupernaturalEffect(EffectVisualEffect(GetLocalInt(oPlaceable,"ConstantEffectVFX2")));
|
|
eVFX=EffectLinkEffects(eVFX2,eVFX);
|
|
}
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVFX,oPlaceable);
|
|
}
|
|
|
|
void ConstantEffectOff(object oPlaceable)
|
|
{
|
|
effect eEffect=GetFirstEffect(oPlaceable);
|
|
while(GetIsEffectValid(eEffect)==TRUE)
|
|
{
|
|
if(GetEffectType(eEffect)==EFFECT_TYPE_VISUALEFFECT)
|
|
{
|
|
RemoveEffect(oPlaceable, eEffect);
|
|
}
|
|
eEffect=GetNextEffect(oPlaceable);
|
|
}
|
|
}
|
|
|
|
void PlaceableActivate(object oPlaceable)
|
|
{
|
|
AssignCommand(oPlaceable,PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
|
|
if(GetLocalInt(oPlaceable,"OnOffVFX"))
|
|
{
|
|
effect eVFX=SupernaturalEffect(EffectVisualEffect(GetLocalInt(oPlaceable,"OnOffVFX")));
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVFX,oPlaceable);
|
|
}
|
|
}
|
|
|
|
void PlaceableDeactivate(object oPlaceable)
|
|
{
|
|
AssignCommand(oPlaceable,PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE));
|
|
if(GetLocalInt(oPlaceable,"OnOffVFX"))
|
|
{
|
|
effect eEffect=GetFirstEffect(oPlaceable);
|
|
while(GetIsEffectValid(eEffect)==TRUE)
|
|
{
|
|
if(GetEffectType(eEffect)==EFFECT_TYPE_VISUALEFFECT)
|
|
{
|
|
RemoveEffect(oPlaceable, eEffect);
|
|
}
|
|
eEffect=GetNextEffect(oPlaceable);
|
|
}
|
|
}
|
|
if(GetLocalInt(oPlaceable,"ConstantEffectVFX"))
|
|
{
|
|
ConstantEffectOn(oPlaceable);
|
|
}
|
|
}
|
|
|
|
void PlaceableClose(object oPlaceable)
|
|
{
|
|
if(GetIsOpen(oPlaceable))
|
|
{
|
|
AssignCommand(oPlaceable,PlayAnimation(ANIMATION_PLACEABLE_CLOSE));
|
|
}
|
|
}
|
|
|
|
void DoorClose(object oDoor)
|
|
{
|
|
if(GetIsOpen(oDoor))
|
|
{
|
|
AssignCommand(oDoor,ActionCloseDoor(oDoor));
|
|
}
|
|
}
|
|
|
|
void PlaceableOpen(object oPlaceable)
|
|
{
|
|
if(!GetIsOpen(oPlaceable))
|
|
{
|
|
AssignCommand(oPlaceable,PlayAnimation(ANIMATION_PLACEABLE_OPEN));
|
|
}
|
|
}
|
|
|
|
void DoorOpen(object oDoor)
|
|
{
|
|
if(!GetIsOpen(oDoor))
|
|
{
|
|
AssignCommand(oDoor,ActionOpenDoor(oDoor));
|
|
}
|
|
}
|
|
|
|
void UpdateAreaLightning(object oArea)
|
|
{
|
|
}
|
|
|
|
|
|
|