Aller au contenu

Photo

If statement for creature trigger


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

#1
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
Another noob question, please be gentle :(

I need to trigger DestroyObject on a specific creature when it enters a trigger. I've managed to put together what I think is everything I need from various tutorials, but I'm a bit stumped about the part where I need to check if the event creator is my creature.

Here is the script in question. I'd like to know what to put as the if statement (the trigger should only fire if the creature with the tag "my_creature" enters the area.

#include "events_h"

void main()
{
    event ev = GetCurrentEvent();  
    int nEventType = GetEventType(ev);
   
    switch(nEventType)
    {
         case EVENT_TYPE_ENTER:
         {
             object oCreature = GetEventCreator(ev); // creature entering the object           
             object oCorimae = GetObjectByTag("my_creature",1);
             {
                if ?????What goes here?????
                {
                    DestroyObject(oCreature, 0);
                    DestroyObject(OBJECT_SELF, 0);
                }
             }
             break;
         }
    }

}

#2
TimelordDC

TimelordDC
  • Members
  • 923 messages
if (oCreature == oCorimae)

#3
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
Thanks :)



So if I understand correctly, = defines something, while == is a 'comparison' ?

#4
Guest_dewkl_*

Guest_dewkl_*
  • Guests
Yes, the first is an assignment operator, the second is a logical operator (comparison).

Read more about it here.

Modifié par dewkl, 30 mai 2010 - 01:10 .


#5
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages

Kilrogg_ wrote...
DestroyObject(oCreature, 0);
DestroyObject(OBJECT_SELF, 0);


Just an advice. You'll find the following note in the DestroyObject function description.

Destroy the specified object. !!GEORG SAYS: DO NOT USE. EVER. Use
core_h.Safe_Destroy_Object instead!!


I don't know who George is, but maybe you should use Safe_Destroy_Object instead

#6
CID-78

CID-78
  • Members
  • 1 124 messages
You don't know who george is? you should have encountered his notes in most bioware scripts in all games the last decade or so. but in the end you learn to not listen to him.



He is the kind of guy that tell people to not touch a knife just because you may endup cutting yourself. leaving out the fact that a knife is really usefull if it's used properly.

#7
Proleric

Proleric
  • Members
  • 2 352 messages
I've always imagined that Georg's comments are primarily for internal consumption within Bioware, in which context it would be entirely appropriate for certain things only to be touched by the gurus.

Also, it's always good to know that certain things are fragile, even if we decide to ignore the warning at our own risk. Posted Image

Modifié par Proleric1, 31 mai 2010 - 09:03 .