Jump to content


Photo

Strangeness with this script


  • Please log in to reply
11 replies to this topic

#1 temnix

temnix
  • Member
  • 983 posts

Posted 24 September 2016 - 12:34 PM

I summon a creature to do some work for me. A character nearby gets hit by an effect that changes his alignment to NONE. I expect the creature to notice this and put a charm on him. This is the creature's script:

 

IF
	True()
THEN
	RESPONSE #100
		ReallyForceSpellRES("VISION_#",Myself) // Not important, just a vision-enhancing spell to make sure it sees everyone
		Wait(2) // For everyone to get settled
		Continue()
END

IF
	Alignment(Nearest,NONE)
THEN
	RESPONSE #100
		ReallyForceSpellRES("SPWI104",Nearest) // Charm Person
END

What happens after this is that the creature casts the spell alright, but always at itself. I can put an area-effect there as well, it doesn't matter. Always centers it on itself.

 

What's up?



#2 Ulb

Ulb
  • Modder
  • 373 posts

Posted 24 September 2016 - 01:09 PM

Does it cast the spell every time you summon it or only after a creature with a “none” alignment is in sight?

 

I ask because I think your trigger should only work if the alignment changed creature is actually the closest one to your helper creature. So if anything else is between them it shouldn't fire at all.

 

If it always fires that might mean that the “none” alignment might be treated by the script as “any” and thus always becomes true.

 

Not sure though why it would always target itself.. unless of course “nearest” can include the executing creature as well.

 

PS:

If I'm right about the trigger you could probably use “see” and “lastseen” to fix that issue.



#3 temnix

temnix
  • Member
  • 983 posts

Posted 24 September 2016 - 03:19 PM

The creature starts casting if the nearest character is unaligned and stops if I put someone else between them. Then resumes if I move the unaligned one closer again. So it really does detect what's going on, but for some reason casts it on itself. The creature is Lawful Good, just to avoid confusing it. And I don't think Nearest can be triggered by oneself anyway.

 

What was that about See and LastSeen?

 

By the way, the mods in your signatures. The one with "D2" material. That's Diablo 2, isn't it? What's Blizzard policy on using their materials for mods to other games? I tried to get a response from them about it, but I think my mail went in a black hole of corporate majesty.



#4 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5148 posts

Posted 24 September 2016 - 10:34 PM

What was that about See and LastSeen?
I would expect it to be:
 IF
	See(Alignment(Nearest,NONE))
THEN
	RESPONSE #100
		ReallyForceSpellRES("SPWI104",LastSeen) 
END

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#5 Ulb

Ulb
  • Modder
  • 373 posts

Posted 25 September 2016 - 01:56 AM

The creature starts casting if the nearest character is unaligned and stops if I put someone else between them. Then resumes if I move the unaligned one closer again. So it really does detect what's going on, but for some reason casts it on itself. The creature is Lawful Good, just to avoid confusing it. And I don't think Nearest can be triggered by oneself anyway.

 

What was that about See and LastSeen?

 

By the way, the mods in your signatures. The one with "D2" material. That's Diablo 2, isn't it? What's Blizzard policy on using their materials for mods to other games? I tried to get a response from them about it, but I think my mail went in a black hole of corporate majesty.

 

Hm, in that case I'm out of ideas. As for see/lastseen; yeah, something like what the Imp posted. I'd probably try to avoid nearest just in case it doesn't work the way we think it does but that's just because I'm pretty clueless when it comes to scripting..

 

Maybe something like this:

 


IF

See([ANYONE.0.0.0.0.0.NONE])

THEN
RESPONSE #100

ReallyForceSpellRES("SPWI104",LastSeen)

DestroySelf()

END

 

 

The D2 stuff is indeed from Diablo2. I wouldn't expect to get their official OK for you to use any of their stuff for modding other games but I doubt anyone really cares as long as you don't make any money off it and your stuff keeps a low profile. Biggest issue is that you can't post that kind of stuff on the Beamdog forums due to their copyright policy.



#6 temnix

temnix
  • Member
  • 983 posts

Posted 25 September 2016 - 10:19 AM

What was that about See and LastSeen?
I would expect it to be:
 IF
	See(Alignment(Nearest,NONE))
THEN
	RESPONSE #100
		ReallyForceSpellRES("SPWI104",LastSeen) 
END

 

I'll try this and see if it makes a difference. You'll get a separate-line thank you if it does.



#7 temnix

temnix
  • Member
  • 983 posts

Posted 25 September 2016 - 12:36 PM

LastSeen isn't recognized as an object. With () or without it. ...LastSeenBy(), that works.

 

No no no. See(Alignment(Nearest,NONE)) has wrong syntax.

 

By the way, how does Detect() work vis-a-vis LastSeenBy()? See() puts the creature in that object, but what's the object for Detect()?

 

This is the script I have right now. The creature still casts the spell on itself.

 

IF
	See(Nearest)
	Alignment(Nearest,NONE)
THEN
	RESPONSE #100
		ReallyForceSpellRES("SPWI003",LastSeenBy()) // Charm Person
END

 

To Ulb: say, if I wanted to import a creature from Diablo, in what files are their animations stored? Better yet, from the first Diablo?

 

A Steel Knight would make an awesome party member. :devil:


Edited by temnix, 25 September 2016 - 12:57 PM.


#8 Ulb

Ulb
  • Modder
  • 373 posts

Posted 25 September 2016 - 02:48 PM

I seem to recall that I had some issues with ******SpellRES when I made my Animal Companions mod. If I remember correctly spellRES was actually somewhat buggy and ignored the object parameter.

Have you tried using ReallyForceSpell for your code? There is a real chance that that's the issue.

 

 

No no no. See(Alignment(Nearest,NONE)) has wrong syntax.

 

Have you tried this line from my code:

 

 

 

 

See([ANYONE.0.0.0.0.0.NONE])

It should be in the right syntax and would get rid of the nearest in your code.

(With nearest you would have to add checks for secondnearest, thirdnearest, .. and so forth.)

 

 

To Ulb: say, if I wanted to import a creature from Diablo, in what files are their animations stored? Better yet, from the first Diablo?

 

A Steel Knight would make an awesome party member. :devil:

 

 

Sorry, it's been a few years and I don't remember what file types the animations are stored in,

I used a modding tool from a D2 modding site to extract the animations as .gifs  though. Assuming these sites still exist it shouldn't be too hard to find the right program.

A word of warning though: Diablo2 (and probably Diablo1 was well) creates animation shadows dynamically, so the animations come without shadows. You'd either have to add them manually or maybe find someone with a programm/script that can do that automatically.



#9 temnix

temnix
  • Member
  • 983 posts

Posted 25 September 2016 - 07:06 PM

Hey, that's a swell idea about getting rid of Nearest! I hate those long scripts. I'll give it a try. There is another problem that comes up - Near Infinity takes the NONE alignment value to mean 0, so it's going to turn ANYONE.0.0.0.0.0.NONE into ANYONE.0.0.0.0.0.0, which is the same as any alignment. Just a quirk of the program. I'm going to have to write the script somewhere else... In DLTCEP?

 

This is the situation as I described it to someone:

 

What I can tell is that ANYONE (what you get after NI's auto-abbreviation of ANYONE.0.0.0.0.0.NONE)) - any alignment - is treated separately by the engine from a specific alignment. If you put in a trigger for, e.g., LAWFUL_EVIL higher up in the script and a trigger for ANYONE below, the first action gets repeated again and again. The script never gets to the second action so long as there is someone Lawful Evil nearby, and that Lawful Evil doesn't get treated like "anyone", i.e. the action for Anyone is skipped.

Here is the script I currently have:

 

IF
    See([0.0.0.0.0.0.LAWFUL_EVIL])
THEN
    RESPONSE #100
        ReallyForceSpellRES("SPWI003",LastSeenBy(Myself)) // Magic Missile - Edwin gets this again and again, but strangely enough not Kagain; Ulb - I can't use a non-RES version because I'm not touching IDS files for my spells, they are all cast through RES. I've never had a problem with it.
END

IF
    See([ANYONE])
THEN
    RESPONSE #100
        ReallyForceSpellRES("SPWI108",LastSeenBy(Myself)) // Protection From Petrification - After Edwin went down, the creature put the Protection on Kagain
END

 

I'd really like to know if I truly can't use zeroes. I mean, there are probably many values in IDS files that equal 0 - maybe races, classes... And what about the NONE alignment itself? Surely it's used for something! Possibly for summoned things like a Bigby's Fist. If it's used, it can be used by me, and I need it as a perfect creature marker. I mean, it does work if you switch a creature to NONE through an effect. The alignment disappears from the character sheet.


Edited by temnix, 25 September 2016 - 07:35 PM.


#10 Ulb

Ulb
  • Modder
  • 373 posts

Posted 26 September 2016 - 03:51 AM

The "none" alignment resolving to 0 in alignment.ids is what I was getting at in my previous post. If the script treats it as “any” (like it does for all other “0” parameters) then I doubt you can utilize the “none” alignment for your idea.

 

 

As for the script you posted, I'm not quite sure I understand what you're getting at.

 

The script looks fine. It isn't supposed to ever get down to the second trigger as long as a LAWFUL_EVIL creature is around. If you wanted it to go down to the second trigger you could either add a continue() to the first trigger or add a local variable.

 

E.g.:

 

 


IF 
See([0.0.0.0.0.0.LAWFUL_EVIL]) 
THEN RESPONSE #100 
ReallyForceSpellRES("SPWI003",LastSeenBy(Myself)) 
Continue() 
END

 

 

(This causes the script to not restart after an IF argument returns true.)

 

or

 

 

 

IF 
See([0.0.0.0.0.0.LAWFUL_EVIL]) 
Global("LW_TRIGGER","LOCALS",0) 
THEN RESPONSE #100 
SetGlobal("LW_TRIGGER","LOCALS",1) 
ReallyForceSpellRES("SPWI003",LastSeenBy(Myself)) 
END

 

 

(This would cause the the argument to always return false after it's been executed once.)


Edited by Ulb, 26 September 2016 - 03:52 AM.


#11 Fiann of the Silver Hand

Fiann of the Silver Hand
  • Member
  • 286 posts

Posted 26 September 2016 - 07:05 PM

Scripts can be wonky.  Sometimes splitting up triggers into separate blocks that set specific variables to be collectively checked later can work more reliably than trying to check them all at once.



#12 temnix

temnix
  • Member
  • 983 posts

Posted 27 September 2016 - 05:20 AM

Yeah, I haven't thought about Continue(). There is enough strangeness here, to be sure. What's important is that I see that I can't use NONE for my marker.