collapse

Author Topic: Python mysteries  (Read 5387 times)

Offline Malkav

  • Antediluvian
  • *****
  • Posts: 1637
Re: Python mysteries
« Reply #15 on: May 21, 2016, 10:17:46 AM »
Hm, I'm not sure exactly how python handles importing scripts, especially if you already have imported the script you're using in chinatown.py.
You could try one of the other ways to import things
-from vamputil import *
-from vamputil import [specific function]
Co Author of Camarilla Edition Mod

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #16 on: May 21, 2016, 04:44:54 PM »
I tried to make the function import, but the thing is, I don't even understand how distanceSquared is a vamputil only function.

I sort of managed to make it work in my al_chquest script by copying this in it:
Code: [Select]
def distanceSquared(pos1, pos2):
    pc = __main__.FindPlayer()
    killer = Find("game_killer")
    victim = Find("game_victim")
    pos1 = pc.GetOrigin()
    pos2 = killer.GetOrigin()

Somehow, the game reconize distanceSquared, with this script above def GameExecution():
But the killer shoot the victim as soon as the map is loaded, no matter what number I set in
if(distanceSquared(pos1, pos2) < 400):

So it got me thinking, there must be a way to make it calculate the distance, right?
I tried to reproduce it from vamputil, but I don't understand how it is done there...

Hm, I'm not sure exactly how python handles importing scripts, especially if you already have imported the script you're using in chinatown.py.

I am not sure either, I looked at how Burgermeister did it and went from there. It doesn't appear too difficult, since the rest of the scripts is working properly, except for those with a distanceSquared in it, apparently.

Offline Malkav

  • Antediluvian
  • *****
  • Posts: 1637
Re: Python mysteries
« Reply #17 on: May 21, 2016, 10:00:22 PM »
Have you tried if other utility functions like isClan() work?
Or maybe it's a typo in the function call?
Send me your .py files attached to an email and I have a look. I'll send you a pm with my mail address.
Co Author of Camarilla Edition Mod

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #18 on: May 22, 2016, 08:50:02 AM »
Have you tried if other utility functions like isClan() work?

You mean something like __main__.FindPlayer().clan ?
I tried just now to check that the player is not nosferatu and it work. But I know that  _main_  functions are imported from:
import __main__
from __main__ import G
at the top of the file.

I don't know what to write to do the same with distanceSquared.

Offline Malkav

  • Antediluvian
  • *****
  • Posts: 1637
Re: Python mysteries
« Reply #19 on: May 22, 2016, 09:29:24 PM »
I was talking about anothe utility function in vamputil. The one that is used for clanchecks in dialogs. There you often have something like IsClan(pc, "Nosferatu") in the conditions.
So I thought you might check if this function works. If it does the problem is specific to distanceSquared.
Co Author of Camarilla Edition Mod

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #20 on: May 23, 2016, 04:36:54 PM »
I was talking about anothe utility function in vamputil. The one that is used for clanchecks in dialogs. There you often have something like IsClan(pc, "Nosferatu") in the conditions.
So I thought you might check if this function works. If it does the problem is specific to distanceSquared.

I understood only later what you meant. The problem was not specific to distanceSquared, but I figured out how to import specific functions to a new py file.

For example,
from vamputil import IsClan
will import the IsClan function, while
import vamputil
will not import anything at all, at least not in a new py, it seem...

Anyway,
from vamputil import distanceSquared
do the trick to import the function, the bad news is, the script don't trigger, because depending on the indentation, various errors happens, name error, script name not defined, pos1 is referenced before assignment... and others I don't have in mind right now.

I twisted my script around so often yesterday and I am tired of being delayed by this, so I will find a other way than using distanceSquared, even if I have to change the quest content a little.

Other functions like IsClan, IsDead, work without problem.

Thanks Malkav, at least, I now know what to do to import specific functions, but distanceSquared seem a little, what's the word, capricious?

Offline Malkav

  • Antediluvian
  • *****
  • Posts: 1637
Re: Python mysteries
« Reply #21 on: May 24, 2016, 07:10:42 AM »
Hm, as I already said in the pm, you should make all indentations exactly the same wide, 2 or 4. This is not strictly necessary for the compiler but you can read the code and spot errors better.
When I first looked in the code I thought the problem was no indentation after the if.
And 400 for distanceSquared seems awfully close to me. That's 20 game units, practically on the killer's toes. I think the usual dialog distance is about 50 to 80.
Co Author of Camarilla Edition Mod

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #22 on: May 24, 2016, 05:00:16 PM »
Hm, as I already said in the pm, you should make all indentations exactly the same wide, 2 or 4. This is not strictly necessary for the compiler but you can read the code and spot errors better.
When I first looked in the code I thought the problem was no indentation after the if.
And 400 for distanceSquared seems awfully close to me. That's 20 game units, practically on the killer's toes. I think the usual dialog distance is about 50 to 80.

I changed the indentation, if only for other people who would want to read it.
I find spotting errors quite easy in notepad++, and rarely make indentations mistakes now.
The distance you see is just one of severals I tried, but it is indeed too short.

I think I found the real problem, trying to come up with a other way without distanceSquared, bear with me a moment.

So in my previous tests with distanceSquared properly imported, I noticed that when the indentation were good, the error in the console was:
name error, GameExecutionb() not defined

And in my new iteration, I made a script scene that is called via a
__main__.ScheduleTask(0.1,"GameExecutionb()")

The error is the same, and the distanceSquared version also had a __main__.ScheduleTask
If I use it in any script, then it suddently become "not defined"
Yet, Burgermeister used this command and didn't do anything special to import it. The other __main__ commands work without problem.

So, I don't understand. I sent you a other pm with my new script version, in case you want to have a look.

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #23 on: May 24, 2016, 06:33:32 PM »
Oh boy, oh boy... Look no further, I just understood what was wrong...
Looking again at CQM py, I realized that I had to do the same thing with
__main__.ScheduleTask, that with the python trigger by map entities. Adding alchquest. in front of the script's name like that:
__main__.ScheduleTask(0.1,"al_chquest.GameExecutionb()")

I made a quick test with distanceSquared and it WORKS!!! AH AH AH AH!!!!!! EVERYTHING WORKS!!!!
The dark side of the force, is finally going to unleash...

Offline Malkav

  • Antediluvian
  • *****
  • Posts: 1637
Re: Python mysteries
« Reply #24 on: May 26, 2016, 08:01:25 AM »
Yep, now that you say it... :facepalm:
Too long since I've done some of the more fancy python scripting.
Co Author of Camarilla Edition Mod

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #25 on: May 30, 2016, 06:01:25 PM »
I have a memory problem and I don't want to create a new topic for this.
Could someone describe for me how the haven is handle at the end?
You always go to santa monica with Jack, right?
Then it's the bloodhunt, and if you go to your haven from the taxi later, do you go to skyline, or the tremere haven, if you have one of those?

Offline Maxus Corvin

  • Methuselah
  • ****
  • Posts: 389
  • As of yet, only half evil...
Re: Python mysteries
« Reply #26 on: May 30, 2016, 08:51:38 PM »
I have a memory problem and I don't want to create a new topic for this.
Could someone describe for me how the haven is handle at the end?
You always go to santa monica with Jack, right?
Then it's the bloodhunt, and if you go to your haven from the taxi later, do you go to skyline, or the tremere haven, if you have one of those?

Yeah, it depends on which is your main haven at that point - which can still be the SM Apartment, or Skyline, the Tremere Chantry, or the Downtown Sewers haven. But you do go to one of them. 
...

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #27 on: May 31, 2016, 04:32:09 PM »
Thanks Maxus. I forgot the nosferatu haven, downtown too.

Offline Aloysius

  • Methuselah
  • ****
  • Posts: 349
Re: Python mysteries
« Reply #28 on: May 31, 2016, 07:37:54 PM »
From memory... With the bloodhunt i always started in the SM's (I tried with five clans, even with the Tremere) I don't know about the Sewer's (i never finished the game with Nossie), but after escaping you cannot go in any other haven (although you can go in the Tremere Chantry to Strauss if you choose the Camarilla's side).
Maybe i'm wrong, Maxus, and you're right... I rely on my experiences...  :smile:

Maybe something changed with the latest patches? Or in some MOD?

For the bloodhunt, santa monica is the only map which have a duplicate with the bloodhunt stuffs implemented, so it's logic that you go there.
For returning to the haven after that, my fuzzy memories tell me that I almost always went to SM haven, but in many of my games, I stayed with the rat hole in SM...

The skyline aspect, "oh my, my neighbours are all quests characters and end up dead on top of that", always bothered me.
Tremere haven require to be tremere and more importantly, sign up to be the pyramid's underling, so, no thank you...

After looking, there are code in python to make the player return to other havens if they are allowed to, which is too bad for me...
It mean I have to take them into account in my script for the new haven...


Offline 3Dell

  • Neonate
  • **
  • Posts: 54
Re: Python mysteries
« Reply #29 on: June 12, 2016, 11:57:54 AM »
Anyone can help me understand how the inventory? Do I understand correctly that when we click on Armor0/1/2/3, that activates a Python schript and replaces the PC model? Where can I find this document and schript? Is this line in Vampytil?

"if(notIdle == 0 and pc.active_protean < 2 and pc.HasWeaponEquipped("item_w_unarmed")):
        #This version supports custom models
        BruM1="models/character/pc/male/brujah/armor0/brujah_male_armor_0.mdl"
        BruM2="models/character/pc/male/brujah/armor1/brujah_male_armor_1.mdl"
        BruM3="models/character/pc/male/brujah/armor2/brujah_male_armor_2.mdl"
        BruM4="models/character/pc/male/brujah/armor3/brujah_male_armor_3.mdl"
        BruF1="models/character/pc/female/brujah/armor0/brujah_female_armor_0.mdl"............."

Also, I wonder whether it is possible to .VMF file, which is associated with the .and TTZ .TTX provide a link to the Python schript?
« Last Edit: June 12, 2016, 12:01:59 PM by 3Dell »