this code fires in a conversation:
#include "events_h"
#include "global_objects_h"
#include "utility_h"
#include "sys_chargen_h"
void main()
{
object oHero = GetHero();
object oNecklace = GetItemInEquipSlot(11, oHero);
object oItem = GetObjectByTag("necklace2");
if (oNecklace == oItem)
{
UT_TeamGoesHostile(1);
}
}
it's supposed to look if the character has necklace2 equipped in item slot 11 and if it does, team 1 attacks.
when i play the game the result is that the player gets attacked after initiating conversation no matter if he wears the necklace or not. the tags are all checkin out so that's not the problem here.
welp i've run into problems
Débuté par
gordonbrown82
, janv. 15 2010 08:48
#1
Posté 15 janvier 2010 - 08:48
#2
Posté 15 janvier 2010 - 10:05
Did you make sure that the creatures on the team srart out in the Neutral group?
Not likely related to your current problem, but a better way to check if the item is equipped would be
[dascript]
void main()
{
object oHero = GetHero();
object oNecklace = GetItemInEquipSlot(11, oHero);
if (GetTag(oNecklace) == "necklace2")
{
UT_TeamGoesHostile(1);
}
}
[/dascript]
The problem with your original code is that if there is more than one object with the tag "necklace2" it will often fail (since you can't be sure which object will be returned by GetObjectByTag).
Not likely related to your current problem, but a better way to check if the item is equipped would be
[dascript]
void main()
{
object oHero = GetHero();
object oNecklace = GetItemInEquipSlot(11, oHero);
if (GetTag(oNecklace) == "necklace2")
{
UT_TeamGoesHostile(1);
}
}
[/dascript]
The problem with your original code is that if there is more than one object with the tag "necklace2" it will often fail (since you can't be sure which object will be returned by GetObjectByTag).
#3
Posté 15 janvier 2010 - 11:00
thanks craig your code worked immediately. why i don't know. the only difference i see it that yours is a tag comparison instead of an object comparison.
#4
Posté 15 janvier 2010 - 11:20
gordonbrown82 wrote...
thanks craig your code worked immediately. why i don't know. the only difference i see it that yours is a tag comparison instead of an object comparison.
Which helps avoid the problem of comparing the object if, by chance, there are more than one "necklace2"'s. At least I think that's why Craig's code is different. Correct?
#5
Posté 15 janvier 2010 - 11:32
would that necklace2 be in the main campaign or something because i know that i haven't made such an object. i made a new necklace called "ikflcizgq" and gave it to the player but that didn't work either. but also i don't get why it would make a difference if there are more necklaces. if item slot 11 doesn't contain anything, and that nothing is compared to something, then the comparison should be invalid and the UT_TeamGoesHostile shouldn't fire.
#6
Posté 15 janvier 2010 - 03:29
Here's what I think the problem was. I don't think GetObjectByTag can grab an item out of a creature's inventory, so that function would return OBJECT_INVALID. If the player wasn't wearing any necklace, GetItemInEquipmentSlot would return OBJECT_INVALID as well.
OBJECT_INVALID == OBJECT_INVALID resolves to TRUE, so the team goes hostile.
OBJECT_INVALID == OBJECT_INVALID resolves to TRUE, so the team goes hostile.
#7
Posté 15 janvier 2010 - 03:51
ok thanks david.
#8
Posté 18 janvier 2010 - 04:22
gordonbrown82 wrote...
thanks craig your code worked immediately. why i don't know. the only difference i see it that yours is a tag comparison instead of an object comparison.
That's was the difference. Your script compare different data; you compare a whole object with an Object Tag, if (oNecklace == oItem).
You mast compare theobject Tag with another object Tag , if (GetTag(oNecklace) == oItem).





Retour en haut







