Aller au contenu

Photo

Problems with line in script - can someone take a look


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

#1
Sonmeister

Sonmeister
  • Members
  • 167 messages
This script works great.  Then I added this line and it won't compile.


Line 94                                        CreateItemOnObject(REVENANT_HIMSELF_RES, REVENANT_KEY_TAG,1);

I've tried all the variations of the line I can think of so is it my tags, resources, or do I need to list the revenant as an object

//--------------------------------------------------------------------------------------------------
/*
    Plot script for "find_key" quest for Revenant.
*/
//--------------------------------------------------------------------------------------------------

#include "utility_h"
#include "wrappers_h"
#include "plot_h"

#include "plt_find_key"

//  Constants
//--------------------------------------------------------------------------------------------------

// tags
const string REVENANT_KEY_TAG  = "revenant_key";
const string REVENANT_HIMSELF  = "my_ruins_revenant";
const string REVENANT_SCROLL_TAG  = "summoning_manuscript";
// resources
const resource REVENANT_KEY_RES   = R"revenant_key.uti";
const resource REVENANT_HIMSELF_RES  = R"my_ruins_revenant.utc";
const resource REVENANT_SCROLL_RES  = R"summoning_manuscript.uti";
//  Functions
//--------------------------------------------------------------------------------------------------

void AddCreatureExperience(int nXp, object oCreature=OBJECT_SELF)
{
    float fXp = IntToFloat(GetExperience(oCreature) + nXp);
    SetCreatureProperty(oCreature, PROPERTY_SIMPLE_EXPERIENCE, fXp);
}

//  Main
//--------------------------------------------------------------------------------------------------

int StartingConditional()
{
    int bResult;

    // deconstruct event
    event evCurrent = GetCurrentEvent();
    int nEventType  = GetEventType(evCurrent);
    int nPlotFlag   = GetEventInteger(evCurrent, 1);

    // common variables
    object oHero = GetHero();

    // Handle Events
    //----------------------------------------------------------------------------------------------

    switch(nEventType)
    {
        // Set Plot Event: Main flags only
        //------------------------------------------------------------------------------------------


 case EVENT_TYPE_SET_PLOT:
        {
            int nNewValue = GetEventInteger(evCurrent, 2);  // Value about to be assigned
            int nOldValue = GetEventInteger(evCurrent, 3);  // Value currently assigned

            switch(nPlotFlag)
            {
                case REVENANT_QUEST_ACCEPT:
                {
                    // open the subplots: one for each item
                    WR_SetPlotFlag(PLT_FIND_KEY, REVENANT_QUEST_ACCEPT, TRUE);

                    // create ring item – don’t need on this plot
                    // CreateItemOnObject(REVENANT_KEY_RES, oHero);

                    // drop the plot giver flag: object 0 is the conversation's owner
                    object oConversationOwner = GetEventObject(evCurrent, 0);
                    SetPlotGiver(oConversationOwner, FALSE);

                    break;
                }
                case REVENANT_QUEST_COMPLETE:
                {
                    // open the subplots: one for each item
                    WR_SetPlotFlag(PLT_FIND_KEY, REVENANT_QUEST_COMPLETE, TRUE);

                    break;
                }
                case REVENANT_QUEST_GIVE_KEY:
                {
                    // open the subplots: one for each item
                    WR_SetPlotFlag(PLT_FIND_KEY, REVENANT_QUEST_GIVE_KEY, TRUE);

                    // remove key item and add to Revenant
*****            RemoveItemsByTag(GetHero(), REVENANT_KEY_TAG);
Line 94      CreateItemOnObject(REVENANT_HIMSELF_RES, REVENANT_KEY_TAG,1);
*****
                    // reward player
                    // AddCreatureMoney(5000, oHero);
                    AddCreatureExperience(1000, oHero);

                    break;
                }
                case REVENANT_QUEST_REWARD:
                {
                    // open the subplots: one for each item
                    WR_SetPlotFlag(PLT_FIND_KEY, REVENANT_QUEST_REWARD, TRUE);

                    // reward player
                    // AddCreatureMoney(5000, oHero);
                    AddCreatureExperience(1000, oHero);

                    break;

                    }
            }

            break;
        }

        // Get Plot Event: Defined flags only
        //------------------------------------------------------------------------------------------
        case EVENT_TYPE_GET_PLOT:
        {
            switch(nPlotFlag)
            {
                case FOUND_KEY:  // Defined Flag in plot fired when item is acquired
                {
                    bResult = IsObjectValid(GetItemPossessedBy(oHero, REVENANT_KEY_TAG));

                    break;

                    // if sub-plot has been completed the player has item
                    if(WR_GetPlotFlag(PLT_FIND_KEY, FOUND_KEY))
                    {
                        bResult = TRUE;
                    }
                    break;
                    }
                    case FOUND_SCROLL:  // Defined Flag in plot fired when item is acquired
                    {
                    bResult = IsObjectValid(GetItemPossessedBy(oHero, REVENANT_SCROLL_TAG));

                    break;

                    // if sub-plot has been completed the player has item
                    if(WR_GetPlotFlag(PLT_FIND_KEY, FOUND_SCROLL))
                    {
                        bResult = TRUE;
                    }
                    break;
                    }
            }
            break;
        }
    }
    return bResult;
}

Modifié par Sonmeister, 24 mai 2010 - 04:37 .


#2
Rolenka

Rolenka
  • Members
  • 2 257 messages
Missing semicolon. Or if it's there and you just didn't paste it, yeah, I'd guess you need to set an object variable as the revenant. I think you can do it with UT_GetNearestObjectByTag.

What did the compiler say?

Modifié par Rolenka, 24 mai 2010 - 04:02 .


#3
Sonmeister

Sonmeister
  • Members
  • 167 messages
Yeah, I didn't paste the semi-colon. The compiler is saying

"Declaration does not match the parameters"

Can you show me how you would use the UT_GetNearestObjectByTag in the script?

Modifié par Sonmeister, 24 mai 2010 - 04:39 .


#4
TimelordDC

TimelordDC
  • Members
  • 923 messages
Check the CreateItemOnObject syntax. You can't use a tag in there -> should be a resource that is created on the object.

And yes, you need the revenant object. Check http://social.biowar...restObjectByTag

Modifié par TimelordDC, 24 mai 2010 - 06:39 .


#5
Proleric

Proleric
  • Members
  • 2 346 messages
Firstly, you'll need the revenant's tag (check what's in the Tag field in the resource properties). That might be something like
const resource REVENANT_HIMSELF_TAG = "my_ruins_revenant";
Then in the body of the script, after oHero is initialised:
object oRevenant = UT_GetNearestObjectByTag(oHero, REVENANT_HIMSELF_TAG);
CreateItemOnObject(oRevenant, REVENANT_KEY_TAG, 1);
Have a look at the Help window for these functions. The parameters you pass must be of exactly the same type as the function prototype. So, for example, the first parameter to CreateItemOnObject has to be an object, not a resource template.

If you know that there will never be more than one resource with the tag in question, you can use the simpler initialisation
object oRevenant = GetObjectByTag(REVENANT_HIMSELF_TAG);

Edit: what TimelordDC said.

Modifié par Proleric1, 24 mai 2010 - 07:06 .


#6
Sonmeister

Sonmeister
  • Members
  • 167 messages
I'm still having troubles -



When I put this under object oHero = GetHero();



object oRevenant = GetObjectByTag(REVENANT_HIMSELF_TAG);



I get "variable defined without type" in the compiler.





Does all of this look OK?



// Constants

//--------------------------------------------------------------------------------------------------



// tags

const string REVENANT_KEY_TAG = "revenant_key";

const string REVENANT_HIMSELF = "my_ruins_revenant";

const string REVENANT_SCROLL_TAG = "summoning_manuscript";

// resources

const resource REVENANT_KEY_RES = R"revenant_key.uti";

const resource REVENANT_HIMSELF_RES = R"my_ruins_revenant.utc";

const resource REVENANT_SCROLL_RES = R"summoning_manuscript.uti";








#7
Proleric

Proleric
  • Members
  • 2 346 messages
That's because you've defined the tag as REVENANT_HIMSELF, but then referred to REVENANT_HIMSELF_TAG. They both need to be the same.

#8
Sonmeister

Sonmeister
  • Members
  • 167 messages
I shouldn't have copy and pasted your reference without checking it. So I added this
object oRevenant = GetObjectByTag(REVENANT_HIMSELF);
And it compiled fine
but then I added on line 95 CreateItemOnObject(REVENANT_HIMSELF, REVENANT_KEY_RES, 1)' and I get "Declaration does not match parameters." 

Edit:  So then I flip flopped it after looking at help and got the same issue...

Modifié par Sonmeister, 24 mai 2010 - 02:24 .


#9
tmp7704

tmp7704
  • Members
  • 11 156 messages
Is there any particular reason to give that key to the Revenant to begin with, rather than simply destroy it and pretend the Revenant has it from that point on?



Alternatively, you could also use MoveItem() to pass the key from the player to the target, rather than take it away and spawn a new one.

#10
Sonmeister

Sonmeister
  • Members
  • 167 messages
I was expecting this question. Actually it's dependent on some conversation choices on whether the Revenant has the key or not or I would have just put it in his inventory since the player would never know. But if he kills the Revenant on some choices the key needs to be on him on others it does not because the player will have it.
I'll check out the MoveItem(). At this point I'm just trying to understand why the script isn't working for future reference too. I like learning the stuff but still have a long way to go.

Edit:  I tried the MoveItem() and can get it to compile fine but had trouble until I defined the key as an object.  This leads me to try some other things with my newly defined object and my old line of attack just for learning purposes.

Edit: So I went back to CreateItemOnObject and it worked fine with the key defined as an object.

This is part of the problem for those of us (like me) not really understanding all parts of scripting.  Not knowing what needs to be defined as an object and not knowing exactly what errors in the compiler are communicating is an issue.
Thanks for all of the help.  I'll test this in game after work and see if it works!

Modifié par Sonmeister, 24 mai 2010 - 03:06 .


#11
CID-78

CID-78
  • Members
  • 1 124 messages
a object is a object and a string is a string. if the function says that it wants a object then it needs a object and not a string.



I can't see how things can be simpler then that?



so read the function description it dictates what data type each parameter should be.



you then need to go from what you know to what it wants.



ie if you know the TAG but it wants a object then you must find a way to get a object from that Tag. usually a quick filter check will give you a suitable function for that kind operation.

#12
tmp7704

tmp7704
  • Members
  • 11 156 messages
To understand it better, you can think of object as of food can. The string is more like a label associated with that can, or an entry on your shopping list that tells you what food you're after -- you still need to perform the action of actually acquiring that food can, if you want to eat it.

#13
Sonmeister

Sonmeister
  • Members
  • 167 messages
Your comments tmp7704 are the kinds of things that help me understand. CID-78 please remember I ask the dumb questions because I have no background. You are correct that the words are self-explanatory in a sense but language is only as good as the meaning you have behind it. For me "object" and "string" aren't fully understood from a computing sense, ie. how each word is used, why it's used, where it's used, it's context, etc. etc. I'm still learning and ask the dumb questions for myself and all others in the same boat. I appreciate the help from both of you and all others on this post.

#14
CID-78

CID-78
  • Members
  • 1 124 messages
well a object is what the english word mean some kind of object. in dascript there is following types of objects and you can't make new types just new variations of those types.



The module (this is the main object and it contain every object in game) there is only one of these accessible. if you are working with addins or override it's the module that is either calling or the one containg the calling object. there is no way of reaching other modules.



Area's (this is the container object that contain everything within a area including terrain, you can only manipulate area's that are currently loaded into the game. ie is on the current arealist.



Creatures (This is the player any NPC, animal or beasts), they are within the area's that are loaded.



Placeables (this is immobile object that the player can interact with such as chests)



Doors (well they are doors that you either can open or contain area transitions)



Triggers (these are static draw surfaces that trigger a script event when a creature enter/exit them)



AreaofEffect (these are similar to triggers but they are attached to a object so they maybe moving around)



Item (any inventory item such as weapons)



store (a container that hold all the items that is for sale) must be called from a script to be physically viewable.



projectile (the fireball or arrow that someone is throwing)



map (the worldmap or any submap)



party (the container containing the player and any companions and followers)



sounds (the object that make sounds)



waypoint (a marked location in the area)



vfx (a visual effect)



you also got tile, mappatch and gui but i doubt you will ever get in contact with those.





a string is simply a array of letters, it can be used like any text in RL, to find a object, to name a object, to be spoken by a creature and so on.

#15
iceon

iceon
  • Members
  • 18 messages
A string is a container of characters.
for instance a string can contain the word: hi

A string is just a text, never more nor less. It contains text just like this post is a string.

Example usage of a text:
Console.WriteLine("Hello")

The characters (letters) written within the "" is a string. It is an amount of characters forming a text. I could aswell have written
string myString = "hi"
Console.WriteLine(myString)

The endresult would be the same, it would just print out the characters, text.. just like this post is saved and handeld as a string.

For information on Object you could read this:
http://msdn.microsof...t(v=VS.80).aspx

The code wants an object, which means it wants the Revenant itself, not a text saying Revenant, it don't know what to do with a text. If you are running you want air, you don't want the word air.

Programming can be rather weird if you do not get the basic understanding at first.

Then again, I do not know what more you are trying to do in the end and how much of coding you have learned. But I understand CID-78, since if a person is coding something and asks for help, it is to assume that that person have basic understanding of coding.

Even so, for someone like CID-78 the basic knowledge of strings, ints, booleans, DateTime objects etc is all very simple and standard in everyday life. which makes it frustrating to explain to someone with no basic knowledge about it. It is rather obvious to us just like it is obvious to you that 1+2 = 3, but explain that to a 4 year old, why is 1+2 = 3, but not only shall he learn 1+2 = 3 but you have to teach him the very core of counting with +, he shall learn to understand the logic, not to memorize what is written on paper. So you can imagine how it feels.

I bet I even managed to say alot of things wrong and will get ranted over and over again for my text but... couldn't care less :) IMO you should try to learn the logic and it will become a lot clearer. The logic is best learned to try to create things in pieces instead of taking on all at once.

Edit: Hehe CID was way ahead of me, ohh well :)

Modifié par iceon, 25 mai 2010 - 07:58 .


#16
CID-78

CID-78
  • Members
  • 1 124 messages
some times it's easier to just leave details out. and not explain why a apple isn't a orange and just tell them they aren't the same and leave it at that.



more information may confuse them even more rather then help them grasp it.



some people just want it simple and put round thing in round holes and square things in square holes. and not know how the round thing becomes round or how a square thing is round thing with more corners.

or that a round thing is a square with less corners.

#17
Sonmeister

Sonmeister
  • Members
  • 167 messages
I hear what both of you are saying and appreciate it all. In my case, I am really trying to learn scripting as I go (I have a limited knowledge of programming) and actually find it very exciting. When I write a script and actually see it do what I want in game, that's cool. I also enjoy the troubleshooting/problem solving side of it. I've slowly progressed from just blatantly copy and pasting scripts to writing my own and that's where I need the most help. But at least I'm trying.



I am learning a piece at a time through making my mod. The breakdown of what objects are in respect to the DA toolset by CID and what a string is by iceon, is exactly the kind of thing that helps me understand.



When you (ie. programmers) look at a script it all probably makes sense, for me, I'm getting there but have a ways to go. My wife thinks I'm crazy cuz I sit around studying scripts (from the Single Player game) to try and figure out how to do something I want to put in my mod then I tackle it.



Anyway, the toolset has been mostly fun (and aggravating at times). It feeds my graphic design side, my computer interest side, my story teller side and my problem solving side. I'm hoping all of the hours spent on the mod will be worth it to the Community too.