Aller au contenu

Photo

SetProjectileImpactEvent


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
edmogt1

edmogt1
  • Members
  • 52 messages
Can someone explain how this works?  Say, I want to apply damage to a target after the projectile hits the target.
What do I pass to the event parameter of SetProjectileImpactEvent and how do I handle that event?
Posted ImagePosted Image

#2
edmogt1

edmogt1
  • Members
  • 52 messages
figured it out:P

for posterity:  In case of a custom spell script,  you use id: 90210 for your event, then set your event parameters:

event evProjectileImpact = Event(90210);
SetEventInteger(evProjectileImpact, 0,  stEvent.nAbility);
SetEventObject(evProjectileImpact , 0, stEvent.oTarget);

and in the same script you add a case to the event type switch

case 90210:
{
    int nAbility = GetEventInteger(ev, 0);
Posted ImagePosted Image

#3
Craig Graff

Craig Graff
  • Members
  • 608 messages
Assuming you actually wanted to use SetProjectileImpactEvent instead of making a spell script you can find an example below (from den360cr_caladrius.nss):
[dascript]
                case CAI_CALADRIUS_DEATH_BOLT:
                {
                    object oBolt;
                    object oTarget;
                    vector vSource = GetPosition(oThis);
                    event evDeathbolt = Event(EVENT_TYPE_CALADRIUS_DEATHBOLT_HITS);

                    vSource.z += 1.5; // Take this up to aproximately chest height

                    //Get a target that isn't Caladrius
                    SetTeamId(oThis, -1);
                    oTarget = DEN_GetRandomTeamMember(DEN_TEAM_ALIENAGE_CALADRIUS_WAVE_2);
                    SetTeamId(oThis, DEN_TEAM_ALIENAGE_CALADRIUS_WAVE_2);

                    if (IsObjectValid(oTarget)
                        && !IsDeadOrDying(oTarget))
                    {
                        SetFacingObject(oThis, oTarget);

                        evDeathbolt = SetEventObject(evDeathbolt, 0, oTarget);
                        evDeathbolt = SetEventObject(evDeathbolt, 1, oThis);

                        oBolt = FireHomingProjectile(104, vSource, oTarget, 0, oThis);

                        SetProjectileImpactEvent(oBolt, evDeathbolt);
                    }
                    CAI_SetCustomAI(oThis, CAI_CALADRIUS_WAITING_TO_CAST);

                    break;
                }
[/dascript]

#4
edmogt1

edmogt1
  • Members
  • 52 messages
I still have a problem with this, though. The 90210 event fires correctly, it goes to the creature_core script, to the rules_core but it dies there because GetEventInteger(ev, 0) (for ability id) is zero. Somehow the the event parameters are going out of scope.



Does anyone have an idea why this is happening?

#5
Sunjammer

Sunjammer
  • Members
  • 926 messages
The code in your second post isn't assigning the modified event returned by the SetEvent* functions. Try something like:

event evProjectileImpact = Event(90210);
evProjectileImpact = SetEventInteger(evProjectileImpact, 0,  stEvent.nAbility);
evProjectileImpact = SetEventObject(evProjectileImpact , 0, stEvent.oTarget);

Modifié par Sunjammer, 27 juillet 2010 - 11:09 .