Aller au contenu

Photo

Posting a Script - Because It Works Now :)


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

#1
Morbane

Morbane
  • Members
  • 1 883 messages
int IsUsingSilver(object oTarget)
{
	object oWeapon = GetLastWeaponUsed(oTarget);
	if(GetItemBaseMaterialType(oWeapon) == GMATERIAL_METAL_ALCHEMICAL_SILVER)
	{
		return TRUE;
	}
	return FALSE;
}

  • Kaldor Silverwand, rjshae et bealzebub aiment ceci

#2
Morbane

Morbane
  • Members
  • 1 883 messages

GM: What is the purpose?

 

Barbarian: The formatting in the forums... the wind in my hair!

 

GM: Yes... it is good. Drink!



#3
kevL

kevL
  • Members
  • 4 074 messages

yes, it is good



#4
Morbane

Morbane
  • Members
  • 1 883 messages

int IsUsingSilver(object oTarget)
{
	object oWeapon = GetLastWeaponUsed(oTarget);
	if(oWeapon == OBJECT_INVALID) return FALSE;
	
	if(GetItemBaseMaterialType(oWeapon) == GMATERIAL_METAL_ALCHEMICAL_SILVER)
	{
		return TRUE;
	}
	return FALSE;
}

This is the version that actually works BTW...

 

if enemy AI makes it change weapons, like from sword to bow - and the timing is right, the game will lock because the enemy has no weapon to check for.

 

this script was written for a Feat with an AOE HB.

 

thank you, that is all... :D



#5
kevL

kevL
  • Members
  • 4 074 messages

/heh

 

:)


  • Morbane aime ceci

#6
rjshae

rjshae
  • Members
  • 4 506 messages

I guess you could probably do something like...

int IsUsingSilver(object oTarget)
{
    object oWeapon = GetLastWeaponUsed(oTarget);
    return ( ( oWeapon != OBJECT_INVALID) &&
             ( GetItemBaseMaterialType(oWeapon) == GMATERIAL_METAL_ALCHEMICAL_SILVER ) );
}

but, eh, same diff.



#7
Morbane

Morbane
  • Members
  • 1 883 messages

I guess you could probably do something like...

int IsUsingSilver(object oTarget)
{
    object oWeapon = GetLastWeaponUsed(oTarget);
    return ( ( oWeapon != OBJECT_INVALID) &&
             ( GetItemBaseMaterialType(oWeapon) == GMATERIAL_METAL_ALCHEMICAL_SILVER ) );
}

but, eh, same diff.

 

looking at this, and it looks like the return does not actually return anything useful - that is OBJECT_INVALID may be an int and GMATERIAL_METAL_ALCHEMICAL_SILVER is as well - but the return value would be whatever number that the const strings represent - not TRUE or FALSE.

 

or am i just not seeing the logic?



#8
rjshae

rjshae
  • Members
  • 4 506 messages

If you used it in an 'if' conditional, would it not give a true/false value? Same principle.



#9
kevL

kevL
  • Members
  • 4 074 messages

Morbane,
look at it this way,

both expressions in the parenthesis need to evaluate TRUE for the return to be true.

if (oWeapon != OBJECT_INVALID) -> if true
if (basematerial == Silver) -> if true

then TRUE.



#10
Morbane

Morbane
  • Members
  • 1 883 messages

got it.

 

always happy to see ways of streamlining script code :D