Scripting
Moderators: Haplo, Lead Developers
Scripting
ok so i can script..i have read scripting for dummies morrowind version...and i have made scripts that work so i can mainly follow how to make them....and i have an idea of what i want but im not sure if its right...(i just found this script in my documents, pretty sure its the right one...)
Begin FightScript
short Fight
endif
if ( GetDistance Mrene_FightrTestScript2 <= 800)
StartCombat Mrene_FightrTestScript2
endif
if ( GetTarget Mrene_FightrTestScript2 == 1 )
if ( GetHealth <= 0 )
StopCombat
AiWander 280 6 0 40 30 20 0 0 0
endif
endif
end
this seem rite i forgot if this is the script i wanted...anyways a basic script to make 2 npcs fight....but does anyone know if u have a companion (follow script) then is there a way to alter it and add it so when by a "rival" guild per se...they start combat? maybe i forgot but maybe some one can tell me what they think...
Begin FightScript
short Fight
endif
if ( GetDistance Mrene_FightrTestScript2 <= 800)
StartCombat Mrene_FightrTestScript2
endif
if ( GetTarget Mrene_FightrTestScript2 == 1 )
if ( GetHealth <= 0 )
StopCombat
AiWander 280 6 0 40 30 20 0 0 0
endif
endif
end
this seem rite i forgot if this is the script i wanted...anyways a basic script to make 2 npcs fight....but does anyone know if u have a companion (follow script) then is there a way to alter it and add it so when by a "rival" guild per se...they start combat? maybe i forgot but maybe some one can tell me what they think...
"Look I'm pulling a Night0205 and doubleposting!" -Haplo
...
What is it you're trying to do? Your post really doesn't make a whole lot of sense. Also, any answer you get is probably going to come straight out of SFD. Since you have it, you could try reading it.
What is it you're trying to do? Your post really doesn't make a whole lot of sense. Also, any answer you get is probably going to come straight out of SFD. Since you have it, you could try reading it.
Q1-77-Tel current progress:
[url=http://tamriel-rebuilt.org/old_forum/viewtopic.php?p=266462#266462]Journals 100% done.[/url]
Practical implementation is now underway.
[url=http://tamriel-rebuilt.org/old_forum/viewtopic.php?p=266462#266462]Journals 100% done.[/url]
Practical implementation is now underway.
well i read through SFD again... and my friend and i were wondring if anyone could enlighten us as to how we can make two factions, or more fight each other on sight, without us starting the battle...for instances we walk in a room and redoran guards start to attack hlaalu gaurds? is this possible? how? thanks
"Look I'm pulling a Night0205 and doubleposting!" -Haplo
- The Greatness
- Developer
- Posts: 358
- Joined: Sat May 29, 2010 5:13 pm
Surely 'NPC1->StartCombat, NPC2' would do the trick.Beave wrote:As far as I know there isn't any built-in method for making NPC's fight each other. You'll have to code the fight yourself, but you can probably use functions in the game related to factions (I think there's one for faction reaction). But like Faalen said, it should all be in MSFD.
Is Mrene_FightrTestScript2 an NPC? It doesn't sound like one.Drift3r wrote:Begin FightScript
short Fight
endif ;you don't need this endif
if ( GetDistance Mrene_FightrTestScript2 <= 800) ;GetDistance should be used with an object
StartCombat Mrene_FightrTestScript2 ;this should be like my example above, unless you actually want StartScript
endif
if ( GetTarget Mrene_FightrTestScript2 == 1 ) ;what?
if ( GetHealth <= 0 ) ;I would use GetDeadCount, which will return 1 when they are dead
StopCombat
AiWander 280 6 0 40 30 20 0 0 0
endif
endif
end
Warning: may contain large amounts of sarcasm.
Myzel- We never actually see slaves working on Vvardenfell either. They're always just standing there. If you ask me they deserve a good whipping.
Myzel- We never actually see slaves working on Vvardenfell either. They're always just standing there. If you ask me they deserve a good whipping.
I don't know if Morrowind works like Oblivion in that NPCs start fighting if their Fight value is high enough and their Disposition towards eachother low enough. If yes, you could create a dummy faction with faction reaction of, let's say, -100 towards another faction, and NPCs of these factions should start fighting on sight. But as I said, I don't know if it works that way, taking disposition into account.
That's what I mean. You have to include this because NPC's don't just attack each other based on certain factors.The Greatness wrote: Surely 'NPC1->StartCombat, NPC2' would do the trick.
That's my guess, although there was a piece of the code that didn't make sense:The Greatness wrote: Is Mrene_FightrTestScript2 an NPC? It doesn't sound like one.
Code: Select all
if ( GetTarget Mrene_FightrTestScript2 == 1 )
if ( GetHealth <= 0 )
StopCombat
AiWander 280 6 0 40 30 20 0 0 0
endif
endif
-
- Developer
- Posts: 835
- Joined: Mon Oct 27, 2008 11:18 pm
- Location: London
This will only make 2 NPCs fight. I think the OP wanted to create a battle with 2 factions. The trouble you get is if you have them fighting in pairs, so a whole set of duels. Once the duel is over, the winner just stands there, ruining the impression of a large battle.The Greatness wrote:'NPC1->StartCombat, NPC2' would do the trick.
You need to have a script on each NPC that says:
Code: Select all
If person A not dead
Fight person A
Else If person B not dead
Fight person B
Else If ... etc
The trouble is the scripts would be different for every NPC (a whole lot of effort). We actually have this implemented in TR in a tomb in Map2 I belive, although I can't remember the location. I tweaked the code and was quite proud of the solution - they are split into groups of fighters, which then cycle through the enemies in the opposing faction just as per the above script. However, they all use the same script: which enemy they start with depends on their initial X-coordinate (so they are unique and all initially attack a different enemy).
You might want to test Why's idea, because that would be a nice solution, but I have a feeling that doesn't work in Morrowind.
Edit: found it. It's called "Norem", just East of Windmoth Legion Fort. The main battle takes place in the cell "Norem, Interior" (although the others also have similar battles). The related scripts are prefixed "TR_m2_Norem_" and are all commented, so you should be able to see how it's set up.
Edit 2: The suggestion of using GetDistance might not be a good idea because if you have multiple scripts running in the same cell all calling GetDistance each frame, that could cause some lag.
MaMeeshkaMowSkwoz - choose your syllables
-
- Developer
- Posts: 835
- Joined: Mon Oct 27, 2008 11:18 pm
- Location: London
Inspired idea! But how would you deal with one of the "leaders" dying?Why wrote:Another thing you could do if you want a large battle, make one side AIFollow one NPC, the other side AIFollow another NPC, and have the two NPCs start combat. That should result in everyone fighting everyone.
MaMeeshkaMowSkwoz - choose your syllables
- The Greatness
- Developer
- Posts: 358
- Joined: Sat May 29, 2010 5:13 pm
Hopefully as they had already started fighting they wouldn't just stop and stand still.MMMowSkwoz wrote:Inspired idea! But how would you deal with one of the "leaders" dying?Why wrote:Another thing you could do if you want a large battle, make one side AIFollow one NPC, the other side AIFollow another NPC, and have the two NPCs start combat. That should result in everyone fighting everyone.
Warning: may contain large amounts of sarcasm.
Myzel- We never actually see slaves working on Vvardenfell either. They're always just standing there. If you ask me they deserve a good whipping.
Myzel- We never actually see slaves working on Vvardenfell either. They're always just standing there. If you ask me they deserve a good whipping.
I *think* that once they initiate combat, they won't stop until the other side is down, since when the leader is attacked, all his followers initiate combat with the attacker, as a result of which all the attacker's followers initiate combat with all his attackers. If not, everyone from one side should follow eachother, that should work too but requires some more coding.
well i tried something like this...except different in a sense..i used the mod *give your orders* and had a group of followers redoran guards follow me..i proceeded to punch a hlaalu guard and the group of guards not after me talked to me and i resisted arrest they attacked me and i levitated away...after a short distance they redirected there attention to the redoran and began to fight both individually and double teaming each other...i dont know if this holds any hidden coding secrets other wise is this how a battle supposed to run..i would like this but without my involvment (hiring guards)..Why wrote:I *think* that once they initiate combat, they won't stop until the other side is down, since when the leader is attacked, all his followers initiate combat with the attacker, as a result of which all the attacker's followers initiate combat with all his attackers. If not, everyone from one side should follow eachother, that should work too but requires some more coding.
"Look I'm pulling a Night0205 and doubleposting!" -Haplo
- The Greatness
- Developer
- Posts: 358
- Joined: Sat May 29, 2010 5:13 pm
What happened there is that first and foremost all gaurds are scripted to try and arrest you if you break the law. Why not try the same thing again but attack some bandits so you're not breaking the law. And please don't put so many '...'s. Just one is fine.Drift3r wrote:well i tried something like this...except different in a sense..i used the mod *give your orders* and had a group of followers redoran guards follow me..i proceeded to punch a hlaalu guard and the group of guards not after me talked to me and i resisted arrest they attacked me and i levitated away...after a short distance they redirected there attention to the redoran and began to fight both individually and double teaming each other...i dont know if this holds any hidden coding secrets other wise is this how a battle supposed to run..i would like this but without my involvment (hiring guards)..Why wrote:I *think* that once they initiate combat, they won't stop until the other side is down, since when the leader is attacked, all his followers initiate combat with the attacker, as a result of which all the attacker's followers initiate combat with all his attackers. If not, everyone from one side should follow eachother, that should work too but requires some more coding.
Warning: may contain large amounts of sarcasm.
Myzel- We never actually see slaves working on Vvardenfell either. They're always just standing there. If you ask me they deserve a good whipping.
Myzel- We never actually see slaves working on Vvardenfell either. They're always just standing there. If you ask me they deserve a good whipping.