Code: Select all
#RequireContext CSmAction
#Include "TextLib" as TextLib
#Include "MathLib" as MathLib
#Setting C_Cooldown 20000
#Setting C_EnergyCost 6400
#Setting C_EnergyMax 6400
#Setting C_EnergyReload True
#Setting C_Fragments 200
#Const C_ProjectileName1 "Projectile 1"
#Const C_AnimName "Anim1"
Cooldown = C_Cooldown;
EnergyMax = C_EnergyMax;
EnergyCost = C_EnergyCost;
EnergyReload = C_EnergyReload;
declare AnimId0 = GetAnimModelId(C_AnimName);
declare ProjectileId1 = GetProjectileModelId(C_ProjectileName1);
while (True) {
foreach (Event in PendingEvents) {
switch (Event.Type) {
case CSmActionEvent::EType::OnHitPlayer : {
SendRulesEvent("damage", [TextLib::ToText(Event.Damage)], Owner, Event.Player);
}
}
}
if (Owner.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned && IsActive && (Energy >= EnergyCost) && Cooldown_IsReady(Now) && !Owner.IsOnTechNoWeapon && !Owner.IsInWater ) {
Cooldown_Start();
Energy -= EnergyCost;
//PlayAnimOnPlayer(AnimId0, Owner);
//CreateShoot(Owner, ProjectileId1);
//Mapsize is 48x48 blocks == 384x384 meters
declare Integer Counter = 1;
while (Counter <= C_Fragments) {
declare Real PPX = MathLib::Rand(0.0, 384.0); // 192.0
declare Real PPY = 192.0;
declare Real PPZ = MathLib::Rand(0.0, 384.0); // 192.0
declare Vec3 P_Pos = <PPX, PPY, PPZ>;
declare Real Angle1 = MathLib::Rand(-0.4, 0.4);
declare Real Angle2 = MathLib::Rand(-0.4, 0.4);
declare Vec3 P_Dir = <Angle1, -1.0, Angle2>;
declare Vec3 P_Speed = <0.0, 0.0, 0.0>;
CreateProjectile(Owner, ProjectileId1, P_Pos, P_Dir, P_Speed);
SendRulesEvent("fire", Text[], Owner, Null);
Counter += 1;
sleep(C_Cooldown / C_Fragments);
}
}
yield;
}
Thus far i have rewritten it to MP4 :
Code: Select all
// MeteorShower
// Unleashes a devestating meteor shower on the whole map
// Version 01.03.2019
// Changes MP3 > MP4 :
// GetAnimModelId replaced by Anim_GetModelId
// GetProjectileModelId replaced by Projectile_GetModelId
// Event.Player replaced by Event.Victim
// PlayAnimOnPlayer replaced by Anim_PlayOnPlayer
// Bug C_EnergyReload. Tmp workaround (Eole) 01.03.2019
// Replace EnergyReload = C_EnergyReload; with
// if (Energy < EnergyMax) {
// Energy += 10;
// if (Energy > EnergyMax) {
// Energy = EnergyMax;
// }
#RequireContext CSmAction
#Include "TextLib" as TextLib
#Include "MathLib" as MathLib
#Setting C_Cooldown 20000
#Setting C_EnergyCost 6400
#Setting C_EnergyMax 6400
#Setting C_EnergyReload True
#Setting C_Fragments 200
#Const C_ProjectileName1 "Projectile 1"
#Const C_AnimName "Anim1"
main() {
Cooldown = C_Cooldown;
EnergyMax = C_EnergyMax;
EnergyCost = C_EnergyCost;
if (Energy < EnergyMax) {
Energy += 10;
if (Energy > EnergyMax) {
Energy = EnergyMax;
}
}
declare AnimId0 = Anim_GetModelId(C_AnimName);
declare ProjectileId1 = Projectile_GetModelId(C_ProjectileName1);
foreach (Event in PendingEvents) {
switch (Event.Type) {
case CSmActionEvent::EType::OnHitPlayer : {
SendRulesEvent("damage", [TextLib::ToText(Event.Damage)], Owner, Event.Victim);
}
}
}
if (Owner != Null && Owner.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned && IsActive && (Energy >= EnergyCost) && Cooldown_IsReady() && !Owner.IsOnTechNoWeapon && !Owner.IsInWater ) {
Cooldown_Start();
Energy -= EnergyCost;
//Mapsize is 48x48 blocks == 384x384 meters
declare Integer Counter = 1;
while (Counter <= C_Fragments) {
declare Real PPX = MathLib::Rand(0.0, 384.0); // 192.0
declare Real PPY = 192.0;
declare Real PPZ = MathLib::Rand(0.0, 384.0); // 192.0
declare Vec3 P_Pos = <PPX, PPY, PPZ>;
declare Real Angle1 = MathLib::Rand(-0.4, 0.4);
declare Real Angle2 = MathLib::Rand(-0.4, 0.4);
declare Vec3 P_Dir = <Angle1, -1.0, Angle2>;
declare Vec3 P_Speed = <0.0, 0.0, 0.0>;
Projectile_CreateAtLocation(ProjectileId1, Owner, P_Pos, P_Dir, P_Speed);
SendRulesEvent("fire", [], Owner, Null);
Counter += 1;
//sleep(C_Cooldown / C_Fragments);
}
}
}
I was coding something like Timer +1 on every tick and then evaluate if counter x 100 > timer, but i got quite lost in that code
This is my latest try on that:
Code: Select all
// MeteorShower
// Unleashes a devestating meteor shower on the whole map
// Version 01.03.2019
// Changes MP3 > MP4 :
// GetAnimModelId replaced by Anim_GetModelId
// GetProjectileModelId replaced by Projectile_GetModelId
// Event.Player replaced by Event.Victim
// PlayAnimOnPlayer replaced by Anim_PlayOnPlayer
// Bug C_EnergyReload. Tmp workaround (Eole) 01.03.2019
// Replace EnergyReload = C_EnergyReload; with
// if (Energy < EnergyMax) {
// Energy += 10;
// if (Energy > EnergyMax) {
// Energy = EnergyMax;
// }
#RequireContext CSmAction
#Include "TextLib" as TextLib
#Include "MathLib" as MathLib
#Setting C_Cooldown 20000
#Setting C_EnergyCost 6400
#Setting C_EnergyMax 6400
#Setting C_EnergyReload True
#Setting C_Fragments 200
#Const C_ProjectileName1 "Projectile 1"
#Const C_AnimName "Anim1"
main() {
Cooldown = C_Cooldown;
EnergyMax = C_EnergyMax;
EnergyCost = C_EnergyCost;
if (Energy < EnergyMax) {
Energy += 10;
if (Energy > EnergyMax) {
Energy = EnergyMax;
}
}
declare AnimId0 = Anim_GetModelId(C_AnimName);
declare ProjectileId1 = Projectile_GetModelId(C_ProjectileName1);
foreach (Event in PendingEvents) {
switch (Event.Type) {
case CSmActionEvent::EType::OnHitPlayer : {
SendRulesEvent("damage", [TextLib::ToText(Event.Damage)], Owner, Event.Victim);
}
}
}
if (Owner.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned && IsActive && (Energy >= EnergyCost) && Cooldown_IsReady() && !Owner.IsOnTechNoWeapon && !Owner.IsInWater ) {
Cooldown_Start();
Energy -= EnergyCost;
//Mapsize is 48x48 blocks == 384x384 meters
declare Integer Counter = 1;
declare Integer Time = 1000;
while (Counter <= C_Fragments) {
Time +=1;
if (Counter * 1000 >= Time) {
declare Real PPX = MathLib::Rand(0.0, 384.0); // 192.0
declare Real PPY = 192.0;
declare Real PPZ = MathLib::Rand(0.0, 384.0); // 192.0
declare Vec3 P_Pos = <PPX, PPY, PPZ>;
declare Real Angle1 = MathLib::Rand(-0.4, 0.4);
declare Real Angle2 = MathLib::Rand(-0.4, 0.4);
declare Vec3 P_Dir = <Angle1, -1.0, Angle2>;
declare Vec3 P_Speed = <0.0, 0.0, 0.0>;
Projectile_CreateAtLocation(ProjectileId1, Owner, P_Pos, P_Dir, P_Speed);
SendRulesEvent("fire", [], Owner, Null);
Counter += 1;
}
//sleep(C_Cooldown / C_Fragments);
}
}
}
Any one can give me a heads up on this?
14.03.2019 Solution (based on script mention in this topic)
Code: Select all
main() {
declare Integer Delay = C_Cooldown / C_Fragments // Can of course be hardcode too
declare Integer TimeToAddFragment for This = Now + Delay
if (Now >= TimeToAddFragment) {
DO STUFF HERE (fire, animate etc)
} else {
TimeToAddFragment = Now + Delay;
}