I'm trying to write a script that will give a creature a random weapon (from a list) when they spawn. This should be really easy, but for some reason it just isn't working.
I made a copy of x2_def_spawn for the monsters I want this to apply to, and simply added
ExecuteScript("bones_items", OBJECT_SELF); to it to generate the loot.
bones_items looks like this
void main()
{
int iRand = d4(1);
switch (iRand){
case 1: CreateItemOnObject("waxbt003", OBJECT_SELF); break;
case 2: CreateItemOnObject("waxbt004", OBJECT_SELF); break;
case 3: CreateItemOnObject("waxbt005", OBJECT_SELF); break;
case 4: CreateItemOnObject("waxbt006", OBJECT_SELF); break;
}
ActionEquipMostDamagingMelee();
}
The item never seems to be created, as the enemy never seems to switch to it, or drop it when they die. I've tried many different item combinations with NPCs who are able to equip anything.
Creature spawn with random weapons
Débuté par
EzRemake
, déc. 03 2013 05:57
#1
Posté 03 décembre 2013 - 05:57
#2
Posté 03 décembre 2013 - 06:37
Add this line into the script after the switch statement:
SpeakString("Created item " + IntToString(iRand));
Make sure the creature actually says that line -- if you don't see it, your script isn't firing properly.
SpeakString("Created item " + IntToString(iRand));
Make sure the creature actually says that line -- if you don't see it, your script isn't firing properly.
#3
Posté 03 décembre 2013 - 07:44
I knew it was going to be something small and stupid, turns out in this scenario you have to refer to the tag of the item, not the resref... Seems when dealing with giving items to players it's resref, and to creatures it's tag
The more you know lol
The more you know lol
#4
Posté 03 décembre 2013 - 09:30
What I've come up with looks like this
void main()
{
int iRand = d3(1);
object oMainhand;
object oOffhand;
switch (iRand){
case 1: oMainhand = CreateItemOnObject("CeremonialScythe", OBJECT_SELF);
SetDroppableFlag(oMainhand, FALSE);
ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
break;
case 2: oMainhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
oOffhand = CreateItemOnObject("BoneShield", OBJECT_SELF);
SetDroppableFlag(oMainhand, FALSE);
SetDroppableFlag(oOffhand, FALSE);
ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
ActionEquipItem(oOffhand, INVENTORY_SLOT_LEFTHAND);
break;
case 3: oMainhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
oOffhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
SetDroppableFlag(oMainhand, FALSE);
SetDroppableFlag(oOffhand, FALSE);
ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
ActionEquipItem(oOffhand, INVENTORY_SLOT_LEFTHAND);
break;
}
}
I plan to use this in the future, giving certain types of monsters many particular setups, more than just the three listed here. Will this cause instability or lag when multiple creatures are spawning throughout the server with scripts like this tied to them?
void main()
{
int iRand = d3(1);
object oMainhand;
object oOffhand;
switch (iRand){
case 1: oMainhand = CreateItemOnObject("CeremonialScythe", OBJECT_SELF);
SetDroppableFlag(oMainhand, FALSE);
ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
break;
case 2: oMainhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
oOffhand = CreateItemOnObject("BoneShield", OBJECT_SELF);
SetDroppableFlag(oMainhand, FALSE);
SetDroppableFlag(oOffhand, FALSE);
ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
ActionEquipItem(oOffhand, INVENTORY_SLOT_LEFTHAND);
break;
case 3: oMainhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
oOffhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
SetDroppableFlag(oMainhand, FALSE);
SetDroppableFlag(oOffhand, FALSE);
ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
ActionEquipItem(oOffhand, INVENTORY_SLOT_LEFTHAND);
break;
}
}
I plan to use this in the future, giving certain types of monsters many particular setups, more than just the three listed here. Will this cause instability or lag when multiple creatures are spawning throughout the server with scripts like this tied to them?
Modifié par EzRemake, 03 décembre 2013 - 09:34 .
#5
Posté 03 décembre 2013 - 11:46





Retour en haut







