In testing this weapon, I cant get the second stage to fire when I call for CSmActionEvent::EType::OnProjectileEnd:
also i should point out that it works when I put the second stage firing fucntions in the CSmActionEvent::EType::OnPlayerHit: but thats not how I want it to work.
Heres the code:
Any help would be greatly appreciated.
Code: Select all
#RequireContext CSmAction
#Include "TextLib" as TextLib
#Setting C_Cooldown 300
#Setting C_EnergyCost 1600
#Setting C_EnergyMax 6400
#Setting C_EnergyReload True
#Setting C_2Stage False
#Setting C_PrimingTime 100
#Const C_ProjectileName1 "Projectile 1"
#Const C_ProjectileName2 "Projectile 2"
#Const C_AnimName "Anim1"
Cooldown = C_Cooldown;
EnergyMax = C_EnergyMax;
EnergyCost = C_EnergyCost;
EnergyReload = C_EnergyReload;
declare PrimeTime = C_PrimingTime;
declare AnimId0 = GetAnimModelId(C_AnimName);
declare ProjectileId1 = GetProjectileModelId(C_ProjectileName1);
declare ProjectileId2 = GetProjectileModelId(C_ProjectileName2);
declare Boolean Prime = False;
declare Integer StartTime;
while (True) {
foreach (Event in PendingEvents) {
switch (Event.Type) {
case CSmActionEvent::EType::OnHitPlayer : {
SendRulesEvent("damage", [TextLib::ToText(Event.Damage)], Owner, Event.Player);
}
case CSmActionEvent::EType::OnProjectileEnd:{
if(Event.ProjectileModelId == ProjectileId1){
if (Prime == True){
if (Now >= StartTime + PrimeTime) {
declare Vec3 EndPos = Event.Position;
declare Vec3 EndDir = Event.Direction;
declare Vec3 Speed = Event.Normal;
CreateProjectile(Owner, ProjectileId2, EndPos, EndDir, Speed);
SendRulesEvent("fire", Text[], Owner, Null);
Prime = False;
}
}
}
}
}
}
if (Owner.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned && IsActive && (Energy >= EnergyCost) && Cooldown_IsReady(Now) && !Owner.IsOnTechNoWeapon && !Owner.IsInWater ) {
Cooldown_Start();
Energy -= EnergyCost;
PlayAnimOnPlayer(AnimId0, Owner);
if(C_2Stage == False){
CreateShoot(Owner, ProjectileId1);
SendRulesEvent("fire", Text[], Owner, Null);
} else if (C_2Stage == True){
CreateShoot(Owner, ProjectileId1);
Prime = True;
StartTime = Now;
}
}
yield;
}