So, I'm having a bit of trouble with this. I've got a customer merchant set to spawn in my camp if he's not already there each time I enter it. That parts works just fine.
I've instituted a dialogue option where you can tell him he's not safe, and that he should leave. This sets a plot flag, called TOLD_TO_LEAVE.
I'd like the script to check two conditions: if he's not already there AND if he hasn't been told to leave, then spawn the merchant.
I have this so far:
#include "wrappers_h"
#include "plt_merch_plot"
void main()
{
object oPlayer = GetMainControlled();
object oMerchant = UT_GetNearestObjectByTag(oPlayer, "merchant_guy");
if (!IsObjectValid(oMerchant)) && (WR_GetPlotFlag(PLT_MERCH_PLOT,TOLD_TO_LEAVE))
{
object oArea = GetObjectByTag("cam100ar_camp_plains");
location lMerchantLocation = Location(oArea, Vector(166.61, 124.77, -1.33),85.4);
CreateObject(OBJECT_TYPE_CREATURE, R"merchant_guy.utc", lMerchantLocation);
}
}
It seems to be the proper C++ syntax for setting two conditions on an if statement, but I keep getting an "Unknown state in compiler" error. Maybe dragon age handles it differently?
Also, I think, as written, this will only spawn him if the plot flag TOLD_TO_LEAVE *has* been set, which is backwards. As silly as it makes me feel, I'm not sure how to specify this.
Is it a ! in front of WR_GetPlotFlag? Or am I using the wrong statement altogether?
if statements with two conditions, one of which is a plot flag
Débuté par
cstanish
, déc. 12 2009 09:47
#1
Posté 12 décembre 2009 - 09:47
#2
Posté 12 décembre 2009 - 10:15
your if statement should look like this:
"if (!IsObjectValid(oMerchant) && WR_GetPlotFlag(PLT_MERCH_PLOT,TOLD_TO_LEAVE))"
It's all about the rule that condition for IF should be in braces. So it's if (A &&
and not if (A) && (
I'd suggest adding another flag like MERCHANT_SPAWNED and then check whether he's been spawned or not using the plot and not the searching for object function (which is more resource consuming for player)
Check this part of the wiki: http://social.biowar...n_existing_area
edit:
it should be actualy WR_GetPlotFlag(PLT_MERCH_PLOT,TOLD_TO_LEAVE)==FALSE if you want your script to do what you've described
edit2:
erhm, well, simple "!" in fron of the second function will do as well
"if (!IsObjectValid(oMerchant) && WR_GetPlotFlag(PLT_MERCH_PLOT,TOLD_TO_LEAVE))"
It's all about the rule that condition for IF should be in braces. So it's if (A &&
I'd suggest adding another flag like MERCHANT_SPAWNED and then check whether he's been spawned or not using the plot and not the searching for object function (which is more resource consuming for player)
Check this part of the wiki: http://social.biowar...n_existing_area
edit:
it should be actualy WR_GetPlotFlag(PLT_MERCH_PLOT,TOLD_TO_LEAVE)==FALSE if you want your script to do what you've described
edit2:
erhm, well, simple "!" in fron of the second function will do as well
Modifié par Gocek, 12 décembre 2009 - 10:37 .
#3
Posté 13 décembre 2009 - 12:01
Thanks a million for your help!
It will compile now, but something is not right still. I tried both with a ! in front of WR_etc. and with ==FALSE after the plot flag, and I made sure to take the dialogue option that would set that flag as true, but after that when I leave and come back the guy still spawns.
Hmmm.
It will compile now, but something is not right still. I tried both with a ! in front of WR_etc. and with ==FALSE after the plot flag, and I made sure to take the dialogue option that would set that flag as true, but after that when I leave and come back the guy still spawns.
Hmmm.
#4
Posté 13 décembre 2009 - 12:14
Oh wait now I understand why it's not working.
The script basically tells the game: If I'm in camp and the merchant does not exist AND the merchant hasn't been told to leave, then spawn the merchant.
However, I can't set the flag if the merchant hasn't already been spawned, right? So the first time the merchant will spawn, but the condition !IsObjectValid is not being met on subsequent returns, because the merchant spawned before and is still there.
So what I really need to do is to find out how to despawn the merchant if that plot flag has been set.
Thanks Gocek for helping me solve that syntax issue. I was concentrating on that so much that I didn't notice the logic didn't really work.
The script basically tells the game: If I'm in camp and the merchant does not exist AND the merchant hasn't been told to leave, then spawn the merchant.
However, I can't set the flag if the merchant hasn't already been spawned, right? So the first time the merchant will spawn, but the condition !IsObjectValid is not being met on subsequent returns, because the merchant spawned before and is still there.
So what I really need to do is to find out how to despawn the merchant if that plot flag has been set.
Thanks Gocek for helping me solve that syntax issue. I was concentrating on that so much that I didn't notice the logic didn't really work.
#5
Posté 13 décembre 2009 - 05:20
You can also use GetObjectActive, which will return false for both a creature that has been set inactive and one which is not yet spawned.





Retour en haut






