Announcement

Collapse
No announcement yet.

Need a bit of help in coding

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need a bit of help in coding

    Hi ppl!

    I'm new to scripting and I can't manage to make a ONSPowerCore to trigger an event when it has taken damage and I would like help.
    I wanted to make it like RedActivationName, BlueActivationName, and DestroyedEventName in the Events tab of Actor Properties.

    The most I could figure is the code should have TriggerEvent(); and belong somewhere in Function TakeDamage() of ONSPowerCore.

    #2
    Originally posted by Jacen View Post
    The most I could figure is the code should have TriggerEvent(); and belong somewhere in Function TakeDamage() of ONSPowerCore.
    That's pretty much all there is to it. (Of course, apart from defining a new variable for the event name.)

    Comment


      #3
      I'm surprised that I figured that right but I'm not familiar with coding (I only know the basics of C++) and I tried writing it but it did not work. I was only able to interpret its meaning.
      Could you write down a step by step instruction, please and thanks

      Comment


        #4
        If you're not familiar with programming, I'd recommend learning a little more before trying something as specialised as UnrealScript. Try learning a bit of Java; UnrealScript's syntax is largely very similar to that of Java.

        Or you could just try an UnrealScript tutorial; I've seen some posted on this forum a few times.

        Comment


          #5
          If you already have some C++ experience, "UnrealScript compared with other languages" might give you an overview of what is different in UnrealScript.

          Comment


            #6
            Thanks for the suggestion guys. I tried writing it again. And here's what I got:

            Code:
            class ONSPowerCore extends DestroyableObjective
            
            var(Events) name            TakeDamageEventName;
            
            function TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
            {
              // All the original code before
              if ((DamageEventThreshold > 0) && (AccumulatedDamage >= DamageEventThreshold))
              {
                		TriggerEvent(TakeDamageEvent,self, InstigatedBy);
                		TriggerEvent(TakeDamageEventName,self, InstigatedBy);   // What's self and InstigatedBy
                		AccumulatedDamage = 0;
              }
              // All the original code after
            }
            This was change in my map using UnrealEd but the TakeDamageEventName was not in the Events tab. I noticed when I compiled changed using the UnrealScript Editor, the bar on the bottom was white. Did I do anything wrong?

            Comment


              #7
              You don't want to edit any existing code. Really.

              You never change anything that came with the game, you always add to it.

              Comment


                #8
                I do not think it compiled since the bar did not say anything like "Successful." Thanks for the warning. I was afraid to subclass it because I think it might corrupt the onslaught game and bot AI.
                I'm still stuck with same problem anyways because it did not seem to work. Any help?

                I wrote this instead
                Code:
                class MyONSPowerCoreBlue extends ONSPowerCoreBlue
                	placeable;
                
                var(Events) name         TakeDamageEventName;
                
                function TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
                {
                        // All the original code of ONSPowerCore before
                
                    	if ((DamageEventThreshold > 0) && (AccumulatedDamage >= DamageEventThreshold))
                    	{
                    		TriggerEvent(TakeDamageEvent,self, InstigatedBy);
                		TriggerEvent(TakeDamageEventName,self, InstigatedBy);
                    		AccumulatedDamage = 0;
                    	}
                	
                        // All the original code after
                }

                Comment


                  #9
                  Usual question for posts like that: How do you know it doesn't work, what do you expect to happen and what exactly happens when you try?

                  Comment


                    #10
                    My goal is to create a "TakeDamageEventName" for the two power cores of an onslaught game which will trigger an outside event picked up by a Action_WaitforEvent in a Scripted Trigger.
                    Here's what I did:
                    I created a subclass of ONSPowerCoreBlue and Red with the code written above named "MyONSPowerCoreBlue" and "MyOnsPowerCoreRed" and compiled it.
                    Then I added the two cores into my level. When I opened the actor properties of each core, the "TakeDamageEventName" was there. After that, I matched the name of the "TakeDamageEventName" with Action_WaitforEvent in a Scripted Trigger (The next order of sequence is to trigger a mover).
                    I play tested it, shot the power core, mover didn't move.

                    Comment

                    Working...
                    X